@li0ard/gostcurves
GOST R 34.10 curves and DSA in pure TypeScript
docs
Warning
This library is currently in alpha stage: the lib is not very stable yet, and there may be a lot of bugs feel free to try it out, though, any feedback is appreciated!
# from NPM
npm i @li0ard/gostcurves
# from JSR
bunx jsr i @li0ard/gostcurves
- DSA (various curves included)
- VKO key agreement function
- Points conversion from Weierstrass to Twisted Edwards form and vice versa
- Provides simple and modern API
- Most of the APIs are strictly typed
- Fully complies with GOST R 34.10-2012 (RFC 7091) and GOST R 34.10-2001 (RFC 5832) standard
- Supports Bun, Node.js, Deno, Browsers
import { ID_GOSTR3410_2012_256_PARAM_SET_A, sign, verify, getPublicKey } from "@li0ard/gostcurves";
let curve = ID_GOSTR3410_2012_256_PARAM_SET_A;
let privKey = hexToBytes("0ca68a44333dbee1daea1e80dbdd560a43215886a392472b898ed3721e1177e0");
let publicKey = getPublicKey(curve, privKey);
let digest = hexToBytes("2dfbc1b372d89a1188c09c52e0eec61fce52032ab1022e8e67ece6672b043ee5");
let signature = sign(curve, privKey, digest);
console.log(signature); // -> Uint8Array [...]
console.log(verify(curve, publicKey, digest, signature)); // -> true
import { ID_GOSTR3410_2012_512_PARAM_SET_A, getPublicKey, kek_34102012256 } from "@li0ard/gostcurves"
let curve = ID_GOSTR3410_2012_512_PARAM_SET_A;
let ukm = hexToBytes("27c744853c60801d")
let alicePriv = hexToBytes("67b63ca4ac8d2bb32618d89296c7476dbeb9f9048496f202b1902cf2ce41dbc2f847712d960483458d4b380867f426c7ca0ff5782702dbc44ee8fc72d9ec90c9");
let bobPriv = hexToBytes("dbd09213a592da5bbfd8ed068cccccbbfbeda4feac96b9b4908591440b0714803b9eb763ef932266d4c0181a9b73eacf9013efc65ec07c888515f1b6f759c848");
let alicePub = getPublicKey(curve, alicePriv);
let bobPub = getPublicKey(curve, bobPriv);
console.log(kek_34102012256(curve, alicePriv, bobPub, ukm)) // -> c9a9a77320e2cc559ed72dce6f47e2192ccea95fa648670582c054c0ef36c221
console.log(kek_34102012256(curve, bobPriv, alicePub, ukm)) // -> c9a9a77320e2cc559ed72dce6f47e2192ccea95fa648670582c054c0ef36c221