@noble/curves 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +49 -8
  2. package/lib/_shortw_utils.d.ts +11 -26
  3. package/lib/abstract/bls.d.ts +51 -35
  4. package/lib/abstract/bls.js +77 -139
  5. package/lib/abstract/{group.d.ts → curve.d.ts} +31 -1
  6. package/lib/abstract/{group.js → curve.js} +39 -2
  7. package/lib/abstract/edwards.d.ts +30 -81
  8. package/lib/abstract/edwards.js +225 -420
  9. package/lib/abstract/hash-to-curve.d.ts +25 -6
  10. package/lib/abstract/hash-to-curve.js +40 -12
  11. package/lib/abstract/modular.d.ts +20 -7
  12. package/lib/abstract/modular.js +80 -51
  13. package/lib/abstract/montgomery.js +3 -4
  14. package/lib/abstract/poseidon.d.ts +29 -0
  15. package/lib/abstract/poseidon.js +115 -0
  16. package/lib/abstract/utils.d.ts +5 -34
  17. package/lib/abstract/utils.js +23 -63
  18. package/lib/abstract/weierstrass.d.ts +56 -79
  19. package/lib/abstract/weierstrass.js +509 -641
  20. package/lib/bls12-381.d.ts +1 -0
  21. package/lib/bls12-381.js +75 -65
  22. package/lib/bn.js +1 -1
  23. package/lib/ed25519.d.ts +7 -5
  24. package/lib/ed25519.js +87 -84
  25. package/lib/ed448.d.ts +3 -0
  26. package/lib/ed448.js +88 -84
  27. package/lib/esm/abstract/bls.js +77 -139
  28. package/lib/esm/abstract/{group.js → curve.js} +37 -1
  29. package/lib/esm/abstract/edwards.js +223 -418
  30. package/lib/esm/abstract/hash-to-curve.js +38 -11
  31. package/lib/esm/abstract/modular.js +77 -50
  32. package/lib/esm/abstract/montgomery.js +4 -7
  33. package/lib/esm/abstract/poseidon.js +109 -0
  34. package/lib/esm/abstract/utils.js +21 -59
  35. package/lib/esm/abstract/weierstrass.js +508 -640
  36. package/lib/esm/bls12-381.js +86 -76
  37. package/lib/esm/bn.js +1 -1
  38. package/lib/esm/ed25519.js +85 -83
  39. package/lib/esm/ed448.js +86 -83
  40. package/lib/esm/jubjub.js +6 -5
  41. package/lib/esm/p256.js +11 -9
  42. package/lib/esm/p384.js +11 -9
  43. package/lib/esm/p521.js +13 -12
  44. package/lib/esm/secp256k1.js +118 -157
  45. package/lib/esm/stark.js +104 -39
  46. package/lib/jubjub.d.ts +3 -2
  47. package/lib/jubjub.js +6 -5
  48. package/lib/p192.d.ts +22 -52
  49. package/lib/p224.d.ts +22 -52
  50. package/lib/p256.d.ts +25 -52
  51. package/lib/p256.js +13 -10
  52. package/lib/p384.d.ts +25 -52
  53. package/lib/p384.js +13 -10
  54. package/lib/p521.d.ts +25 -52
  55. package/lib/p521.js +15 -13
  56. package/lib/secp256k1.d.ts +26 -42
  57. package/lib/secp256k1.js +118 -157
  58. package/lib/stark.d.ts +36 -21
  59. package/lib/stark.js +107 -39
  60. package/package.json +14 -9
package/lib/p192.d.ts CHANGED
@@ -23,41 +23,26 @@ export declare const P192: Readonly<{
23
23
  k2: bigint;
24
24
  };
25
25
  } | undefined;
26
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
27
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
28
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
29
- readonly mapToCurve?: ((scalar: bigint[]) => {
30
- x: bigint;
31
- y: bigint;
32
- }) | undefined;
26
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
27
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
33
28
  lowS: boolean;
34
29
  readonly hash: import("./abstract/utils.js").CHash;
35
30
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
36
31
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
37
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
32
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
33
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
38
34
  }>;
39
35
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
41
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
42
- lowS?: boolean | undefined;
43
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
44
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
45
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
46
- lowS?: boolean | undefined;
47
- } | undefined) => boolean;
48
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
49
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
36
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
37
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
38
+ verify: (signature: import("./abstract/utils.js").Hex | {
39
+ r: bigint;
40
+ s: bigint;
41
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
42
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
50
43
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
51
44
  utils: {
52
- mod: (a: bigint, b?: bigint | undefined) => bigint;
53
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
54
- _bigintToBytes: (num: bigint) => Uint8Array;
55
- _bigintToString: (num: bigint) => string;
56
45
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
57
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
58
- _isWithinCurveOrder: (num: bigint) => boolean;
59
- _isValidFieldElement: (num: bigint) => boolean;
60
- _weierstrassEquation: (x: bigint) => bigint;
61
46
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
62
47
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
63
48
  randomPrivateKey: () => Uint8Array;
@@ -88,41 +73,26 @@ export declare const secp192r1: Readonly<{
88
73
  k2: bigint;
89
74
  };
90
75
  } | undefined;
91
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
92
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
93
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
94
- readonly mapToCurve?: ((scalar: bigint[]) => {
95
- x: bigint;
96
- y: bigint;
97
- }) | undefined;
76
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
77
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
98
78
  lowS: boolean;
99
79
  readonly hash: import("./abstract/utils.js").CHash;
100
80
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
101
81
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
102
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
82
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
83
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
103
84
  }>;
104
85
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
105
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
106
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
107
- lowS?: boolean | undefined;
108
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
109
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
110
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
111
- lowS?: boolean | undefined;
112
- } | undefined) => boolean;
113
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
114
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
86
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
87
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
88
+ verify: (signature: import("./abstract/utils.js").Hex | {
89
+ r: bigint;
90
+ s: bigint;
91
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
92
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
115
93
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
116
94
  utils: {
117
- mod: (a: bigint, b?: bigint | undefined) => bigint;
118
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
119
- _bigintToBytes: (num: bigint) => Uint8Array;
120
- _bigintToString: (num: bigint) => string;
121
95
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
122
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
123
- _isWithinCurveOrder: (num: bigint) => boolean;
124
- _isValidFieldElement: (num: bigint) => boolean;
125
- _weierstrassEquation: (x: bigint) => bigint;
126
96
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
127
97
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
128
98
  randomPrivateKey: () => Uint8Array;
package/lib/p224.d.ts CHANGED
@@ -23,41 +23,26 @@ export declare const P224: Readonly<{
23
23
  k2: bigint;
24
24
  };
25
25
  } | undefined;
26
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
27
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
28
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
29
- readonly mapToCurve?: ((scalar: bigint[]) => {
30
- x: bigint;
31
- y: bigint;
32
- }) | undefined;
26
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
27
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
33
28
  lowS: boolean;
34
29
  readonly hash: import("./abstract/utils.js").CHash;
35
30
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
36
31
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
37
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
32
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
33
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
38
34
  }>;
39
35
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
41
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
42
- lowS?: boolean | undefined;
43
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
44
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
45
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
46
- lowS?: boolean | undefined;
47
- } | undefined) => boolean;
48
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
49
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
36
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
37
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
38
+ verify: (signature: import("./abstract/utils.js").Hex | {
39
+ r: bigint;
40
+ s: bigint;
41
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
42
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
50
43
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
51
44
  utils: {
52
- mod: (a: bigint, b?: bigint | undefined) => bigint;
53
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
54
- _bigintToBytes: (num: bigint) => Uint8Array;
55
- _bigintToString: (num: bigint) => string;
56
45
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
57
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
58
- _isWithinCurveOrder: (num: bigint) => boolean;
59
- _isValidFieldElement: (num: bigint) => boolean;
60
- _weierstrassEquation: (x: bigint) => bigint;
61
46
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
62
47
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
63
48
  randomPrivateKey: () => Uint8Array;
@@ -88,41 +73,26 @@ export declare const secp224r1: Readonly<{
88
73
  k2: bigint;
89
74
  };
90
75
  } | undefined;
91
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
92
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
93
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
94
- readonly mapToCurve?: ((scalar: bigint[]) => {
95
- x: bigint;
96
- y: bigint;
97
- }) | undefined;
76
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
77
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
98
78
  lowS: boolean;
99
79
  readonly hash: import("./abstract/utils.js").CHash;
100
80
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
101
81
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
102
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
82
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
83
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
103
84
  }>;
104
85
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
105
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
106
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
107
- lowS?: boolean | undefined;
108
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
109
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
110
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
111
- lowS?: boolean | undefined;
112
- } | undefined) => boolean;
113
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
114
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
86
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
87
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
88
+ verify: (signature: import("./abstract/utils.js").Hex | {
89
+ r: bigint;
90
+ s: bigint;
91
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
92
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
115
93
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
116
94
  utils: {
117
- mod: (a: bigint, b?: bigint | undefined) => bigint;
118
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
119
- _bigintToBytes: (num: bigint) => Uint8Array;
120
- _bigintToString: (num: bigint) => string;
121
95
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
122
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
123
- _isWithinCurveOrder: (num: bigint) => boolean;
124
- _isValidFieldElement: (num: bigint) => boolean;
125
- _weierstrassEquation: (x: bigint) => bigint;
126
96
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
127
97
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
128
98
  randomPrivateKey: () => Uint8Array;
package/lib/p256.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as htf from './abstract/hash-to-curve.js';
1
2
  export declare const P256: Readonly<{
2
3
  create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn;
3
4
  CURVE: Readonly<{
@@ -23,41 +24,26 @@ export declare const P256: Readonly<{
23
24
  k2: bigint;
24
25
  };
25
26
  } | undefined;
26
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
27
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
28
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
29
- readonly mapToCurve?: ((scalar: bigint[]) => {
30
- x: bigint;
31
- y: bigint;
32
- }) | undefined;
27
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
28
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
33
29
  lowS: boolean;
34
30
  readonly hash: import("./abstract/utils.js").CHash;
35
31
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
36
32
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
37
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
33
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
34
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
38
35
  }>;
39
36
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
41
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
42
- lowS?: boolean | undefined;
43
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
44
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
45
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
46
- lowS?: boolean | undefined;
47
- } | undefined) => boolean;
48
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
49
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
37
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
38
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
39
+ verify: (signature: import("./abstract/utils.js").Hex | {
40
+ r: bigint;
41
+ s: bigint;
42
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
43
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
50
44
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
51
45
  utils: {
52
- mod: (a: bigint, b?: bigint | undefined) => bigint;
53
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
54
- _bigintToBytes: (num: bigint) => Uint8Array;
55
- _bigintToString: (num: bigint) => string;
56
46
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
57
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
58
- _isWithinCurveOrder: (num: bigint) => boolean;
59
- _isValidFieldElement: (num: bigint) => boolean;
60
- _weierstrassEquation: (x: bigint) => bigint;
61
47
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
62
48
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
63
49
  randomPrivateKey: () => Uint8Array;
@@ -88,43 +74,30 @@ export declare const secp256r1: Readonly<{
88
74
  k2: bigint;
89
75
  };
90
76
  } | undefined;
91
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
92
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
93
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
94
- readonly mapToCurve?: ((scalar: bigint[]) => {
95
- x: bigint;
96
- y: bigint;
97
- }) | undefined;
77
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
78
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
98
79
  lowS: boolean;
99
80
  readonly hash: import("./abstract/utils.js").CHash;
100
81
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
101
82
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
102
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
83
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
84
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
103
85
  }>;
104
86
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
105
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
106
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
107
- lowS?: boolean | undefined;
108
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
109
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
110
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
111
- lowS?: boolean | undefined;
112
- } | undefined) => boolean;
113
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
114
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
87
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
88
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
89
+ verify: (signature: import("./abstract/utils.js").Hex | {
90
+ r: bigint;
91
+ s: bigint;
92
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
93
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
115
94
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
116
95
  utils: {
117
- mod: (a: bigint, b?: bigint | undefined) => bigint;
118
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
119
- _bigintToBytes: (num: bigint) => Uint8Array;
120
- _bigintToString: (num: bigint) => string;
121
96
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
122
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
123
- _isWithinCurveOrder: (num: bigint) => boolean;
124
- _isValidFieldElement: (num: bigint) => boolean;
125
- _weierstrassEquation: (x: bigint) => bigint;
126
97
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
127
98
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
128
99
  randomPrivateKey: () => Uint8Array;
129
100
  };
130
101
  }>;
102
+ declare const hashToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>, encodeToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>;
103
+ export { hashToCurve, encodeToCurve };
package/lib/p256.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.secp256r1 = exports.P256 = void 0;
3
+ exports.encodeToCurve = exports.hashToCurve = exports.secp256r1 = exports.P256 = void 0;
4
4
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
5
  const _shortw_utils_js_1 = require("./_shortw_utils.js");
6
6
  const sha256_1 = require("@noble/hashes/sha256");
7
7
  const modular_js_1 = require("./abstract/modular.js");
8
8
  const weierstrass_js_1 = require("./abstract/weierstrass.js");
9
+ const htf = require("./abstract/hash-to-curve.js");
9
10
  // NIST secp256r1 aka P256
10
11
  // https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-256
11
12
  // Field over which we'll do calculations; 2n**224n * (2n**32n-1n) + 2n**192n + 2n**96n-1n
@@ -29,14 +30,16 @@ exports.P256 = (0, _shortw_utils_js_1.createCurve)({
29
30
  Gy: BigInt('0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5'),
30
31
  h: BigInt(1),
31
32
  lowS: false,
32
- mapToCurve: (scalars) => mapSWU(scalars[0]),
33
- htfDefaults: {
34
- DST: 'P256_XMD:SHA-256_SSWU_RO_',
35
- p: Fp.ORDER,
36
- m: 1,
37
- k: 128,
38
- expand: 'xmd',
39
- hash: sha256_1.sha256,
40
- },
41
33
  }, sha256_1.sha256);
42
34
  exports.secp256r1 = exports.P256;
35
+ const { hashToCurve, encodeToCurve } = htf.hashToCurve(exports.secp256r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
36
+ DST: 'P256_XMD:SHA-256_SSWU_RO_',
37
+ encodeDST: 'P256_XMD:SHA-256_SSWU_NU_',
38
+ p: Fp.ORDER,
39
+ m: 1,
40
+ k: 128,
41
+ expand: 'xmd',
42
+ hash: sha256_1.sha256,
43
+ });
44
+ exports.hashToCurve = hashToCurve;
45
+ exports.encodeToCurve = encodeToCurve;
package/lib/p384.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import * as htf from './abstract/hash-to-curve.js';
1
2
  export declare const P384: Readonly<{
2
3
  create: (hash: import("./abstract/utils.js").CHash) => import("./abstract/weierstrass.js").CurveFn;
3
4
  CURVE: Readonly<{
@@ -23,41 +24,26 @@ export declare const P384: Readonly<{
23
24
  k2: bigint;
24
25
  };
25
26
  } | undefined;
26
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
27
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
28
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
29
- readonly mapToCurve?: ((scalar: bigint[]) => {
30
- x: bigint;
31
- y: bigint;
32
- }) | undefined;
27
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
28
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
33
29
  lowS: boolean;
34
30
  readonly hash: import("./abstract/utils.js").CHash;
35
31
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
36
32
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
37
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
33
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
34
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
38
35
  }>;
39
36
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
40
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
41
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
42
- lowS?: boolean | undefined;
43
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
44
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
45
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
46
- lowS?: boolean | undefined;
47
- } | undefined) => boolean;
48
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
49
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
37
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
38
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
39
+ verify: (signature: import("./abstract/utils.js").Hex | {
40
+ r: bigint;
41
+ s: bigint;
42
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
43
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
50
44
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
51
45
  utils: {
52
- mod: (a: bigint, b?: bigint | undefined) => bigint;
53
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
54
- _bigintToBytes: (num: bigint) => Uint8Array;
55
- _bigintToString: (num: bigint) => string;
56
46
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
57
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
58
- _isWithinCurveOrder: (num: bigint) => boolean;
59
- _isValidFieldElement: (num: bigint) => boolean;
60
- _weierstrassEquation: (x: bigint) => bigint;
61
47
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
62
48
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
63
49
  randomPrivateKey: () => Uint8Array;
@@ -88,43 +74,30 @@ export declare const secp384r1: Readonly<{
88
74
  k2: bigint;
89
75
  };
90
76
  } | undefined;
91
- readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => boolean) | undefined;
92
- readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjectivePointType<bigint>) => import("./abstract/weierstrass.js").ProjectivePointType<bigint>) | undefined;
93
- readonly htfDefaults?: import("./abstract/hash-to-curve.js").htfOpts | undefined;
94
- readonly mapToCurve?: ((scalar: bigint[]) => {
95
- x: bigint;
96
- y: bigint;
97
- }) | undefined;
77
+ readonly isTorsionFree?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => boolean) | undefined;
78
+ readonly clearCofactor?: ((c: import("./abstract/weierstrass.js").ProjConstructor<bigint>, point: import("./abstract/weierstrass.js").ProjPointType<bigint>) => import("./abstract/weierstrass.js").ProjPointType<bigint>) | undefined;
98
79
  lowS: boolean;
99
80
  readonly hash: import("./abstract/utils.js").CHash;
100
81
  readonly hmac: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;
101
82
  readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
102
- readonly truncateHash?: ((hash: Uint8Array, truncateOnly?: boolean | undefined) => bigint) | undefined;
83
+ readonly bits2int?: ((bytes: Uint8Array) => bigint) | undefined;
84
+ readonly bits2int_modN?: ((bytes: Uint8Array) => bigint) | undefined;
103
85
  }>;
104
86
  getPublicKey: (privateKey: import("./abstract/utils.js").PrivKey, isCompressed?: boolean | undefined) => Uint8Array;
105
- getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/weierstrass.js").PubKey, isCompressed?: boolean | undefined) => Uint8Array;
106
- sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: {
107
- lowS?: boolean | undefined;
108
- extraEntropy?: (true | import("./abstract/utils.js").Hex) | undefined;
109
- } | undefined) => import("./abstract/weierstrass.js").SignatureType;
110
- verify: (signature: import("./abstract/utils.js").Hex | import("./abstract/weierstrass.js").SignatureType, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/weierstrass.js").PubKey, opts?: {
111
- lowS?: boolean | undefined;
112
- } | undefined) => boolean;
113
- Point: import("./abstract/weierstrass.js").PointConstructor<bigint>;
114
- ProjectivePoint: import("./abstract/weierstrass.js").ProjectiveConstructor<bigint>;
87
+ getSharedSecret: (privateA: import("./abstract/utils.js").PrivKey, publicB: import("./abstract/utils.js").Hex, isCompressed?: boolean | undefined) => Uint8Array;
88
+ sign: (msgHash: import("./abstract/utils.js").Hex, privKey: import("./abstract/utils.js").PrivKey, opts?: import("./abstract/weierstrass.js").SignOpts | undefined) => import("./abstract/weierstrass.js").SignatureType;
89
+ verify: (signature: import("./abstract/utils.js").Hex | {
90
+ r: bigint;
91
+ s: bigint;
92
+ }, msgHash: import("./abstract/utils.js").Hex, publicKey: import("./abstract/utils.js").Hex, opts?: import("./abstract/weierstrass.js").VerOpts | undefined) => boolean;
93
+ ProjectivePoint: import("./abstract/weierstrass.js").ProjConstructor<bigint>;
115
94
  Signature: import("./abstract/weierstrass.js").SignatureConstructor;
116
95
  utils: {
117
- mod: (a: bigint, b?: bigint | undefined) => bigint;
118
- invert: (number: bigint, modulo?: bigint | undefined) => bigint;
119
- _bigintToBytes: (num: bigint) => Uint8Array;
120
- _bigintToString: (num: bigint) => string;
121
96
  _normalizePrivateKey: (key: import("./abstract/utils.js").PrivKey) => bigint;
122
- _normalizePublicKey: (publicKey: import("./abstract/weierstrass.js").PubKey) => import("./abstract/weierstrass.js").PointType<bigint>;
123
- _isWithinCurveOrder: (num: bigint) => boolean;
124
- _isValidFieldElement: (num: bigint) => boolean;
125
- _weierstrassEquation: (x: bigint) => bigint;
126
97
  isValidPrivateKey(privateKey: import("./abstract/utils.js").PrivKey): boolean;
127
98
  hashToPrivateKey: (hash: import("./abstract/utils.js").Hex) => Uint8Array;
128
99
  randomPrivateKey: () => Uint8Array;
129
100
  };
130
101
  }>;
102
+ declare const hashToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>, encodeToCurve: (msg: import("./abstract/utils.js").Hex, options?: htf.htfBasicOpts | undefined) => htf.H2CPoint<bigint>;
103
+ export { hashToCurve, encodeToCurve };
package/lib/p384.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.secp384r1 = exports.P384 = void 0;
3
+ exports.encodeToCurve = exports.hashToCurve = exports.secp384r1 = exports.P384 = void 0;
4
4
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
5
  const _shortw_utils_js_1 = require("./_shortw_utils.js");
6
6
  const sha512_1 = require("@noble/hashes/sha512");
7
7
  const modular_js_1 = require("./abstract/modular.js");
8
8
  const weierstrass_js_1 = require("./abstract/weierstrass.js");
9
+ const htf = require("./abstract/hash-to-curve.js");
9
10
  // NIST secp384r1 aka P384
10
11
  // https://www.secg.org/sec2-v2.pdf, https://neuromancer.sk/std/nist/P-384
11
12
  // Field over which we'll do calculations. 2n**384n - 2n**128n - 2n**96n + 2n**32n - 1n
@@ -34,14 +35,16 @@ exports.P384 = (0, _shortw_utils_js_1.createCurve)({
34
35
  Gy: BigInt('0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f'),
35
36
  h: BigInt(1),
36
37
  lowS: false,
37
- mapToCurve: (scalars) => mapSWU(scalars[0]),
38
- htfDefaults: {
39
- DST: 'P384_XMD:SHA-384_SSWU_RO_',
40
- p: Fp.ORDER,
41
- m: 1,
42
- k: 192,
43
- expand: 'xmd',
44
- hash: sha512_1.sha384,
45
- },
46
38
  }, sha512_1.sha384);
47
39
  exports.secp384r1 = exports.P384;
40
+ const { hashToCurve, encodeToCurve } = htf.hashToCurve(exports.secp384r1.ProjectivePoint, (scalars) => mapSWU(scalars[0]), {
41
+ DST: 'P384_XMD:SHA-384_SSWU_RO_',
42
+ encodeDST: 'P384_XMD:SHA-384_SSWU_NU_',
43
+ p: Fp.ORDER,
44
+ m: 1,
45
+ k: 192,
46
+ expand: 'xmd',
47
+ hash: sha512_1.sha384,
48
+ });
49
+ exports.hashToCurve = hashToCurve;
50
+ exports.encodeToCurve = encodeToCurve;