_shortw_utils.d.ts 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { randomBytes } from '@noble/hashes/utils';
  2. import { CHash } from './abstract/utils.js';
  3. import { CurveType } from './abstract/weierstrass.js';
  4. export declare function getHash(hash: CHash): {
  5. hash: CHash;
  6. hmac: (key: Uint8Array, ...msgs: Uint8Array[]) => Uint8Array;
  7. randomBytes: typeof randomBytes;
  8. };
  9. type CurveDef = Readonly<Omit<CurveType, 'hash' | 'hmac' | 'randomBytes'>>;
  10. export declare function createCurve(curveDef: CurveDef, defHash: CHash): Readonly<{
  11. create: (hash: CHash) => import("./abstract/weierstrass.js").CurveFn;
  12. CURVE: ReturnType<(curve: CurveType) => Readonly<{
  13. readonly nBitLength: number;
  14. readonly nByteLength: number;
  15. readonly Fp: import("./abstract/modular.js").IField<bigint>;
  16. readonly n: bigint;
  17. readonly h: bigint;
  18. readonly hEff?: bigint;
  19. readonly Gx: bigint;
  20. readonly Gy: bigint;
  21. readonly allowInfinityPoint?: boolean;
  22. readonly a: bigint;
  23. readonly b: bigint;
  24. readonly allowedPrivateKeyLengths?: readonly number[];
  25. readonly wrapPrivateKey?: boolean;
  26. readonly endo?: {
  27. beta: bigint;
  28. splitScalar: (k: bigint) => {
  29. k1neg: boolean;
  30. k1: bigint;
  31. k2neg: boolean;
  32. k2: bigint;
  33. };
  34. };
  35. readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
  36. readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
  37. readonly hash: CHash;
  38. readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
  39. readonly randomBytes: (bytesLength?: number) => Uint8Array;
  40. lowS: boolean;
  41. readonly bits2int?: (bytes: Uint8Array) => bigint;
  42. readonly bits2int_modN?: (bytes: Uint8Array) => bigint;
  43. readonly p: bigint;
  44. }>>;
  45. getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean) => Uint8Array;
  46. getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean) => Uint8Array;
  47. sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts) => import("./abstract/weierstrass.js").RecoveredSignatureType;
  48. verify: (signature: import("./abstract/utils.js").Hex | {
  49. r: bigint;
  50. s: bigint;
  51. }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts) => boolean;
  52. ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
  53. Signature: import("./abstract/weierstrass.js").SignatureConstructor;
  54. utils: {
  55. normPrivateKeyToScalar: (key: import("./abstract/utils.js").PrivKey) => bigint;
  56. isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
  57. randomPrivateKey: () => Uint8Array;
  58. precompute: (windowSize?: number, point?: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>;
  59. };
  60. }>;
  61. export {};
  62. //# sourceMappingURL=_shortw_utils.d.ts.map