import { weierstrass } from '@noble/curves/abstract/weierstrass'; import { Field } from '@noble/curves/abstract/modular'; import { CHash } from '@noble/curves/abstract/utils'; const emptyHash: CHash = Object.assign( (_message: Uint8Array | string): Uint8Array => { return new Uint8Array(); // 返回一个空的 Uint8Array }, { blockLen: 0, outputLen: 0, create: (_opts?: { dkLen?: number }): any => { return {}; }, } ); // only use to convert key pair export const sm2Curve = weierstrass({ // sm2: short weierstrass. a: BigInt( '115792089210356248756420345214020892766250353991924191454421193933289684991996' ), b: BigInt( '18505919022281880113072981827955639221458448578012075254857346196103069175443' ), Fp: Field( BigInt( '115792089210356248756420345214020892766250353991924191454421193933289684991999' ) ), h: BigInt(1), n: BigInt( '115792089210356248756420345214020892766061623724957744567843809356293439045923' ), Gx: BigInt( '22963146547237050559479531362550074578802567295341616970375194840604139615431' ), Gy: BigInt( '85132369209828568825618990617112496413088388631904505083283536607588877201568' ), hash: emptyHash, hmac: (_key: Uint8Array, ..._msgs: Uint8Array[]) => new Uint8Array(), randomBytes: (_bytesLength?: number) => new Uint8Array(), });