@noble/curves 1.9.5 → 2.0.0-beta.1

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 (211) hide show
  1. package/README.md +267 -421
  2. package/abstract/bls.d.ts +49 -111
  3. package/abstract/bls.d.ts.map +1 -1
  4. package/abstract/bls.js +108 -152
  5. package/abstract/bls.js.map +1 -1
  6. package/abstract/curve.d.ts +7 -48
  7. package/abstract/curve.d.ts.map +1 -1
  8. package/abstract/curve.js +22 -47
  9. package/abstract/curve.js.map +1 -1
  10. package/abstract/edwards.d.ts +17 -68
  11. package/abstract/edwards.d.ts.map +1 -1
  12. package/abstract/edwards.js +98 -175
  13. package/abstract/edwards.js.map +1 -1
  14. package/abstract/fft.js +14 -27
  15. package/abstract/fft.js.map +1 -1
  16. package/abstract/hash-to-curve.d.ts +11 -24
  17. package/abstract/hash-to-curve.d.ts.map +1 -1
  18. package/abstract/hash-to-curve.js +30 -35
  19. package/abstract/hash-to-curve.js.map +1 -1
  20. package/abstract/modular.d.ts +5 -17
  21. package/abstract/modular.d.ts.map +1 -1
  22. package/abstract/modular.js +166 -167
  23. package/abstract/modular.js.map +1 -1
  24. package/abstract/montgomery.d.ts +4 -9
  25. package/abstract/montgomery.d.ts.map +1 -1
  26. package/abstract/montgomery.js +17 -20
  27. package/abstract/montgomery.js.map +1 -1
  28. package/abstract/oprf.d.ts +282 -0
  29. package/abstract/oprf.d.ts.map +1 -0
  30. package/abstract/oprf.js +297 -0
  31. package/abstract/oprf.js.map +1 -0
  32. package/abstract/poseidon.js +20 -24
  33. package/abstract/poseidon.js.map +1 -1
  34. package/abstract/tower.d.ts +9 -7
  35. package/abstract/tower.d.ts.map +1 -1
  36. package/abstract/tower.js +600 -364
  37. package/abstract/tower.js.map +1 -1
  38. package/abstract/weierstrass.d.ts +12 -145
  39. package/abstract/weierstrass.d.ts.map +1 -1
  40. package/abstract/weierstrass.js +153 -377
  41. package/abstract/weierstrass.js.map +1 -1
  42. package/bls12-381.d.ts +2 -2
  43. package/bls12-381.d.ts.map +1 -1
  44. package/bls12-381.js +174 -216
  45. package/bls12-381.js.map +1 -1
  46. package/bn254.d.ts +58 -10
  47. package/bn254.d.ts.map +1 -1
  48. package/bn254.js +70 -130
  49. package/bn254.js.map +1 -1
  50. package/ed25519.d.ts +12 -31
  51. package/ed25519.d.ts.map +1 -1
  52. package/ed25519.js +104 -146
  53. package/ed25519.js.map +1 -1
  54. package/ed448.d.ts +14 -33
  55. package/ed448.d.ts.map +1 -1
  56. package/ed448.js +105 -132
  57. package/ed448.js.map +1 -1
  58. package/index.js +1 -1
  59. package/misc.d.ts +10 -14
  60. package/misc.d.ts.map +1 -1
  61. package/misc.js +51 -60
  62. package/misc.js.map +1 -1
  63. package/nist.d.ts +11 -14
  64. package/nist.d.ts.map +1 -1
  65. package/nist.js +46 -55
  66. package/nist.js.map +1 -1
  67. package/package.json +9 -224
  68. package/secp256k1.d.ts +7 -23
  69. package/secp256k1.d.ts.map +1 -1
  70. package/secp256k1.js +72 -83
  71. package/secp256k1.js.map +1 -1
  72. package/src/abstract/bls.ts +197 -344
  73. package/src/abstract/curve.ts +10 -83
  74. package/src/abstract/edwards.ts +96 -223
  75. package/src/abstract/hash-to-curve.ts +32 -45
  76. package/src/abstract/modular.ts +144 -130
  77. package/src/abstract/montgomery.ts +21 -22
  78. package/src/abstract/oprf.ts +600 -0
  79. package/src/abstract/tower.ts +627 -382
  80. package/src/abstract/weierstrass.ts +101 -482
  81. package/src/bls12-381.ts +148 -176
  82. package/src/bn254.ts +67 -122
  83. package/src/ed25519.ts +65 -118
  84. package/src/ed448.ts +63 -113
  85. package/src/index.ts +1 -1
  86. package/src/misc.ts +66 -49
  87. package/src/nist.ts +48 -57
  88. package/src/secp256k1.ts +56 -88
  89. package/src/utils.ts +41 -61
  90. package/src/webcrypto.ts +362 -0
  91. package/utils.d.ts +28 -19
  92. package/utils.d.ts.map +1 -1
  93. package/utils.js +45 -121
  94. package/utils.js.map +1 -1
  95. package/webcrypto.d.ts +47 -0
  96. package/webcrypto.d.ts.map +1 -0
  97. package/webcrypto.js +231 -0
  98. package/webcrypto.js.map +1 -0
  99. package/esm/_shortw_utils.d.ts +0 -19
  100. package/esm/_shortw_utils.d.ts.map +0 -1
  101. package/esm/_shortw_utils.js +0 -16
  102. package/esm/_shortw_utils.js.map +0 -1
  103. package/esm/abstract/bls.d.ts +0 -190
  104. package/esm/abstract/bls.d.ts.map +0 -1
  105. package/esm/abstract/bls.js +0 -408
  106. package/esm/abstract/bls.js.map +0 -1
  107. package/esm/abstract/curve.d.ts +0 -231
  108. package/esm/abstract/curve.d.ts.map +0 -1
  109. package/esm/abstract/curve.js +0 -465
  110. package/esm/abstract/curve.js.map +0 -1
  111. package/esm/abstract/edwards.d.ts +0 -237
  112. package/esm/abstract/edwards.d.ts.map +0 -1
  113. package/esm/abstract/edwards.js +0 -632
  114. package/esm/abstract/edwards.js.map +0 -1
  115. package/esm/abstract/fft.d.ts +0 -122
  116. package/esm/abstract/fft.d.ts.map +0 -1
  117. package/esm/abstract/fft.js +0 -425
  118. package/esm/abstract/fft.js.map +0 -1
  119. package/esm/abstract/hash-to-curve.d.ts +0 -102
  120. package/esm/abstract/hash-to-curve.d.ts.map +0 -1
  121. package/esm/abstract/hash-to-curve.js +0 -203
  122. package/esm/abstract/hash-to-curve.js.map +0 -1
  123. package/esm/abstract/modular.d.ts +0 -171
  124. package/esm/abstract/modular.d.ts.map +0 -1
  125. package/esm/abstract/modular.js +0 -530
  126. package/esm/abstract/modular.js.map +0 -1
  127. package/esm/abstract/montgomery.d.ts +0 -30
  128. package/esm/abstract/montgomery.d.ts.map +0 -1
  129. package/esm/abstract/montgomery.js +0 -157
  130. package/esm/abstract/montgomery.js.map +0 -1
  131. package/esm/abstract/poseidon.d.ts +0 -68
  132. package/esm/abstract/poseidon.d.ts.map +0 -1
  133. package/esm/abstract/poseidon.js +0 -296
  134. package/esm/abstract/poseidon.js.map +0 -1
  135. package/esm/abstract/tower.d.ts +0 -93
  136. package/esm/abstract/tower.d.ts.map +0 -1
  137. package/esm/abstract/tower.js +0 -502
  138. package/esm/abstract/tower.js.map +0 -1
  139. package/esm/abstract/utils.d.ts +0 -5
  140. package/esm/abstract/utils.d.ts.map +0 -1
  141. package/esm/abstract/utils.js +0 -7
  142. package/esm/abstract/utils.js.map +0 -1
  143. package/esm/abstract/weierstrass.d.ts +0 -412
  144. package/esm/abstract/weierstrass.d.ts.map +0 -1
  145. package/esm/abstract/weierstrass.js +0 -1428
  146. package/esm/abstract/weierstrass.js.map +0 -1
  147. package/esm/bls12-381.d.ts +0 -16
  148. package/esm/bls12-381.d.ts.map +0 -1
  149. package/esm/bls12-381.js +0 -738
  150. package/esm/bls12-381.js.map +0 -1
  151. package/esm/bn254.d.ts +0 -18
  152. package/esm/bn254.d.ts.map +0 -1
  153. package/esm/bn254.js +0 -246
  154. package/esm/bn254.js.map +0 -1
  155. package/esm/ed25519.d.ts +0 -106
  156. package/esm/ed25519.d.ts.map +0 -1
  157. package/esm/ed25519.js +0 -467
  158. package/esm/ed25519.js.map +0 -1
  159. package/esm/ed448.d.ts +0 -101
  160. package/esm/ed448.d.ts.map +0 -1
  161. package/esm/ed448.js +0 -448
  162. package/esm/ed448.js.map +0 -1
  163. package/esm/index.d.ts +0 -2
  164. package/esm/index.d.ts.map +0 -1
  165. package/esm/index.js +0 -17
  166. package/esm/index.js.map +0 -1
  167. package/esm/jubjub.d.ts +0 -12
  168. package/esm/jubjub.d.ts.map +0 -1
  169. package/esm/jubjub.js +0 -12
  170. package/esm/jubjub.js.map +0 -1
  171. package/esm/misc.d.ts +0 -19
  172. package/esm/misc.d.ts.map +0 -1
  173. package/esm/misc.js +0 -109
  174. package/esm/misc.js.map +0 -1
  175. package/esm/nist.d.ts +0 -21
  176. package/esm/nist.d.ts.map +0 -1
  177. package/esm/nist.js +0 -132
  178. package/esm/nist.js.map +0 -1
  179. package/esm/p256.d.ts +0 -16
  180. package/esm/p256.d.ts.map +0 -1
  181. package/esm/p256.js +0 -16
  182. package/esm/p256.js.map +0 -1
  183. package/esm/p384.d.ts +0 -16
  184. package/esm/p384.d.ts.map +0 -1
  185. package/esm/p384.js +0 -16
  186. package/esm/p384.js.map +0 -1
  187. package/esm/p521.d.ts +0 -16
  188. package/esm/p521.d.ts.map +0 -1
  189. package/esm/p521.js +0 -16
  190. package/esm/p521.js.map +0 -1
  191. package/esm/package.json +0 -4
  192. package/esm/pasta.d.ts +0 -10
  193. package/esm/pasta.d.ts.map +0 -1
  194. package/esm/pasta.js +0 -10
  195. package/esm/pasta.js.map +0 -1
  196. package/esm/secp256k1.d.ts +0 -89
  197. package/esm/secp256k1.d.ts.map +0 -1
  198. package/esm/secp256k1.js +0 -292
  199. package/esm/secp256k1.js.map +0 -1
  200. package/esm/utils.d.ts +0 -110
  201. package/esm/utils.d.ts.map +0 -1
  202. package/esm/utils.js +0 -322
  203. package/esm/utils.js.map +0 -1
  204. package/src/_shortw_utils.ts +0 -21
  205. package/src/abstract/utils.ts +0 -7
  206. package/src/jubjub.ts +0 -12
  207. package/src/p256.ts +0 -15
  208. package/src/p384.ts +0 -15
  209. package/src/p521.ts +0 -15
  210. package/src/package.json +0 -3
  211. package/src/pasta.ts +0 -9
package/esm/utils.js DELETED
@@ -1,322 +0,0 @@
1
- /**
2
- * Hex, bytes and number utilities.
3
- * @module
4
- */
5
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
- import { abytes as abytes_, bytesToHex as bytesToHex_, concatBytes as concatBytes_, hexToBytes as hexToBytes_, isBytes as isBytes_, } from '@noble/hashes/utils.js';
7
- export { abytes, anumber, bytesToHex, bytesToUtf8, concatBytes, hexToBytes, isBytes, randomBytes, utf8ToBytes, } from '@noble/hashes/utils.js';
8
- const _0n = /* @__PURE__ */ BigInt(0);
9
- const _1n = /* @__PURE__ */ BigInt(1);
10
- export function abool(title, value) {
11
- if (typeof value !== 'boolean')
12
- throw new Error(title + ' boolean expected, got ' + value);
13
- }
14
- // tmp name until v2
15
- export function _abool2(value, title = '') {
16
- if (typeof value !== 'boolean') {
17
- const prefix = title && `"${title}"`;
18
- throw new Error(prefix + 'expected boolean, got type=' + typeof value);
19
- }
20
- return value;
21
- }
22
- // tmp name until v2
23
- /** Asserts something is Uint8Array. */
24
- export function _abytes2(value, length, title = '') {
25
- const bytes = isBytes_(value);
26
- const len = value?.length;
27
- const needsLen = length !== undefined;
28
- if (!bytes || (needsLen && len !== length)) {
29
- const prefix = title && `"${title}"`;
30
- const ofLen = needsLen ? ` of length ${length}` : '';
31
- const got = bytes ? `length=${len}` : `type=${typeof value}`;
32
- throw new Error(prefix + 'expected Uint8Array' + ofLen + ', got ' + got);
33
- }
34
- return value;
35
- }
36
- // Used in weierstrass, der
37
- export function numberToHexUnpadded(num) {
38
- const hex = num.toString(16);
39
- return hex.length & 1 ? '0' + hex : hex;
40
- }
41
- export function hexToNumber(hex) {
42
- if (typeof hex !== 'string')
43
- throw new Error('hex string expected, got ' + typeof hex);
44
- return hex === '' ? _0n : BigInt('0x' + hex); // Big Endian
45
- }
46
- // BE: Big Endian, LE: Little Endian
47
- export function bytesToNumberBE(bytes) {
48
- return hexToNumber(bytesToHex_(bytes));
49
- }
50
- export function bytesToNumberLE(bytes) {
51
- abytes_(bytes);
52
- return hexToNumber(bytesToHex_(Uint8Array.from(bytes).reverse()));
53
- }
54
- export function numberToBytesBE(n, len) {
55
- return hexToBytes_(n.toString(16).padStart(len * 2, '0'));
56
- }
57
- export function numberToBytesLE(n, len) {
58
- return numberToBytesBE(n, len).reverse();
59
- }
60
- // Unpadded, rarely used
61
- export function numberToVarBytesBE(n) {
62
- return hexToBytes_(numberToHexUnpadded(n));
63
- }
64
- /**
65
- * Takes hex string or Uint8Array, converts to Uint8Array.
66
- * Validates output length.
67
- * Will throw error for other types.
68
- * @param title descriptive title for an error e.g. 'secret key'
69
- * @param hex hex string or Uint8Array
70
- * @param expectedLength optional, will compare to result array's length
71
- * @returns
72
- */
73
- export function ensureBytes(title, hex, expectedLength) {
74
- let res;
75
- if (typeof hex === 'string') {
76
- try {
77
- res = hexToBytes_(hex);
78
- }
79
- catch (e) {
80
- throw new Error(title + ' must be hex string or Uint8Array, cause: ' + e);
81
- }
82
- }
83
- else if (isBytes_(hex)) {
84
- // Uint8Array.from() instead of hash.slice() because node.js Buffer
85
- // is instance of Uint8Array, and its slice() creates **mutable** copy
86
- res = Uint8Array.from(hex);
87
- }
88
- else {
89
- throw new Error(title + ' must be hex string or Uint8Array');
90
- }
91
- const len = res.length;
92
- if (typeof expectedLength === 'number' && len !== expectedLength)
93
- throw new Error(title + ' of length ' + expectedLength + ' expected, got ' + len);
94
- return res;
95
- }
96
- // Compares 2 u8a-s in kinda constant time
97
- export function equalBytes(a, b) {
98
- if (a.length !== b.length)
99
- return false;
100
- let diff = 0;
101
- for (let i = 0; i < a.length; i++)
102
- diff |= a[i] ^ b[i];
103
- return diff === 0;
104
- }
105
- /**
106
- * Copies Uint8Array. We can't use u8a.slice(), because u8a can be Buffer,
107
- * and Buffer#slice creates mutable copy. Never use Buffers!
108
- */
109
- export function copyBytes(bytes) {
110
- return Uint8Array.from(bytes);
111
- }
112
- /**
113
- * Decodes 7-bit ASCII string to Uint8Array, throws on non-ascii symbols
114
- * Should be safe to use for things expected to be ASCII.
115
- * Returns exact same result as utf8ToBytes for ASCII or throws.
116
- */
117
- export function asciiToBytes(ascii) {
118
- return Uint8Array.from(ascii, (c, i) => {
119
- const charCode = c.charCodeAt(0);
120
- if (c.length !== 1 || charCode > 127) {
121
- throw new Error(`string contains non-ASCII character "${ascii[i]}" with code ${charCode} at position ${i}`);
122
- }
123
- return charCode;
124
- });
125
- }
126
- /**
127
- * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
128
- */
129
- // export const utf8ToBytes: typeof utf8ToBytes_ = utf8ToBytes_;
130
- /**
131
- * Converts bytes to string using UTF8 encoding.
132
- * @example bytesToUtf8(Uint8Array.from([97, 98, 99])) // 'abc'
133
- */
134
- // export const bytesToUtf8: typeof bytesToUtf8_ = bytesToUtf8_;
135
- // Is positive bigint
136
- const isPosBig = (n) => typeof n === 'bigint' && _0n <= n;
137
- export function inRange(n, min, max) {
138
- return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;
139
- }
140
- /**
141
- * Asserts min <= n < max. NOTE: It's < max and not <= max.
142
- * @example
143
- * aInRange('x', x, 1n, 256n); // would assume x is in (1n..255n)
144
- */
145
- export function aInRange(title, n, min, max) {
146
- // Why min <= n < max and not a (min < n < max) OR b (min <= n <= max)?
147
- // consider P=256n, min=0n, max=P
148
- // - a for min=0 would require -1: `inRange('x', x, -1n, P)`
149
- // - b would commonly require subtraction: `inRange('x', x, 0n, P - 1n)`
150
- // - our way is the cleanest: `inRange('x', x, 0n, P)
151
- if (!inRange(n, min, max))
152
- throw new Error('expected valid ' + title + ': ' + min + ' <= n < ' + max + ', got ' + n);
153
- }
154
- // Bit operations
155
- /**
156
- * Calculates amount of bits in a bigint.
157
- * Same as `n.toString(2).length`
158
- * TODO: merge with nLength in modular
159
- */
160
- export function bitLen(n) {
161
- let len;
162
- for (len = 0; n > _0n; n >>= _1n, len += 1)
163
- ;
164
- return len;
165
- }
166
- /**
167
- * Gets single bit at position.
168
- * NOTE: first bit position is 0 (same as arrays)
169
- * Same as `!!+Array.from(n.toString(2)).reverse()[pos]`
170
- */
171
- export function bitGet(n, pos) {
172
- return (n >> BigInt(pos)) & _1n;
173
- }
174
- /**
175
- * Sets single bit at position.
176
- */
177
- export function bitSet(n, pos, value) {
178
- return n | ((value ? _1n : _0n) << BigInt(pos));
179
- }
180
- /**
181
- * Calculate mask for N bits. Not using ** operator with bigints because of old engines.
182
- * Same as BigInt(`0b${Array(i).fill('1').join('')}`)
183
- */
184
- export const bitMask = (n) => (_1n << BigInt(n)) - _1n;
185
- /**
186
- * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs.
187
- * @returns function that will call DRBG until 2nd arg returns something meaningful
188
- * @example
189
- * const drbg = createHmacDRBG<Key>(32, 32, hmac);
190
- * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined
191
- */
192
- export function createHmacDrbg(hashLen, qByteLen, hmacFn) {
193
- if (typeof hashLen !== 'number' || hashLen < 2)
194
- throw new Error('hashLen must be a number');
195
- if (typeof qByteLen !== 'number' || qByteLen < 2)
196
- throw new Error('qByteLen must be a number');
197
- if (typeof hmacFn !== 'function')
198
- throw new Error('hmacFn must be a function');
199
- // Step B, Step C: set hashLen to 8*ceil(hlen/8)
200
- const u8n = (len) => new Uint8Array(len); // creates Uint8Array
201
- const u8of = (byte) => Uint8Array.of(byte); // another shortcut
202
- let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs.
203
- let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same
204
- let i = 0; // Iterations counter, will throw when over 1000
205
- const reset = () => {
206
- v.fill(1);
207
- k.fill(0);
208
- i = 0;
209
- };
210
- const h = (...b) => hmacFn(k, v, ...b); // hmac(k)(v, ...values)
211
- const reseed = (seed = u8n(0)) => {
212
- // HMAC-DRBG reseed() function. Steps D-G
213
- k = h(u8of(0x00), seed); // k = hmac(k || v || 0x00 || seed)
214
- v = h(); // v = hmac(k || v)
215
- if (seed.length === 0)
216
- return;
217
- k = h(u8of(0x01), seed); // k = hmac(k || v || 0x01 || seed)
218
- v = h(); // v = hmac(k || v)
219
- };
220
- const gen = () => {
221
- // HMAC-DRBG generate() function
222
- if (i++ >= 1000)
223
- throw new Error('drbg: tried 1000 values');
224
- let len = 0;
225
- const out = [];
226
- while (len < qByteLen) {
227
- v = h();
228
- const sl = v.slice();
229
- out.push(sl);
230
- len += v.length;
231
- }
232
- return concatBytes_(...out);
233
- };
234
- const genUntil = (seed, pred) => {
235
- reset();
236
- reseed(seed); // Steps D-G
237
- let res = undefined; // Step H: grind until k is in [1..n-1]
238
- while (!(res = pred(gen())))
239
- reseed();
240
- reset();
241
- return res;
242
- };
243
- return genUntil;
244
- }
245
- // Validating curves and fields
246
- const validatorFns = {
247
- bigint: (val) => typeof val === 'bigint',
248
- function: (val) => typeof val === 'function',
249
- boolean: (val) => typeof val === 'boolean',
250
- string: (val) => typeof val === 'string',
251
- stringOrUint8Array: (val) => typeof val === 'string' || isBytes_(val),
252
- isSafeInteger: (val) => Number.isSafeInteger(val),
253
- array: (val) => Array.isArray(val),
254
- field: (val, object) => object.Fp.isValid(val),
255
- hash: (val) => typeof val === 'function' && Number.isSafeInteger(val.outputLen),
256
- };
257
- // type Record<K extends string | number | symbol, T> = { [P in K]: T; }
258
- export function validateObject(object, validators, optValidators = {}) {
259
- const checkField = (fieldName, type, isOptional) => {
260
- const checkVal = validatorFns[type];
261
- if (typeof checkVal !== 'function')
262
- throw new Error('invalid validator function');
263
- const val = object[fieldName];
264
- if (isOptional && val === undefined)
265
- return;
266
- if (!checkVal(val, object)) {
267
- throw new Error('param ' + String(fieldName) + ' is invalid. Expected ' + type + ', got ' + val);
268
- }
269
- };
270
- for (const [fieldName, type] of Object.entries(validators))
271
- checkField(fieldName, type, false);
272
- for (const [fieldName, type] of Object.entries(optValidators))
273
- checkField(fieldName, type, true);
274
- return object;
275
- }
276
- // validate type tests
277
- // const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 };
278
- // const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok!
279
- // // Should fail type-check
280
- // const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' });
281
- // const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' });
282
- // const z3 = validateObject(o, { test: 'boolean', z: 'bug' });
283
- // const z4 = validateObject(o, { a: 'boolean', z: 'bug' });
284
- export function isHash(val) {
285
- return typeof val === 'function' && Number.isSafeInteger(val.outputLen);
286
- }
287
- export function _validateObject(object, fields, optFields = {}) {
288
- if (!object || typeof object !== 'object')
289
- throw new Error('expected valid options object');
290
- function checkField(fieldName, expectedType, isOpt) {
291
- const val = object[fieldName];
292
- if (isOpt && val === undefined)
293
- return;
294
- const current = typeof val;
295
- if (current !== expectedType || val === null)
296
- throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
297
- }
298
- Object.entries(fields).forEach(([k, v]) => checkField(k, v, false));
299
- Object.entries(optFields).forEach(([k, v]) => checkField(k, v, true));
300
- }
301
- /**
302
- * throws not implemented error
303
- */
304
- export const notImplemented = () => {
305
- throw new Error('not implemented');
306
- };
307
- /**
308
- * Memoizes (caches) computation result.
309
- * Uses WeakMap: the value is going auto-cleaned by GC after last reference is removed.
310
- */
311
- export function memoized(fn) {
312
- const map = new WeakMap();
313
- return (arg, ...args) => {
314
- const val = map.get(arg);
315
- if (val !== undefined)
316
- return val;
317
- const computed = fn(arg, ...args);
318
- map.set(arg, computed);
319
- return computed;
320
- };
321
- }
322
- //# sourceMappingURL=utils.js.map
package/esm/utils.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,sEAAsE;AACtE,OAAO,EACL,MAAM,IAAI,OAAO,EACjB,UAAU,IAAI,WAAW,EACzB,WAAW,IAAI,YAAY,EAC3B,UAAU,IAAI,WAAW,EACzB,OAAO,IAAI,QAAQ,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,MAAM,EACN,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,OAAO,EACP,WAAW,EACX,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACtC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAWtC,MAAM,UAAU,KAAK,CAAC,KAAa,EAAE,KAAc;IACjD,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,KAAK,GAAG,yBAAyB,GAAG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AAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAU,EAAE;IACxC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACtB,EAA6B;IAE7B,MAAM,GAAG,GAAG,IAAI,OAAO,EAAQ,CAAC;IAChC,OAAO,CAAC,GAAM,EAAE,GAAG,IAAO,EAAK,EAAE;QAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,GAAG,KAAK,SAAS;YAAE,OAAO,GAAG,CAAC;QAClC,MAAM,QAAQ,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAClC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * Utilities for short weierstrass curves, combined with noble-hashes.
3
- * @module
4
- */
5
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
- import { type CurveFn, type CurveType, weierstrass } from './abstract/weierstrass.ts';
7
- import type { CHash } from './utils.ts';
8
-
9
- /** connects noble-curves to noble-hashes */
10
- export function getHash(hash: CHash): { hash: CHash } {
11
- return { hash };
12
- }
13
- /** Same API as @noble/hashes, with ability to create curve with custom hash */
14
- export type CurveDef = Readonly<Omit<CurveType, 'hash'>>;
15
- export type CurveFnWithCreate = CurveFn & { create: (hash: CHash) => CurveFn };
16
-
17
- /** @deprecated use new `weierstrass()` and `ecdsa()` methods */
18
- export function createCurve(curveDef: CurveDef, defHash: CHash): CurveFnWithCreate {
19
- const create = (hash: CHash): CurveFn => weierstrass({ ...curveDef, hash: hash });
20
- return { ...create(defHash), create };
21
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * @module
3
- */
4
- export * from '../utils.ts';
5
-
6
- // TODO
7
- // @deprecated use `@noble/curves/utils.js`
package/src/jubjub.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * @deprecated
3
- * @module
4
- */
5
- import { jubjub_findGroupHash, jubjub_groupHash, jubjub as jubjubn } from './misc.ts';
6
-
7
- /** @deprecated use `import { jubjub } from '@noble/curves/misc.js';` */
8
- export const jubjub: typeof jubjubn = jubjubn;
9
- /** @deprecated use `import { jubjub_findGroupHash } from '@noble/curves/misc.js';` */
10
- export const findGroupHash: typeof jubjub_findGroupHash = jubjub_findGroupHash;
11
- /** @deprecated use `import { jubjub_groupHash } from '@noble/curves/misc.js';` */
12
- export const groupHash: typeof jubjub_groupHash = jubjub_groupHash;
package/src/p256.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * NIST secp256r1 aka p256.
3
- * @module
4
- */
5
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
- import { type H2CMethod } from './abstract/hash-to-curve.ts';
7
- import { p256_hasher, p256 as p256n } from './nist.ts';
8
- /** @deprecated use `import { p256 } from '@noble/curves/nist.js';` */
9
- export const p256: typeof p256n = p256n;
10
- /** @deprecated use `import { p256 } from '@noble/curves/nist.js';` */
11
- export const secp256r1: typeof p256n = p256n;
12
- /** @deprecated use `import { p256_hasher } from '@noble/curves/nist.js';` */
13
- export const hashToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => p256_hasher.hashToCurve)();
14
- /** @deprecated use `import { p256_hasher } from '@noble/curves/nist.js';` */
15
- export const encodeToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => p256_hasher.encodeToCurve)();
package/src/p384.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * NIST secp384r1 aka p384.
3
- * @module
4
- */
5
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
- import { type H2CMethod } from './abstract/hash-to-curve.ts';
7
- import { p384_hasher, p384 as p384n } from './nist.ts';
8
- /** @deprecated use `import { p384 } from '@noble/curves/nist.js';` */
9
- export const p384: typeof p384n = p384n;
10
- /** @deprecated use `import { p384 } from '@noble/curves/nist.js';` */
11
- export const secp384r1: typeof p384n = p384n;
12
- /** @deprecated use `import { p384_hasher } from '@noble/curves/nist.js';` */
13
- export const hashToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => p384_hasher.hashToCurve)();
14
- /** @deprecated use `import { p384_hasher } from '@noble/curves/nist.js';` */
15
- export const encodeToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => p384_hasher.encodeToCurve)();
package/src/p521.ts DELETED
@@ -1,15 +0,0 @@
1
- /**
2
- * NIST secp521r1 aka p521.
3
- * @module
4
- */
5
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
- import { type H2CMethod } from './abstract/hash-to-curve.ts';
7
- import { p521_hasher, p521 as p521n } from './nist.ts';
8
- /** @deprecated use `import { p521 } from '@noble/curves/nist.js';` */
9
- export const p521: typeof p521n = p521n;
10
- /** @deprecated use `import { p521 } from '@noble/curves/nist.js';` */
11
- export const secp521r1: typeof p521n = p521n;
12
- /** @deprecated use `import { p521_hasher } from '@noble/curves/nist.js';` */
13
- export const hashToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => p521_hasher.hashToCurve)();
14
- /** @deprecated use `import { p521_hasher } from '@noble/curves/nist.js';` */
15
- export const encodeToCurve: H2CMethod<bigint> = /* @__PURE__ */ (() => p521_hasher.encodeToCurve)();
package/src/package.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
package/src/pasta.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * @deprecated
3
- * @module
4
- */
5
- import { pallas as pn, vesta as vn } from './misc.ts';
6
- /** @deprecated */
7
- export const pallas: typeof pn = pn;
8
- /** @deprecated */
9
- export const vesta: typeof vn = vn;