UNPKG

@zlattice/lattice-js

Version:

Lattice blockchain TypeScript SDK with dual module support (CJS + ESM)

27 lines 1.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.field = exports.sm2Curve = exports.sm2Fp = void 0; const modular_1 = require("@noble/curves/abstract/modular"); // finite field for mod arithmetics const utils_1 = require("@noble/curves/abstract/utils"); const weierstrass_1 = require("@noble/curves/abstract/weierstrass"); const bn_1 = require("./bn.js"); const hmac_1 = require("./hmac.js"); const rng_1 = require("./rng.js"); const sm3_1 = require("./sm3.js"); exports.sm2Fp = (0, modular_1.Field)(BigInt('115792089210356248756420345214020892766250353991924191454421193933289684991999')); exports.sm2Curve = (0, weierstrass_1.weierstrass)({ // sm2: short weierstrass. a: BigInt('115792089210356248756420345214020892766250353991924191454421193933289684991996'), b: BigInt('18505919022281880113072981827955639221458448578012075254857346196103069175443'), Fp: exports.sm2Fp, h: bn_1.ONE, n: BigInt('115792089210356248756420345214020892766061623724957744567843809356293439045923'), Gx: BigInt('22963146547237050559479531362550074578802567295341616970375194840604139615431'), Gy: BigInt('85132369209828568825618990617112496413088388631904505083283536607588877201568'), hash: sm3_1.sm3, hmac: (key, ...msgs) => (0, hmac_1.hmac)(sm3_1.sm3, key, (0, utils_1.concatBytes)(...msgs)), randomBytes: rng_1.randomBytes, }); // 有限域运算 exports.field = (0, modular_1.Field)(BigInt(exports.sm2Curve.CURVE.n)); //# sourceMappingURL=ec.js.map