@sentio/sdk-bundle 4.0.1-rc.2 → 4.0.1-rc.4
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.
- package/assets/chainlink-oracles-sepolia.json +21 -0
- package/assets/chainlink-oracles.json +219 -0
- package/dist/{0x1-B_N1Dd6d.js → 0x1-CWhLCIJf.js} +30 -22
- package/dist/0x1-CWhLCIJf.js.map +1 -0
- package/dist/{AbstractKeylessAccount-dvYSW9Go.js → AbstractKeylessAccount-DE1e2Glg.js} +3 -2
- package/dist/{AbstractKeylessAccount-dvYSW9Go.js.map → AbstractKeylessAccount-DE1e2Glg.js.map} +1 -1
- package/dist/_md-CZAi2AzY.js +644 -0
- package/dist/_md-CZAi2AzY.js.map +1 -0
- package/dist/aptos/builtin/0x1.js +2 -2
- package/dist/aptos/builtin/0x3.js +3 -3
- package/dist/aptos/builtin/0x3.js.map +1 -1
- package/dist/aptos/builtin/0x4.js +3 -3
- package/dist/aptos/builtin/0x4.js.map +1 -1
- package/dist/aptos/builtin/index.js +1 -1
- package/dist/aptos/ext/index.js +2 -2
- package/dist/aptos/index.js +2 -2
- package/dist/{aptos-DPeebJ9j.js → aptos-Cgfa8IQj.js} +257 -47
- package/dist/{aptos-DPeebJ9j.js.map → aptos-Cgfa8IQj.js.map} +1 -1
- package/dist/{coin-DREiK-Br.js → coin-CBrx3CpG.js} +1514 -105
- package/dist/coin-CBrx3CpG.js.map +1 -0
- package/dist/{coin-CWRVUEBa.js → coin-Mht4Jgvj.js} +803 -4
- package/dist/coin-Mht4Jgvj.js.map +1 -0
- package/dist/eth/builtin/eacaggregatorproxy.js +1 -1
- package/dist/eth/builtin/erc1155.js +1 -1
- package/dist/eth/builtin/erc20.js +1 -1
- package/dist/eth/builtin/erc721.js +1 -1
- package/dist/eth/builtin/index.js +1 -1
- package/dist/eth/builtin/weth9.js +1 -1
- package/dist/eth/index.js +1 -1
- package/dist/iota/builtin/0x1.js +3 -3
- package/dist/iota/builtin/0x2.js +168 -5
- package/dist/iota/builtin/0x2.js.map +1 -1
- package/dist/iota/builtin/0x3.js +3 -3
- package/dist/iota/ext/index.js +1 -1
- package/dist/iota/index.js +3 -3
- package/dist/{keyless-B3QnUmtL.js → keyless-nGiRkJjM.js} +1278 -976
- package/dist/keyless-nGiRkJjM.js.map +1 -0
- package/dist/move/index.js +1 -1
- package/dist/{move-Dr-DL5zT.js → move-BVvdKH2Q.js} +7 -7
- package/dist/{move-Dr-DL5zT.js.map → move-BVvdKH2Q.js.map} +1 -1
- package/dist/sui/builtin/0x1.js +1 -1
- package/dist/sui/builtin/0x2.js +4 -4
- package/dist/sui/builtin/0x3.js +4 -4
- package/dist/sui/builtin/index.js +1 -1
- package/dist/sui/ext/index.js +1 -1
- package/dist/sui/index.js +3 -3
- package/dist/{sui-BbKeYXM3.js → sui-BcHp8IsJ.js} +17 -17
- package/dist/{sui-BbKeYXM3.js.map → sui-BcHp8IsJ.js.map} +1 -1
- package/dist/testing/index.js +6 -6
- package/dist/utils/index.js +1 -1
- package/dist/{utils-Jndk-n_F.js → utils-BQ0dnllb.js} +11 -903
- package/dist/utils-BQ0dnllb.js.map +1 -0
- package/package.json +2 -2
- package/assets/chainlink-oracles-sepolia.csv +0 -19
- package/assets/chainlink-oracles.csv +0 -217
- package/dist/0x1-B_N1Dd6d.js.map +0 -1
- package/dist/base-BvfRCgEy.js +0 -959
- package/dist/base-BvfRCgEy.js.map +0 -1
- package/dist/coin-CWRVUEBa.js.map +0 -1
- package/dist/coin-DREiK-Br.js.map +0 -1
- package/dist/dist-CA96PSzE.js +0 -824
- package/dist/dist-CA96PSzE.js.map +0 -1
- package/dist/keyless-B3QnUmtL.js.map +0 -1
- package/dist/utils-Jndk-n_F.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as __name, i as __exportAll, n as __commonJSMin } from "./bignumber-DddanwOv.js";
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as anumber$4, B as rotr$1, C as rotrSL$1, D as abytes$4, E as split$1, F as createHasher$2, I as hexToBytes$2, L as isBytes$4, M as bytesToHex$2, N as clean$2, O as aexists$2, P as concatBytes$2, R as oidNist$1, S as rotrSH$1, T as shrSL$1, U as u32$1, V as swap32IfBE$1, _ as rotlSL, a as SHA512_IV$1, b as rotrBH$1, c as add3L$1, d as add5H$1, f as add5L$1, g as rotlSH, h as rotlBL, i as SHA256_IV$1, j as aoutput$2, k as ahash$1, l as add4H$1, m as rotlBH, n as HashMD$1, o as add$1, r as Maj$1, s as add3H$1, t as Chi$1, u as add4L$1, w as shrSH$1, x as rotrBL$1, z as randomBytes$2 } from "./_md-CZAi2AzY.js";
|
|
3
3
|
|
|
4
4
|
//#region ../../node_modules/.pnpm/@aptos-labs+ts-sdk@7.1.0/node_modules/@aptos-labs/ts-sdk/dist/utils/const.js
|
|
5
5
|
/**
|
|
@@ -91,413 +91,6 @@ const FIREBASE_AUTH_ISS_PATTERN = /^https:\/\/securetoken\.google\.com\/[a-zA-Z0
|
|
|
91
91
|
*/
|
|
92
92
|
const TEXT_ENCODER = new TextEncoder();
|
|
93
93
|
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/utils.js
|
|
96
|
-
/**
|
|
97
|
-
* Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.
|
|
98
|
-
* @param a - value to test
|
|
99
|
-
* @returns `true` when the value is a Uint8Array-compatible view.
|
|
100
|
-
* @example
|
|
101
|
-
* Check whether a value is a Uint8Array-compatible view.
|
|
102
|
-
* ```ts
|
|
103
|
-
* isBytes(new Uint8Array([1, 2, 3]));
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
function isBytes$2(a) {
|
|
107
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
108
|
-
}
|
|
109
|
-
__name(isBytes$2, "isBytes");
|
|
110
|
-
/**
|
|
111
|
-
* Asserts something is a non-negative integer.
|
|
112
|
-
* @param n - number to validate
|
|
113
|
-
* @param title - label included in thrown errors
|
|
114
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
115
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
116
|
-
* @example
|
|
117
|
-
* Validate a non-negative integer option.
|
|
118
|
-
* ```ts
|
|
119
|
-
* anumber(32, 'length');
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
function anumber$2(n, title = "") {
|
|
123
|
-
if (typeof n !== "number") {
|
|
124
|
-
const prefix = title && `"${title}" `;
|
|
125
|
-
throw new TypeError(`${prefix}expected number, got ${typeof n}`);
|
|
126
|
-
}
|
|
127
|
-
if (!Number.isSafeInteger(n) || n < 0) {
|
|
128
|
-
const prefix = title && `"${title}" `;
|
|
129
|
-
throw new RangeError(`${prefix}expected integer >= 0, got ${n}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
__name(anumber$2, "anumber");
|
|
133
|
-
/**
|
|
134
|
-
* Asserts something is Uint8Array.
|
|
135
|
-
* @param value - value to validate
|
|
136
|
-
* @param length - optional exact length constraint
|
|
137
|
-
* @param title - label included in thrown errors
|
|
138
|
-
* @returns The validated byte array.
|
|
139
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
140
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
141
|
-
* @example
|
|
142
|
-
* Validate that a value is a byte array.
|
|
143
|
-
* ```ts
|
|
144
|
-
* abytes(new Uint8Array([1, 2, 3]));
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
function abytes$2(value, length, title = "") {
|
|
148
|
-
const bytes = isBytes$2(value);
|
|
149
|
-
const len = value?.length;
|
|
150
|
-
const needsLen = length !== void 0;
|
|
151
|
-
if (!bytes || needsLen && len !== length) {
|
|
152
|
-
const prefix = title && `"${title}" `;
|
|
153
|
-
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
154
|
-
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
155
|
-
const message = prefix + "expected Uint8Array" + ofLen + ", got " + got;
|
|
156
|
-
if (!bytes) throw new TypeError(message);
|
|
157
|
-
throw new RangeError(message);
|
|
158
|
-
}
|
|
159
|
-
return value;
|
|
160
|
-
}
|
|
161
|
-
__name(abytes$2, "abytes");
|
|
162
|
-
/**
|
|
163
|
-
* Asserts something is a wrapped hash constructor.
|
|
164
|
-
* @param h - hash constructor to validate
|
|
165
|
-
* @throws On wrong argument types or invalid hash wrapper shape. {@link TypeError}
|
|
166
|
-
* @throws On invalid hash metadata ranges or values. {@link RangeError}
|
|
167
|
-
* @throws If the hash metadata allows empty outputs or block sizes. {@link Error}
|
|
168
|
-
* @example
|
|
169
|
-
* Validate a callable hash wrapper.
|
|
170
|
-
* ```ts
|
|
171
|
-
* import { ahash } from '@noble/hashes/utils.js';
|
|
172
|
-
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
173
|
-
* ahash(sha256);
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
function ahash(h) {
|
|
177
|
-
if (typeof h !== "function" || typeof h.create !== "function") throw new TypeError("Hash must wrapped by utils.createHasher");
|
|
178
|
-
anumber$2(h.outputLen);
|
|
179
|
-
anumber$2(h.blockLen);
|
|
180
|
-
if (h.outputLen < 1) throw new Error("\"outputLen\" must be >= 1");
|
|
181
|
-
if (h.blockLen < 1) throw new Error("\"blockLen\" must be >= 1");
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Asserts a hash instance has not been destroyed or finished.
|
|
185
|
-
* @param instance - hash instance to validate
|
|
186
|
-
* @param checkFinished - whether to reject finalized instances
|
|
187
|
-
* @throws If the hash instance has already been destroyed or finalized. {@link Error}
|
|
188
|
-
* @example
|
|
189
|
-
* Validate that a hash instance is still usable.
|
|
190
|
-
* ```ts
|
|
191
|
-
* import { aexists } from '@noble/hashes/utils.js';
|
|
192
|
-
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
193
|
-
* const hash = sha256.create();
|
|
194
|
-
* aexists(hash);
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
function aexists$1(instance, checkFinished = true) {
|
|
198
|
-
if (instance.destroyed) throw new Error("Hash instance has been destroyed");
|
|
199
|
-
if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called");
|
|
200
|
-
}
|
|
201
|
-
__name(aexists$1, "aexists");
|
|
202
|
-
/**
|
|
203
|
-
* Asserts output is a sufficiently-sized byte array.
|
|
204
|
-
* @param out - destination buffer
|
|
205
|
-
* @param instance - hash instance providing output length
|
|
206
|
-
* Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.
|
|
207
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
208
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
209
|
-
* @example
|
|
210
|
-
* Validate a caller-provided digest buffer.
|
|
211
|
-
* ```ts
|
|
212
|
-
* import { aoutput } from '@noble/hashes/utils.js';
|
|
213
|
-
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
214
|
-
* const hash = sha256.create();
|
|
215
|
-
* aoutput(new Uint8Array(hash.outputLen), hash);
|
|
216
|
-
* ```
|
|
217
|
-
*/
|
|
218
|
-
function aoutput$1(out, instance) {
|
|
219
|
-
abytes$2(out, void 0, "digestInto() output");
|
|
220
|
-
const min = instance.outputLen;
|
|
221
|
-
if (out.length < min) throw new RangeError("\"digestInto() output\" expected to be of length >=" + min);
|
|
222
|
-
}
|
|
223
|
-
__name(aoutput$1, "aoutput");
|
|
224
|
-
/**
|
|
225
|
-
* Casts a typed array view to Uint32Array.
|
|
226
|
-
* `arr.byteOffset` must already be 4-byte aligned or the platform
|
|
227
|
-
* Uint32Array constructor will throw.
|
|
228
|
-
* @param arr - source typed array
|
|
229
|
-
* @returns Uint32Array view over the same buffer.
|
|
230
|
-
* @example
|
|
231
|
-
* Reinterpret a byte array as 32-bit words.
|
|
232
|
-
* ```ts
|
|
233
|
-
* u32(new Uint8Array(8));
|
|
234
|
-
* ```
|
|
235
|
-
*/
|
|
236
|
-
function u32$1(arr) {
|
|
237
|
-
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
238
|
-
}
|
|
239
|
-
__name(u32$1, "u32");
|
|
240
|
-
/**
|
|
241
|
-
* Zeroizes typed arrays in place. Warning: JS provides no guarantees.
|
|
242
|
-
* @param arrays - arrays to overwrite with zeros
|
|
243
|
-
* @example
|
|
244
|
-
* Zeroize sensitive buffers in place.
|
|
245
|
-
* ```ts
|
|
246
|
-
* clean(new Uint8Array([1, 2, 3]));
|
|
247
|
-
* ```
|
|
248
|
-
*/
|
|
249
|
-
function clean$1(...arrays) {
|
|
250
|
-
for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
|
|
251
|
-
}
|
|
252
|
-
__name(clean$1, "clean");
|
|
253
|
-
/**
|
|
254
|
-
* Creates a DataView for byte-level manipulation.
|
|
255
|
-
* @param arr - source typed array
|
|
256
|
-
* @returns DataView over the same buffer region.
|
|
257
|
-
* @example
|
|
258
|
-
* Create a DataView over an existing buffer.
|
|
259
|
-
* ```ts
|
|
260
|
-
* createView(new Uint8Array(4));
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
function createView$1(arr) {
|
|
264
|
-
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
265
|
-
}
|
|
266
|
-
__name(createView$1, "createView");
|
|
267
|
-
/**
|
|
268
|
-
* Rotate-right operation for uint32 values.
|
|
269
|
-
* @param word - source word
|
|
270
|
-
* @param shift - shift amount in bits
|
|
271
|
-
* @returns Rotated word.
|
|
272
|
-
* @example
|
|
273
|
-
* Rotate a 32-bit word to the right.
|
|
274
|
-
* ```ts
|
|
275
|
-
* rotr(0x12345678, 8);
|
|
276
|
-
* ```
|
|
277
|
-
*/
|
|
278
|
-
function rotr(word, shift) {
|
|
279
|
-
return word << 32 - shift | word >>> shift;
|
|
280
|
-
}
|
|
281
|
-
/** Whether the current platform is little-endian. */
|
|
282
|
-
const isLE$1 = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
283
|
-
/**
|
|
284
|
-
* Byte-swap operation for uint32 values.
|
|
285
|
-
* @param word - source word
|
|
286
|
-
* @returns Word with reversed byte order.
|
|
287
|
-
* @example
|
|
288
|
-
* Reverse the byte order of a 32-bit word.
|
|
289
|
-
* ```ts
|
|
290
|
-
* byteSwap(0x11223344);
|
|
291
|
-
* ```
|
|
292
|
-
*/
|
|
293
|
-
function byteSwap$1(word) {
|
|
294
|
-
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
295
|
-
}
|
|
296
|
-
__name(byteSwap$1, "byteSwap");
|
|
297
|
-
/**
|
|
298
|
-
* Byte-swaps every word of a Uint32Array in place.
|
|
299
|
-
* @param arr - array to mutate
|
|
300
|
-
* @returns The same array after mutation; callers pass live state arrays here.
|
|
301
|
-
* @example
|
|
302
|
-
* Reverse the byte order of every word in place.
|
|
303
|
-
* ```ts
|
|
304
|
-
* byteSwap32(new Uint32Array([0x11223344]));
|
|
305
|
-
* ```
|
|
306
|
-
*/
|
|
307
|
-
function byteSwap32$1(arr) {
|
|
308
|
-
for (let i = 0; i < arr.length; i++) arr[i] = byteSwap$1(arr[i]);
|
|
309
|
-
return arr;
|
|
310
|
-
}
|
|
311
|
-
__name(byteSwap32$1, "byteSwap32");
|
|
312
|
-
/**
|
|
313
|
-
* Conditionally byte-swaps a Uint32Array on big-endian platforms.
|
|
314
|
-
* @param u - array to normalize for host endianness
|
|
315
|
-
* @returns Original or byte-swapped array depending on platform endianness.
|
|
316
|
-
* On big-endian runtimes this mutates `u` in place via `byteSwap32(...)`.
|
|
317
|
-
* @example
|
|
318
|
-
* Normalize a word array for host endianness.
|
|
319
|
-
* ```ts
|
|
320
|
-
* swap32IfBE(new Uint32Array([0x11223344]));
|
|
321
|
-
* ```
|
|
322
|
-
*/
|
|
323
|
-
const swap32IfBE$1 = isLE$1 ? (u) => u : byteSwap32$1;
|
|
324
|
-
const hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
|
|
325
|
-
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
326
|
-
/**
|
|
327
|
-
* Convert byte array to hex string.
|
|
328
|
-
* Uses the built-in function when available and assumes it matches the tested
|
|
329
|
-
* fallback semantics.
|
|
330
|
-
* @param bytes - bytes to encode
|
|
331
|
-
* @returns Lowercase hexadecimal string.
|
|
332
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
333
|
-
* @example
|
|
334
|
-
* Convert bytes to lowercase hexadecimal.
|
|
335
|
-
* ```ts
|
|
336
|
-
* bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // 'cafe0123'
|
|
337
|
-
* ```
|
|
338
|
-
*/
|
|
339
|
-
function bytesToHex$1(bytes) {
|
|
340
|
-
abytes$2(bytes);
|
|
341
|
-
if (hasHexBuiltin) return bytes.toHex();
|
|
342
|
-
let hex = "";
|
|
343
|
-
for (let i = 0; i < bytes.length; i++) hex += hexes[bytes[i]];
|
|
344
|
-
return hex;
|
|
345
|
-
}
|
|
346
|
-
__name(bytesToHex$1, "bytesToHex");
|
|
347
|
-
const asciis = {
|
|
348
|
-
_0: 48,
|
|
349
|
-
_9: 57,
|
|
350
|
-
A: 65,
|
|
351
|
-
F: 70,
|
|
352
|
-
a: 97,
|
|
353
|
-
f: 102
|
|
354
|
-
};
|
|
355
|
-
function asciiToBase16(ch) {
|
|
356
|
-
if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0;
|
|
357
|
-
if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10);
|
|
358
|
-
if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10);
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* Convert hex string to byte array. Uses built-in function, when available.
|
|
362
|
-
* @param hex - hexadecimal string to decode
|
|
363
|
-
* @returns Decoded bytes.
|
|
364
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
365
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
366
|
-
* @example
|
|
367
|
-
* Decode lowercase hexadecimal into bytes.
|
|
368
|
-
* ```ts
|
|
369
|
-
* hexToBytes('cafe0123'); // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
370
|
-
* ```
|
|
371
|
-
*/
|
|
372
|
-
function hexToBytes$1(hex) {
|
|
373
|
-
if (typeof hex !== "string") throw new TypeError("hex string expected, got " + typeof hex);
|
|
374
|
-
if (hasHexBuiltin) try {
|
|
375
|
-
return Uint8Array.fromHex(hex);
|
|
376
|
-
} catch (error) {
|
|
377
|
-
if (error instanceof SyntaxError) throw new RangeError(error.message);
|
|
378
|
-
throw error;
|
|
379
|
-
}
|
|
380
|
-
const hl = hex.length;
|
|
381
|
-
const al = hl / 2;
|
|
382
|
-
if (hl % 2) throw new RangeError("hex string expected, got unpadded hex of length " + hl);
|
|
383
|
-
const array = new Uint8Array(al);
|
|
384
|
-
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
385
|
-
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
386
|
-
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
387
|
-
if (n1 === void 0 || n2 === void 0) {
|
|
388
|
-
const char = hex[hi] + hex[hi + 1];
|
|
389
|
-
throw new RangeError("hex string expected, got non-hex character \"" + char + "\" at index " + hi);
|
|
390
|
-
}
|
|
391
|
-
array[ai] = n1 * 16 + n2;
|
|
392
|
-
}
|
|
393
|
-
return array;
|
|
394
|
-
}
|
|
395
|
-
__name(hexToBytes$1, "hexToBytes");
|
|
396
|
-
/**
|
|
397
|
-
* Copies several Uint8Arrays into one.
|
|
398
|
-
* @param arrays - arrays to concatenate
|
|
399
|
-
* @returns Concatenated byte array.
|
|
400
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
401
|
-
* @example
|
|
402
|
-
* Concatenate multiple byte arrays.
|
|
403
|
-
* ```ts
|
|
404
|
-
* concatBytes(new Uint8Array([1]), new Uint8Array([2]));
|
|
405
|
-
* ```
|
|
406
|
-
*/
|
|
407
|
-
function concatBytes$1(...arrays) {
|
|
408
|
-
let sum = 0;
|
|
409
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
410
|
-
const a = arrays[i];
|
|
411
|
-
abytes$2(a);
|
|
412
|
-
sum += a.length;
|
|
413
|
-
}
|
|
414
|
-
const res = new Uint8Array(sum);
|
|
415
|
-
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
416
|
-
const a = arrays[i];
|
|
417
|
-
res.set(a, pad);
|
|
418
|
-
pad += a.length;
|
|
419
|
-
}
|
|
420
|
-
return res;
|
|
421
|
-
}
|
|
422
|
-
__name(concatBytes$1, "concatBytes");
|
|
423
|
-
/**
|
|
424
|
-
* Creates a callable hash function from a stateful class constructor.
|
|
425
|
-
* @param hashCons - hash constructor or factory
|
|
426
|
-
* @param info - optional metadata such as DER OID
|
|
427
|
-
* @returns Frozen callable hash wrapper with `.create()`.
|
|
428
|
-
* Wrapper construction eagerly calls `hashCons(undefined)` once to read
|
|
429
|
-
* `outputLen` / `blockLen`, so constructor side effects happen at module
|
|
430
|
-
* init time.
|
|
431
|
-
* @example
|
|
432
|
-
* Wrap a stateful hash constructor into a callable helper.
|
|
433
|
-
* ```ts
|
|
434
|
-
* import { createHasher } from '@noble/hashes/utils.js';
|
|
435
|
-
* import { sha256 } from '@noble/hashes/sha2.js';
|
|
436
|
-
* const wrapped = createHasher(sha256.create, { oid: sha256.oid });
|
|
437
|
-
* wrapped(new Uint8Array([1]));
|
|
438
|
-
* ```
|
|
439
|
-
*/
|
|
440
|
-
function createHasher$1(hashCons, info = {}) {
|
|
441
|
-
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
442
|
-
const tmp = hashCons(void 0);
|
|
443
|
-
hashC.outputLen = tmp.outputLen;
|
|
444
|
-
hashC.blockLen = tmp.blockLen;
|
|
445
|
-
hashC.canXOF = tmp.canXOF;
|
|
446
|
-
hashC.create = (opts) => hashCons(opts);
|
|
447
|
-
Object.assign(hashC, info);
|
|
448
|
-
return Object.freeze(hashC);
|
|
449
|
-
}
|
|
450
|
-
__name(createHasher$1, "createHasher");
|
|
451
|
-
/**
|
|
452
|
-
* Cryptographically secure PRNG backed by `crypto.getRandomValues`.
|
|
453
|
-
* @param bytesLength - number of random bytes to generate
|
|
454
|
-
* @returns Random bytes.
|
|
455
|
-
* The platform `getRandomValues()` implementation still defines any
|
|
456
|
-
* single-call length cap, and this helper rejects oversize requests
|
|
457
|
-
* with a stable library `RangeError` instead of host-specific errors.
|
|
458
|
-
* @throws On wrong argument types. {@link TypeError}
|
|
459
|
-
* @throws On wrong argument ranges or values. {@link RangeError}
|
|
460
|
-
* @throws If the current runtime does not provide `crypto.getRandomValues`. {@link Error}
|
|
461
|
-
* @example
|
|
462
|
-
* Generate a fresh random key or nonce.
|
|
463
|
-
* ```ts
|
|
464
|
-
* const key = randomBytes(16);
|
|
465
|
-
* ```
|
|
466
|
-
*/
|
|
467
|
-
function randomBytes$1(bytesLength = 32) {
|
|
468
|
-
anumber$2(bytesLength, "bytesLength");
|
|
469
|
-
const cr = typeof globalThis === "object" ? globalThis.crypto : null;
|
|
470
|
-
if (typeof cr?.getRandomValues !== "function") throw new Error("crypto.getRandomValues must be defined");
|
|
471
|
-
if (bytesLength > 65536) throw new RangeError(`"bytesLength" expected <= 65536, got ${bytesLength}`);
|
|
472
|
-
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
473
|
-
}
|
|
474
|
-
__name(randomBytes$1, "randomBytes");
|
|
475
|
-
/**
|
|
476
|
-
* Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.
|
|
477
|
-
* @param suffix - final OID byte for the selected hash.
|
|
478
|
-
* The helper accepts any byte even though only the documented NIST hash
|
|
479
|
-
* suffixes are meaningful downstream.
|
|
480
|
-
* @returns Object containing the DER-encoded OID.
|
|
481
|
-
* @example
|
|
482
|
-
* Build OID metadata for a NIST hash.
|
|
483
|
-
* ```ts
|
|
484
|
-
* oidNist(0x01);
|
|
485
|
-
* ```
|
|
486
|
-
*/
|
|
487
|
-
const oidNist = (suffix) => ({ oid: Uint8Array.from([
|
|
488
|
-
6,
|
|
489
|
-
9,
|
|
490
|
-
96,
|
|
491
|
-
134,
|
|
492
|
-
72,
|
|
493
|
-
1,
|
|
494
|
-
101,
|
|
495
|
-
3,
|
|
496
|
-
4,
|
|
497
|
-
2,
|
|
498
|
-
suffix
|
|
499
|
-
]) });
|
|
500
|
-
|
|
501
94
|
//#endregion
|
|
502
95
|
//#region ../../node_modules/.pnpm/@aptos-labs+ts-sdk@7.1.0/node_modules/@aptos-labs/ts-sdk/dist/bcs/consts.js
|
|
503
96
|
const MAX_U16_NUMBER = 65535;
|
|
@@ -616,7 +209,7 @@ var Hex = class Hex {
|
|
|
616
209
|
* @category Serialization
|
|
617
210
|
*/
|
|
618
211
|
toStringWithoutPrefix() {
|
|
619
|
-
return bytesToHex$
|
|
212
|
+
return bytesToHex$2(this.data);
|
|
620
213
|
}
|
|
621
214
|
/**
|
|
622
215
|
* Get the hex data as a string with the 0x prefix.
|
|
@@ -645,7 +238,7 @@ var Hex = class Hex {
|
|
|
645
238
|
if (input.length === 0) throw new ParsingError("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.", HexInvalidReason.TOO_SHORT);
|
|
646
239
|
if (input.length % 2 !== 0) throw new ParsingError("Hex string must be an even number of hex characters.", HexInvalidReason.INVALID_LENGTH);
|
|
647
240
|
try {
|
|
648
|
-
return new Hex(hexToBytes$
|
|
241
|
+
return new Hex(hexToBytes$2(input));
|
|
649
242
|
} catch (error) {
|
|
650
243
|
throw new ParsingError(`Hex string contains invalid hex characters: ${error?.message}`, HexInvalidReason.INVALID_HEX_CHARS);
|
|
651
244
|
}
|
|
@@ -1867,7 +1460,7 @@ var AccountAddress = class AccountAddress extends Serializable {
|
|
|
1867
1460
|
* @category Serialization
|
|
1868
1461
|
*/
|
|
1869
1462
|
toStringWithoutPrefix() {
|
|
1870
|
-
let hex = bytesToHex$
|
|
1463
|
+
let hex = bytesToHex$2(this.data);
|
|
1871
1464
|
if (this.isSpecial()) hex = hex[hex.length - 1];
|
|
1872
1465
|
return hex;
|
|
1873
1466
|
}
|
|
@@ -1894,7 +1487,7 @@ var AccountAddress = class AccountAddress extends Serializable {
|
|
|
1894
1487
|
* @category Serialization
|
|
1895
1488
|
*/
|
|
1896
1489
|
toStringLongWithoutPrefix() {
|
|
1897
|
-
return bytesToHex$
|
|
1490
|
+
return bytesToHex$2(this.data);
|
|
1898
1491
|
}
|
|
1899
1492
|
/**
|
|
1900
1493
|
* Convert the account address to a string in SHORT format, which is 0x followed by the shortest
|
|
@@ -1916,7 +1509,7 @@ var AccountAddress = class AccountAddress extends Serializable {
|
|
|
1916
1509
|
* @category Serialization
|
|
1917
1510
|
*/
|
|
1918
1511
|
toStringShortWithoutPrefix() {
|
|
1919
|
-
const hex = bytesToHex$
|
|
1512
|
+
const hex = bytesToHex$2(this.data).replace(/^0+/, "");
|
|
1920
1513
|
return hex === "" ? "0" : hex;
|
|
1921
1514
|
}
|
|
1922
1515
|
/**
|
|
@@ -2068,7 +1661,7 @@ var AccountAddress = class AccountAddress extends Serializable {
|
|
|
2068
1661
|
if (maxMissingChars > 63 || maxMissingChars < 0) throw new ParsingError(`maxMissingChars must be between or equal to 0 and 63. Received ${maxMissingChars}`, AddressInvalidReason.INVALID_PADDING_STRICTNESS);
|
|
2069
1662
|
let addressBytes;
|
|
2070
1663
|
try {
|
|
2071
|
-
addressBytes = hexToBytes$
|
|
1664
|
+
addressBytes = hexToBytes$2(parsedInput.padStart(64, "0"));
|
|
2072
1665
|
} catch (error) {
|
|
2073
1666
|
throw new ParsingError(`Hex characters are invalid: ${error?.message}`, AddressInvalidReason.INVALID_HEX_CHARS);
|
|
2074
1667
|
}
|
|
@@ -2147,54 +1740,6 @@ Received ${input}`, AddressInvalidReason.TOO_SHORT);
|
|
|
2147
1740
|
}
|
|
2148
1741
|
};
|
|
2149
1742
|
|
|
2150
|
-
//#endregion
|
|
2151
|
-
//#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/_u64.js
|
|
2152
|
-
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
2153
|
-
const _32n = /* @__PURE__ */ BigInt(32);
|
|
2154
|
-
function fromBig(n, le = false) {
|
|
2155
|
-
if (le) return {
|
|
2156
|
-
h: Number(n & U32_MASK64),
|
|
2157
|
-
l: Number(n >> _32n & U32_MASK64)
|
|
2158
|
-
};
|
|
2159
|
-
return {
|
|
2160
|
-
h: Number(n >> _32n & U32_MASK64) | 0,
|
|
2161
|
-
l: Number(n & U32_MASK64) | 0
|
|
2162
|
-
};
|
|
2163
|
-
}
|
|
2164
|
-
function split(lst, le = false) {
|
|
2165
|
-
const len = lst.length;
|
|
2166
|
-
let Ah = new Uint32Array(len);
|
|
2167
|
-
let Al = new Uint32Array(len);
|
|
2168
|
-
for (let i = 0; i < len; i++) {
|
|
2169
|
-
const { h, l } = fromBig(lst[i], le);
|
|
2170
|
-
[Ah[i], Al[i]] = [h, l];
|
|
2171
|
-
}
|
|
2172
|
-
return [Ah, Al];
|
|
2173
|
-
}
|
|
2174
|
-
const shrSH = (h, _l, s) => h >>> s;
|
|
2175
|
-
const shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
2176
|
-
const rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
2177
|
-
const rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
2178
|
-
const rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
2179
|
-
const rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
2180
|
-
const rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
2181
|
-
const rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
2182
|
-
const rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
2183
|
-
const rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
2184
|
-
function add(Ah, Al, Bh, Bl) {
|
|
2185
|
-
const l = (Al >>> 0) + (Bl >>> 0);
|
|
2186
|
-
return {
|
|
2187
|
-
h: Ah + Bh + (l / 2 ** 32 | 0) | 0,
|
|
2188
|
-
l: l | 0
|
|
2189
|
-
};
|
|
2190
|
-
}
|
|
2191
|
-
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
2192
|
-
const add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
2193
|
-
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
2194
|
-
const add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
2195
|
-
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
2196
|
-
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
2197
|
-
|
|
2198
1743
|
//#endregion
|
|
2199
1744
|
//#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/sha3.js
|
|
2200
1745
|
/**
|
|
@@ -2230,7 +1775,7 @@ for (let round = 0, R = _1n$14, x = 1, y = 0; round < 24; round++) {
|
|
|
2230
1775
|
}
|
|
2231
1776
|
_SHA3_IOTA.push(t);
|
|
2232
1777
|
}
|
|
2233
|
-
const IOTAS = split(_SHA3_IOTA, true);
|
|
1778
|
+
const IOTAS = split$1(_SHA3_IOTA, true);
|
|
2234
1779
|
const SHA3_IOTA_H = IOTAS[0];
|
|
2235
1780
|
const SHA3_IOTA_L = IOTAS[1];
|
|
2236
1781
|
const rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
|
|
@@ -2248,7 +1793,7 @@ const rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
|
|
|
2248
1793
|
* ```
|
|
2249
1794
|
*/
|
|
2250
1795
|
function keccakP(s, rounds = 24) {
|
|
2251
|
-
anumber$
|
|
1796
|
+
anumber$4(rounds, "rounds");
|
|
2252
1797
|
if (rounds < 1 || rounds > 24) throw new Error("\"rounds\" expected integer 1..24");
|
|
2253
1798
|
const B = /* @__PURE__ */ new Uint32Array(10);
|
|
2254
1799
|
for (let round = 24 - rounds; round < 24; round++) {
|
|
@@ -2296,7 +1841,7 @@ function keccakP(s, rounds = 24) {
|
|
|
2296
1841
|
s[0] ^= SHA3_IOTA_H[round];
|
|
2297
1842
|
s[1] ^= SHA3_IOTA_L[round];
|
|
2298
1843
|
}
|
|
2299
|
-
clean$
|
|
1844
|
+
clean$2(B);
|
|
2300
1845
|
}
|
|
2301
1846
|
/**
|
|
2302
1847
|
* Keccak sponge function.
|
|
@@ -2335,7 +1880,7 @@ var Keccak = class Keccak {
|
|
|
2335
1880
|
this.enableXOF = enableXOF;
|
|
2336
1881
|
this.canXOF = enableXOF;
|
|
2337
1882
|
this.rounds = rounds;
|
|
2338
|
-
anumber$
|
|
1883
|
+
anumber$4(outputLen, "outputLen");
|
|
2339
1884
|
if (!(0 < blockLen && blockLen < 200)) throw new Error("only keccak-f1600 function is supported");
|
|
2340
1885
|
this.state = /* @__PURE__ */ new Uint8Array(200);
|
|
2341
1886
|
this.state32 = u32$1(this.state);
|
|
@@ -2351,8 +1896,8 @@ var Keccak = class Keccak {
|
|
|
2351
1896
|
this.pos = 0;
|
|
2352
1897
|
}
|
|
2353
1898
|
update(data) {
|
|
2354
|
-
aexists$
|
|
2355
|
-
abytes$
|
|
1899
|
+
aexists$2(this);
|
|
1900
|
+
abytes$4(data);
|
|
2356
1901
|
const { blockLen, state } = this;
|
|
2357
1902
|
const len = data.length;
|
|
2358
1903
|
for (let pos = 0; pos < len;) {
|
|
@@ -2372,8 +1917,8 @@ var Keccak = class Keccak {
|
|
|
2372
1917
|
this.keccak();
|
|
2373
1918
|
}
|
|
2374
1919
|
writeInto(out) {
|
|
2375
|
-
aexists$
|
|
2376
|
-
abytes$
|
|
1920
|
+
aexists$2(this, false);
|
|
1921
|
+
abytes$4(out);
|
|
2377
1922
|
this.finish();
|
|
2378
1923
|
const bufferOut = this.state;
|
|
2379
1924
|
const { blockLen } = this;
|
|
@@ -2391,11 +1936,11 @@ var Keccak = class Keccak {
|
|
|
2391
1936
|
return this.writeInto(out);
|
|
2392
1937
|
}
|
|
2393
1938
|
xof(bytes) {
|
|
2394
|
-
anumber$
|
|
1939
|
+
anumber$4(bytes);
|
|
2395
1940
|
return this.xofInto(new Uint8Array(bytes));
|
|
2396
1941
|
}
|
|
2397
1942
|
digestInto(out) {
|
|
2398
|
-
aoutput$
|
|
1943
|
+
aoutput$2(out, this);
|
|
2399
1944
|
if (this.finished) throw new Error("digest() was already called");
|
|
2400
1945
|
this.writeInto(out.subarray(0, this.outputLen));
|
|
2401
1946
|
this.destroy();
|
|
@@ -2407,7 +1952,7 @@ var Keccak = class Keccak {
|
|
|
2407
1952
|
}
|
|
2408
1953
|
destroy() {
|
|
2409
1954
|
this.destroyed = true;
|
|
2410
|
-
clean$
|
|
1955
|
+
clean$2(this.state);
|
|
2411
1956
|
}
|
|
2412
1957
|
_cloneInto(to) {
|
|
2413
1958
|
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
@@ -2426,7 +1971,7 @@ var Keccak = class Keccak {
|
|
|
2426
1971
|
return to;
|
|
2427
1972
|
}
|
|
2428
1973
|
};
|
|
2429
|
-
const genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher$
|
|
1974
|
+
const genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher$2(() => new Keccak(blockLen, suffix, outputLen), info);
|
|
2430
1975
|
/**
|
|
2431
1976
|
* SHA3-256 hash function. Different from keccak-256.
|
|
2432
1977
|
* @param msg - message bytes to hash
|
|
@@ -2437,7 +1982,7 @@ const genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher$1(()
|
|
|
2437
1982
|
* sha3_256(new Uint8Array([97, 98, 99]));
|
|
2438
1983
|
* ```
|
|
2439
1984
|
*/
|
|
2440
|
-
const sha3_256 = /* @__PURE__ */ genKeccak(6, 136, 32, /* @__PURE__ */ oidNist(8));
|
|
1985
|
+
const sha3_256 = /* @__PURE__ */ genKeccak(6, 136, 32, /* @__PURE__ */ oidNist$1(8));
|
|
2441
1986
|
|
|
2442
1987
|
//#endregion
|
|
2443
1988
|
//#region ../../node_modules/.pnpm/@aptos-labs+ts-sdk@7.1.0/node_modules/@aptos-labs/ts-sdk/dist/core/account/utils/address.js
|
|
@@ -2839,193 +2384,6 @@ var AuthenticationKey = class AuthenticationKey extends Serializable {
|
|
|
2839
2384
|
}
|
|
2840
2385
|
};
|
|
2841
2386
|
|
|
2842
|
-
//#endregion
|
|
2843
|
-
//#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/_md.js
|
|
2844
|
-
/**
|
|
2845
|
-
* Internal Merkle-Damgard hash utils.
|
|
2846
|
-
* @module
|
|
2847
|
-
*/
|
|
2848
|
-
/**
|
|
2849
|
-
* Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.
|
|
2850
|
-
* Returns bits from `b` when `a` is set, otherwise from `c`.
|
|
2851
|
-
* The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never
|
|
2852
|
-
* set the same bit.
|
|
2853
|
-
* @param a - selector word
|
|
2854
|
-
* @param b - word chosen when selector bit is set
|
|
2855
|
-
* @param c - word chosen when selector bit is clear
|
|
2856
|
-
* @returns Mixed 32-bit word.
|
|
2857
|
-
* @example
|
|
2858
|
-
* Combine three words with the shared 32-bit choice primitive.
|
|
2859
|
-
* ```ts
|
|
2860
|
-
* Chi(0xffffffff, 0x12345678, 0x87654321);
|
|
2861
|
-
* ```
|
|
2862
|
-
*/
|
|
2863
|
-
function Chi(a, b, c) {
|
|
2864
|
-
return a & b ^ ~a & c;
|
|
2865
|
-
}
|
|
2866
|
-
/**
|
|
2867
|
-
* Shared 32-bit majority primitive reused by SHA-256 and SHA-1.
|
|
2868
|
-
* Returns bits shared by at least two inputs.
|
|
2869
|
-
* @param a - first input word
|
|
2870
|
-
* @param b - second input word
|
|
2871
|
-
* @param c - third input word
|
|
2872
|
-
* @returns Mixed 32-bit word.
|
|
2873
|
-
* @example
|
|
2874
|
-
* Combine three words with the shared 32-bit majority primitive.
|
|
2875
|
-
* ```ts
|
|
2876
|
-
* Maj(0xffffffff, 0x12345678, 0x87654321);
|
|
2877
|
-
* ```
|
|
2878
|
-
*/
|
|
2879
|
-
function Maj(a, b, c) {
|
|
2880
|
-
return a & b ^ a & c ^ b & c;
|
|
2881
|
-
}
|
|
2882
|
-
/**
|
|
2883
|
-
* Merkle-Damgard hash construction base class.
|
|
2884
|
-
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
2885
|
-
* Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit
|
|
2886
|
-
* strings with partial-byte tails.
|
|
2887
|
-
* @param blockLen - internal block size in bytes
|
|
2888
|
-
* @param outputLen - digest size in bytes
|
|
2889
|
-
* @param padOffset - trailing length field size in bytes
|
|
2890
|
-
* @param isLE - whether length and state words are encoded in little-endian
|
|
2891
|
-
* @example
|
|
2892
|
-
* Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.
|
|
2893
|
-
* ```ts
|
|
2894
|
-
* import { _SHA1 } from '@noble/hashes/legacy.js';
|
|
2895
|
-
* const hash = new _SHA1();
|
|
2896
|
-
* hash.update(new Uint8Array([97, 98, 99]));
|
|
2897
|
-
* hash.digest();
|
|
2898
|
-
* ```
|
|
2899
|
-
*/
|
|
2900
|
-
var HashMD = class {
|
|
2901
|
-
blockLen;
|
|
2902
|
-
outputLen;
|
|
2903
|
-
canXOF = false;
|
|
2904
|
-
padOffset;
|
|
2905
|
-
isLE;
|
|
2906
|
-
buffer;
|
|
2907
|
-
view;
|
|
2908
|
-
finished = false;
|
|
2909
|
-
length = 0;
|
|
2910
|
-
pos = 0;
|
|
2911
|
-
destroyed = false;
|
|
2912
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
2913
|
-
this.blockLen = blockLen;
|
|
2914
|
-
this.outputLen = outputLen;
|
|
2915
|
-
this.padOffset = padOffset;
|
|
2916
|
-
this.isLE = isLE;
|
|
2917
|
-
this.buffer = new Uint8Array(blockLen);
|
|
2918
|
-
this.view = createView$1(this.buffer);
|
|
2919
|
-
}
|
|
2920
|
-
update(data) {
|
|
2921
|
-
aexists$1(this);
|
|
2922
|
-
abytes$2(data);
|
|
2923
|
-
const { view, buffer, blockLen } = this;
|
|
2924
|
-
const len = data.length;
|
|
2925
|
-
for (let pos = 0; pos < len;) {
|
|
2926
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
2927
|
-
if (take === blockLen) {
|
|
2928
|
-
const dataView = createView$1(data);
|
|
2929
|
-
for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);
|
|
2930
|
-
continue;
|
|
2931
|
-
}
|
|
2932
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
2933
|
-
this.pos += take;
|
|
2934
|
-
pos += take;
|
|
2935
|
-
if (this.pos === blockLen) {
|
|
2936
|
-
this.process(view, 0);
|
|
2937
|
-
this.pos = 0;
|
|
2938
|
-
}
|
|
2939
|
-
}
|
|
2940
|
-
this.length += data.length;
|
|
2941
|
-
this.roundClean();
|
|
2942
|
-
return this;
|
|
2943
|
-
}
|
|
2944
|
-
digestInto(out) {
|
|
2945
|
-
aexists$1(this);
|
|
2946
|
-
aoutput$1(out, this);
|
|
2947
|
-
this.finished = true;
|
|
2948
|
-
const { buffer, view, blockLen, isLE } = this;
|
|
2949
|
-
let { pos } = this;
|
|
2950
|
-
buffer[pos++] = 128;
|
|
2951
|
-
clean$1(this.buffer.subarray(pos));
|
|
2952
|
-
if (this.padOffset > blockLen - pos) {
|
|
2953
|
-
this.process(view, 0);
|
|
2954
|
-
pos = 0;
|
|
2955
|
-
}
|
|
2956
|
-
for (let i = pos; i < blockLen; i++) buffer[i] = 0;
|
|
2957
|
-
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
2958
|
-
this.process(view, 0);
|
|
2959
|
-
const oview = createView$1(out);
|
|
2960
|
-
const len = this.outputLen;
|
|
2961
|
-
if (len % 4) throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
2962
|
-
const outLen = len / 4;
|
|
2963
|
-
const state = this.get();
|
|
2964
|
-
if (outLen > state.length) throw new Error("_sha2: outputLen bigger than state");
|
|
2965
|
-
for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);
|
|
2966
|
-
}
|
|
2967
|
-
digest() {
|
|
2968
|
-
const { buffer, outputLen } = this;
|
|
2969
|
-
this.digestInto(buffer);
|
|
2970
|
-
const res = buffer.slice(0, outputLen);
|
|
2971
|
-
this.destroy();
|
|
2972
|
-
return res;
|
|
2973
|
-
}
|
|
2974
|
-
_cloneInto(to) {
|
|
2975
|
-
to ||= new this.constructor();
|
|
2976
|
-
to.set(...this.get());
|
|
2977
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
2978
|
-
to.destroyed = destroyed;
|
|
2979
|
-
to.finished = finished;
|
|
2980
|
-
to.length = length;
|
|
2981
|
-
to.pos = pos;
|
|
2982
|
-
if (length % blockLen) to.buffer.set(buffer);
|
|
2983
|
-
return to;
|
|
2984
|
-
}
|
|
2985
|
-
clone() {
|
|
2986
|
-
return this._cloneInto();
|
|
2987
|
-
}
|
|
2988
|
-
};
|
|
2989
|
-
/**
|
|
2990
|
-
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
2991
|
-
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
2992
|
-
*/
|
|
2993
|
-
/** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the
|
|
2994
|
-
* square roots of the first eight prime numbers. Exported as a shared table; callers must treat
|
|
2995
|
-
* it as read-only because constructors copy words from it by index. */
|
|
2996
|
-
const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
2997
|
-
1779033703,
|
|
2998
|
-
3144134277,
|
|
2999
|
-
1013904242,
|
|
3000
|
-
2773480762,
|
|
3001
|
-
1359893119,
|
|
3002
|
-
2600822924,
|
|
3003
|
-
528734635,
|
|
3004
|
-
1541459225
|
|
3005
|
-
]);
|
|
3006
|
-
/** Initial SHA512 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
|
|
3007
|
-
* big-endian 32-bit halves. Derived from the fractional parts of the square roots of the first
|
|
3008
|
-
* eight prime numbers. Exported as a shared table; callers must treat it as read-only because
|
|
3009
|
-
* constructors copy halves from it by index. */
|
|
3010
|
-
const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
3011
|
-
1779033703,
|
|
3012
|
-
4089235720,
|
|
3013
|
-
3144134277,
|
|
3014
|
-
2227873595,
|
|
3015
|
-
1013904242,
|
|
3016
|
-
4271175723,
|
|
3017
|
-
2773480762,
|
|
3018
|
-
1595750129,
|
|
3019
|
-
1359893119,
|
|
3020
|
-
2917565137,
|
|
3021
|
-
2600822924,
|
|
3022
|
-
725511199,
|
|
3023
|
-
528734635,
|
|
3024
|
-
4215389547,
|
|
3025
|
-
1541459225,
|
|
3026
|
-
327033209
|
|
3027
|
-
]);
|
|
3028
|
-
|
|
3029
2387
|
//#endregion
|
|
3030
2388
|
//#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/sha2.js
|
|
3031
2389
|
/**
|
|
@@ -3108,7 +2466,7 @@ const SHA256_K$1 = /* @__PURE__ */ Uint32Array.from([
|
|
|
3108
2466
|
/** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */
|
|
3109
2467
|
const SHA256_W$1 = /* @__PURE__ */ new Uint32Array(64);
|
|
3110
2468
|
/** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */
|
|
3111
|
-
var SHA2_32B$1 = class extends HashMD {
|
|
2469
|
+
var SHA2_32B$1 = class extends HashMD$1 {
|
|
3112
2470
|
static {
|
|
3113
2471
|
__name(this, "SHA2_32B");
|
|
3114
2472
|
}
|
|
@@ -3143,14 +2501,14 @@ var SHA2_32B$1 = class extends HashMD {
|
|
|
3143
2501
|
for (let i = 16; i < 64; i++) {
|
|
3144
2502
|
const W15 = SHA256_W$1[i - 15];
|
|
3145
2503
|
const W2 = SHA256_W$1[i - 2];
|
|
3146
|
-
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
3147
|
-
SHA256_W$1[i] = (rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10) + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16] | 0;
|
|
2504
|
+
const s0 = rotr$1(W15, 7) ^ rotr$1(W15, 18) ^ W15 >>> 3;
|
|
2505
|
+
SHA256_W$1[i] = (rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ W2 >>> 10) + SHA256_W$1[i - 7] + s0 + SHA256_W$1[i - 16] | 0;
|
|
3148
2506
|
}
|
|
3149
2507
|
let { A, B, C, D, E, F, G, H } = this;
|
|
3150
2508
|
for (let i = 0; i < 64; i++) {
|
|
3151
|
-
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
3152
|
-
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i] | 0;
|
|
3153
|
-
const T2 = (rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22)) + Maj(A, B, C) | 0;
|
|
2509
|
+
const sigma1 = rotr$1(E, 6) ^ rotr$1(E, 11) ^ rotr$1(E, 25);
|
|
2510
|
+
const T1 = H + sigma1 + Chi$1(E, F, G) + SHA256_K$1[i] + SHA256_W$1[i] | 0;
|
|
2511
|
+
const T2 = (rotr$1(A, 2) ^ rotr$1(A, 13) ^ rotr$1(A, 22)) + Maj$1(A, B, C) | 0;
|
|
3154
2512
|
H = G;
|
|
3155
2513
|
G = F;
|
|
3156
2514
|
F = E;
|
|
@@ -3171,12 +2529,12 @@ var SHA2_32B$1 = class extends HashMD {
|
|
|
3171
2529
|
this.set(A, B, C, D, E, F, G, H);
|
|
3172
2530
|
}
|
|
3173
2531
|
roundClean() {
|
|
3174
|
-
clean$
|
|
2532
|
+
clean$2(SHA256_W$1);
|
|
3175
2533
|
}
|
|
3176
2534
|
destroy() {
|
|
3177
2535
|
this.destroyed = true;
|
|
3178
2536
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
3179
|
-
clean$
|
|
2537
|
+
clean$2(this.buffer);
|
|
3180
2538
|
}
|
|
3181
2539
|
};
|
|
3182
2540
|
/** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */
|
|
@@ -3184,19 +2542,19 @@ var _SHA256$1 = class extends SHA2_32B$1 {
|
|
|
3184
2542
|
static {
|
|
3185
2543
|
__name(this, "_SHA256");
|
|
3186
2544
|
}
|
|
3187
|
-
A = SHA256_IV[0] | 0;
|
|
3188
|
-
B = SHA256_IV[1] | 0;
|
|
3189
|
-
C = SHA256_IV[2] | 0;
|
|
3190
|
-
D = SHA256_IV[3] | 0;
|
|
3191
|
-
E = SHA256_IV[4] | 0;
|
|
3192
|
-
F = SHA256_IV[5] | 0;
|
|
3193
|
-
G = SHA256_IV[6] | 0;
|
|
3194
|
-
H = SHA256_IV[7] | 0;
|
|
2545
|
+
A = SHA256_IV$1[0] | 0;
|
|
2546
|
+
B = SHA256_IV$1[1] | 0;
|
|
2547
|
+
C = SHA256_IV$1[2] | 0;
|
|
2548
|
+
D = SHA256_IV$1[3] | 0;
|
|
2549
|
+
E = SHA256_IV$1[4] | 0;
|
|
2550
|
+
F = SHA256_IV$1[5] | 0;
|
|
2551
|
+
G = SHA256_IV$1[6] | 0;
|
|
2552
|
+
H = SHA256_IV$1[7] | 0;
|
|
3195
2553
|
constructor() {
|
|
3196
2554
|
super(32);
|
|
3197
2555
|
}
|
|
3198
2556
|
};
|
|
3199
|
-
const K512$1 = /* @__PURE__ */ (() => split([
|
|
2557
|
+
const K512$1 = /* @__PURE__ */ (() => split$1([
|
|
3200
2558
|
"0x428a2f98d728ae22",
|
|
3201
2559
|
"0x7137449123ef65cd",
|
|
3202
2560
|
"0xb5c0fbcfec4d3b2f",
|
|
@@ -3283,7 +2641,7 @@ const SHA512_Kl$1 = /* @__PURE__ */ (() => K512$1[1])();
|
|
|
3283
2641
|
const SHA512_W_H$1 = /* @__PURE__ */ new Uint32Array(80);
|
|
3284
2642
|
const SHA512_W_L$1 = /* @__PURE__ */ new Uint32Array(80);
|
|
3285
2643
|
/** Internal SHA-384 / SHA-512 compression engine from RFC 6234 §6.4. */
|
|
3286
|
-
var SHA2_64B$1 = class extends HashMD {
|
|
2644
|
+
var SHA2_64B$1 = class extends HashMD$1 {
|
|
3287
2645
|
static {
|
|
3288
2646
|
__name(this, "SHA2_64B");
|
|
3289
2647
|
}
|
|
@@ -3337,27 +2695,27 @@ var SHA2_64B$1 = class extends HashMD {
|
|
|
3337
2695
|
for (let i = 16; i < 80; i++) {
|
|
3338
2696
|
const W15h = SHA512_W_H$1[i - 15] | 0;
|
|
3339
2697
|
const W15l = SHA512_W_L$1[i - 15] | 0;
|
|
3340
|
-
const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
|
|
3341
|
-
const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
|
|
2698
|
+
const s0h = rotrSH$1(W15h, W15l, 1) ^ rotrSH$1(W15h, W15l, 8) ^ shrSH$1(W15h, W15l, 7);
|
|
2699
|
+
const s0l = rotrSL$1(W15h, W15l, 1) ^ rotrSL$1(W15h, W15l, 8) ^ shrSL$1(W15h, W15l, 7);
|
|
3342
2700
|
const W2h = SHA512_W_H$1[i - 2] | 0;
|
|
3343
2701
|
const W2l = SHA512_W_L$1[i - 2] | 0;
|
|
3344
|
-
const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
|
|
3345
|
-
const s1l = rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6);
|
|
3346
|
-
const SUMl = add4L(s0l, s1l, SHA512_W_L$1[i - 7], SHA512_W_L$1[i - 16]);
|
|
3347
|
-
SHA512_W_H$1[i] = add4H(SUMl, s0h, s1h, SHA512_W_H$1[i - 7], SHA512_W_H$1[i - 16]) | 0;
|
|
2702
|
+
const s1h = rotrSH$1(W2h, W2l, 19) ^ rotrBH$1(W2h, W2l, 61) ^ shrSH$1(W2h, W2l, 6);
|
|
2703
|
+
const s1l = rotrSL$1(W2h, W2l, 19) ^ rotrBL$1(W2h, W2l, 61) ^ shrSL$1(W2h, W2l, 6);
|
|
2704
|
+
const SUMl = add4L$1(s0l, s1l, SHA512_W_L$1[i - 7], SHA512_W_L$1[i - 16]);
|
|
2705
|
+
SHA512_W_H$1[i] = add4H$1(SUMl, s0h, s1h, SHA512_W_H$1[i - 7], SHA512_W_H$1[i - 16]) | 0;
|
|
3348
2706
|
SHA512_W_L$1[i] = SUMl | 0;
|
|
3349
2707
|
}
|
|
3350
2708
|
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
3351
2709
|
for (let i = 0; i < 80; i++) {
|
|
3352
|
-
const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
|
|
3353
|
-
const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
|
|
2710
|
+
const sigma1h = rotrSH$1(Eh, El, 14) ^ rotrSH$1(Eh, El, 18) ^ rotrBH$1(Eh, El, 41);
|
|
2711
|
+
const sigma1l = rotrSL$1(Eh, El, 14) ^ rotrSL$1(Eh, El, 18) ^ rotrBL$1(Eh, El, 41);
|
|
3354
2712
|
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
3355
2713
|
const CHIl = El & Fl ^ ~El & Gl;
|
|
3356
|
-
const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl$1[i], SHA512_W_L$1[i]);
|
|
3357
|
-
const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh$1[i], SHA512_W_H$1[i]);
|
|
2714
|
+
const T1ll = add5L$1(Hl, sigma1l, CHIl, SHA512_Kl$1[i], SHA512_W_L$1[i]);
|
|
2715
|
+
const T1h = add5H$1(T1ll, Hh, sigma1h, CHIh, SHA512_Kh$1[i], SHA512_W_H$1[i]);
|
|
3358
2716
|
const T1l = T1ll | 0;
|
|
3359
|
-
const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
|
|
3360
|
-
const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
|
|
2717
|
+
const sigma0h = rotrSH$1(Ah, Al, 28) ^ rotrBH$1(Ah, Al, 34) ^ rotrBH$1(Ah, Al, 39);
|
|
2718
|
+
const sigma0l = rotrSL$1(Ah, Al, 28) ^ rotrBL$1(Ah, Al, 34) ^ rotrBL$1(Ah, Al, 39);
|
|
3361
2719
|
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
3362
2720
|
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
3363
2721
|
Hh = Gh | 0;
|
|
@@ -3366,33 +2724,33 @@ var SHA2_64B$1 = class extends HashMD {
|
|
|
3366
2724
|
Gl = Fl | 0;
|
|
3367
2725
|
Fh = Eh | 0;
|
|
3368
2726
|
Fl = El | 0;
|
|
3369
|
-
({h: Eh, l: El} = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
2727
|
+
({h: Eh, l: El} = add$1(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
3370
2728
|
Dh = Ch | 0;
|
|
3371
2729
|
Dl = Cl | 0;
|
|
3372
2730
|
Ch = Bh | 0;
|
|
3373
2731
|
Cl = Bl | 0;
|
|
3374
2732
|
Bh = Ah | 0;
|
|
3375
2733
|
Bl = Al | 0;
|
|
3376
|
-
const All = add3L(T1l, sigma0l, MAJl);
|
|
3377
|
-
Ah = add3H(All, T1h, sigma0h, MAJh);
|
|
2734
|
+
const All = add3L$1(T1l, sigma0l, MAJl);
|
|
2735
|
+
Ah = add3H$1(All, T1h, sigma0h, MAJh);
|
|
3378
2736
|
Al = All | 0;
|
|
3379
2737
|
}
|
|
3380
|
-
({h: Ah, l: Al} = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
3381
|
-
({h: Bh, l: Bl} = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
3382
|
-
({h: Ch, l: Cl} = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
3383
|
-
({h: Dh, l: Dl} = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
3384
|
-
({h: Eh, l: El} = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
3385
|
-
({h: Fh, l: Fl} = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
3386
|
-
({h: Gh, l: Gl} = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
3387
|
-
({h: Hh, l: Hl} = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
2738
|
+
({h: Ah, l: Al} = add$1(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
2739
|
+
({h: Bh, l: Bl} = add$1(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
2740
|
+
({h: Ch, l: Cl} = add$1(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
2741
|
+
({h: Dh, l: Dl} = add$1(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
2742
|
+
({h: Eh, l: El} = add$1(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
2743
|
+
({h: Fh, l: Fl} = add$1(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
2744
|
+
({h: Gh, l: Gl} = add$1(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
2745
|
+
({h: Hh, l: Hl} = add$1(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
3388
2746
|
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
3389
2747
|
}
|
|
3390
2748
|
roundClean() {
|
|
3391
|
-
clean$
|
|
2749
|
+
clean$2(SHA512_W_H$1, SHA512_W_L$1);
|
|
3392
2750
|
}
|
|
3393
2751
|
destroy() {
|
|
3394
2752
|
this.destroyed = true;
|
|
3395
|
-
clean$
|
|
2753
|
+
clean$2(this.buffer);
|
|
3396
2754
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
3397
2755
|
}
|
|
3398
2756
|
};
|
|
@@ -3401,22 +2759,22 @@ var _SHA512$1 = class extends SHA2_64B$1 {
|
|
|
3401
2759
|
static {
|
|
3402
2760
|
__name(this, "_SHA512");
|
|
3403
2761
|
}
|
|
3404
|
-
Ah = SHA512_IV[0] | 0;
|
|
3405
|
-
Al = SHA512_IV[1] | 0;
|
|
3406
|
-
Bh = SHA512_IV[2] | 0;
|
|
3407
|
-
Bl = SHA512_IV[3] | 0;
|
|
3408
|
-
Ch = SHA512_IV[4] | 0;
|
|
3409
|
-
Cl = SHA512_IV[5] | 0;
|
|
3410
|
-
Dh = SHA512_IV[6] | 0;
|
|
3411
|
-
Dl = SHA512_IV[7] | 0;
|
|
3412
|
-
Eh = SHA512_IV[8] | 0;
|
|
3413
|
-
El = SHA512_IV[9] | 0;
|
|
3414
|
-
Fh = SHA512_IV[10] | 0;
|
|
3415
|
-
Fl = SHA512_IV[11] | 0;
|
|
3416
|
-
Gh = SHA512_IV[12] | 0;
|
|
3417
|
-
Gl = SHA512_IV[13] | 0;
|
|
3418
|
-
Hh = SHA512_IV[14] | 0;
|
|
3419
|
-
Hl = SHA512_IV[15] | 0;
|
|
2762
|
+
Ah = SHA512_IV$1[0] | 0;
|
|
2763
|
+
Al = SHA512_IV$1[1] | 0;
|
|
2764
|
+
Bh = SHA512_IV$1[2] | 0;
|
|
2765
|
+
Bl = SHA512_IV$1[3] | 0;
|
|
2766
|
+
Ch = SHA512_IV$1[4] | 0;
|
|
2767
|
+
Cl = SHA512_IV$1[5] | 0;
|
|
2768
|
+
Dh = SHA512_IV$1[6] | 0;
|
|
2769
|
+
Dl = SHA512_IV$1[7] | 0;
|
|
2770
|
+
Eh = SHA512_IV$1[8] | 0;
|
|
2771
|
+
El = SHA512_IV$1[9] | 0;
|
|
2772
|
+
Fh = SHA512_IV$1[10] | 0;
|
|
2773
|
+
Fl = SHA512_IV$1[11] | 0;
|
|
2774
|
+
Gh = SHA512_IV$1[12] | 0;
|
|
2775
|
+
Gl = SHA512_IV$1[13] | 0;
|
|
2776
|
+
Hh = SHA512_IV$1[14] | 0;
|
|
2777
|
+
Hl = SHA512_IV$1[15] | 0;
|
|
3420
2778
|
constructor() {
|
|
3421
2779
|
super(64);
|
|
3422
2780
|
}
|
|
@@ -3436,7 +2794,7 @@ var _SHA512$1 = class extends SHA2_64B$1 {
|
|
|
3436
2794
|
* sha256(new Uint8Array([97, 98, 99]));
|
|
3437
2795
|
* ```
|
|
3438
2796
|
*/
|
|
3439
|
-
const sha256$1 = /* @__PURE__ */ createHasher$
|
|
2797
|
+
const sha256$1 = /* @__PURE__ */ createHasher$2(() => new _SHA256$1(), /* @__PURE__ */ oidNist$1(1));
|
|
3440
2798
|
/**
|
|
3441
2799
|
* SHA2-512 hash function from RFC 4634.
|
|
3442
2800
|
* @param msg - message bytes to hash
|
|
@@ -3447,7 +2805,7 @@ const sha256$1 = /* @__PURE__ */ createHasher$1(() => new _SHA256$1(), /* @__PUR
|
|
|
3447
2805
|
* sha512(new Uint8Array([97, 98, 99]));
|
|
3448
2806
|
* ```
|
|
3449
2807
|
*/
|
|
3450
|
-
const sha512$1 = /* @__PURE__ */ createHasher$
|
|
2808
|
+
const sha512$1 = /* @__PURE__ */ createHasher$2(() => new _SHA512$1(), /* @__PURE__ */ oidNist$1(3));
|
|
3451
2809
|
|
|
3452
2810
|
//#endregion
|
|
3453
2811
|
//#region ../../node_modules/.pnpm/@noble+curves@2.2.0/node_modules/@noble/curves/utils.js
|
|
@@ -3469,7 +2827,7 @@ const sha512$1 = /* @__PURE__ */ createHasher$1(() => new _SHA512$1(), /* @__PUR
|
|
|
3469
2827
|
* abytes(new Uint8Array(1));
|
|
3470
2828
|
* ```
|
|
3471
2829
|
*/
|
|
3472
|
-
const abytes$
|
|
2830
|
+
const abytes$3 = /* @__PURE__ */ __name((value, length, title) => abytes$4(value, length, title), "abytes");
|
|
3473
2831
|
/**
|
|
3474
2832
|
* Validates that a value is a non-negative safe integer.
|
|
3475
2833
|
* @param n - Value to validate.
|
|
@@ -3481,7 +2839,7 @@ const abytes$1 = /* @__PURE__ */ __name((value, length, title) => abytes$2(value
|
|
|
3481
2839
|
* anumber(1);
|
|
3482
2840
|
* ```
|
|
3483
2841
|
*/
|
|
3484
|
-
const anumber$
|
|
2842
|
+
const anumber$3 = anumber$4;
|
|
3485
2843
|
/**
|
|
3486
2844
|
* Encodes bytes as lowercase hex.
|
|
3487
2845
|
* @param bytes - Bytes to encode.
|
|
@@ -3493,7 +2851,7 @@ const anumber$1 = anumber$2;
|
|
|
3493
2851
|
* bytesToHex(Uint8Array.of(1, 2, 3));
|
|
3494
2852
|
* ```
|
|
3495
2853
|
*/
|
|
3496
|
-
const bytesToHex = bytesToHex$
|
|
2854
|
+
const bytesToHex$1 = bytesToHex$2;
|
|
3497
2855
|
/**
|
|
3498
2856
|
* Concatenates byte arrays.
|
|
3499
2857
|
* @param arrays - Byte arrays to join.
|
|
@@ -3505,7 +2863,7 @@ const bytesToHex = bytesToHex$1;
|
|
|
3505
2863
|
* concatBytes(Uint8Array.of(1), Uint8Array.of(2));
|
|
3506
2864
|
* ```
|
|
3507
2865
|
*/
|
|
3508
|
-
const concatBytes = (...arrays) => concatBytes$
|
|
2866
|
+
const concatBytes$1 = /* @__PURE__ */ __name((...arrays) => concatBytes$2(...arrays), "concatBytes");
|
|
3509
2867
|
/**
|
|
3510
2868
|
* Decodes lowercase or uppercase hex into bytes.
|
|
3511
2869
|
* @param hex - Hex string to decode.
|
|
@@ -3517,7 +2875,7 @@ const concatBytes = (...arrays) => concatBytes$1(...arrays);
|
|
|
3517
2875
|
* hexToBytes('0102');
|
|
3518
2876
|
* ```
|
|
3519
2877
|
*/
|
|
3520
|
-
const hexToBytes = (hex) => hexToBytes$
|
|
2878
|
+
const hexToBytes$1 = /* @__PURE__ */ __name((hex) => hexToBytes$2(hex), "hexToBytes");
|
|
3521
2879
|
/**
|
|
3522
2880
|
* Checks whether a value is a Uint8Array.
|
|
3523
2881
|
* @param a - Value to inspect.
|
|
@@ -3529,7 +2887,7 @@ const hexToBytes = (hex) => hexToBytes$1(hex);
|
|
|
3529
2887
|
* isBytes(new Uint8Array(1));
|
|
3530
2888
|
* ```
|
|
3531
2889
|
*/
|
|
3532
|
-
const isBytes$
|
|
2890
|
+
const isBytes$3 = isBytes$4;
|
|
3533
2891
|
/**
|
|
3534
2892
|
* Reads random bytes from the platform CSPRNG.
|
|
3535
2893
|
* @param bytesLength - Number of random bytes to read.
|
|
@@ -3541,7 +2899,7 @@ const isBytes$1 = isBytes$2;
|
|
|
3541
2899
|
* randomBytes(2);
|
|
3542
2900
|
* ```
|
|
3543
2901
|
*/
|
|
3544
|
-
const randomBytes = (bytesLength) => randomBytes$
|
|
2902
|
+
const randomBytes$1 = /* @__PURE__ */ __name((bytesLength) => randomBytes$2(bytesLength), "randomBytes");
|
|
3545
2903
|
const _0n$13 = /* @__PURE__ */ BigInt(0);
|
|
3546
2904
|
const _1n$13 = /* @__PURE__ */ BigInt(1);
|
|
3547
2905
|
/**
|
|
@@ -3580,7 +2938,7 @@ __name(abool$2, "abool");
|
|
|
3580
2938
|
function abignumber$1(n) {
|
|
3581
2939
|
if (typeof n === "bigint") {
|
|
3582
2940
|
if (!isPosBig$1(n)) throw new RangeError("positive bigint expected, got " + n);
|
|
3583
|
-
} else anumber$
|
|
2941
|
+
} else anumber$3(n);
|
|
3584
2942
|
return n;
|
|
3585
2943
|
}
|
|
3586
2944
|
__name(abignumber$1, "abignumber");
|
|
@@ -3658,7 +3016,7 @@ __name(hexToNumber$1, "hexToNumber");
|
|
|
3658
3016
|
* ```
|
|
3659
3017
|
*/
|
|
3660
3018
|
function bytesToNumberBE$1(bytes) {
|
|
3661
|
-
return hexToNumber$1(bytesToHex$
|
|
3019
|
+
return hexToNumber$1(bytesToHex$2(bytes));
|
|
3662
3020
|
}
|
|
3663
3021
|
__name(bytesToNumberBE$1, "bytesToNumberBE");
|
|
3664
3022
|
/**
|
|
@@ -3674,7 +3032,7 @@ __name(bytesToNumberBE$1, "bytesToNumberBE");
|
|
|
3674
3032
|
* ```
|
|
3675
3033
|
*/
|
|
3676
3034
|
function bytesToNumberLE$1(bytes) {
|
|
3677
|
-
return hexToNumber$1(bytesToHex$
|
|
3035
|
+
return hexToNumber$1(bytesToHex$2(copyBytes$2(abytes$4(bytes)).reverse()));
|
|
3678
3036
|
}
|
|
3679
3037
|
__name(bytesToNumberLE$1, "bytesToNumberLE");
|
|
3680
3038
|
/**
|
|
@@ -3691,12 +3049,12 @@ __name(bytesToNumberLE$1, "bytesToNumberLE");
|
|
|
3691
3049
|
* ```
|
|
3692
3050
|
*/
|
|
3693
3051
|
function numberToBytesBE$1(n, len) {
|
|
3694
|
-
anumber$
|
|
3052
|
+
anumber$4(len);
|
|
3695
3053
|
if (len === 0) throw new RangeError("zero length");
|
|
3696
3054
|
n = abignumber$1(n);
|
|
3697
3055
|
const hex = n.toString(16);
|
|
3698
3056
|
if (hex.length > len * 2) throw new RangeError("number too large");
|
|
3699
|
-
return hexToBytes$
|
|
3057
|
+
return hexToBytes$2(hex.padStart(len * 2, "0"));
|
|
3700
3058
|
}
|
|
3701
3059
|
__name(numberToBytesBE$1, "numberToBytesBE");
|
|
3702
3060
|
/**
|
|
@@ -3729,8 +3087,8 @@ __name(numberToBytesLE$1, "numberToBytesLE");
|
|
|
3729
3087
|
* ```
|
|
3730
3088
|
*/
|
|
3731
3089
|
function equalBytes$1(a, b) {
|
|
3732
|
-
a = abytes$
|
|
3733
|
-
b = abytes$
|
|
3090
|
+
a = abytes$3(a);
|
|
3091
|
+
b = abytes$3(b);
|
|
3734
3092
|
if (a.length !== b.length) return false;
|
|
3735
3093
|
let diff = 0;
|
|
3736
3094
|
for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
|
|
@@ -3750,7 +3108,7 @@ __name(equalBytes$1, "equalBytes");
|
|
|
3750
3108
|
* ```
|
|
3751
3109
|
*/
|
|
3752
3110
|
function copyBytes$2(bytes) {
|
|
3753
|
-
return Uint8Array.from(abytes$
|
|
3111
|
+
return Uint8Array.from(abytes$3(bytes));
|
|
3754
3112
|
}
|
|
3755
3113
|
__name(copyBytes$2, "copyBytes");
|
|
3756
3114
|
/**
|
|
@@ -3889,8 +3247,8 @@ const bitMask$1 = /* @__PURE__ */ __name((n) => (_1n$13 << BigInt(n)) - _1n$13,
|
|
|
3889
3247
|
* ```
|
|
3890
3248
|
*/
|
|
3891
3249
|
function createHmacDrbg$1(hashLen, qByteLen, hmacFn) {
|
|
3892
|
-
anumber$
|
|
3893
|
-
anumber$
|
|
3250
|
+
anumber$4(hashLen, "hashLen");
|
|
3251
|
+
anumber$4(qByteLen, "qByteLen");
|
|
3894
3252
|
if (typeof hmacFn !== "function") throw new TypeError("hmacFn must be a function");
|
|
3895
3253
|
const u8n = (len) => new Uint8Array(len);
|
|
3896
3254
|
const NULL = Uint8Array.of();
|
|
@@ -3905,7 +3263,7 @@ function createHmacDrbg$1(hashLen, qByteLen, hmacFn) {
|
|
|
3905
3263
|
k.fill(0);
|
|
3906
3264
|
i = 0;
|
|
3907
3265
|
};
|
|
3908
|
-
const h = (...msgs) => hmacFn(k, concatBytes(v, ...msgs));
|
|
3266
|
+
const h = (...msgs) => hmacFn(k, concatBytes$1(v, ...msgs));
|
|
3909
3267
|
const reseed = (seed = NULL) => {
|
|
3910
3268
|
k = h(byte0, seed);
|
|
3911
3269
|
v = h();
|
|
@@ -3923,7 +3281,7 @@ function createHmacDrbg$1(hashLen, qByteLen, hmacFn) {
|
|
|
3923
3281
|
out.push(sl);
|
|
3924
3282
|
len += v.length;
|
|
3925
3283
|
}
|
|
3926
|
-
return concatBytes(...out);
|
|
3284
|
+
return concatBytes$1(...out);
|
|
3927
3285
|
};
|
|
3928
3286
|
const genUntil = (seed, pred) => {
|
|
3929
3287
|
reset();
|
|
@@ -4410,7 +3768,7 @@ function FpIsSquare(Fp, n) {
|
|
|
4410
3768
|
* ```
|
|
4411
3769
|
*/
|
|
4412
3770
|
function nLength$1(n, nBitLength) {
|
|
4413
|
-
if (nBitLength !== void 0) anumber$
|
|
3771
|
+
if (nBitLength !== void 0) anumber$3(nBitLength);
|
|
4414
3772
|
if (n <= _0n$12) throw new Error("invalid n length: expected positive n, got " + n);
|
|
4415
3773
|
if (nBitLength !== void 0 && nBitLength < 1) throw new Error("invalid n length: expected positive bit length, got " + nBitLength);
|
|
4416
3774
|
const bits = bitLen$1(n);
|
|
@@ -4520,7 +3878,7 @@ var _Field$1 = class {
|
|
|
4520
3878
|
return this.isLE ? numberToBytesLE$1(num, this.BYTES) : numberToBytesBE$1(num, this.BYTES);
|
|
4521
3879
|
}
|
|
4522
3880
|
fromBytes(bytes, skipValidation = false) {
|
|
4523
|
-
abytes$
|
|
3881
|
+
abytes$3(bytes);
|
|
4524
3882
|
const { _lengths: allowedLengths, BYTES, isLE, ORDER, _mod: modFromBytes } = this;
|
|
4525
3883
|
if (allowedLengths) {
|
|
4526
3884
|
if (bytes.length < 1 || !allowedLengths.includes(bytes.length) || bytes.length > BYTES) throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
|
|
@@ -4641,7 +3999,7 @@ __name(getMinHashLength$1, "getMinHashLength");
|
|
|
4641
3999
|
* ```
|
|
4642
4000
|
*/
|
|
4643
4001
|
function mapHashToField$1(key, fieldOrder, isLE = false) {
|
|
4644
|
-
abytes$
|
|
4002
|
+
abytes$3(key);
|
|
4645
4003
|
const len = key.length;
|
|
4646
4004
|
const fieldLen = getFieldBytesLength$1(fieldOrder);
|
|
4647
4005
|
const minLen = Math.max(getMinHashLength$1(fieldOrder), 16);
|
|
@@ -5139,7 +4497,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
5139
4497
|
static fromBytes(bytes, zip215 = false) {
|
|
5140
4498
|
const len = Fp.BYTES;
|
|
5141
4499
|
const { a, d } = CURVE;
|
|
5142
|
-
bytes = copyBytes$2(abytes$
|
|
4500
|
+
bytes = copyBytes$2(abytes$3(bytes, len, "point"));
|
|
5143
4501
|
abool$2(zip215, "zip215");
|
|
5144
4502
|
const normed = copyBytes$2(bytes);
|
|
5145
4503
|
const lastByte = bytes[len - 1];
|
|
@@ -5159,7 +4517,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
5159
4517
|
});
|
|
5160
4518
|
}
|
|
5161
4519
|
static fromHex(hex, zip215 = false) {
|
|
5162
|
-
return Point.fromBytes(hexToBytes(hex), zip215);
|
|
4520
|
+
return Point.fromBytes(hexToBytes$1(hex), zip215);
|
|
5163
4521
|
}
|
|
5164
4522
|
get x() {
|
|
5165
4523
|
return this.toAffine().x;
|
|
@@ -5286,7 +4644,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
5286
4644
|
return bytes;
|
|
5287
4645
|
}
|
|
5288
4646
|
toHex() {
|
|
5289
|
-
return bytesToHex(this.toBytes());
|
|
4647
|
+
return bytesToHex$1(this.toBytes());
|
|
5290
4648
|
}
|
|
5291
4649
|
toString() {
|
|
5292
4650
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
@@ -5355,7 +4713,7 @@ var PrimeEdwardsPoint = class {
|
|
|
5355
4713
|
return this.ep.toAffine(invertedZ);
|
|
5356
4714
|
}
|
|
5357
4715
|
toHex() {
|
|
5358
|
-
return bytesToHex(this.toBytes());
|
|
4716
|
+
return bytesToHex$1(this.toBytes());
|
|
5359
4717
|
}
|
|
5360
4718
|
toString() {
|
|
5361
4719
|
return this.toHex();
|
|
@@ -5432,7 +4790,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
5432
4790
|
asafenumber(outputLen, "hash.outputLen");
|
|
5433
4791
|
if (outputLen !== expectedLen) throw new Error(`hash.outputLen must be ${expectedLen}, got ${outputLen}`);
|
|
5434
4792
|
}
|
|
5435
|
-
const randomBytes
|
|
4793
|
+
const randomBytes = opts.randomBytes === void 0 ? randomBytes$1 : opts.randomBytes;
|
|
5436
4794
|
const adjustScalarBytes = opts.adjustScalarBytes === void 0 ? (bytes) => bytes : opts.adjustScalarBytes;
|
|
5437
4795
|
const domain = opts.domain === void 0 ? (data, ctx, phflag) => {
|
|
5438
4796
|
abool$2(phflag, "phflag");
|
|
@@ -5444,8 +4802,8 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
5444
4802
|
}
|
|
5445
4803
|
function getPrivateScalar(key) {
|
|
5446
4804
|
const len = lengths.secretKey;
|
|
5447
|
-
abytes$
|
|
5448
|
-
const hashed = abytes$
|
|
4805
|
+
abytes$3(key, lengths.secretKey, "secretKey");
|
|
4806
|
+
const hashed = abytes$3(hash(key), 2 * len, "hashedSecretKey");
|
|
5449
4807
|
const head = adjustScalarBytes(hashed.slice(0, len));
|
|
5450
4808
|
return {
|
|
5451
4809
|
head,
|
|
@@ -5472,11 +4830,11 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
5472
4830
|
return getExtendedPublicKey(secretKey).pointBytes;
|
|
5473
4831
|
}
|
|
5474
4832
|
function hashDomainToScalar(context = Uint8Array.of(), ...msgs) {
|
|
5475
|
-
return modN_LE(hash(domain(concatBytes(...msgs), abytes$
|
|
4833
|
+
return modN_LE(hash(domain(concatBytes$1(...msgs), abytes$3(context, void 0, "context"), !!prehash)));
|
|
5476
4834
|
}
|
|
5477
4835
|
/** Signs message with secret key. RFC8032 5.1.6 */
|
|
5478
4836
|
function sign(msg, secretKey, options = {}) {
|
|
5479
|
-
msg = abytes$
|
|
4837
|
+
msg = abytes$3(msg, void 0, "message");
|
|
5480
4838
|
if (prehash) msg = prehash(msg);
|
|
5481
4839
|
const { prefix, scalar, pointBytes } = getExtendedPublicKey(secretKey);
|
|
5482
4840
|
const r = hashDomainToScalar(options.context, prefix, msg);
|
|
@@ -5484,7 +4842,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
5484
4842
|
const k = hashDomainToScalar(options.context, R, pointBytes, msg);
|
|
5485
4843
|
const s = Fn.create(r + k * scalar);
|
|
5486
4844
|
if (!Fn.isValid(s)) throw new Error("sign failed: invalid s");
|
|
5487
|
-
return abytes$
|
|
4845
|
+
return abytes$3(concatBytes$1(R, Fn.toBytes(s)), lengths.signature, "result");
|
|
5488
4846
|
}
|
|
5489
4847
|
const verifyOpts = { zip215: opts.zip215 };
|
|
5490
4848
|
/**
|
|
@@ -5495,9 +4853,9 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
5495
4853
|
const { context } = options;
|
|
5496
4854
|
const zip215 = options.zip215 === void 0 ? !!verifyOpts.zip215 : options.zip215;
|
|
5497
4855
|
const len = lengths.signature;
|
|
5498
|
-
sig = abytes$
|
|
5499
|
-
msg = abytes$
|
|
5500
|
-
publicKey = abytes$
|
|
4856
|
+
sig = abytes$3(sig, len, "signature");
|
|
4857
|
+
msg = abytes$3(msg, void 0, "message");
|
|
4858
|
+
publicKey = abytes$3(publicKey, lengths.publicKey, "publicKey");
|
|
5501
4859
|
if (zip215 !== void 0) abool$2(zip215, "zip215");
|
|
5502
4860
|
if (prehash) msg = prehash(msg);
|
|
5503
4861
|
const mid = len / 2;
|
|
@@ -5525,11 +4883,11 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
5525
4883
|
seed: _size
|
|
5526
4884
|
};
|
|
5527
4885
|
function randomSecretKey(seed) {
|
|
5528
|
-
seed = seed === void 0 ? randomBytes
|
|
5529
|
-
return abytes$
|
|
4886
|
+
seed = seed === void 0 ? randomBytes(lengths.seed) : seed;
|
|
4887
|
+
return abytes$3(seed, lengths.seed, "seed");
|
|
5530
4888
|
}
|
|
5531
4889
|
function isValidSecretKey(key) {
|
|
5532
|
-
return isBytes$
|
|
4890
|
+
return isBytes$3(key) && key.length === lengths.secretKey;
|
|
5533
4891
|
}
|
|
5534
4892
|
function isValidPublicKey(key, zip215) {
|
|
5535
4893
|
try {
|
|
@@ -5562,7 +4920,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
5562
4920
|
},
|
|
5563
4921
|
toMontgomerySecret(secretKey) {
|
|
5564
4922
|
const size = lengths.secretKey;
|
|
5565
|
-
abytes$
|
|
4923
|
+
abytes$3(secretKey, size);
|
|
5566
4924
|
return adjustScalarBytes(hash(secretKey.subarray(0, size))).subarray(0, size);
|
|
5567
4925
|
}
|
|
5568
4926
|
};
|
|
@@ -5600,7 +4958,7 @@ function strxor(a, b) {
|
|
|
5600
4958
|
return arr;
|
|
5601
4959
|
}
|
|
5602
4960
|
function normDST(DST) {
|
|
5603
|
-
if (!isBytes$
|
|
4961
|
+
if (!isBytes$3(DST) && typeof DST !== "string") throw new Error("DST must be Uint8Array or ascii string");
|
|
5604
4962
|
const dst = typeof DST === "string" ? asciiToBytes(DST) : DST;
|
|
5605
4963
|
if (dst.length === 0) throw new Error("DST must be non-empty");
|
|
5606
4964
|
return dst;
|
|
@@ -5626,25 +4984,25 @@ function normDST(DST) {
|
|
|
5626
4984
|
* ```
|
|
5627
4985
|
*/
|
|
5628
4986
|
function expand_message_xmd(msg, DST, lenInBytes, H) {
|
|
5629
|
-
abytes$
|
|
4987
|
+
abytes$3(msg);
|
|
5630
4988
|
asafenumber(lenInBytes);
|
|
5631
4989
|
DST = normDST(DST);
|
|
5632
|
-
if (DST.length > 255) DST = H(concatBytes(asciiToBytes("H2C-OVERSIZE-DST-"), DST));
|
|
4990
|
+
if (DST.length > 255) DST = H(concatBytes$1(asciiToBytes("H2C-OVERSIZE-DST-"), DST));
|
|
5633
4991
|
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
|
|
5634
4992
|
const ell = Math.ceil(lenInBytes / b_in_bytes);
|
|
5635
4993
|
if (lenInBytes > 65535 || ell > 255) throw new Error("expand_message_xmd: invalid lenInBytes");
|
|
5636
|
-
const DST_prime = concatBytes(DST, i2osp(DST.length, 1));
|
|
4994
|
+
const DST_prime = concatBytes$1(DST, i2osp(DST.length, 1));
|
|
5637
4995
|
const Z_pad = new Uint8Array(r_in_bytes);
|
|
5638
4996
|
const l_i_b_str = i2osp(lenInBytes, 2);
|
|
5639
4997
|
const b = new Array(ell);
|
|
5640
|
-
const b_0 = H(concatBytes(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
|
|
5641
|
-
b[0] = H(concatBytes(b_0, i2osp(1, 1), DST_prime));
|
|
5642
|
-
for (let i = 1; i < ell; i++) b[i] = H(concatBytes(...[
|
|
4998
|
+
const b_0 = H(concatBytes$1(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
|
|
4999
|
+
b[0] = H(concatBytes$1(b_0, i2osp(1, 1), DST_prime));
|
|
5000
|
+
for (let i = 1; i < ell; i++) b[i] = H(concatBytes$1(...[
|
|
5643
5001
|
strxor(b_0, b[i - 1]),
|
|
5644
5002
|
i2osp(i + 1, 1),
|
|
5645
5003
|
DST_prime
|
|
5646
5004
|
]));
|
|
5647
|
-
return concatBytes(...b).slice(0, lenInBytes);
|
|
5005
|
+
return concatBytes$1(...b).slice(0, lenInBytes);
|
|
5648
5006
|
}
|
|
5649
5007
|
/**
|
|
5650
5008
|
* Produces a uniformly random byte string using an extendable-output function (XOF) H.
|
|
@@ -5676,7 +5034,7 @@ function expand_message_xmd(msg, DST, lenInBytes, H) {
|
|
|
5676
5034
|
* ```
|
|
5677
5035
|
*/
|
|
5678
5036
|
function expand_message_xof(msg, DST, lenInBytes, k, H) {
|
|
5679
|
-
abytes$
|
|
5037
|
+
abytes$3(msg);
|
|
5680
5038
|
asafenumber(lenInBytes);
|
|
5681
5039
|
DST = normDST(DST);
|
|
5682
5040
|
if (DST.length > 255) {
|
|
@@ -5719,7 +5077,7 @@ function hash_to_field(msg, count, options) {
|
|
|
5719
5077
|
});
|
|
5720
5078
|
const { p, k, m, hash, expand, DST } = options;
|
|
5721
5079
|
asafenumber(hash.outputLen, "valid hash");
|
|
5722
|
-
abytes$
|
|
5080
|
+
abytes$3(msg);
|
|
5723
5081
|
asafenumber(count);
|
|
5724
5082
|
if (count < 1) throw new Error("hash_to_field: expected count >= 1");
|
|
5725
5083
|
if (m < 1) throw new Error("hash_to_field: expected m >= 1");
|
|
@@ -5798,12 +5156,12 @@ const _DST_scalar = "HashToScalar-";
|
|
|
5798
5156
|
* const point = hasher.encodeToCurve(new TextEncoder().encode('hello noble'));
|
|
5799
5157
|
* ```
|
|
5800
5158
|
*/
|
|
5801
|
-
function createHasher(Point, mapToCurve, defaults) {
|
|
5159
|
+
function createHasher$1(Point, mapToCurve, defaults) {
|
|
5802
5160
|
if (typeof mapToCurve !== "function") throw new Error("mapToCurve() must be defined");
|
|
5803
5161
|
const snapshot = (src) => Object.freeze({
|
|
5804
5162
|
...src,
|
|
5805
|
-
DST: isBytes$
|
|
5806
|
-
...src.encodeDST === void 0 ? {} : { encodeDST: isBytes$
|
|
5163
|
+
DST: isBytes$3(src.DST) ? copyBytes$2(src.DST) : src.DST,
|
|
5164
|
+
...src.encodeDST === void 0 ? {} : { encodeDST: isBytes$3(src.encodeDST) ? copyBytes$2(src.encodeDST) : src.encodeDST }
|
|
5807
5165
|
});
|
|
5808
5166
|
const safeDefaults = snapshot(defaults);
|
|
5809
5167
|
function map(num) {
|
|
@@ -5850,6 +5208,7 @@ function createHasher(Point, mapToCurve, defaults) {
|
|
|
5850
5208
|
}
|
|
5851
5209
|
});
|
|
5852
5210
|
}
|
|
5211
|
+
__name(createHasher$1, "createHasher");
|
|
5853
5212
|
|
|
5854
5213
|
//#endregion
|
|
5855
5214
|
//#region ../../node_modules/.pnpm/@noble+curves@2.2.0/node_modules/@noble/curves/ed25519.js
|
|
@@ -6015,7 +5374,7 @@ var _RistrettoPoint = class _RistrettoPoint extends PrimeEdwardsPoint {
|
|
|
6015
5374
|
return new _RistrettoPoint(ep);
|
|
6016
5375
|
}
|
|
6017
5376
|
static fromBytes(bytes) {
|
|
6018
|
-
abytes$
|
|
5377
|
+
abytes$4(bytes, 32);
|
|
6019
5378
|
const { a, d } = ed25519_CURVE;
|
|
6020
5379
|
const P = ed25519_CURVE_p;
|
|
6021
5380
|
const mod = (n) => Fp$2.create(n);
|
|
@@ -6043,7 +5402,7 @@ var _RistrettoPoint = class _RistrettoPoint extends PrimeEdwardsPoint {
|
|
|
6043
5402
|
* @param hex - Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
|
|
6044
5403
|
*/
|
|
6045
5404
|
static fromHex(hex) {
|
|
6046
|
-
return _RistrettoPoint.fromBytes(hexToBytes$
|
|
5405
|
+
return _RistrettoPoint.fromBytes(hexToBytes$2(hex));
|
|
6047
5406
|
}
|
|
6048
5407
|
/**
|
|
6049
5408
|
* Encodes ristretto point to Uint8Array.
|
|
@@ -6139,7 +5498,7 @@ const ristretto255_hasher = Object.freeze({
|
|
|
6139
5498
|
* `hash_to_ristretto255` function defined in RFC 9380.
|
|
6140
5499
|
*/
|
|
6141
5500
|
deriveToCurve(bytes) {
|
|
6142
|
-
abytes$
|
|
5501
|
+
abytes$4(bytes, 64);
|
|
6143
5502
|
const R1 = calcElligatorRistrettoMap(bytes255ToNumberLE(bytes.subarray(0, 32)));
|
|
6144
5503
|
const R2 = calcElligatorRistrettoMap(bytes255ToNumberLE(bytes.subarray(32, 64)));
|
|
6145
5504
|
return new _RistrettoPoint(R1.add(R2));
|
|
@@ -6169,8 +5528,8 @@ var _HMAC$1 = class {
|
|
|
6169
5528
|
finished = false;
|
|
6170
5529
|
destroyed = false;
|
|
6171
5530
|
constructor(hash, key) {
|
|
6172
|
-
ahash(hash);
|
|
6173
|
-
abytes$
|
|
5531
|
+
ahash$1(hash);
|
|
5532
|
+
abytes$4(key, void 0, "key");
|
|
6174
5533
|
this.iHash = hash.create();
|
|
6175
5534
|
if (typeof this.iHash.update !== "function") throw new Error("Expected instance of class which extends utils.Hash");
|
|
6176
5535
|
this.blockLen = this.iHash.blockLen;
|
|
@@ -6183,16 +5542,16 @@ var _HMAC$1 = class {
|
|
|
6183
5542
|
this.oHash = hash.create();
|
|
6184
5543
|
for (let i = 0; i < pad.length; i++) pad[i] ^= 106;
|
|
6185
5544
|
this.oHash.update(pad);
|
|
6186
|
-
clean$
|
|
5545
|
+
clean$2(pad);
|
|
6187
5546
|
}
|
|
6188
5547
|
update(buf) {
|
|
6189
|
-
aexists$
|
|
5548
|
+
aexists$2(this);
|
|
6190
5549
|
this.iHash.update(buf);
|
|
6191
5550
|
return this;
|
|
6192
5551
|
}
|
|
6193
5552
|
digestInto(out) {
|
|
6194
|
-
aexists$
|
|
6195
|
-
aoutput$
|
|
5553
|
+
aexists$2(this);
|
|
5554
|
+
aoutput$2(out, this);
|
|
6196
5555
|
this.finished = true;
|
|
6197
5556
|
const buf = out.subarray(0, this.outputLen);
|
|
6198
5557
|
this.iHash.digestInto(buf);
|
|
@@ -6232,6 +5591,194 @@ const hmac$1 = /* @__PURE__ */ (() => {
|
|
|
6232
5591
|
return hmac_;
|
|
6233
5592
|
})();
|
|
6234
5593
|
|
|
5594
|
+
//#endregion
|
|
5595
|
+
//#region ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/utils.js
|
|
5596
|
+
/**
|
|
5597
|
+
* Utilities for hex, bytes, CSPRNG.
|
|
5598
|
+
* @module
|
|
5599
|
+
*/
|
|
5600
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5601
|
+
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
|
5602
|
+
function isBytes$2(a) {
|
|
5603
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
5604
|
+
}
|
|
5605
|
+
__name(isBytes$2, "isBytes");
|
|
5606
|
+
/** Asserts something is positive integer. */
|
|
5607
|
+
function anumber$2(n, title = "") {
|
|
5608
|
+
if (!Number.isSafeInteger(n) || n < 0) {
|
|
5609
|
+
const prefix = title && `"${title}" `;
|
|
5610
|
+
throw new Error(`${prefix}expected integer >= 0, got ${n}`);
|
|
5611
|
+
}
|
|
5612
|
+
}
|
|
5613
|
+
__name(anumber$2, "anumber");
|
|
5614
|
+
/** Asserts something is Uint8Array. */
|
|
5615
|
+
function abytes$2(value, length, title = "") {
|
|
5616
|
+
const bytes = isBytes$2(value);
|
|
5617
|
+
const len = value?.length;
|
|
5618
|
+
const needsLen = length !== void 0;
|
|
5619
|
+
if (!bytes || needsLen && len !== length) {
|
|
5620
|
+
const prefix = title && `"${title}" `;
|
|
5621
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
5622
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
5623
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
5624
|
+
}
|
|
5625
|
+
return value;
|
|
5626
|
+
}
|
|
5627
|
+
__name(abytes$2, "abytes");
|
|
5628
|
+
/** Asserts something is hash */
|
|
5629
|
+
function ahash(h) {
|
|
5630
|
+
if (typeof h !== "function" || typeof h.create !== "function") throw new Error("Hash must wrapped by utils.createHasher");
|
|
5631
|
+
anumber$2(h.outputLen);
|
|
5632
|
+
anumber$2(h.blockLen);
|
|
5633
|
+
}
|
|
5634
|
+
/** Asserts a hash instance has not been destroyed / finished */
|
|
5635
|
+
function aexists$1(instance, checkFinished = true) {
|
|
5636
|
+
if (instance.destroyed) throw new Error("Hash instance has been destroyed");
|
|
5637
|
+
if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called");
|
|
5638
|
+
}
|
|
5639
|
+
__name(aexists$1, "aexists");
|
|
5640
|
+
/** Asserts output is properly-sized byte array */
|
|
5641
|
+
function aoutput$1(out, instance) {
|
|
5642
|
+
abytes$2(out, void 0, "digestInto() output");
|
|
5643
|
+
const min = instance.outputLen;
|
|
5644
|
+
if (out.length < min) throw new Error("\"digestInto() output\" expected to be of length >=" + min);
|
|
5645
|
+
}
|
|
5646
|
+
__name(aoutput$1, "aoutput");
|
|
5647
|
+
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
5648
|
+
function clean$1(...arrays) {
|
|
5649
|
+
for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
|
|
5650
|
+
}
|
|
5651
|
+
__name(clean$1, "clean");
|
|
5652
|
+
/** Create DataView of an array for easy byte-level manipulation. */
|
|
5653
|
+
function createView$1(arr) {
|
|
5654
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
5655
|
+
}
|
|
5656
|
+
__name(createView$1, "createView");
|
|
5657
|
+
/** The rotate right (circular right shift) operation for uint32 */
|
|
5658
|
+
function rotr(word, shift) {
|
|
5659
|
+
return word << 32 - shift | word >>> shift;
|
|
5660
|
+
}
|
|
5661
|
+
/** The rotate left (circular left shift) operation for uint32 */
|
|
5662
|
+
function rotl(word, shift) {
|
|
5663
|
+
return word << shift | word >>> 32 - shift >>> 0;
|
|
5664
|
+
}
|
|
5665
|
+
const hasHexBuiltin$1 = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
|
|
5666
|
+
const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
5667
|
+
/**
|
|
5668
|
+
* Convert byte array to hex string. Uses built-in function, when available.
|
|
5669
|
+
* @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
|
|
5670
|
+
*/
|
|
5671
|
+
function bytesToHex(bytes) {
|
|
5672
|
+
abytes$2(bytes);
|
|
5673
|
+
if (hasHexBuiltin$1) return bytes.toHex();
|
|
5674
|
+
let hex = "";
|
|
5675
|
+
for (let i = 0; i < bytes.length; i++) hex += hexes[bytes[i]];
|
|
5676
|
+
return hex;
|
|
5677
|
+
}
|
|
5678
|
+
const asciis = {
|
|
5679
|
+
_0: 48,
|
|
5680
|
+
_9: 57,
|
|
5681
|
+
A: 65,
|
|
5682
|
+
F: 70,
|
|
5683
|
+
a: 97,
|
|
5684
|
+
f: 102
|
|
5685
|
+
};
|
|
5686
|
+
function asciiToBase16(ch) {
|
|
5687
|
+
if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0;
|
|
5688
|
+
if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10);
|
|
5689
|
+
if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10);
|
|
5690
|
+
}
|
|
5691
|
+
/**
|
|
5692
|
+
* Convert hex string to byte array. Uses built-in function, when available.
|
|
5693
|
+
* @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
|
|
5694
|
+
*/
|
|
5695
|
+
function hexToBytes(hex) {
|
|
5696
|
+
if (typeof hex !== "string") throw new Error("hex string expected, got " + typeof hex);
|
|
5697
|
+
if (hasHexBuiltin$1) return Uint8Array.fromHex(hex);
|
|
5698
|
+
const hl = hex.length;
|
|
5699
|
+
const al = hl / 2;
|
|
5700
|
+
if (hl % 2) throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
5701
|
+
const array = new Uint8Array(al);
|
|
5702
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
5703
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
5704
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
5705
|
+
if (n1 === void 0 || n2 === void 0) {
|
|
5706
|
+
const char = hex[hi] + hex[hi + 1];
|
|
5707
|
+
throw new Error("hex string expected, got non-hex character \"" + char + "\" at index " + hi);
|
|
5708
|
+
}
|
|
5709
|
+
array[ai] = n1 * 16 + n2;
|
|
5710
|
+
}
|
|
5711
|
+
return array;
|
|
5712
|
+
}
|
|
5713
|
+
/**
|
|
5714
|
+
* Converts string to bytes using UTF8 encoding.
|
|
5715
|
+
* Built-in doesn't validate input to be string: we do the check.
|
|
5716
|
+
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
5717
|
+
*/
|
|
5718
|
+
function utf8ToBytes(str) {
|
|
5719
|
+
if (typeof str !== "string") throw new Error("string expected");
|
|
5720
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
5721
|
+
}
|
|
5722
|
+
/**
|
|
5723
|
+
* Helper for KDFs: consumes uint8array or string.
|
|
5724
|
+
* When string is passed, does utf8 decoding, using TextDecoder.
|
|
5725
|
+
*/
|
|
5726
|
+
function kdfInputToBytes(data, errorTitle = "") {
|
|
5727
|
+
if (typeof data === "string") return utf8ToBytes(data);
|
|
5728
|
+
return abytes$2(data, void 0, errorTitle);
|
|
5729
|
+
}
|
|
5730
|
+
/** Copies several Uint8Arrays into one. */
|
|
5731
|
+
function concatBytes(...arrays) {
|
|
5732
|
+
let sum = 0;
|
|
5733
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
5734
|
+
const a = arrays[i];
|
|
5735
|
+
abytes$2(a);
|
|
5736
|
+
sum += a.length;
|
|
5737
|
+
}
|
|
5738
|
+
const res = new Uint8Array(sum);
|
|
5739
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
5740
|
+
const a = arrays[i];
|
|
5741
|
+
res.set(a, pad);
|
|
5742
|
+
pad += a.length;
|
|
5743
|
+
}
|
|
5744
|
+
return res;
|
|
5745
|
+
}
|
|
5746
|
+
/** Merges default options and passed options. */
|
|
5747
|
+
function checkOpts(defaults, opts) {
|
|
5748
|
+
if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]") throw new Error("options must be object or undefined");
|
|
5749
|
+
return Object.assign(defaults, opts);
|
|
5750
|
+
}
|
|
5751
|
+
/** Creates function with outputLen, blockLen, create properties from a class constructor. */
|
|
5752
|
+
function createHasher(hashCons, info = {}) {
|
|
5753
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
5754
|
+
const tmp = hashCons(void 0);
|
|
5755
|
+
hashC.outputLen = tmp.outputLen;
|
|
5756
|
+
hashC.blockLen = tmp.blockLen;
|
|
5757
|
+
hashC.create = (opts) => hashCons(opts);
|
|
5758
|
+
Object.assign(hashC, info);
|
|
5759
|
+
return Object.freeze(hashC);
|
|
5760
|
+
}
|
|
5761
|
+
/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
|
|
5762
|
+
function randomBytes(bytesLength = 32) {
|
|
5763
|
+
const cr = typeof globalThis === "object" ? globalThis.crypto : null;
|
|
5764
|
+
if (typeof cr?.getRandomValues !== "function") throw new Error("crypto.getRandomValues must be defined");
|
|
5765
|
+
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
5766
|
+
}
|
|
5767
|
+
/** Creates OID opts for NIST hashes, with prefix 06 09 60 86 48 01 65 03 04 02. */
|
|
5768
|
+
const oidNist = (suffix) => ({ oid: Uint8Array.from([
|
|
5769
|
+
6,
|
|
5770
|
+
9,
|
|
5771
|
+
96,
|
|
5772
|
+
134,
|
|
5773
|
+
72,
|
|
5774
|
+
1,
|
|
5775
|
+
101,
|
|
5776
|
+
3,
|
|
5777
|
+
4,
|
|
5778
|
+
2,
|
|
5779
|
+
suffix
|
|
5780
|
+
]) });
|
|
5781
|
+
|
|
6235
5782
|
//#endregion
|
|
6236
5783
|
//#region ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/hmac.js
|
|
6237
5784
|
/**
|
|
@@ -6247,8 +5794,8 @@ var _HMAC = class {
|
|
|
6247
5794
|
finished = false;
|
|
6248
5795
|
destroyed = false;
|
|
6249
5796
|
constructor(hash, key) {
|
|
6250
|
-
ahash
|
|
6251
|
-
abytes$
|
|
5797
|
+
ahash(hash);
|
|
5798
|
+
abytes$2(key, void 0, "key");
|
|
6252
5799
|
this.iHash = hash.create();
|
|
6253
5800
|
if (typeof this.iHash.update !== "function") throw new Error("Expected instance of class which extends utils.Hash");
|
|
6254
5801
|
this.blockLen = this.iHash.blockLen;
|
|
@@ -6261,16 +5808,16 @@ var _HMAC = class {
|
|
|
6261
5808
|
this.oHash = hash.create();
|
|
6262
5809
|
for (let i = 0; i < pad.length; i++) pad[i] ^= 106;
|
|
6263
5810
|
this.oHash.update(pad);
|
|
6264
|
-
clean$
|
|
5811
|
+
clean$1(pad);
|
|
6265
5812
|
}
|
|
6266
5813
|
update(buf) {
|
|
6267
|
-
aexists$
|
|
5814
|
+
aexists$1(this);
|
|
6268
5815
|
this.iHash.update(buf);
|
|
6269
5816
|
return this;
|
|
6270
5817
|
}
|
|
6271
5818
|
digestInto(out) {
|
|
6272
|
-
aexists$
|
|
6273
|
-
abytes$
|
|
5819
|
+
aexists$1(this);
|
|
5820
|
+
abytes$2(out, this.outputLen, "output");
|
|
6274
5821
|
this.finished = true;
|
|
6275
5822
|
this.iHash.digestInto(out);
|
|
6276
5823
|
this.oHash.update(out);
|
|
@@ -6323,14 +5870,14 @@ hmac.create = (hash, key) => new _HMAC(hash, key);
|
|
|
6323
5870
|
* @module
|
|
6324
5871
|
*/
|
|
6325
5872
|
function pbkdf2Init(hash, _password, _salt, _opts) {
|
|
6326
|
-
ahash
|
|
5873
|
+
ahash(hash);
|
|
6327
5874
|
const { c, dkLen, asyncTick } = checkOpts({
|
|
6328
5875
|
dkLen: 32,
|
|
6329
5876
|
asyncTick: 10
|
|
6330
5877
|
}, _opts);
|
|
6331
|
-
anumber$
|
|
6332
|
-
anumber$
|
|
6333
|
-
anumber$
|
|
5878
|
+
anumber$2(c, "c");
|
|
5879
|
+
anumber$2(dkLen, "dkLen");
|
|
5880
|
+
anumber$2(asyncTick, "asyncTick");
|
|
6334
5881
|
if (c < 1) throw new Error("iterations (c) must be >= 1");
|
|
6335
5882
|
const password = kdfInputToBytes(_password, "password");
|
|
6336
5883
|
const salt = kdfInputToBytes(_salt, "salt");
|
|
@@ -6349,7 +5896,7 @@ function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {
|
|
|
6349
5896
|
PRF.destroy();
|
|
6350
5897
|
PRFSalt.destroy();
|
|
6351
5898
|
if (prfW) prfW.destroy();
|
|
6352
|
-
clean$
|
|
5899
|
+
clean$1(u);
|
|
6353
5900
|
return DK;
|
|
6354
5901
|
}
|
|
6355
5902
|
/**
|
|
@@ -6365,7 +5912,7 @@ function pbkdf2(hash, password, salt, opts) {
|
|
|
6365
5912
|
const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
|
|
6366
5913
|
let prfW;
|
|
6367
5914
|
const arr = /* @__PURE__ */ new Uint8Array(4);
|
|
6368
|
-
const view = createView$
|
|
5915
|
+
const view = createView$1(arr);
|
|
6369
5916
|
const u = new Uint8Array(PRF.outputLen);
|
|
6370
5917
|
for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
|
|
6371
5918
|
const Ti = DK.subarray(pos, pos + PRF.outputLen);
|
|
@@ -6380,6 +5927,196 @@ function pbkdf2(hash, password, salt, opts) {
|
|
|
6380
5927
|
return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);
|
|
6381
5928
|
}
|
|
6382
5929
|
|
|
5930
|
+
//#endregion
|
|
5931
|
+
//#region ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_md.js
|
|
5932
|
+
/**
|
|
5933
|
+
* Internal Merkle-Damgard hash utils.
|
|
5934
|
+
* @module
|
|
5935
|
+
*/
|
|
5936
|
+
/** Choice: a ? b : c */
|
|
5937
|
+
function Chi(a, b, c) {
|
|
5938
|
+
return a & b ^ ~a & c;
|
|
5939
|
+
}
|
|
5940
|
+
/** Majority function, true if any two inputs is true. */
|
|
5941
|
+
function Maj(a, b, c) {
|
|
5942
|
+
return a & b ^ a & c ^ b & c;
|
|
5943
|
+
}
|
|
5944
|
+
/**
|
|
5945
|
+
* Merkle-Damgard hash construction base class.
|
|
5946
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
5947
|
+
*/
|
|
5948
|
+
var HashMD = class {
|
|
5949
|
+
blockLen;
|
|
5950
|
+
outputLen;
|
|
5951
|
+
padOffset;
|
|
5952
|
+
isLE;
|
|
5953
|
+
buffer;
|
|
5954
|
+
view;
|
|
5955
|
+
finished = false;
|
|
5956
|
+
length = 0;
|
|
5957
|
+
pos = 0;
|
|
5958
|
+
destroyed = false;
|
|
5959
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
5960
|
+
this.blockLen = blockLen;
|
|
5961
|
+
this.outputLen = outputLen;
|
|
5962
|
+
this.padOffset = padOffset;
|
|
5963
|
+
this.isLE = isLE;
|
|
5964
|
+
this.buffer = new Uint8Array(blockLen);
|
|
5965
|
+
this.view = createView$1(this.buffer);
|
|
5966
|
+
}
|
|
5967
|
+
update(data) {
|
|
5968
|
+
aexists$1(this);
|
|
5969
|
+
abytes$2(data);
|
|
5970
|
+
const { view, buffer, blockLen } = this;
|
|
5971
|
+
const len = data.length;
|
|
5972
|
+
for (let pos = 0; pos < len;) {
|
|
5973
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
5974
|
+
if (take === blockLen) {
|
|
5975
|
+
const dataView = createView$1(data);
|
|
5976
|
+
for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);
|
|
5977
|
+
continue;
|
|
5978
|
+
}
|
|
5979
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
5980
|
+
this.pos += take;
|
|
5981
|
+
pos += take;
|
|
5982
|
+
if (this.pos === blockLen) {
|
|
5983
|
+
this.process(view, 0);
|
|
5984
|
+
this.pos = 0;
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5987
|
+
this.length += data.length;
|
|
5988
|
+
this.roundClean();
|
|
5989
|
+
return this;
|
|
5990
|
+
}
|
|
5991
|
+
digestInto(out) {
|
|
5992
|
+
aexists$1(this);
|
|
5993
|
+
aoutput$1(out, this);
|
|
5994
|
+
this.finished = true;
|
|
5995
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
5996
|
+
let { pos } = this;
|
|
5997
|
+
buffer[pos++] = 128;
|
|
5998
|
+
clean$1(this.buffer.subarray(pos));
|
|
5999
|
+
if (this.padOffset > blockLen - pos) {
|
|
6000
|
+
this.process(view, 0);
|
|
6001
|
+
pos = 0;
|
|
6002
|
+
}
|
|
6003
|
+
for (let i = pos; i < blockLen; i++) buffer[i] = 0;
|
|
6004
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
|
|
6005
|
+
this.process(view, 0);
|
|
6006
|
+
const oview = createView$1(out);
|
|
6007
|
+
const len = this.outputLen;
|
|
6008
|
+
if (len % 4) throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
6009
|
+
const outLen = len / 4;
|
|
6010
|
+
const state = this.get();
|
|
6011
|
+
if (outLen > state.length) throw new Error("_sha2: outputLen bigger than state");
|
|
6012
|
+
for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);
|
|
6013
|
+
}
|
|
6014
|
+
digest() {
|
|
6015
|
+
const { buffer, outputLen } = this;
|
|
6016
|
+
this.digestInto(buffer);
|
|
6017
|
+
const res = buffer.slice(0, outputLen);
|
|
6018
|
+
this.destroy();
|
|
6019
|
+
return res;
|
|
6020
|
+
}
|
|
6021
|
+
_cloneInto(to) {
|
|
6022
|
+
to ||= new this.constructor();
|
|
6023
|
+
to.set(...this.get());
|
|
6024
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
6025
|
+
to.destroyed = destroyed;
|
|
6026
|
+
to.finished = finished;
|
|
6027
|
+
to.length = length;
|
|
6028
|
+
to.pos = pos;
|
|
6029
|
+
if (length % blockLen) to.buffer.set(buffer);
|
|
6030
|
+
return to;
|
|
6031
|
+
}
|
|
6032
|
+
clone() {
|
|
6033
|
+
return this._cloneInto();
|
|
6034
|
+
}
|
|
6035
|
+
};
|
|
6036
|
+
/**
|
|
6037
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
6038
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
6039
|
+
*/
|
|
6040
|
+
/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
|
|
6041
|
+
const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
6042
|
+
1779033703,
|
|
6043
|
+
3144134277,
|
|
6044
|
+
1013904242,
|
|
6045
|
+
2773480762,
|
|
6046
|
+
1359893119,
|
|
6047
|
+
2600822924,
|
|
6048
|
+
528734635,
|
|
6049
|
+
1541459225
|
|
6050
|
+
]);
|
|
6051
|
+
/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */
|
|
6052
|
+
const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
6053
|
+
1779033703,
|
|
6054
|
+
4089235720,
|
|
6055
|
+
3144134277,
|
|
6056
|
+
2227873595,
|
|
6057
|
+
1013904242,
|
|
6058
|
+
4271175723,
|
|
6059
|
+
2773480762,
|
|
6060
|
+
1595750129,
|
|
6061
|
+
1359893119,
|
|
6062
|
+
2917565137,
|
|
6063
|
+
2600822924,
|
|
6064
|
+
725511199,
|
|
6065
|
+
528734635,
|
|
6066
|
+
4215389547,
|
|
6067
|
+
1541459225,
|
|
6068
|
+
327033209
|
|
6069
|
+
]);
|
|
6070
|
+
|
|
6071
|
+
//#endregion
|
|
6072
|
+
//#region ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_u64.js
|
|
6073
|
+
/**
|
|
6074
|
+
* Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
|
|
6075
|
+
* @todo re-check https://issues.chromium.org/issues/42212588
|
|
6076
|
+
* @module
|
|
6077
|
+
*/
|
|
6078
|
+
const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
6079
|
+
const _32n = /* @__PURE__ */ BigInt(32);
|
|
6080
|
+
function fromBig(n, le = false) {
|
|
6081
|
+
if (le) return {
|
|
6082
|
+
h: Number(n & U32_MASK64),
|
|
6083
|
+
l: Number(n >> _32n & U32_MASK64)
|
|
6084
|
+
};
|
|
6085
|
+
return {
|
|
6086
|
+
h: Number(n >> _32n & U32_MASK64) | 0,
|
|
6087
|
+
l: Number(n & U32_MASK64) | 0
|
|
6088
|
+
};
|
|
6089
|
+
}
|
|
6090
|
+
function split(lst, le = false) {
|
|
6091
|
+
const len = lst.length;
|
|
6092
|
+
let Ah = new Uint32Array(len);
|
|
6093
|
+
let Al = new Uint32Array(len);
|
|
6094
|
+
for (let i = 0; i < len; i++) {
|
|
6095
|
+
const { h, l } = fromBig(lst[i], le);
|
|
6096
|
+
[Ah[i], Al[i]] = [h, l];
|
|
6097
|
+
}
|
|
6098
|
+
return [Ah, Al];
|
|
6099
|
+
}
|
|
6100
|
+
const shrSH = (h, _l, s) => h >>> s;
|
|
6101
|
+
const shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
6102
|
+
const rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
6103
|
+
const rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
6104
|
+
const rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
6105
|
+
const rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
6106
|
+
function add(Ah, Al, Bh, Bl) {
|
|
6107
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
6108
|
+
return {
|
|
6109
|
+
h: Ah + Bh + (l / 2 ** 32 | 0) | 0,
|
|
6110
|
+
l: l | 0
|
|
6111
|
+
};
|
|
6112
|
+
}
|
|
6113
|
+
const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
6114
|
+
const add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
6115
|
+
const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
6116
|
+
const add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
6117
|
+
const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
6118
|
+
const add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
6119
|
+
|
|
6383
6120
|
//#endregion
|
|
6384
6121
|
//#region ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/sha2.js
|
|
6385
6122
|
/**
|
|
@@ -6462,7 +6199,7 @@ const SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
|
6462
6199
|
/** Reusable temporary buffer. "W" comes straight from spec. */
|
|
6463
6200
|
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
6464
6201
|
/** Internal 32-byte base SHA2 hash class. */
|
|
6465
|
-
var SHA2_32B = class extends HashMD
|
|
6202
|
+
var SHA2_32B = class extends HashMD {
|
|
6466
6203
|
constructor(outputLen) {
|
|
6467
6204
|
super(64, outputLen, 8, false);
|
|
6468
6205
|
}
|
|
@@ -6494,14 +6231,14 @@ var SHA2_32B = class extends HashMD$1 {
|
|
|
6494
6231
|
for (let i = 16; i < 64; i++) {
|
|
6495
6232
|
const W15 = SHA256_W[i - 15];
|
|
6496
6233
|
const W2 = SHA256_W[i - 2];
|
|
6497
|
-
const s0 = rotr
|
|
6498
|
-
SHA256_W[i] = (rotr
|
|
6234
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
6235
|
+
SHA256_W[i] = (rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10) + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
6499
6236
|
}
|
|
6500
6237
|
let { A, B, C, D, E, F, G, H } = this;
|
|
6501
6238
|
for (let i = 0; i < 64; i++) {
|
|
6502
|
-
const sigma1 = rotr
|
|
6503
|
-
const T1 = H + sigma1 + Chi
|
|
6504
|
-
const T2 = (rotr
|
|
6239
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
6240
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
6241
|
+
const T2 = (rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22)) + Maj(A, B, C) | 0;
|
|
6505
6242
|
H = G;
|
|
6506
6243
|
G = F;
|
|
6507
6244
|
F = E;
|
|
@@ -6522,28 +6259,28 @@ var SHA2_32B = class extends HashMD$1 {
|
|
|
6522
6259
|
this.set(A, B, C, D, E, F, G, H);
|
|
6523
6260
|
}
|
|
6524
6261
|
roundClean() {
|
|
6525
|
-
clean$
|
|
6262
|
+
clean$1(SHA256_W);
|
|
6526
6263
|
}
|
|
6527
6264
|
destroy() {
|
|
6528
6265
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
6529
|
-
clean$
|
|
6266
|
+
clean$1(this.buffer);
|
|
6530
6267
|
}
|
|
6531
6268
|
};
|
|
6532
6269
|
/** Internal SHA2-256 hash class. */
|
|
6533
6270
|
var _SHA256 = class extends SHA2_32B {
|
|
6534
|
-
A = SHA256_IV
|
|
6535
|
-
B = SHA256_IV
|
|
6536
|
-
C = SHA256_IV
|
|
6537
|
-
D = SHA256_IV
|
|
6538
|
-
E = SHA256_IV
|
|
6539
|
-
F = SHA256_IV
|
|
6540
|
-
G = SHA256_IV
|
|
6541
|
-
H = SHA256_IV
|
|
6271
|
+
A = SHA256_IV[0] | 0;
|
|
6272
|
+
B = SHA256_IV[1] | 0;
|
|
6273
|
+
C = SHA256_IV[2] | 0;
|
|
6274
|
+
D = SHA256_IV[3] | 0;
|
|
6275
|
+
E = SHA256_IV[4] | 0;
|
|
6276
|
+
F = SHA256_IV[5] | 0;
|
|
6277
|
+
G = SHA256_IV[6] | 0;
|
|
6278
|
+
H = SHA256_IV[7] | 0;
|
|
6542
6279
|
constructor() {
|
|
6543
6280
|
super(32);
|
|
6544
6281
|
}
|
|
6545
6282
|
};
|
|
6546
|
-
const K512 = /* @__PURE__ */ (() => split
|
|
6283
|
+
const K512 = /* @__PURE__ */ (() => split([
|
|
6547
6284
|
"0x428a2f98d728ae22",
|
|
6548
6285
|
"0x7137449123ef65cd",
|
|
6549
6286
|
"0xb5c0fbcfec4d3b2f",
|
|
@@ -6630,7 +6367,7 @@ const SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
|
|
|
6630
6367
|
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
6631
6368
|
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
6632
6369
|
/** Internal 64-byte base SHA2 hash class. */
|
|
6633
|
-
var SHA2_64B = class extends HashMD
|
|
6370
|
+
var SHA2_64B = class extends HashMD {
|
|
6634
6371
|
constructor(outputLen) {
|
|
6635
6372
|
super(128, outputLen, 16, false);
|
|
6636
6373
|
}
|
|
@@ -6681,27 +6418,27 @@ var SHA2_64B = class extends HashMD$1 {
|
|
|
6681
6418
|
for (let i = 16; i < 80; i++) {
|
|
6682
6419
|
const W15h = SHA512_W_H[i - 15] | 0;
|
|
6683
6420
|
const W15l = SHA512_W_L[i - 15] | 0;
|
|
6684
|
-
const s0h = rotrSH
|
|
6685
|
-
const s0l = rotrSL
|
|
6421
|
+
const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
|
|
6422
|
+
const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
|
|
6686
6423
|
const W2h = SHA512_W_H[i - 2] | 0;
|
|
6687
6424
|
const W2l = SHA512_W_L[i - 2] | 0;
|
|
6688
|
-
const s1h = rotrSH
|
|
6689
|
-
const s1l = rotrSL
|
|
6690
|
-
const SUMl = add4L
|
|
6691
|
-
SHA512_W_H[i] = add4H
|
|
6425
|
+
const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
|
|
6426
|
+
const s1l = rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6);
|
|
6427
|
+
const SUMl = add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
6428
|
+
SHA512_W_H[i] = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]) | 0;
|
|
6692
6429
|
SHA512_W_L[i] = SUMl | 0;
|
|
6693
6430
|
}
|
|
6694
6431
|
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
6695
6432
|
for (let i = 0; i < 80; i++) {
|
|
6696
|
-
const sigma1h = rotrSH
|
|
6697
|
-
const sigma1l = rotrSL
|
|
6433
|
+
const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
|
|
6434
|
+
const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
|
|
6698
6435
|
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
6699
6436
|
const CHIl = El & Fl ^ ~El & Gl;
|
|
6700
|
-
const T1ll = add5L
|
|
6701
|
-
const T1h = add5H
|
|
6437
|
+
const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
6438
|
+
const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
6702
6439
|
const T1l = T1ll | 0;
|
|
6703
|
-
const sigma0h = rotrSH
|
|
6704
|
-
const sigma0l = rotrSL
|
|
6440
|
+
const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
|
|
6441
|
+
const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
|
|
6705
6442
|
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
6706
6443
|
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
6707
6444
|
Hh = Gh | 0;
|
|
@@ -6710,53 +6447,53 @@ var SHA2_64B = class extends HashMD$1 {
|
|
|
6710
6447
|
Gl = Fl | 0;
|
|
6711
6448
|
Fh = Eh | 0;
|
|
6712
6449
|
Fl = El | 0;
|
|
6713
|
-
({h: Eh, l: El} = add
|
|
6450
|
+
({h: Eh, l: El} = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
6714
6451
|
Dh = Ch | 0;
|
|
6715
6452
|
Dl = Cl | 0;
|
|
6716
6453
|
Ch = Bh | 0;
|
|
6717
6454
|
Cl = Bl | 0;
|
|
6718
6455
|
Bh = Ah | 0;
|
|
6719
6456
|
Bl = Al | 0;
|
|
6720
|
-
const All = add3L
|
|
6721
|
-
Ah = add3H
|
|
6457
|
+
const All = add3L(T1l, sigma0l, MAJl);
|
|
6458
|
+
Ah = add3H(All, T1h, sigma0h, MAJh);
|
|
6722
6459
|
Al = All | 0;
|
|
6723
6460
|
}
|
|
6724
|
-
({h: Ah, l: Al} = add
|
|
6725
|
-
({h: Bh, l: Bl} = add
|
|
6726
|
-
({h: Ch, l: Cl} = add
|
|
6727
|
-
({h: Dh, l: Dl} = add
|
|
6728
|
-
({h: Eh, l: El} = add
|
|
6729
|
-
({h: Fh, l: Fl} = add
|
|
6730
|
-
({h: Gh, l: Gl} = add
|
|
6731
|
-
({h: Hh, l: Hl} = add
|
|
6461
|
+
({h: Ah, l: Al} = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
6462
|
+
({h: Bh, l: Bl} = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
6463
|
+
({h: Ch, l: Cl} = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
6464
|
+
({h: Dh, l: Dl} = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
6465
|
+
({h: Eh, l: El} = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
6466
|
+
({h: Fh, l: Fl} = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
6467
|
+
({h: Gh, l: Gl} = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
6468
|
+
({h: Hh, l: Hl} = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
6732
6469
|
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
6733
6470
|
}
|
|
6734
6471
|
roundClean() {
|
|
6735
|
-
clean$
|
|
6472
|
+
clean$1(SHA512_W_H, SHA512_W_L);
|
|
6736
6473
|
}
|
|
6737
6474
|
destroy() {
|
|
6738
|
-
clean$
|
|
6475
|
+
clean$1(this.buffer);
|
|
6739
6476
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
6740
6477
|
}
|
|
6741
6478
|
};
|
|
6742
6479
|
/** Internal SHA2-512 hash class. */
|
|
6743
6480
|
var _SHA512 = class extends SHA2_64B {
|
|
6744
|
-
Ah = SHA512_IV
|
|
6745
|
-
Al = SHA512_IV
|
|
6746
|
-
Bh = SHA512_IV
|
|
6747
|
-
Bl = SHA512_IV
|
|
6748
|
-
Ch = SHA512_IV
|
|
6749
|
-
Cl = SHA512_IV
|
|
6750
|
-
Dh = SHA512_IV
|
|
6751
|
-
Dl = SHA512_IV
|
|
6752
|
-
Eh = SHA512_IV
|
|
6753
|
-
El = SHA512_IV
|
|
6754
|
-
Fh = SHA512_IV
|
|
6755
|
-
Fl = SHA512_IV
|
|
6756
|
-
Gh = SHA512_IV
|
|
6757
|
-
Gl = SHA512_IV
|
|
6758
|
-
Hh = SHA512_IV
|
|
6759
|
-
Hl = SHA512_IV
|
|
6481
|
+
Ah = SHA512_IV[0] | 0;
|
|
6482
|
+
Al = SHA512_IV[1] | 0;
|
|
6483
|
+
Bh = SHA512_IV[2] | 0;
|
|
6484
|
+
Bl = SHA512_IV[3] | 0;
|
|
6485
|
+
Ch = SHA512_IV[4] | 0;
|
|
6486
|
+
Cl = SHA512_IV[5] | 0;
|
|
6487
|
+
Dh = SHA512_IV[6] | 0;
|
|
6488
|
+
Dl = SHA512_IV[7] | 0;
|
|
6489
|
+
Eh = SHA512_IV[8] | 0;
|
|
6490
|
+
El = SHA512_IV[9] | 0;
|
|
6491
|
+
Fh = SHA512_IV[10] | 0;
|
|
6492
|
+
Fl = SHA512_IV[11] | 0;
|
|
6493
|
+
Gh = SHA512_IV[12] | 0;
|
|
6494
|
+
Gl = SHA512_IV[13] | 0;
|
|
6495
|
+
Hh = SHA512_IV[14] | 0;
|
|
6496
|
+
Hl = SHA512_IV[15] | 0;
|
|
6760
6497
|
constructor() {
|
|
6761
6498
|
super(64);
|
|
6762
6499
|
}
|
|
@@ -6769,9 +6506,574 @@ var _SHA512 = class extends SHA2_64B {
|
|
|
6769
6506
|
* - Each sha256 hash is executing 2^18 bit operations.
|
|
6770
6507
|
* - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.
|
|
6771
6508
|
*/
|
|
6772
|
-
const sha256 = /* @__PURE__ */ createHasher
|
|
6509
|
+
const sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), /* @__PURE__ */ oidNist(1));
|
|
6773
6510
|
/** SHA2-512 hash function from RFC 4634. */
|
|
6774
|
-
const sha512 = /* @__PURE__ */ createHasher
|
|
6511
|
+
const sha512 = /* @__PURE__ */ createHasher(() => new _SHA512(), /* @__PURE__ */ oidNist(3));
|
|
6512
|
+
|
|
6513
|
+
//#endregion
|
|
6514
|
+
//#region ../../node_modules/.pnpm/@scure+base@2.0.0/node_modules/@scure/base/index.js
|
|
6515
|
+
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
6516
|
+
function isBytes$1(a) {
|
|
6517
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
6518
|
+
}
|
|
6519
|
+
__name(isBytes$1, "isBytes");
|
|
6520
|
+
/** Asserts something is Uint8Array. */
|
|
6521
|
+
function abytes$1(b) {
|
|
6522
|
+
if (!isBytes$1(b)) throw new Error("Uint8Array expected");
|
|
6523
|
+
}
|
|
6524
|
+
__name(abytes$1, "abytes");
|
|
6525
|
+
function isArrayOf(isString, arr) {
|
|
6526
|
+
if (!Array.isArray(arr)) return false;
|
|
6527
|
+
if (arr.length === 0) return true;
|
|
6528
|
+
if (isString) return arr.every((item) => typeof item === "string");
|
|
6529
|
+
else return arr.every((item) => Number.isSafeInteger(item));
|
|
6530
|
+
}
|
|
6531
|
+
function afn(input) {
|
|
6532
|
+
if (typeof input !== "function") throw new Error("function expected");
|
|
6533
|
+
return true;
|
|
6534
|
+
}
|
|
6535
|
+
function astr(label, input) {
|
|
6536
|
+
if (typeof input !== "string") throw new Error(`${label}: string expected`);
|
|
6537
|
+
return true;
|
|
6538
|
+
}
|
|
6539
|
+
function anumber$1(n) {
|
|
6540
|
+
if (!Number.isSafeInteger(n)) throw new Error(`invalid integer: ${n}`);
|
|
6541
|
+
}
|
|
6542
|
+
__name(anumber$1, "anumber");
|
|
6543
|
+
function aArr(input) {
|
|
6544
|
+
if (!Array.isArray(input)) throw new Error("array expected");
|
|
6545
|
+
}
|
|
6546
|
+
function astrArr(label, input) {
|
|
6547
|
+
if (!isArrayOf(true, input)) throw new Error(`${label}: array of strings expected`);
|
|
6548
|
+
}
|
|
6549
|
+
function anumArr(label, input) {
|
|
6550
|
+
if (!isArrayOf(false, input)) throw new Error(`${label}: array of numbers expected`);
|
|
6551
|
+
}
|
|
6552
|
+
/**
|
|
6553
|
+
* @__NO_SIDE_EFFECTS__
|
|
6554
|
+
*/
|
|
6555
|
+
function chain(...args) {
|
|
6556
|
+
const id = (a) => a;
|
|
6557
|
+
const wrap = (a, b) => (c) => a(b(c));
|
|
6558
|
+
return {
|
|
6559
|
+
encode: args.map((x) => x.encode).reduceRight(wrap, id),
|
|
6560
|
+
decode: args.map((x) => x.decode).reduce(wrap, id)
|
|
6561
|
+
};
|
|
6562
|
+
}
|
|
6563
|
+
/**
|
|
6564
|
+
* Encodes integer radix representation to array of strings using alphabet and back.
|
|
6565
|
+
* Could also be array of strings.
|
|
6566
|
+
* @__NO_SIDE_EFFECTS__
|
|
6567
|
+
*/
|
|
6568
|
+
function alphabet(letters) {
|
|
6569
|
+
const lettersA = typeof letters === "string" ? letters.split("") : letters;
|
|
6570
|
+
const len = lettersA.length;
|
|
6571
|
+
astrArr("alphabet", lettersA);
|
|
6572
|
+
const indexes = new Map(lettersA.map((l, i) => [l, i]));
|
|
6573
|
+
return {
|
|
6574
|
+
encode: (digits) => {
|
|
6575
|
+
aArr(digits);
|
|
6576
|
+
return digits.map((i) => {
|
|
6577
|
+
if (!Number.isSafeInteger(i) || i < 0 || i >= len) throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
|
|
6578
|
+
return lettersA[i];
|
|
6579
|
+
});
|
|
6580
|
+
},
|
|
6581
|
+
decode: (input) => {
|
|
6582
|
+
aArr(input);
|
|
6583
|
+
return input.map((letter) => {
|
|
6584
|
+
astr("alphabet.decode", letter);
|
|
6585
|
+
const i = indexes.get(letter);
|
|
6586
|
+
if (i === void 0) throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
|
|
6587
|
+
return i;
|
|
6588
|
+
});
|
|
6589
|
+
}
|
|
6590
|
+
};
|
|
6591
|
+
}
|
|
6592
|
+
/**
|
|
6593
|
+
* @__NO_SIDE_EFFECTS__
|
|
6594
|
+
*/
|
|
6595
|
+
function join(separator = "") {
|
|
6596
|
+
astr("join", separator);
|
|
6597
|
+
return {
|
|
6598
|
+
encode: (from) => {
|
|
6599
|
+
astrArr("join.decode", from);
|
|
6600
|
+
return from.join(separator);
|
|
6601
|
+
},
|
|
6602
|
+
decode: (to) => {
|
|
6603
|
+
astr("join.decode", to);
|
|
6604
|
+
return to.split(separator);
|
|
6605
|
+
}
|
|
6606
|
+
};
|
|
6607
|
+
}
|
|
6608
|
+
/**
|
|
6609
|
+
* Pad strings array so it has integer number of bits
|
|
6610
|
+
* @__NO_SIDE_EFFECTS__
|
|
6611
|
+
*/
|
|
6612
|
+
function padding(bits, chr = "=") {
|
|
6613
|
+
anumber$1(bits);
|
|
6614
|
+
astr("padding", chr);
|
|
6615
|
+
return {
|
|
6616
|
+
encode(data) {
|
|
6617
|
+
astrArr("padding.encode", data);
|
|
6618
|
+
while (data.length * bits % 8) data.push(chr);
|
|
6619
|
+
return data;
|
|
6620
|
+
},
|
|
6621
|
+
decode(input) {
|
|
6622
|
+
astrArr("padding.decode", input);
|
|
6623
|
+
let end = input.length;
|
|
6624
|
+
if (end * bits % 8) throw new Error("padding: invalid, string should have whole number of bytes");
|
|
6625
|
+
for (; end > 0 && input[end - 1] === chr; end--) if ((end - 1) * bits % 8 === 0) throw new Error("padding: invalid, string has too much padding");
|
|
6626
|
+
return input.slice(0, end);
|
|
6627
|
+
}
|
|
6628
|
+
};
|
|
6629
|
+
}
|
|
6630
|
+
/**
|
|
6631
|
+
* @__NO_SIDE_EFFECTS__
|
|
6632
|
+
*/
|
|
6633
|
+
function normalize$1(fn) {
|
|
6634
|
+
afn(fn);
|
|
6635
|
+
return {
|
|
6636
|
+
encode: (from) => from,
|
|
6637
|
+
decode: (to) => fn(to)
|
|
6638
|
+
};
|
|
6639
|
+
}
|
|
6640
|
+
__name(normalize$1, "normalize");
|
|
6641
|
+
/**
|
|
6642
|
+
* Slow: O(n^2) time complexity
|
|
6643
|
+
*/
|
|
6644
|
+
function convertRadix(data, from, to) {
|
|
6645
|
+
if (from < 2) throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
|
|
6646
|
+
if (to < 2) throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
|
|
6647
|
+
aArr(data);
|
|
6648
|
+
if (!data.length) return [];
|
|
6649
|
+
let pos = 0;
|
|
6650
|
+
const res = [];
|
|
6651
|
+
const digits = Array.from(data, (d) => {
|
|
6652
|
+
anumber$1(d);
|
|
6653
|
+
if (d < 0 || d >= from) throw new Error(`invalid integer: ${d}`);
|
|
6654
|
+
return d;
|
|
6655
|
+
});
|
|
6656
|
+
const dlen = digits.length;
|
|
6657
|
+
while (true) {
|
|
6658
|
+
let carry = 0;
|
|
6659
|
+
let done = true;
|
|
6660
|
+
for (let i = pos; i < dlen; i++) {
|
|
6661
|
+
const digit = digits[i];
|
|
6662
|
+
const fromCarry = from * carry;
|
|
6663
|
+
const digitBase = fromCarry + digit;
|
|
6664
|
+
if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) throw new Error("convertRadix: carry overflow");
|
|
6665
|
+
const div = digitBase / to;
|
|
6666
|
+
carry = digitBase % to;
|
|
6667
|
+
const rounded = Math.floor(div);
|
|
6668
|
+
digits[i] = rounded;
|
|
6669
|
+
if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase) throw new Error("convertRadix: carry overflow");
|
|
6670
|
+
if (!done) continue;
|
|
6671
|
+
else if (!rounded) pos = i;
|
|
6672
|
+
else done = false;
|
|
6673
|
+
}
|
|
6674
|
+
res.push(carry);
|
|
6675
|
+
if (done) break;
|
|
6676
|
+
}
|
|
6677
|
+
for (let i = 0; i < data.length - 1 && data[i] === 0; i++) res.push(0);
|
|
6678
|
+
return res.reverse();
|
|
6679
|
+
}
|
|
6680
|
+
const gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
|
|
6681
|
+
const radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from, to) => from + (to - gcd(from, to));
|
|
6682
|
+
const powers = /* @__PURE__ */ (() => {
|
|
6683
|
+
let res = [];
|
|
6684
|
+
for (let i = 0; i < 40; i++) res.push(2 ** i);
|
|
6685
|
+
return res;
|
|
6686
|
+
})();
|
|
6687
|
+
/**
|
|
6688
|
+
* Implemented with numbers, because BigInt is 5x slower
|
|
6689
|
+
*/
|
|
6690
|
+
function convertRadix2(data, from, to, padding) {
|
|
6691
|
+
aArr(data);
|
|
6692
|
+
if (from <= 0 || from > 32) throw new Error(`convertRadix2: wrong from=${from}`);
|
|
6693
|
+
if (to <= 0 || to > 32) throw new Error(`convertRadix2: wrong to=${to}`);
|
|
6694
|
+
if (/* @__PURE__ */ radix2carry(from, to) > 32) throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from, to)}`);
|
|
6695
|
+
let carry = 0;
|
|
6696
|
+
let pos = 0;
|
|
6697
|
+
const max = powers[from];
|
|
6698
|
+
const mask = powers[to] - 1;
|
|
6699
|
+
const res = [];
|
|
6700
|
+
for (const n of data) {
|
|
6701
|
+
anumber$1(n);
|
|
6702
|
+
if (n >= max) throw new Error(`convertRadix2: invalid data word=${n} from=${from}`);
|
|
6703
|
+
carry = carry << from | n;
|
|
6704
|
+
if (pos + from > 32) throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
|
|
6705
|
+
pos += from;
|
|
6706
|
+
for (; pos >= to; pos -= to) res.push((carry >> pos - to & mask) >>> 0);
|
|
6707
|
+
const pow = powers[pos];
|
|
6708
|
+
if (pow === void 0) throw new Error("invalid carry");
|
|
6709
|
+
carry &= pow - 1;
|
|
6710
|
+
}
|
|
6711
|
+
carry = carry << to - pos & mask;
|
|
6712
|
+
if (!padding && pos >= from) throw new Error("Excess padding");
|
|
6713
|
+
if (!padding && carry > 0) throw new Error(`Non-zero padding: ${carry}`);
|
|
6714
|
+
if (padding && pos > 0) res.push(carry >>> 0);
|
|
6715
|
+
return res;
|
|
6716
|
+
}
|
|
6717
|
+
/**
|
|
6718
|
+
* @__NO_SIDE_EFFECTS__
|
|
6719
|
+
*/
|
|
6720
|
+
function radix(num) {
|
|
6721
|
+
anumber$1(num);
|
|
6722
|
+
const _256 = 2 ** 8;
|
|
6723
|
+
return {
|
|
6724
|
+
encode: (bytes) => {
|
|
6725
|
+
if (!isBytes$1(bytes)) throw new Error("radix.encode input should be Uint8Array");
|
|
6726
|
+
return convertRadix(Array.from(bytes), _256, num);
|
|
6727
|
+
},
|
|
6728
|
+
decode: (digits) => {
|
|
6729
|
+
anumArr("radix.decode", digits);
|
|
6730
|
+
return Uint8Array.from(convertRadix(digits, num, _256));
|
|
6731
|
+
}
|
|
6732
|
+
};
|
|
6733
|
+
}
|
|
6734
|
+
/**
|
|
6735
|
+
* If both bases are power of same number (like `2**8 <-> 2**64`),
|
|
6736
|
+
* there is a linear algorithm. For now we have implementation for power-of-two bases only.
|
|
6737
|
+
* @__NO_SIDE_EFFECTS__
|
|
6738
|
+
*/
|
|
6739
|
+
function radix2(bits, revPadding = false) {
|
|
6740
|
+
anumber$1(bits);
|
|
6741
|
+
if (bits <= 0 || bits > 32) throw new Error("radix2: bits should be in (0..32]");
|
|
6742
|
+
if (/* @__PURE__ */ radix2carry(8, bits) > 32 || /* @__PURE__ */ radix2carry(bits, 8) > 32) throw new Error("radix2: carry overflow");
|
|
6743
|
+
return {
|
|
6744
|
+
encode: (bytes) => {
|
|
6745
|
+
if (!isBytes$1(bytes)) throw new Error("radix2.encode input should be Uint8Array");
|
|
6746
|
+
return convertRadix2(Array.from(bytes), 8, bits, !revPadding);
|
|
6747
|
+
},
|
|
6748
|
+
decode: (digits) => {
|
|
6749
|
+
anumArr("radix2.decode", digits);
|
|
6750
|
+
return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
|
|
6751
|
+
}
|
|
6752
|
+
};
|
|
6753
|
+
}
|
|
6754
|
+
function unsafeWrapper(fn) {
|
|
6755
|
+
afn(fn);
|
|
6756
|
+
return function(...args) {
|
|
6757
|
+
try {
|
|
6758
|
+
return fn.apply(null, args);
|
|
6759
|
+
} catch (e) {}
|
|
6760
|
+
};
|
|
6761
|
+
}
|
|
6762
|
+
function checksum(len, fn) {
|
|
6763
|
+
anumber$1(len);
|
|
6764
|
+
afn(fn);
|
|
6765
|
+
return {
|
|
6766
|
+
encode(data) {
|
|
6767
|
+
if (!isBytes$1(data)) throw new Error("checksum.encode: input should be Uint8Array");
|
|
6768
|
+
const sum = fn(data).slice(0, len);
|
|
6769
|
+
const res = new Uint8Array(data.length + len);
|
|
6770
|
+
res.set(data);
|
|
6771
|
+
res.set(sum, data.length);
|
|
6772
|
+
return res;
|
|
6773
|
+
},
|
|
6774
|
+
decode(data) {
|
|
6775
|
+
if (!isBytes$1(data)) throw new Error("checksum.decode: input should be Uint8Array");
|
|
6776
|
+
const payload = data.slice(0, -len);
|
|
6777
|
+
const oldChecksum = data.slice(-len);
|
|
6778
|
+
const newChecksum = fn(payload).slice(0, len);
|
|
6779
|
+
for (let i = 0; i < len; i++) if (newChecksum[i] !== oldChecksum[i]) throw new Error("Invalid checksum");
|
|
6780
|
+
return payload;
|
|
6781
|
+
}
|
|
6782
|
+
};
|
|
6783
|
+
}
|
|
6784
|
+
/**
|
|
6785
|
+
* base16 encoding from RFC 4648.
|
|
6786
|
+
* @example
|
|
6787
|
+
* ```js
|
|
6788
|
+
* base16.encode(Uint8Array.from([0x12, 0xab]));
|
|
6789
|
+
* // => '12AB'
|
|
6790
|
+
* ```
|
|
6791
|
+
*/
|
|
6792
|
+
const base16 = chain(radix2(4), alphabet("0123456789ABCDEF"), join(""));
|
|
6793
|
+
/**
|
|
6794
|
+
* base32 encoding from RFC 4648. Has padding.
|
|
6795
|
+
* Use `base32nopad` for unpadded version.
|
|
6796
|
+
* Also check out `base32hex`, `base32hexnopad`, `base32crockford`.
|
|
6797
|
+
* @example
|
|
6798
|
+
* ```js
|
|
6799
|
+
* base32.encode(Uint8Array.from([0x12, 0xab]));
|
|
6800
|
+
* // => 'CKVQ===='
|
|
6801
|
+
* base32.decode('CKVQ====');
|
|
6802
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
6803
|
+
* ```
|
|
6804
|
+
*/
|
|
6805
|
+
const base32 = chain(radix2(5), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), padding(5), join(""));
|
|
6806
|
+
/**
|
|
6807
|
+
* base32 encoding from RFC 4648. No padding.
|
|
6808
|
+
* Use `base32` for padded version.
|
|
6809
|
+
* Also check out `base32hex`, `base32hexnopad`, `base32crockford`.
|
|
6810
|
+
* @example
|
|
6811
|
+
* ```js
|
|
6812
|
+
* base32nopad.encode(Uint8Array.from([0x12, 0xab]));
|
|
6813
|
+
* // => 'CKVQ'
|
|
6814
|
+
* base32nopad.decode('CKVQ');
|
|
6815
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
6816
|
+
* ```
|
|
6817
|
+
*/
|
|
6818
|
+
const base32nopad = chain(radix2(5), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), join(""));
|
|
6819
|
+
/**
|
|
6820
|
+
* base32 encoding from RFC 4648. Padded. Compared to ordinary `base32`, slightly different alphabet.
|
|
6821
|
+
* Use `base32hexnopad` for unpadded version.
|
|
6822
|
+
* @example
|
|
6823
|
+
* ```js
|
|
6824
|
+
* base32hex.encode(Uint8Array.from([0x12, 0xab]));
|
|
6825
|
+
* // => '2ALG===='
|
|
6826
|
+
* base32hex.decode('2ALG====');
|
|
6827
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
6828
|
+
* ```
|
|
6829
|
+
*/
|
|
6830
|
+
const base32hex = chain(radix2(5), alphabet("0123456789ABCDEFGHIJKLMNOPQRSTUV"), padding(5), join(""));
|
|
6831
|
+
/**
|
|
6832
|
+
* base32 encoding from RFC 4648. No padding. Compared to ordinary `base32`, slightly different alphabet.
|
|
6833
|
+
* Use `base32hex` for padded version.
|
|
6834
|
+
* @example
|
|
6835
|
+
* ```js
|
|
6836
|
+
* base32hexnopad.encode(Uint8Array.from([0x12, 0xab]));
|
|
6837
|
+
* // => '2ALG'
|
|
6838
|
+
* base32hexnopad.decode('2ALG');
|
|
6839
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
6840
|
+
* ```
|
|
6841
|
+
*/
|
|
6842
|
+
const base32hexnopad = chain(radix2(5), alphabet("0123456789ABCDEFGHIJKLMNOPQRSTUV"), join(""));
|
|
6843
|
+
/**
|
|
6844
|
+
* base32 encoding from RFC 4648. Doug Crockford's version.
|
|
6845
|
+
* https://www.crockford.com/base32.html
|
|
6846
|
+
* @example
|
|
6847
|
+
* ```js
|
|
6848
|
+
* base32crockford.encode(Uint8Array.from([0x12, 0xab]));
|
|
6849
|
+
* // => '2ANG'
|
|
6850
|
+
* base32crockford.decode('2ANG');
|
|
6851
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
6852
|
+
* ```
|
|
6853
|
+
*/
|
|
6854
|
+
const base32crockford = chain(radix2(5), alphabet("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), join(""), normalize$1((s) => s.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
|
|
6855
|
+
const hasBase64Builtin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toBase64 === "function" && typeof Uint8Array.fromBase64 === "function")();
|
|
6856
|
+
const decodeBase64Builtin = (s, isUrl) => {
|
|
6857
|
+
astr("base64", s);
|
|
6858
|
+
const re = isUrl ? /^[A-Za-z0-9=_-]+$/ : /^[A-Za-z0-9=+/]+$/;
|
|
6859
|
+
const alphabet = isUrl ? "base64url" : "base64";
|
|
6860
|
+
if (s.length > 0 && !re.test(s)) throw new Error("invalid base64");
|
|
6861
|
+
return Uint8Array.fromBase64(s, {
|
|
6862
|
+
alphabet,
|
|
6863
|
+
lastChunkHandling: "strict"
|
|
6864
|
+
});
|
|
6865
|
+
};
|
|
6866
|
+
/**
|
|
6867
|
+
* base64 from RFC 4648. Padded.
|
|
6868
|
+
* Use `base64nopad` for unpadded version.
|
|
6869
|
+
* Also check out `base64url`, `base64urlnopad`.
|
|
6870
|
+
* Falls back to built-in function, when available.
|
|
6871
|
+
* @example
|
|
6872
|
+
* ```js
|
|
6873
|
+
* base64.encode(Uint8Array.from([0x12, 0xab]));
|
|
6874
|
+
* // => 'Eqs='
|
|
6875
|
+
* base64.decode('Eqs=');
|
|
6876
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
6877
|
+
* ```
|
|
6878
|
+
*/
|
|
6879
|
+
const base64 = hasBase64Builtin ? {
|
|
6880
|
+
encode(b) {
|
|
6881
|
+
abytes$1(b);
|
|
6882
|
+
return b.toBase64();
|
|
6883
|
+
},
|
|
6884
|
+
decode(s) {
|
|
6885
|
+
return decodeBase64Builtin(s, false);
|
|
6886
|
+
}
|
|
6887
|
+
} : chain(radix2(6), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), padding(6), join(""));
|
|
6888
|
+
/**
|
|
6889
|
+
* base64 from RFC 4648. No padding.
|
|
6890
|
+
* Use `base64` for padded version.
|
|
6891
|
+
* @example
|
|
6892
|
+
* ```js
|
|
6893
|
+
* base64nopad.encode(Uint8Array.from([0x12, 0xab]));
|
|
6894
|
+
* // => 'Eqs'
|
|
6895
|
+
* base64nopad.decode('Eqs');
|
|
6896
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
6897
|
+
* ```
|
|
6898
|
+
*/
|
|
6899
|
+
const base64nopad = chain(radix2(6), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), join(""));
|
|
6900
|
+
/**
|
|
6901
|
+
* base64 from RFC 4648, using URL-safe alphabet. Padded.
|
|
6902
|
+
* Use `base64urlnopad` for unpadded version.
|
|
6903
|
+
* Falls back to built-in function, when available.
|
|
6904
|
+
* @example
|
|
6905
|
+
* ```js
|
|
6906
|
+
* base64url.encode(Uint8Array.from([0x12, 0xab]));
|
|
6907
|
+
* // => 'Eqs='
|
|
6908
|
+
* base64url.decode('Eqs=');
|
|
6909
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
6910
|
+
* ```
|
|
6911
|
+
*/
|
|
6912
|
+
const base64url = hasBase64Builtin ? {
|
|
6913
|
+
encode(b) {
|
|
6914
|
+
abytes$1(b);
|
|
6915
|
+
return b.toBase64({ alphabet: "base64url" });
|
|
6916
|
+
},
|
|
6917
|
+
decode(s) {
|
|
6918
|
+
return decodeBase64Builtin(s, true);
|
|
6919
|
+
}
|
|
6920
|
+
} : chain(radix2(6), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), padding(6), join(""));
|
|
6921
|
+
/**
|
|
6922
|
+
* base64 from RFC 4648, using URL-safe alphabet. No padding.
|
|
6923
|
+
* Use `base64url` for padded version.
|
|
6924
|
+
* @example
|
|
6925
|
+
* ```js
|
|
6926
|
+
* base64urlnopad.encode(Uint8Array.from([0x12, 0xab]));
|
|
6927
|
+
* // => 'Eqs'
|
|
6928
|
+
* base64urlnopad.decode('Eqs');
|
|
6929
|
+
* // => Uint8Array.from([0x12, 0xab])
|
|
6930
|
+
* ```
|
|
6931
|
+
*/
|
|
6932
|
+
const base64urlnopad = chain(radix2(6), alphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), join(""));
|
|
6933
|
+
const genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => chain(radix(58), alphabet(abc), join(""));
|
|
6934
|
+
/**
|
|
6935
|
+
* base58: base64 without ambigous characters +, /, 0, O, I, l.
|
|
6936
|
+
* Quadratic (O(n^2)) - so, can't be used on large inputs.
|
|
6937
|
+
* @example
|
|
6938
|
+
* ```js
|
|
6939
|
+
* base58.decode('01abcdef');
|
|
6940
|
+
* // => '3UhJW'
|
|
6941
|
+
* ```
|
|
6942
|
+
*/
|
|
6943
|
+
const base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
6944
|
+
/**
|
|
6945
|
+
* Method, which creates base58check encoder.
|
|
6946
|
+
* Requires function, calculating sha256.
|
|
6947
|
+
*/
|
|
6948
|
+
const createBase58check = (sha256) => chain(checksum(4, (data) => sha256(sha256(data))), base58);
|
|
6949
|
+
const BECH_ALPHABET = chain(alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), join(""));
|
|
6950
|
+
const POLYMOD_GENERATORS = [
|
|
6951
|
+
996825010,
|
|
6952
|
+
642813549,
|
|
6953
|
+
513874426,
|
|
6954
|
+
1027748829,
|
|
6955
|
+
705979059
|
|
6956
|
+
];
|
|
6957
|
+
function bech32Polymod(pre) {
|
|
6958
|
+
const b = pre >> 25;
|
|
6959
|
+
let chk = (pre & 33554431) << 5;
|
|
6960
|
+
for (let i = 0; i < POLYMOD_GENERATORS.length; i++) if ((b >> i & 1) === 1) chk ^= POLYMOD_GENERATORS[i];
|
|
6961
|
+
return chk;
|
|
6962
|
+
}
|
|
6963
|
+
function bechChecksum(prefix, words, encodingConst = 1) {
|
|
6964
|
+
const len = prefix.length;
|
|
6965
|
+
let chk = 1;
|
|
6966
|
+
for (let i = 0; i < len; i++) {
|
|
6967
|
+
const c = prefix.charCodeAt(i);
|
|
6968
|
+
if (c < 33 || c > 126) throw new Error(`Invalid prefix (${prefix})`);
|
|
6969
|
+
chk = bech32Polymod(chk) ^ c >> 5;
|
|
6970
|
+
}
|
|
6971
|
+
chk = bech32Polymod(chk);
|
|
6972
|
+
for (let i = 0; i < len; i++) chk = bech32Polymod(chk) ^ prefix.charCodeAt(i) & 31;
|
|
6973
|
+
for (let v of words) chk = bech32Polymod(chk) ^ v;
|
|
6974
|
+
for (let i = 0; i < 6; i++) chk = bech32Polymod(chk);
|
|
6975
|
+
chk ^= encodingConst;
|
|
6976
|
+
return BECH_ALPHABET.encode(convertRadix2([chk % powers[30]], 30, 5, false));
|
|
6977
|
+
}
|
|
6978
|
+
/**
|
|
6979
|
+
* @__NO_SIDE_EFFECTS__
|
|
6980
|
+
*/
|
|
6981
|
+
function genBech32(encoding) {
|
|
6982
|
+
const ENCODING_CONST = encoding === "bech32" ? 1 : 734539939;
|
|
6983
|
+
const _words = radix2(5);
|
|
6984
|
+
const fromWords = _words.decode;
|
|
6985
|
+
const toWords = _words.encode;
|
|
6986
|
+
const fromWordsUnsafe = unsafeWrapper(fromWords);
|
|
6987
|
+
function encode(prefix, words, limit = 90) {
|
|
6988
|
+
astr("bech32.encode prefix", prefix);
|
|
6989
|
+
if (isBytes$1(words)) words = Array.from(words);
|
|
6990
|
+
anumArr("bech32.encode", words);
|
|
6991
|
+
const plen = prefix.length;
|
|
6992
|
+
if (plen === 0) throw new TypeError(`Invalid prefix length ${plen}`);
|
|
6993
|
+
const actualLength = plen + 7 + words.length;
|
|
6994
|
+
if (limit !== false && actualLength > limit) throw new TypeError(`Length ${actualLength} exceeds limit ${limit}`);
|
|
6995
|
+
const lowered = prefix.toLowerCase();
|
|
6996
|
+
const sum = bechChecksum(lowered, words, ENCODING_CONST);
|
|
6997
|
+
return `${lowered}1${BECH_ALPHABET.encode(words)}${sum}`;
|
|
6998
|
+
}
|
|
6999
|
+
function decode(str, limit = 90) {
|
|
7000
|
+
astr("bech32.decode input", str);
|
|
7001
|
+
const slen = str.length;
|
|
7002
|
+
if (slen < 8 || limit !== false && slen > limit) throw new TypeError(`invalid string length: ${slen} (${str}). Expected (8..${limit})`);
|
|
7003
|
+
const lowered = str.toLowerCase();
|
|
7004
|
+
if (str !== lowered && str !== str.toUpperCase()) throw new Error(`String must be lowercase or uppercase`);
|
|
7005
|
+
const sepIndex = lowered.lastIndexOf("1");
|
|
7006
|
+
if (sepIndex === 0 || sepIndex === -1) throw new Error(`Letter "1" must be present between prefix and data only`);
|
|
7007
|
+
const prefix = lowered.slice(0, sepIndex);
|
|
7008
|
+
const data = lowered.slice(sepIndex + 1);
|
|
7009
|
+
if (data.length < 6) throw new Error("Data must be at least 6 characters long");
|
|
7010
|
+
const words = BECH_ALPHABET.decode(data).slice(0, -6);
|
|
7011
|
+
const sum = bechChecksum(prefix, words, ENCODING_CONST);
|
|
7012
|
+
if (!data.endsWith(sum)) throw new Error(`Invalid checksum in ${str}: expected "${sum}"`);
|
|
7013
|
+
return {
|
|
7014
|
+
prefix,
|
|
7015
|
+
words
|
|
7016
|
+
};
|
|
7017
|
+
}
|
|
7018
|
+
const decodeUnsafe = unsafeWrapper(decode);
|
|
7019
|
+
function decodeToBytes(str) {
|
|
7020
|
+
const { prefix, words } = decode(str, false);
|
|
7021
|
+
return {
|
|
7022
|
+
prefix,
|
|
7023
|
+
words,
|
|
7024
|
+
bytes: fromWords(words)
|
|
7025
|
+
};
|
|
7026
|
+
}
|
|
7027
|
+
function encodeFromBytes(prefix, bytes) {
|
|
7028
|
+
return encode(prefix, toWords(bytes));
|
|
7029
|
+
}
|
|
7030
|
+
return {
|
|
7031
|
+
encode,
|
|
7032
|
+
decode,
|
|
7033
|
+
encodeFromBytes,
|
|
7034
|
+
decodeToBytes,
|
|
7035
|
+
decodeUnsafe,
|
|
7036
|
+
fromWords,
|
|
7037
|
+
fromWordsUnsafe,
|
|
7038
|
+
toWords
|
|
7039
|
+
};
|
|
7040
|
+
}
|
|
7041
|
+
/**
|
|
7042
|
+
* bech32 from BIP 173. Operates on words.
|
|
7043
|
+
* For high-level, check out scure-btc-signer:
|
|
7044
|
+
* https://github.com/paulmillr/scure-btc-signer.
|
|
7045
|
+
*/
|
|
7046
|
+
const bech32 = genBech32("bech32");
|
|
7047
|
+
/**
|
|
7048
|
+
* bech32m from BIP 350. Operates on words.
|
|
7049
|
+
* It was to mitigate `bech32` weaknesses.
|
|
7050
|
+
* For high-level, check out scure-btc-signer:
|
|
7051
|
+
* https://github.com/paulmillr/scure-btc-signer.
|
|
7052
|
+
*/
|
|
7053
|
+
const bech32m = genBech32("bech32m");
|
|
7054
|
+
const hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
|
|
7055
|
+
const hexBuiltin = {
|
|
7056
|
+
encode(data) {
|
|
7057
|
+
abytes$1(data);
|
|
7058
|
+
return data.toHex();
|
|
7059
|
+
},
|
|
7060
|
+
decode(s) {
|
|
7061
|
+
astr("hex", s);
|
|
7062
|
+
return Uint8Array.fromHex(s);
|
|
7063
|
+
}
|
|
7064
|
+
};
|
|
7065
|
+
/**
|
|
7066
|
+
* hex string decoder. Uses built-in function, when available.
|
|
7067
|
+
* @example
|
|
7068
|
+
* ```js
|
|
7069
|
+
* const b = hex.decode("0102ff"); // => new Uint8Array([ 1, 2, 255 ])
|
|
7070
|
+
* const str = hex.encode(b); // "0102ff"
|
|
7071
|
+
* ```
|
|
7072
|
+
*/
|
|
7073
|
+
const hex = hasHexBuiltin ? hexBuiltin : chain(radix2(4), alphabet("0123456789abcdef"), join(""), normalize$1((s) => {
|
|
7074
|
+
if (typeof s !== "string" || s.length % 2 !== 0) throw new TypeError(`hex.decode: expected string, got ${typeof s} with length ${s.length}`);
|
|
7075
|
+
return s.toLowerCase();
|
|
7076
|
+
}));
|
|
6775
7077
|
|
|
6776
7078
|
//#endregion
|
|
6777
7079
|
//#region ../../node_modules/.pnpm/@scure+bip39@2.0.1/node_modules/@scure/bip39/index.js
|
|
@@ -8938,7 +9240,7 @@ const DER$1 = {
|
|
|
8938
9240
|
},
|
|
8939
9241
|
decode(tag, data) {
|
|
8940
9242
|
const { Err: E } = DER$1;
|
|
8941
|
-
data = abytes$
|
|
9243
|
+
data = abytes$3(data, void 0, "DER data");
|
|
8942
9244
|
let pos = 0;
|
|
8943
9245
|
if (tag < 0 || tag > 255) throw new E("tlv.encode: wrong tag");
|
|
8944
9246
|
if (data.length < 2 || data[pos++] !== tag) throw new E("tlv.decode: wrong tlv");
|
|
@@ -8985,7 +9287,7 @@ const DER$1 = {
|
|
|
8985
9287
|
},
|
|
8986
9288
|
toSig(bytes) {
|
|
8987
9289
|
const { Err: E, _int: int, _tlv: tlv } = DER$1;
|
|
8988
|
-
const data = abytes$
|
|
9290
|
+
const data = abytes$3(bytes, void 0, "signature");
|
|
8989
9291
|
const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
|
|
8990
9292
|
if (seqLeftBytes.length) throw new E("invalid signature: left bytes after parsing");
|
|
8991
9293
|
const { v: rBytes, l: rLeftBytes } = tlv.decode(2, seqBytes);
|
|
@@ -9064,11 +9366,11 @@ function weierstrass$1(params, extraOpts = {}) {
|
|
|
9064
9366
|
abool$2(isCompressed, "isCompressed");
|
|
9065
9367
|
if (isCompressed) {
|
|
9066
9368
|
assertCompressionIsSupported();
|
|
9067
|
-
return concatBytes(pprefix$1(!Fp.isOdd(y)), bx);
|
|
9068
|
-
} else return concatBytes(Uint8Array.of(4), bx, Fp.toBytes(y));
|
|
9369
|
+
return concatBytes$1(pprefix$1(!Fp.isOdd(y)), bx);
|
|
9370
|
+
} else return concatBytes$1(Uint8Array.of(4), bx, Fp.toBytes(y));
|
|
9069
9371
|
}
|
|
9070
9372
|
function pointFromBytes(bytes) {
|
|
9071
|
-
abytes$
|
|
9373
|
+
abytes$3(bytes, void 0, "Point");
|
|
9072
9374
|
const { publicKey: comp, publicKeyUncompressed: uncomp } = lengths;
|
|
9073
9375
|
const length = bytes.length;
|
|
9074
9376
|
const head = bytes[0];
|
|
@@ -9173,12 +9475,12 @@ function weierstrass$1(params, extraOpts = {}) {
|
|
|
9173
9475
|
return new Point(x, y, Fp.ONE);
|
|
9174
9476
|
}
|
|
9175
9477
|
static fromBytes(bytes) {
|
|
9176
|
-
const P = Point.fromAffine(decodePoint(abytes$
|
|
9478
|
+
const P = Point.fromAffine(decodePoint(abytes$3(bytes, void 0, "point")));
|
|
9177
9479
|
P.assertValidity();
|
|
9178
9480
|
return P;
|
|
9179
9481
|
}
|
|
9180
9482
|
static fromHex(hex) {
|
|
9181
|
-
return Point.fromBytes(hexToBytes(hex));
|
|
9483
|
+
return Point.fromBytes(hexToBytes$1(hex));
|
|
9182
9484
|
}
|
|
9183
9485
|
get x() {
|
|
9184
9486
|
return this.toAffine().x;
|
|
@@ -9427,7 +9729,7 @@ function weierstrass$1(params, extraOpts = {}) {
|
|
|
9427
9729
|
return encodePoint(Point, this, isCompressed);
|
|
9428
9730
|
}
|
|
9429
9731
|
toHex(isCompressed = true) {
|
|
9430
|
-
return bytesToHex(this.toBytes(isCompressed));
|
|
9732
|
+
return bytesToHex$1(this.toBytes(isCompressed));
|
|
9431
9733
|
}
|
|
9432
9734
|
toString() {
|
|
9433
9735
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
@@ -9634,7 +9936,7 @@ __name(getWLengths$1, "getWLengths");
|
|
|
9634
9936
|
*/
|
|
9635
9937
|
function ecdh$1(Point, ecdhOpts = {}) {
|
|
9636
9938
|
const { Fn } = Point;
|
|
9637
|
-
const randomBytes_ = ecdhOpts.randomBytes === void 0 ? randomBytes : ecdhOpts.randomBytes;
|
|
9939
|
+
const randomBytes_ = ecdhOpts.randomBytes === void 0 ? randomBytes$1 : ecdhOpts.randomBytes;
|
|
9638
9940
|
const lengths = Object.assign(getWLengths$1(Point.Fp, Fn), { seed: Math.max(getMinHashLength$1(Fn.ORDER), 16) });
|
|
9639
9941
|
function isValidSecretKey(secretKey) {
|
|
9640
9942
|
try {
|
|
@@ -9661,7 +9963,7 @@ function ecdh$1(Point, ecdhOpts = {}) {
|
|
|
9661
9963
|
*/
|
|
9662
9964
|
function randomSecretKey(seed) {
|
|
9663
9965
|
seed = seed === void 0 ? randomBytes_(lengths.seed) : seed;
|
|
9664
|
-
return mapHashToField$1(abytes$
|
|
9966
|
+
return mapHashToField$1(abytes$3(seed, lengths.seed, "seed"), Fn.ORDER);
|
|
9665
9967
|
}
|
|
9666
9968
|
/**
|
|
9667
9969
|
* Computes public key for a secret key. Checks for validity of the secret key.
|
|
@@ -9677,8 +9979,8 @@ function ecdh$1(Point, ecdhOpts = {}) {
|
|
|
9677
9979
|
function isProbPub(item) {
|
|
9678
9980
|
const { secretKey, publicKey, publicKeyUncompressed } = lengths;
|
|
9679
9981
|
const allowedLengths = Fn._lengths;
|
|
9680
|
-
if (!isBytes$
|
|
9681
|
-
const l = abytes$
|
|
9982
|
+
if (!isBytes$3(item)) return void 0;
|
|
9983
|
+
const l = abytes$3(item, void 0, "key").length;
|
|
9682
9984
|
const isPub = l === publicKey || l === publicKeyUncompressed;
|
|
9683
9985
|
const isSec = l === secretKey || !!allowedLengths?.includes(l);
|
|
9684
9986
|
if (isPub && isSec) return void 0;
|
|
@@ -9749,7 +10051,7 @@ __name(ecdh$1, "ecdh");
|
|
|
9749
10051
|
*/
|
|
9750
10052
|
function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
9751
10053
|
const hash_ = hash;
|
|
9752
|
-
ahash(hash_);
|
|
10054
|
+
ahash$1(hash_);
|
|
9753
10055
|
validateObject$1(ecdsaOpts, {}, {
|
|
9754
10056
|
hmac: "function",
|
|
9755
10057
|
lowS: "boolean",
|
|
@@ -9758,7 +10060,7 @@ function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
|
9758
10060
|
bits2int_modN: "function"
|
|
9759
10061
|
});
|
|
9760
10062
|
ecdsaOpts = Object.assign({}, ecdsaOpts);
|
|
9761
|
-
const randomBytes
|
|
10063
|
+
const randomBytes = ecdsaOpts.randomBytes === void 0 ? randomBytes$1 : ecdsaOpts.randomBytes;
|
|
9762
10064
|
const hmac = ecdsaOpts.hmac === void 0 ? (key, msg) => hmac$1(hash_, key, msg) : ecdsaOpts.hmac;
|
|
9763
10065
|
const { Fp, Fn } = Point;
|
|
9764
10066
|
const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn;
|
|
@@ -9783,7 +10085,7 @@ function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
|
9783
10085
|
function validateSigLength(bytes, format) {
|
|
9784
10086
|
validateSigFormat$1(format);
|
|
9785
10087
|
const size = lengths.signature;
|
|
9786
|
-
return abytes$
|
|
10088
|
+
return abytes$3(bytes, format === "compact" ? size : format === "recovered" ? size + 1 : void 0);
|
|
9787
10089
|
}
|
|
9788
10090
|
/**
|
|
9789
10091
|
* ECDSA signature with its (r, s) properties. Supports compact, recovered & DER representations.
|
|
@@ -9811,7 +10113,7 @@ function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
|
9811
10113
|
validateSigLength(bytes, format);
|
|
9812
10114
|
let recid;
|
|
9813
10115
|
if (format === "der") {
|
|
9814
|
-
const { r, s } = DER$1.toSig(abytes$
|
|
10116
|
+
const { r, s } = DER$1.toSig(abytes$3(bytes));
|
|
9815
10117
|
return new Signature(r, s);
|
|
9816
10118
|
}
|
|
9817
10119
|
if (format === "recovered") {
|
|
@@ -9825,7 +10127,7 @@ function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
|
9825
10127
|
return new Signature(Fn.fromBytes(r), Fn.fromBytes(s), recid);
|
|
9826
10128
|
}
|
|
9827
10129
|
static fromHex(hex, format) {
|
|
9828
|
-
return this.fromBytes(hexToBytes(hex), format);
|
|
10130
|
+
return this.fromBytes(hexToBytes$1(hex), format);
|
|
9829
10131
|
}
|
|
9830
10132
|
assertRecovery() {
|
|
9831
10133
|
const { recovery } = this;
|
|
@@ -9841,9 +10143,9 @@ function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
|
9841
10143
|
const radj = recovery === 2 || recovery === 3 ? r + CURVE_ORDER : r;
|
|
9842
10144
|
if (!Fp.isValid(radj)) throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
9843
10145
|
const x = Fp.toBytes(radj);
|
|
9844
|
-
const R = Point.fromBytes(concatBytes(pprefix$1((recovery & 1) === 0), x));
|
|
10146
|
+
const R = Point.fromBytes(concatBytes$1(pprefix$1((recovery & 1) === 0), x));
|
|
9845
10147
|
const ir = Fn.inv(radj);
|
|
9846
|
-
const h = bits2int_modN(abytes$
|
|
10148
|
+
const h = bits2int_modN(abytes$3(messageHash, void 0, "msgHash"));
|
|
9847
10149
|
const u1 = Fn.create(-h * ir);
|
|
9848
10150
|
const u2 = Fn.create(s * ir);
|
|
9849
10151
|
const Q = Point.BASE.multiplyUnsafe(u1).add(R.multiplyUnsafe(u2));
|
|
@@ -9856,18 +10158,18 @@ function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
|
9856
10158
|
}
|
|
9857
10159
|
toBytes(format = defaultSigOpts.format) {
|
|
9858
10160
|
validateSigFormat$1(format);
|
|
9859
|
-
if (format === "der") return hexToBytes(DER$1.hexFromSig(this));
|
|
10161
|
+
if (format === "der") return hexToBytes$1(DER$1.hexFromSig(this));
|
|
9860
10162
|
const { r, s } = this;
|
|
9861
10163
|
const rb = Fn.toBytes(r);
|
|
9862
10164
|
const sb = Fn.toBytes(s);
|
|
9863
10165
|
if (format === "recovered") {
|
|
9864
10166
|
assertRecoverableCurve();
|
|
9865
|
-
return concatBytes(Uint8Array.of(this.assertRecovery()), rb, sb);
|
|
10167
|
+
return concatBytes$1(Uint8Array.of(this.assertRecovery()), rb, sb);
|
|
9866
10168
|
}
|
|
9867
|
-
return concatBytes(rb, sb);
|
|
10169
|
+
return concatBytes$1(rb, sb);
|
|
9868
10170
|
}
|
|
9869
10171
|
toHex(format) {
|
|
9870
|
-
return bytesToHex(this.toBytes(format));
|
|
10172
|
+
return bytesToHex$1(this.toBytes(format));
|
|
9871
10173
|
}
|
|
9872
10174
|
}
|
|
9873
10175
|
Object.freeze(Signature.prototype);
|
|
@@ -9888,8 +10190,8 @@ function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
|
9888
10190
|
return Fn.toBytes(num);
|
|
9889
10191
|
}
|
|
9890
10192
|
function validateMsgAndHash(message, prehash) {
|
|
9891
|
-
abytes$
|
|
9892
|
-
return prehash ? abytes$
|
|
10193
|
+
abytes$3(message, void 0, "message");
|
|
10194
|
+
return prehash ? abytes$3(hash_(message), void 0, "prehashed message") : message;
|
|
9893
10195
|
}
|
|
9894
10196
|
/**
|
|
9895
10197
|
* Steps A, D of RFC6979 3.2.
|
|
@@ -9907,10 +10209,10 @@ function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
|
9907
10209
|
if (!Fn.isValidNot0(d)) throw new Error("invalid private key");
|
|
9908
10210
|
const seedArgs = [int2octets(d), int2octets(h1int)];
|
|
9909
10211
|
if (extraEntropy != null && extraEntropy !== false) {
|
|
9910
|
-
const e = extraEntropy === true ? randomBytes
|
|
9911
|
-
seedArgs.push(abytes$
|
|
10212
|
+
const e = extraEntropy === true ? randomBytes(lengths.secretKey) : extraEntropy;
|
|
10213
|
+
seedArgs.push(abytes$3(e, void 0, "extraEntropy"));
|
|
9912
10214
|
}
|
|
9913
|
-
const seed = concatBytes(...seedArgs);
|
|
10215
|
+
const seed = concatBytes$1(...seedArgs);
|
|
9914
10216
|
const m = h1int;
|
|
9915
10217
|
function k2sig(kBytes) {
|
|
9916
10218
|
const k = bits2int(kBytes);
|
|
@@ -9966,9 +10268,9 @@ function ecdsa$1(Point, hash, ecdsaOpts = {}) {
|
|
|
9966
10268
|
*/
|
|
9967
10269
|
function verify(signature, message, publicKey, opts = {}) {
|
|
9968
10270
|
const { lowS, prehash, format } = validateSigOpts$1(opts, defaultSigOpts);
|
|
9969
|
-
publicKey = abytes$
|
|
10271
|
+
publicKey = abytes$3(publicKey, void 0, "publicKey");
|
|
9970
10272
|
message = validateMsgAndHash(message, prehash);
|
|
9971
|
-
if (!isBytes$
|
|
10273
|
+
if (!isBytes$3(signature)) {
|
|
9972
10274
|
const end = signature instanceof Signature ? ", use sig.toBytes()" : "";
|
|
9973
10275
|
throw new Error("verify expects Uint8Array signature" + end);
|
|
9974
10276
|
}
|
|
@@ -10104,7 +10406,7 @@ __name(abool$1, "abool");
|
|
|
10104
10406
|
function abignumber(n) {
|
|
10105
10407
|
if (typeof n === "bigint") {
|
|
10106
10408
|
if (!isPosBig(n)) throw new Error("positive bigint expected, got " + n);
|
|
10107
|
-
} else anumber$
|
|
10409
|
+
} else anumber$2(n);
|
|
10108
10410
|
return n;
|
|
10109
10411
|
}
|
|
10110
10412
|
function numberToHexUnpadded(num) {
|
|
@@ -10116,15 +10418,15 @@ function hexToNumber(hex) {
|
|
|
10116
10418
|
return hex === "" ? _0n$7 : BigInt("0x" + hex);
|
|
10117
10419
|
}
|
|
10118
10420
|
function bytesToNumberBE(bytes) {
|
|
10119
|
-
return hexToNumber(bytesToHex
|
|
10421
|
+
return hexToNumber(bytesToHex(bytes));
|
|
10120
10422
|
}
|
|
10121
10423
|
function bytesToNumberLE(bytes) {
|
|
10122
|
-
return hexToNumber(bytesToHex
|
|
10424
|
+
return hexToNumber(bytesToHex(copyBytes$1(abytes$2(bytes)).reverse()));
|
|
10123
10425
|
}
|
|
10124
10426
|
function numberToBytesBE(n, len) {
|
|
10125
|
-
anumber$
|
|
10427
|
+
anumber$2(len);
|
|
10126
10428
|
n = abignumber(n);
|
|
10127
|
-
const res = hexToBytes
|
|
10429
|
+
const res = hexToBytes(n.toString(16).padStart(len * 2, "0"));
|
|
10128
10430
|
if (res.length !== len) throw new Error("number too large");
|
|
10129
10431
|
return res;
|
|
10130
10432
|
}
|
|
@@ -10174,8 +10476,8 @@ const bitMask = (n) => (_1n$7 << BigInt(n)) - _1n$7;
|
|
|
10174
10476
|
* drbg(seed, bytesToKey); // bytesToKey must return Key or undefined
|
|
10175
10477
|
*/
|
|
10176
10478
|
function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
10177
|
-
anumber$
|
|
10178
|
-
anumber$
|
|
10479
|
+
anumber$2(hashLen, "hashLen");
|
|
10480
|
+
anumber$2(qByteLen, "qByteLen");
|
|
10179
10481
|
if (typeof hmacFn !== "function") throw new Error("hmacFn must be a function");
|
|
10180
10482
|
const u8n = (len) => new Uint8Array(len);
|
|
10181
10483
|
const NULL = Uint8Array.of();
|
|
@@ -10190,7 +10492,7 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
10190
10492
|
k.fill(0);
|
|
10191
10493
|
i = 0;
|
|
10192
10494
|
};
|
|
10193
|
-
const h = (...msgs) => hmacFn(k, concatBytes
|
|
10495
|
+
const h = (...msgs) => hmacFn(k, concatBytes(v, ...msgs));
|
|
10194
10496
|
const reseed = (seed = NULL) => {
|
|
10195
10497
|
k = h(byte0, seed);
|
|
10196
10498
|
v = h();
|
|
@@ -10208,7 +10510,7 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
10208
10510
|
out.push(sl);
|
|
10209
10511
|
len += v.length;
|
|
10210
10512
|
}
|
|
10211
|
-
return concatBytes
|
|
10513
|
+
return concatBytes(...out);
|
|
10212
10514
|
};
|
|
10213
10515
|
const genUntil = (seed, pred) => {
|
|
10214
10516
|
reset();
|
|
@@ -10493,7 +10795,7 @@ function FpLegendre(Fp, n) {
|
|
|
10493
10795
|
return yes ? 1 : zero ? 0 : -1;
|
|
10494
10796
|
}
|
|
10495
10797
|
function nLength(n, nBitLength) {
|
|
10496
|
-
if (nBitLength !== void 0) anumber$
|
|
10798
|
+
if (nBitLength !== void 0) anumber$2(nBitLength);
|
|
10497
10799
|
const _nBitLength = nBitLength !== void 0 ? nBitLength : n.toString(2).length;
|
|
10498
10800
|
return {
|
|
10499
10801
|
nBitLength: _nBitLength,
|
|
@@ -10592,7 +10894,7 @@ var _Field = class {
|
|
|
10592
10894
|
return this.isLE ? numberToBytesLE(num, this.BYTES) : numberToBytesBE(num, this.BYTES);
|
|
10593
10895
|
}
|
|
10594
10896
|
fromBytes(bytes, skipValidation = false) {
|
|
10595
|
-
abytes$
|
|
10897
|
+
abytes$2(bytes);
|
|
10596
10898
|
const { _lengths: allowedLengths, BYTES, isLE, ORDER, _mod: modFromBytes } = this;
|
|
10597
10899
|
if (allowedLengths) {
|
|
10598
10900
|
if (!allowedLengths.includes(bytes.length) || bytes.length > BYTES) throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
|
|
@@ -10673,7 +10975,7 @@ function getMinHashLength(fieldOrder) {
|
|
|
10673
10975
|
* @returns valid private scalar
|
|
10674
10976
|
*/
|
|
10675
10977
|
function mapHashToField(key, fieldOrder, isLE = false) {
|
|
10676
|
-
abytes$
|
|
10978
|
+
abytes$2(key);
|
|
10677
10979
|
const len = key.length;
|
|
10678
10980
|
const fieldLen = getFieldBytesLength(fieldOrder);
|
|
10679
10981
|
const minLen = getMinHashLength(fieldOrder);
|
|
@@ -11094,7 +11396,7 @@ const DER = {
|
|
|
11094
11396
|
},
|
|
11095
11397
|
toSig(bytes) {
|
|
11096
11398
|
const { Err: E, _int: int, _tlv: tlv } = DER;
|
|
11097
|
-
const data = abytes$
|
|
11399
|
+
const data = abytes$2(bytes, void 0, "signature");
|
|
11098
11400
|
const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
|
|
11099
11401
|
if (seqLeftBytes.length) throw new E("invalid signature: left bytes after parsing");
|
|
11100
11402
|
const { v: rBytes, l: rLeftBytes } = tlv.decode(2, seqBytes);
|
|
@@ -11162,11 +11464,11 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
11162
11464
|
abool$1(isCompressed, "isCompressed");
|
|
11163
11465
|
if (isCompressed) {
|
|
11164
11466
|
assertCompressionIsSupported();
|
|
11165
|
-
return concatBytes
|
|
11166
|
-
} else return concatBytes
|
|
11467
|
+
return concatBytes(pprefix(!Fp.isOdd(y)), bx);
|
|
11468
|
+
} else return concatBytes(Uint8Array.of(4), bx, Fp.toBytes(y));
|
|
11167
11469
|
}
|
|
11168
11470
|
function pointFromBytes(bytes) {
|
|
11169
|
-
abytes$
|
|
11471
|
+
abytes$2(bytes, void 0, "Point");
|
|
11170
11472
|
const { publicKey: comp, publicKeyUncompressed: uncomp } = lengths;
|
|
11171
11473
|
const length = bytes.length;
|
|
11172
11474
|
const head = bytes[0];
|
|
@@ -11299,12 +11601,12 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
11299
11601
|
return new Point(x, y, Fp.ONE);
|
|
11300
11602
|
}
|
|
11301
11603
|
static fromBytes(bytes) {
|
|
11302
|
-
const P = Point.fromAffine(decodePoint(abytes$
|
|
11604
|
+
const P = Point.fromAffine(decodePoint(abytes$2(bytes, void 0, "point")));
|
|
11303
11605
|
P.assertValidity();
|
|
11304
11606
|
return P;
|
|
11305
11607
|
}
|
|
11306
11608
|
static fromHex(hex) {
|
|
11307
|
-
return Point.fromBytes(hexToBytes
|
|
11609
|
+
return Point.fromBytes(hexToBytes(hex));
|
|
11308
11610
|
}
|
|
11309
11611
|
get x() {
|
|
11310
11612
|
return this.toAffine().x;
|
|
@@ -11521,7 +11823,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
11521
11823
|
return encodePoint(Point, this, isCompressed);
|
|
11522
11824
|
}
|
|
11523
11825
|
toHex(isCompressed = true) {
|
|
11524
|
-
return bytesToHex
|
|
11826
|
+
return bytesToHex(this.toBytes(isCompressed));
|
|
11525
11827
|
}
|
|
11526
11828
|
toString() {
|
|
11527
11829
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
@@ -11550,7 +11852,7 @@ function getWLengths(Fp, Fn) {
|
|
|
11550
11852
|
*/
|
|
11551
11853
|
function ecdh(Point, ecdhOpts = {}) {
|
|
11552
11854
|
const { Fn } = Point;
|
|
11553
|
-
const randomBytes_ = ecdhOpts.randomBytes || randomBytes
|
|
11855
|
+
const randomBytes_ = ecdhOpts.randomBytes || randomBytes;
|
|
11554
11856
|
const lengths = Object.assign(getWLengths(Point.Fp, Fn), { seed: getMinHashLength(Fn.ORDER) });
|
|
11555
11857
|
function isValidSecretKey(secretKey) {
|
|
11556
11858
|
try {
|
|
@@ -11576,7 +11878,7 @@ function ecdh(Point, ecdhOpts = {}) {
|
|
|
11576
11878
|
* (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
|
|
11577
11879
|
*/
|
|
11578
11880
|
function randomSecretKey(seed = randomBytes_(lengths.seed)) {
|
|
11579
|
-
return mapHashToField(abytes$
|
|
11881
|
+
return mapHashToField(abytes$2(seed, lengths.seed, "seed"), Fn.ORDER);
|
|
11580
11882
|
}
|
|
11581
11883
|
/**
|
|
11582
11884
|
* Computes public key for a secret key. Checks for validity of the secret key.
|
|
@@ -11591,9 +11893,9 @@ function ecdh(Point, ecdhOpts = {}) {
|
|
|
11591
11893
|
*/
|
|
11592
11894
|
function isProbPub(item) {
|
|
11593
11895
|
const { secretKey, publicKey, publicKeyUncompressed } = lengths;
|
|
11594
|
-
if (!isBytes$
|
|
11896
|
+
if (!isBytes$2(item)) return void 0;
|
|
11595
11897
|
if ("_lengths" in Fn && Fn._lengths || secretKey === publicKey) return void 0;
|
|
11596
|
-
const l = abytes$
|
|
11898
|
+
const l = abytes$2(item, void 0, "key").length;
|
|
11597
11899
|
return l === publicKey || l === publicKeyUncompressed;
|
|
11598
11900
|
}
|
|
11599
11901
|
/**
|
|
@@ -11641,7 +11943,7 @@ function ecdh(Point, ecdhOpts = {}) {
|
|
|
11641
11943
|
* ```
|
|
11642
11944
|
*/
|
|
11643
11945
|
function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
11644
|
-
ahash
|
|
11946
|
+
ahash(hash);
|
|
11645
11947
|
validateObject(ecdsaOpts, {}, {
|
|
11646
11948
|
hmac: "function",
|
|
11647
11949
|
lowS: "boolean",
|
|
@@ -11650,7 +11952,7 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
11650
11952
|
bits2int_modN: "function"
|
|
11651
11953
|
});
|
|
11652
11954
|
ecdsaOpts = Object.assign({}, ecdsaOpts);
|
|
11653
|
-
const randomBytes = ecdsaOpts.randomBytes || randomBytes
|
|
11955
|
+
const randomBytes$3 = ecdsaOpts.randomBytes || randomBytes;
|
|
11654
11956
|
const hmac$2 = ecdsaOpts.hmac || ((key, msg) => hmac(hash, key, msg));
|
|
11655
11957
|
const { Fp, Fn } = Point;
|
|
11656
11958
|
const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn;
|
|
@@ -11675,7 +11977,7 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
11675
11977
|
function validateSigLength(bytes, format) {
|
|
11676
11978
|
validateSigFormat(format);
|
|
11677
11979
|
const size = lengths.signature;
|
|
11678
|
-
return abytes$
|
|
11980
|
+
return abytes$2(bytes, format === "compact" ? size : format === "recovered" ? size + 1 : void 0);
|
|
11679
11981
|
}
|
|
11680
11982
|
/**
|
|
11681
11983
|
* ECDSA signature with its (r, s) properties. Supports compact, recovered & DER representations.
|
|
@@ -11703,7 +12005,7 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
11703
12005
|
validateSigLength(bytes, format);
|
|
11704
12006
|
let recid;
|
|
11705
12007
|
if (format === "der") {
|
|
11706
|
-
const { r, s } = DER.toSig(abytes$
|
|
12008
|
+
const { r, s } = DER.toSig(abytes$2(bytes));
|
|
11707
12009
|
return new Signature(r, s);
|
|
11708
12010
|
}
|
|
11709
12011
|
if (format === "recovered") {
|
|
@@ -11717,7 +12019,7 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
11717
12019
|
return new Signature(Fn.fromBytes(r), Fn.fromBytes(s), recid);
|
|
11718
12020
|
}
|
|
11719
12021
|
static fromHex(hex, format) {
|
|
11720
|
-
return this.fromBytes(hexToBytes
|
|
12022
|
+
return this.fromBytes(hexToBytes(hex), format);
|
|
11721
12023
|
}
|
|
11722
12024
|
assertRecovery() {
|
|
11723
12025
|
const { recovery } = this;
|
|
@@ -11733,9 +12035,9 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
11733
12035
|
const radj = recovery === 2 || recovery === 3 ? r + CURVE_ORDER : r;
|
|
11734
12036
|
if (!Fp.isValid(radj)) throw new Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
11735
12037
|
const x = Fp.toBytes(radj);
|
|
11736
|
-
const R = Point.fromBytes(concatBytes
|
|
12038
|
+
const R = Point.fromBytes(concatBytes(pprefix((recovery & 1) === 0), x));
|
|
11737
12039
|
const ir = Fn.inv(radj);
|
|
11738
|
-
const h = bits2int_modN(abytes$
|
|
12040
|
+
const h = bits2int_modN(abytes$2(messageHash, void 0, "msgHash"));
|
|
11739
12041
|
const u1 = Fn.create(-h * ir);
|
|
11740
12042
|
const u2 = Fn.create(s * ir);
|
|
11741
12043
|
const Q = Point.BASE.multiplyUnsafe(u1).add(R.multiplyUnsafe(u2));
|
|
@@ -11748,18 +12050,18 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
11748
12050
|
}
|
|
11749
12051
|
toBytes(format = defaultSigOpts.format) {
|
|
11750
12052
|
validateSigFormat(format);
|
|
11751
|
-
if (format === "der") return hexToBytes
|
|
12053
|
+
if (format === "der") return hexToBytes(DER.hexFromSig(this));
|
|
11752
12054
|
const { r, s } = this;
|
|
11753
12055
|
const rb = Fn.toBytes(r);
|
|
11754
12056
|
const sb = Fn.toBytes(s);
|
|
11755
12057
|
if (format === "recovered") {
|
|
11756
12058
|
assertSmallCofactor();
|
|
11757
|
-
return concatBytes
|
|
12059
|
+
return concatBytes(Uint8Array.of(this.assertRecovery()), rb, sb);
|
|
11758
12060
|
}
|
|
11759
|
-
return concatBytes
|
|
12061
|
+
return concatBytes(rb, sb);
|
|
11760
12062
|
}
|
|
11761
12063
|
toHex(format) {
|
|
11762
|
-
return bytesToHex
|
|
12064
|
+
return bytesToHex(this.toBytes(format));
|
|
11763
12065
|
}
|
|
11764
12066
|
}
|
|
11765
12067
|
const bits2int = ecdsaOpts.bits2int || function bits2int_def(bytes) {
|
|
@@ -11778,8 +12080,8 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
11778
12080
|
return Fn.toBytes(num);
|
|
11779
12081
|
}
|
|
11780
12082
|
function validateMsgAndHash(message, prehash) {
|
|
11781
|
-
abytes$
|
|
11782
|
-
return prehash ? abytes$
|
|
12083
|
+
abytes$2(message, void 0, "message");
|
|
12084
|
+
return prehash ? abytes$2(hash(message), void 0, "prehashed message") : message;
|
|
11783
12085
|
}
|
|
11784
12086
|
/**
|
|
11785
12087
|
* Steps A, D of RFC6979 3.2.
|
|
@@ -11797,10 +12099,10 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
11797
12099
|
if (!Fn.isValidNot0(d)) throw new Error("invalid private key");
|
|
11798
12100
|
const seedArgs = [int2octets(d), int2octets(h1int)];
|
|
11799
12101
|
if (extraEntropy != null && extraEntropy !== false) {
|
|
11800
|
-
const e = extraEntropy === true ? randomBytes(lengths.secretKey) : extraEntropy;
|
|
11801
|
-
seedArgs.push(abytes$
|
|
12102
|
+
const e = extraEntropy === true ? randomBytes$3(lengths.secretKey) : extraEntropy;
|
|
12103
|
+
seedArgs.push(abytes$2(e, void 0, "extraEntropy"));
|
|
11802
12104
|
}
|
|
11803
|
-
const seed = concatBytes
|
|
12105
|
+
const seed = concatBytes(...seedArgs);
|
|
11804
12106
|
const m = h1int;
|
|
11805
12107
|
function k2sig(kBytes) {
|
|
11806
12108
|
const k = bits2int(kBytes);
|
|
@@ -11854,9 +12156,9 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
11854
12156
|
*/
|
|
11855
12157
|
function verify(signature, message, publicKey, opts = {}) {
|
|
11856
12158
|
const { lowS, prehash, format } = validateSigOpts(opts, defaultSigOpts);
|
|
11857
|
-
publicKey = abytes$
|
|
12159
|
+
publicKey = abytes$2(publicKey, void 0, "publicKey");
|
|
11858
12160
|
message = validateMsgAndHash(message, prehash);
|
|
11859
|
-
if (!isBytes$
|
|
12161
|
+
if (!isBytes$2(signature)) {
|
|
11860
12162
|
const end = signature instanceof Signature ? ", use sig.toBytes()" : "";
|
|
11861
12163
|
throw new Error("verify expects Uint8Array signature" + end);
|
|
11862
12164
|
}
|
|
@@ -12123,7 +12425,7 @@ function ripemd_f(group, x, y, z) {
|
|
|
12123
12425
|
return x ^ (y | ~z);
|
|
12124
12426
|
}
|
|
12125
12427
|
const BUF_160 = /* @__PURE__ */ new Uint32Array(16);
|
|
12126
|
-
var _RIPEMD160 = class extends HashMD
|
|
12428
|
+
var _RIPEMD160 = class extends HashMD {
|
|
12127
12429
|
h0 = 1732584193;
|
|
12128
12430
|
h1 = -271733879;
|
|
12129
12431
|
h2 = -1732584194;
|
|
@@ -12181,11 +12483,11 @@ var _RIPEMD160 = class extends HashMD$1 {
|
|
|
12181
12483
|
this.set(this.h1 + cl + dr | 0, this.h2 + dl + er | 0, this.h3 + el + ar | 0, this.h4 + al + br | 0, this.h0 + bl + cr | 0);
|
|
12182
12484
|
}
|
|
12183
12485
|
roundClean() {
|
|
12184
|
-
clean$
|
|
12486
|
+
clean$1(BUF_160);
|
|
12185
12487
|
}
|
|
12186
12488
|
destroy() {
|
|
12187
12489
|
this.destroyed = true;
|
|
12188
|
-
clean$
|
|
12490
|
+
clean$1(this.buffer);
|
|
12189
12491
|
this.set(0, 0, 0, 0, 0);
|
|
12190
12492
|
}
|
|
12191
12493
|
};
|
|
@@ -12194,7 +12496,7 @@ var _RIPEMD160 = class extends HashMD$1 {
|
|
|
12194
12496
|
* * https://homes.esat.kuleuven.be/~bosselae/ripemd160.html
|
|
12195
12497
|
* * https://homes.esat.kuleuven.be/~bosselae/ripemd160/pdf/AB-9601/AB-9601.pdf
|
|
12196
12498
|
*/
|
|
12197
|
-
const ripemd160 = /* @__PURE__ */ createHasher
|
|
12499
|
+
const ripemd160 = /* @__PURE__ */ createHasher(() => new _RIPEMD160());
|
|
12198
12500
|
|
|
12199
12501
|
//#endregion
|
|
12200
12502
|
//#region ../../node_modules/.pnpm/@scure+bip32@2.0.1/node_modules/@scure/bip32/index.js
|
|
@@ -12228,11 +12530,11 @@ const BITCOIN_VERSIONS = {
|
|
|
12228
12530
|
/** Hardened offset from Bitcoin, default */
|
|
12229
12531
|
const HARDENED_OFFSET = 2147483648;
|
|
12230
12532
|
const hash160 = (data) => ripemd160(sha256(data));
|
|
12231
|
-
const fromU32 = (data) => createView$
|
|
12533
|
+
const fromU32 = (data) => createView$1(data).getUint32(0, false);
|
|
12232
12534
|
const toU32 = (n) => {
|
|
12233
12535
|
if (!Number.isSafeInteger(n) || n < 0 || n > 2 ** 32 - 1) throw new Error("invalid number, should be from 0 to 2**32-1, got " + n);
|
|
12234
12536
|
const buf = /* @__PURE__ */ new Uint8Array(4);
|
|
12235
|
-
createView$
|
|
12537
|
+
createView$1(buf).setUint32(0, n, false);
|
|
12236
12538
|
return buf;
|
|
12237
12539
|
};
|
|
12238
12540
|
/**
|
|
@@ -12264,14 +12566,14 @@ var HDKey = class HDKey {
|
|
|
12264
12566
|
get privateExtendedKey() {
|
|
12265
12567
|
const priv = this._privateKey;
|
|
12266
12568
|
if (!priv) throw new Error("No private key");
|
|
12267
|
-
return base58check.encode(this.serialize(this.versions.private, concatBytes
|
|
12569
|
+
return base58check.encode(this.serialize(this.versions.private, concatBytes(Uint8Array.of(0), priv)));
|
|
12268
12570
|
}
|
|
12269
12571
|
get publicExtendedKey() {
|
|
12270
12572
|
if (!this._publicKey) throw new Error("No public key");
|
|
12271
12573
|
return base58check.encode(this.serialize(this.versions.public, this._publicKey));
|
|
12272
12574
|
}
|
|
12273
12575
|
static fromMasterSeed(seed, versions = BITCOIN_VERSIONS) {
|
|
12274
|
-
abytes$
|
|
12576
|
+
abytes$2(seed);
|
|
12275
12577
|
if (8 * seed.length < 128 || 8 * seed.length > 512) throw new Error("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got " + seed.length);
|
|
12276
12578
|
const I = hmac(sha512, MASTER_SECRET, seed);
|
|
12277
12579
|
const privateKey = I.slice(0, 32);
|
|
@@ -12283,7 +12585,7 @@ var HDKey = class HDKey {
|
|
|
12283
12585
|
}
|
|
12284
12586
|
static fromExtendedKey(base58key, versions = BITCOIN_VERSIONS) {
|
|
12285
12587
|
const keyBuffer = base58check.decode(base58key);
|
|
12286
|
-
const keyView = createView$
|
|
12588
|
+
const keyView = createView$1(keyBuffer);
|
|
12287
12589
|
const version = keyView.getUint32(0, false);
|
|
12288
12590
|
const opt = {
|
|
12289
12591
|
versions,
|
|
@@ -12357,8 +12659,8 @@ var HDKey = class HDKey {
|
|
|
12357
12659
|
if (index >= 2147483648) {
|
|
12358
12660
|
const priv = this._privateKey;
|
|
12359
12661
|
if (!priv) throw new Error("Could not derive hardened child key");
|
|
12360
|
-
data = concatBytes
|
|
12361
|
-
} else data = concatBytes
|
|
12662
|
+
data = concatBytes(Uint8Array.of(0), priv, data);
|
|
12663
|
+
} else data = concatBytes(this._publicKey, data);
|
|
12362
12664
|
const I = hmac(sha512, this.chainCode, data);
|
|
12363
12665
|
const childTweak = I.slice(0, 32);
|
|
12364
12666
|
const chainCode = I.slice(32);
|
|
@@ -12388,12 +12690,12 @@ var HDKey = class HDKey {
|
|
|
12388
12690
|
}
|
|
12389
12691
|
sign(hash) {
|
|
12390
12692
|
if (!this._privateKey) throw new Error("No privateKey set!");
|
|
12391
|
-
abytes$
|
|
12693
|
+
abytes$2(hash, 32);
|
|
12392
12694
|
return secp256k1.sign(hash, this._privateKey, { prehash: false });
|
|
12393
12695
|
}
|
|
12394
12696
|
verify(hash, signature) {
|
|
12395
|
-
abytes$
|
|
12396
|
-
abytes$
|
|
12697
|
+
abytes$2(hash, 32);
|
|
12698
|
+
abytes$2(signature, 64);
|
|
12397
12699
|
if (!this._publicKey) throw new Error("No publicKey set!");
|
|
12398
12700
|
return secp256k1.verify(signature, hash, this._publicKey, { prehash: false });
|
|
12399
12701
|
}
|
|
@@ -12412,8 +12714,8 @@ var HDKey = class HDKey {
|
|
|
12412
12714
|
}
|
|
12413
12715
|
serialize(version, key) {
|
|
12414
12716
|
if (!this.chainCode) throw new Error("No chainCode set");
|
|
12415
|
-
abytes$
|
|
12416
|
-
return concatBytes
|
|
12717
|
+
abytes$2(key, 33);
|
|
12718
|
+
return concatBytes(toU32(version), new Uint8Array([this.depth]), toU32(this.parentFingerprint), toU32(this.index), this.chainCode, key);
|
|
12417
12719
|
}
|
|
12418
12720
|
};
|
|
12419
12721
|
|
|
@@ -15017,10 +15319,10 @@ function createBlsPairing(fields, G1, G2, params) {
|
|
|
15017
15319
|
}], withFinalExponent);
|
|
15018
15320
|
}
|
|
15019
15321
|
const lengths = { seed: getMinHashLength$1(Fr.ORDER) };
|
|
15020
|
-
const rand = params.randomBytes === void 0 ? randomBytes : params.randomBytes;
|
|
15322
|
+
const rand = params.randomBytes === void 0 ? randomBytes$1 : params.randomBytes;
|
|
15021
15323
|
const randomSecretKey = (seed) => {
|
|
15022
15324
|
seed = seed === void 0 ? rand(lengths.seed) : seed;
|
|
15023
|
-
abytes$
|
|
15325
|
+
abytes$3(seed, lengths.seed, "seed");
|
|
15024
15326
|
return mapHashToField$1(seed, Fr.ORDER);
|
|
15025
15327
|
};
|
|
15026
15328
|
Object.freeze(lengths);
|
|
@@ -15146,7 +15448,7 @@ function createBlsSig(blsPairing, PubPoint, SigPoint, isSigG1, hashToSigCurve, S
|
|
|
15146
15448
|
return agg;
|
|
15147
15449
|
},
|
|
15148
15450
|
hash(messageBytes, DST) {
|
|
15149
|
-
abytes$
|
|
15451
|
+
abytes$3(messageBytes);
|
|
15150
15452
|
return hashToSigCurve(messageBytes, DST ? { DST } : void 0);
|
|
15151
15453
|
},
|
|
15152
15454
|
Signature: Object.freeze({ ...SignatureCoder })
|
|
@@ -15205,11 +15507,11 @@ function blsBasic(fields, G1_Point, G2_Point, params) {
|
|
|
15205
15507
|
}
|
|
15206
15508
|
function blsHashers(fields, G1_Point, G2_Point, params, hasherParams) {
|
|
15207
15509
|
const base = blsBasic(fields, G1_Point, G2_Point, params);
|
|
15208
|
-
const G1Hasher = createHasher(G1_Point, hasherParams.mapToG1 === void 0 ? notImplemented : hasherParams.mapToG1, {
|
|
15510
|
+
const G1Hasher = createHasher$1(G1_Point, hasherParams.mapToG1 === void 0 ? notImplemented : hasherParams.mapToG1, {
|
|
15209
15511
|
...hasherParams.hasherOpts,
|
|
15210
15512
|
...hasherParams.hasherOptsG1
|
|
15211
15513
|
});
|
|
15212
|
-
const G2Hasher = createHasher(G2_Point, hasherParams.mapToG2 === void 0 ? notImplemented : hasherParams.mapToG2, {
|
|
15514
|
+
const G2Hasher = createHasher$1(G2_Point, hasherParams.mapToG2 === void 0 ? notImplemented : hasherParams.mapToG2, {
|
|
15213
15515
|
...hasherParams.hasherOpts,
|
|
15214
15516
|
...hasherParams.hasherOptsG2
|
|
15215
15517
|
});
|
|
@@ -15551,7 +15853,7 @@ var _Field2 = class {
|
|
|
15551
15853
|
}
|
|
15552
15854
|
fromBytes(b) {
|
|
15553
15855
|
const { Fp } = this;
|
|
15554
|
-
abytes$
|
|
15856
|
+
abytes$3(b);
|
|
15555
15857
|
if (b.length !== this.BYTES) throw new Error("fromBytes invalid length=" + b.length);
|
|
15556
15858
|
return this.create({
|
|
15557
15859
|
c0: Fp.fromBytes(b.subarray(0, Fp.BYTES)),
|
|
@@ -15559,7 +15861,7 @@ var _Field2 = class {
|
|
|
15559
15861
|
});
|
|
15560
15862
|
}
|
|
15561
15863
|
toBytes({ c0, c1 }) {
|
|
15562
|
-
return concatBytes(this.Fp.toBytes(c0), this.Fp.toBytes(c1));
|
|
15864
|
+
return concatBytes$1(this.Fp.toBytes(c0), this.Fp.toBytes(c1));
|
|
15563
15865
|
}
|
|
15564
15866
|
cmov({ c0, c1 }, { c0: r0, c1: r1 }, c) {
|
|
15565
15867
|
const { Fp } = this;
|
|
@@ -15761,7 +16063,7 @@ var _Field6 = class {
|
|
|
15761
16063
|
}
|
|
15762
16064
|
fromBytes(b) {
|
|
15763
16065
|
const { Fp2 } = this;
|
|
15764
|
-
abytes$
|
|
16066
|
+
abytes$3(b);
|
|
15765
16067
|
if (b.length !== this.BYTES) throw new Error("fromBytes invalid length=" + b.length);
|
|
15766
16068
|
const B2 = Fp2.BYTES;
|
|
15767
16069
|
return this.create({
|
|
@@ -15772,7 +16074,7 @@ var _Field6 = class {
|
|
|
15772
16074
|
}
|
|
15773
16075
|
toBytes({ c0, c1, c2 }) {
|
|
15774
16076
|
const { Fp2 } = this;
|
|
15775
|
-
return concatBytes(Fp2.toBytes(c0), Fp2.toBytes(c1), Fp2.toBytes(c2));
|
|
16077
|
+
return concatBytes$1(Fp2.toBytes(c0), Fp2.toBytes(c1), Fp2.toBytes(c2));
|
|
15776
16078
|
}
|
|
15777
16079
|
cmov({ c0, c1, c2 }, { c0: r0, c1: r1, c2: r2 }, c) {
|
|
15778
16080
|
const { Fp2 } = this;
|
|
@@ -16000,7 +16302,7 @@ var _Field12 = class {
|
|
|
16000
16302
|
}
|
|
16001
16303
|
fromBytes(b) {
|
|
16002
16304
|
const { Fp6 } = this;
|
|
16003
|
-
abytes$
|
|
16305
|
+
abytes$3(b);
|
|
16004
16306
|
if (b.length !== this.BYTES) throw new Error("fromBytes invalid length=" + b.length);
|
|
16005
16307
|
return this.create({
|
|
16006
16308
|
c0: Fp6.fromBytes(b.subarray(0, Fp6.BYTES)),
|
|
@@ -16009,7 +16311,7 @@ var _Field12 = class {
|
|
|
16009
16311
|
}
|
|
16010
16312
|
toBytes({ c0, c1 }) {
|
|
16011
16313
|
const { Fp6 } = this;
|
|
16012
|
-
return concatBytes(Fp6.toBytes(c0), Fp6.toBytes(c1));
|
|
16314
|
+
return concatBytes$1(Fp6.toBytes(c0), Fp6.toBytes(c1));
|
|
16013
16315
|
}
|
|
16014
16316
|
cmov({ c0, c1 }, { c0: r0, c1: r1 }, c) {
|
|
16015
16317
|
const { Fp6 } = this;
|
|
@@ -16331,7 +16633,7 @@ const sortBit = (parts, p) => {
|
|
|
16331
16633
|
const fp2 = {
|
|
16332
16634
|
encode({ c0, c1 }) {
|
|
16333
16635
|
const { BYTES: L } = Fp$1;
|
|
16334
|
-
return concatBytes(numberToBytesBE$1(c1, L), numberToBytesBE$1(c0, L));
|
|
16636
|
+
return concatBytes$1(numberToBytesBE$1(c1, L), numberToBytesBE$1(c0, L));
|
|
16335
16637
|
},
|
|
16336
16638
|
decode(bytes) {
|
|
16337
16639
|
const { BYTES: L } = Fp$1;
|
|
@@ -16352,7 +16654,7 @@ const coder = (name, Fp, b, encode, decode, yparts) => {
|
|
|
16352
16654
|
if (!compressed && !allowUncompressed) throw new Error("invalid signature: expected compressed encoding");
|
|
16353
16655
|
const infinity = point.is0();
|
|
16354
16656
|
const { x, y } = point.toAffine();
|
|
16355
|
-
const bytes = compressed ? enc(x) : concatBytes(enc(x), enc(y));
|
|
16657
|
+
const bytes = compressed ? enc(x) : concatBytes$1(enc(x), enc(y));
|
|
16356
16658
|
let sort;
|
|
16357
16659
|
if (compressed && !infinity) sort = sortBit(yparts(y), BaseFp.ORDER);
|
|
16358
16660
|
return setMask(bytes, {
|
|
@@ -16362,7 +16664,7 @@ const coder = (name, Fp, b, encode, decode, yparts) => {
|
|
|
16362
16664
|
});
|
|
16363
16665
|
},
|
|
16364
16666
|
decode(bytes) {
|
|
16365
|
-
const { compressed, infinity, sort, value } = parseMask(allowUncompressed ? abytes$
|
|
16667
|
+
const { compressed, infinity, sort, value } = parseMask(allowUncompressed ? abytes$3(bytes, void 0, "point") : abytes$3(bytes, W, "signature"));
|
|
16366
16668
|
if (!allowUncompressed && !compressed) throw new Error("invalid signature: expected compressed encoding");
|
|
16367
16669
|
const len = compressed ? W : 2 * W;
|
|
16368
16670
|
if (value.length !== len) throw new Error(`invalid ${name} point: expected ${len} bytes`);
|
|
@@ -16453,10 +16755,10 @@ function signatureG2FromBytes(bytes) {
|
|
|
16453
16755
|
const signatureCoders = {
|
|
16454
16756
|
ShortSignature: {
|
|
16455
16757
|
fromBytes(bytes) {
|
|
16456
|
-
return signatureG1FromBytes(abytes$
|
|
16758
|
+
return signatureG1FromBytes(abytes$3(bytes));
|
|
16457
16759
|
},
|
|
16458
16760
|
fromHex(hex) {
|
|
16459
|
-
return signatureG1FromBytes(hexToBytes(hex));
|
|
16761
|
+
return signatureG1FromBytes(hexToBytes$1(hex));
|
|
16460
16762
|
},
|
|
16461
16763
|
toBytes(point) {
|
|
16462
16764
|
return signatureG1ToBytes(point);
|
|
@@ -16465,15 +16767,15 @@ const signatureCoders = {
|
|
|
16465
16767
|
return signatureG1ToBytes(point);
|
|
16466
16768
|
},
|
|
16467
16769
|
toHex(point) {
|
|
16468
|
-
return bytesToHex(signatureG1ToBytes(point));
|
|
16770
|
+
return bytesToHex$1(signatureG1ToBytes(point));
|
|
16469
16771
|
}
|
|
16470
16772
|
},
|
|
16471
16773
|
LongSignature: {
|
|
16472
16774
|
fromBytes(bytes) {
|
|
16473
|
-
return signatureG2FromBytes(abytes$
|
|
16775
|
+
return signatureG2FromBytes(abytes$3(bytes));
|
|
16474
16776
|
},
|
|
16475
16777
|
fromHex(hex) {
|
|
16476
|
-
return signatureG2FromBytes(hexToBytes(hex));
|
|
16778
|
+
return signatureG2FromBytes(hexToBytes$1(hex));
|
|
16477
16779
|
},
|
|
16478
16780
|
toBytes(point) {
|
|
16479
16781
|
return signatureG2ToBytes(point);
|
|
@@ -16482,7 +16784,7 @@ const signatureCoders = {
|
|
|
16482
16784
|
return signatureG2ToBytes(point);
|
|
16483
16785
|
},
|
|
16484
16786
|
toHex(point) {
|
|
16485
|
-
return bytesToHex(signatureG2ToBytes(point));
|
|
16787
|
+
return bytesToHex$1(signatureG2ToBytes(point));
|
|
16486
16788
|
}
|
|
16487
16789
|
}
|
|
16488
16790
|
};
|
|
@@ -16546,7 +16848,7 @@ const bls12_params = {
|
|
|
16546
16848
|
ateLoopSize: BLS_X,
|
|
16547
16849
|
xNegative: true,
|
|
16548
16850
|
twistType: "multiplicative",
|
|
16549
|
-
randomBytes
|
|
16851
|
+
randomBytes: randomBytes$1
|
|
16550
16852
|
};
|
|
16551
16853
|
/**
|
|
16552
16854
|
* bls12-381 pairing-friendly curve construction.
|
|
@@ -17648,7 +17950,7 @@ const gcm = /* @__PURE__ */ wrapCipher({
|
|
|
17648
17950
|
* ```
|
|
17649
17951
|
*/
|
|
17650
17952
|
function extract(hash, ikm, salt) {
|
|
17651
|
-
ahash(hash);
|
|
17953
|
+
ahash$1(hash);
|
|
17652
17954
|
if (salt === void 0) salt = new Uint8Array(hash.outputLen);
|
|
17653
17955
|
return hmac$1(hash, salt, ikm);
|
|
17654
17956
|
}
|
|
@@ -17674,15 +17976,15 @@ const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
|
17674
17976
|
* ```
|
|
17675
17977
|
*/
|
|
17676
17978
|
function expand(hash, prk, info, length = 32) {
|
|
17677
|
-
ahash(hash);
|
|
17678
|
-
anumber$
|
|
17679
|
-
abytes$
|
|
17979
|
+
ahash$1(hash);
|
|
17980
|
+
anumber$4(length, "length");
|
|
17981
|
+
abytes$4(prk, void 0, "prk");
|
|
17680
17982
|
const olen = hash.outputLen;
|
|
17681
17983
|
if (prk.length < olen) throw new Error("\"prk\" must be at least HashLen octets");
|
|
17682
17984
|
if (length > 255 * olen) throw new Error("Length must be <= 255*HashLen");
|
|
17683
17985
|
const blocks = Math.ceil(length / olen);
|
|
17684
17986
|
if (info === void 0) info = EMPTY_BUFFER;
|
|
17685
|
-
else abytes$
|
|
17987
|
+
else abytes$4(info, void 0, "info");
|
|
17686
17988
|
const okm = new Uint8Array(blocks * olen);
|
|
17687
17989
|
const HMAC = hmac$1.create(hash, prk);
|
|
17688
17990
|
const HMACTmp = HMAC._cloneInto();
|
|
@@ -17695,7 +17997,7 @@ function expand(hash, prk, info, length = 32) {
|
|
|
17695
17997
|
}
|
|
17696
17998
|
HMAC.destroy();
|
|
17697
17999
|
HMACTmp.destroy();
|
|
17698
|
-
clean$
|
|
18000
|
+
clean$2(T, HKDF_COUNTER);
|
|
17699
18001
|
return okm.slice(0, length);
|
|
17700
18002
|
}
|
|
17701
18003
|
/**
|
|
@@ -17780,10 +18082,10 @@ var SymmetricKey = class SymmetricKey extends Serializable {
|
|
|
17780
18082
|
if (key) {
|
|
17781
18083
|
if (key.length !== SYMMETRIC_KEY_LENGTH) throw new Error(`Must provide a key of size ${SYMMETRIC_KEY_LENGTH}`);
|
|
17782
18084
|
this.key = key;
|
|
17783
|
-
} else this.key = randomBytes$
|
|
18085
|
+
} else this.key = randomBytes$2(SYMMETRIC_KEY_LENGTH);
|
|
17784
18086
|
}
|
|
17785
18087
|
encrypt(msg) {
|
|
17786
|
-
const nonce = randomBytes$
|
|
18088
|
+
const nonce = randomBytes$2(GCM_NONCE_LENGTH);
|
|
17787
18089
|
const serializer = new Serializer();
|
|
17788
18090
|
msg.serialize(serializer);
|
|
17789
18091
|
const bytes = serializer.toUint8Array();
|
|
@@ -17800,7 +18102,7 @@ function hmacKdf(otpSource) {
|
|
|
17800
18102
|
return hkdf(sha256$1, otpSource, HKDF_SALT, /* @__PURE__ */ new Uint8Array(), 32);
|
|
17801
18103
|
}
|
|
17802
18104
|
function getRandomFr() {
|
|
17803
|
-
const randomBigint = leBytesToBigint(randomBytes$
|
|
18105
|
+
const randomBigint = leBytesToBigint(randomBytes$2(128));
|
|
17804
18106
|
return bls12_381.fields.Fr.create(randomBigint);
|
|
17805
18107
|
}
|
|
17806
18108
|
/**
|
|
@@ -36283,5 +36585,5 @@ function parseJwtHeader(jwtHeader) {
|
|
|
36283
36585
|
}
|
|
36284
36586
|
|
|
36285
36587
|
//#endregion
|
|
36286
|
-
export { TypeTagU256 as $, AuthenticationKey as $t, TransactionExecutableEntryFunction as A, Hex as An, MultiKeySignature as At, TypeTagBool as B,
|
|
36287
|
-
//# sourceMappingURL=keyless-
|
|
36588
|
+
export { TypeTagU256 as $, AuthenticationKey as $t, TransactionExecutableEntryFunction as A, Hex as An, MultiKeySignature as At, TypeTagBool as B, I16 as Bt, MultiAgentRawTransaction as C, SigningSchemeInput as Cn, Ed25519Signature as Ct, MultiSigTransactionPayload as D, anyPublicKeyVariantToString as Dn, MultiEd25519Signature as Dt, MultiSig as E, ZkpVariant as En, MultiEd25519PublicKey as Et, TransactionPayloadEntryFunction as F, DEFAULT_MAX_GAS_AMOUNT as Fn, MoveOption as Ft, TypeTagI32 as G, U128 as Gt, TypeTagI128 as H, I32 as Ht, TransactionPayloadMultiSig as I, FIREBASE_AUTH_ISS_PATTERN as In, MoveString as It, TypeTagReference as J, U32 as Jt, TypeTagI64 as K, U16 as Kt, TransactionPayloadScript as L, MIN_MAX_GAS_AMOUNT as Ln, MoveVector as Lt, TransactionExtraConfigV1 as M, APTOS_COIN as Mn, AnySignature as Mt, TransactionInnerPayloadV1 as N, APTOS_FA as Nn, Secp256k1PrivateKey as Nt, Script as O, Serializable as On, AbstractMultiKey as Ot, TransactionPayloadEncryptedPayload as P, AptosApiType as Pn, Secp256k1PublicKey as Pt, TypeTagU16 as Q, Deserializer as Qt, StructTag as R, ProcessorType as Rn, Bool as Rt, FeePayerRawTransaction as S, SigningScheme as Sn, Ed25519PublicKey as St, EntryFunction as T, TransactionResponseType as Tn, accountPublicKeyToSigningScheme as Tt, TypeTagI16 as U, I64 as Ut, TypeTagGeneric as V, I256 as Vt, TypeTagI256 as W, I8 as Wt, TypeTagStruct as X, U8 as Xt, TypeTagSigner as Y, U64 as Yt, TypeTagU128 as Z, FixedBytes as Zt, jwtDecode as _, EphemeralCertificateVariant as _n, AptosApiError as _t, ZeroKnowledgeSig as a, isEncodedStruct as an, stringStructTag as at, generateSigningMessage as b, MoveAbility as bn, EncryptionKey as bt, getIssAudAndUidVal as c, parseEncodedStruct as cn, PayloadAssociatedData as ct, FederatedKeylessPublicKey as d, warnIfDevelopment as dn, ChainId as dt, base64UrlDecode$1 as en, TypeTagU32 as et, bytesToBigIntLE as f, createObjectAddress as fn, getAptosFullNode as ft, EphemeralSignature as g, AnyPublicKeyVariant as gn, aptosRequest as gt, EphemeralPublicKey as h, AccountAuthenticatorVariant as hn, paginateWithObfuscatedCursor as ht, KeylessSignature as i, isBun as in, objectStructTag as it, TransactionExecutableScript as j, MAX_U64_BIG_INT as jn, AnyPublicKey as jt, TransactionExecutableEmpty as k, Serializer as kn, MultiKey as kt, getKeylessConfig as l, sleep as ln, ModuleId as lt, poseidonHash as m, AccountAddress as mn, paginateWithCursor as mt, Groth16Zkp as n, getEnvVar as nn, TypeTagU8 as nt, ZkProof as o, isValidFunctionInfo as on, ClaimedEntryFunction as ot, padAndPackBytesWithLen as p, sha3_256 as pn, getPageWithObfuscatedCursor as pt, TypeTagI8 as q, U256 as qt, KeylessPublicKey as r, getFunctionParts as rn, TypeTagVector as rt, fetchJWK as s, nowInSeconds as sn, DecryptedPlaintext as st, EphemeralCertificate as t, floorToWholeHour as tn, TypeTagU64 as tt, keyless_exports as u, u64ToNumberSafe as un, Identifier as ut, memoizeAsync as v, EphemeralPublicKeyVariant as vn, KeylessError as vt, RawTransaction as w, TransactionAuthenticatorVariant as wn, accountPublicKeyToBaseAccountPublicKey as wt, generateSigningMessageForTransaction as x, MoveFunctionVisibility as xn, Ed25519PrivateKey as xt, deriveTransactionType as y, MimeType as yn, KeylessErrorType as yt, TypeTagAddress as z, TEXT_ENCODER as zn, I128 as zt };
|
|
36589
|
+
//# sourceMappingURL=keyless-nGiRkJjM.js.map
|