@taquito/utils 24.3.1-beta.1 → 25.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2187,22 +2187,62 @@
2187
2187
  };
2188
2188
 
2189
2189
  /**
2190
- * Utilities for hex, bytes, CSPRNG.
2191
- * @module
2190
+ * Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.
2191
+ * @param a - value to test
2192
+ * @returns `true` when the value is a Uint8Array-compatible view.
2193
+ * @example
2194
+ * Check whether a value is a Uint8Array-compatible view.
2195
+ * ```ts
2196
+ * isBytes(new Uint8Array([1, 2, 3]));
2197
+ * ```
2192
2198
  */
2193
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2194
- /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
2195
2199
  function isBytes(a) {
2196
- return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
2200
+ // Plain `instanceof Uint8Array` is too strict for some Buffer / proxy / cross-realm cases.
2201
+ // The fallback still requires a real ArrayBuffer view, so plain
2202
+ // JSON-deserialized `{ constructor: ... }` spoofing is rejected, and
2203
+ // `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.
2204
+ return (a instanceof Uint8Array ||
2205
+ (ArrayBuffer.isView(a) &&
2206
+ a.constructor.name === 'Uint8Array' &&
2207
+ 'BYTES_PER_ELEMENT' in a &&
2208
+ a.BYTES_PER_ELEMENT === 1));
2197
2209
  }
2198
- /** Asserts something is positive integer. */
2210
+ /**
2211
+ * Asserts something is a non-negative integer.
2212
+ * @param n - number to validate
2213
+ * @param title - label included in thrown errors
2214
+ * @throws On wrong argument types. {@link TypeError}
2215
+ * @throws On wrong argument ranges or values. {@link RangeError}
2216
+ * @example
2217
+ * Validate a non-negative integer option.
2218
+ * ```ts
2219
+ * anumber(32, 'length');
2220
+ * ```
2221
+ */
2199
2222
  function anumber(n, title = '') {
2223
+ if (typeof n !== 'number') {
2224
+ const prefix = title && `"${title}" `;
2225
+ throw new TypeError(`${prefix}expected number, got ${typeof n}`);
2226
+ }
2200
2227
  if (!Number.isSafeInteger(n) || n < 0) {
2201
2228
  const prefix = title && `"${title}" `;
2202
- throw new Error(`${prefix}expected integer >= 0, got ${n}`);
2229
+ throw new RangeError(`${prefix}expected integer >= 0, got ${n}`);
2203
2230
  }
2204
2231
  }
2205
- /** Asserts something is Uint8Array. */
2232
+ /**
2233
+ * Asserts something is Uint8Array.
2234
+ * @param value - value to validate
2235
+ * @param length - optional exact length constraint
2236
+ * @param title - label included in thrown errors
2237
+ * @returns The validated byte array.
2238
+ * @throws On wrong argument types. {@link TypeError}
2239
+ * @throws On wrong argument ranges or values. {@link RangeError}
2240
+ * @example
2241
+ * Validate that a value is a byte array.
2242
+ * ```ts
2243
+ * abytes(new Uint8Array([1, 2, 3]));
2244
+ * ```
2245
+ */
2206
2246
  function abytes(value, length, title = '') {
2207
2247
  const bytes = isBytes(value);
2208
2248
  const len = value?.length;
@@ -2211,64 +2251,171 @@
2211
2251
  const prefix = title && `"${title}" `;
2212
2252
  const ofLen = needsLen ? ` of length ${length}` : '';
2213
2253
  const got = bytes ? `length=${len}` : `type=${typeof value}`;
2214
- throw new Error(prefix + 'expected Uint8Array' + ofLen + ', got ' + got);
2254
+ const message = prefix + 'expected Uint8Array' + ofLen + ', got ' + got;
2255
+ if (!bytes)
2256
+ throw new TypeError(message);
2257
+ throw new RangeError(message);
2215
2258
  }
2216
2259
  return value;
2217
2260
  }
2218
- /** Asserts a hash instance has not been destroyed / finished */
2261
+ /**
2262
+ * Asserts a hash instance has not been destroyed or finished.
2263
+ * @param instance - hash instance to validate
2264
+ * @param checkFinished - whether to reject finalized instances
2265
+ * @throws If the hash instance has already been destroyed or finalized. {@link Error}
2266
+ * @example
2267
+ * Validate that a hash instance is still usable.
2268
+ * ```ts
2269
+ * import { aexists } from '@noble/hashes/utils.js';
2270
+ * import { sha256 } from '@noble/hashes/sha2.js';
2271
+ * const hash = sha256.create();
2272
+ * aexists(hash);
2273
+ * ```
2274
+ */
2219
2275
  function aexists(instance, checkFinished = true) {
2220
2276
  if (instance.destroyed)
2221
2277
  throw new Error('Hash instance has been destroyed');
2222
2278
  if (checkFinished && instance.finished)
2223
2279
  throw new Error('Hash#digest() has already been called');
2224
2280
  }
2225
- /** Asserts output is properly-sized byte array */
2281
+ /**
2282
+ * Asserts output is a sufficiently-sized byte array.
2283
+ * @param out - destination buffer
2284
+ * @param instance - hash instance providing output length
2285
+ * Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.
2286
+ * @throws On wrong argument types. {@link TypeError}
2287
+ * @throws On wrong argument ranges or values. {@link RangeError}
2288
+ * @example
2289
+ * Validate a caller-provided digest buffer.
2290
+ * ```ts
2291
+ * import { aoutput } from '@noble/hashes/utils.js';
2292
+ * import { sha256 } from '@noble/hashes/sha2.js';
2293
+ * const hash = sha256.create();
2294
+ * aoutput(new Uint8Array(hash.outputLen), hash);
2295
+ * ```
2296
+ */
2226
2297
  function aoutput(out, instance) {
2227
2298
  abytes(out, undefined, 'digestInto() output');
2228
2299
  const min = instance.outputLen;
2229
2300
  if (out.length < min) {
2230
- throw new Error('"digestInto() output" expected to be of length >=' + min);
2301
+ throw new RangeError('"digestInto() output" expected to be of length >=' + min);
2231
2302
  }
2232
2303
  }
2233
- /** Cast u8 / u16 / u32 to u32. */
2304
+ /**
2305
+ * Casts a typed array view to Uint32Array.
2306
+ * `arr.byteOffset` must already be 4-byte aligned or the platform
2307
+ * Uint32Array constructor will throw.
2308
+ * @param arr - source typed array
2309
+ * @returns Uint32Array view over the same buffer.
2310
+ * @example
2311
+ * Reinterpret a byte array as 32-bit words.
2312
+ * ```ts
2313
+ * u32(new Uint8Array(8));
2314
+ * ```
2315
+ */
2234
2316
  function u32(arr) {
2235
2317
  return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
2236
2318
  }
2237
- /** Zeroize a byte array. Warning: JS provides no guarantees. */
2319
+ /**
2320
+ * Zeroizes typed arrays in place. Warning: JS provides no guarantees.
2321
+ * @param arrays - arrays to overwrite with zeros
2322
+ * @example
2323
+ * Zeroize sensitive buffers in place.
2324
+ * ```ts
2325
+ * clean(new Uint8Array([1, 2, 3]));
2326
+ * ```
2327
+ */
2238
2328
  function clean(...arrays) {
2239
2329
  for (let i = 0; i < arrays.length; i++) {
2240
2330
  arrays[i].fill(0);
2241
2331
  }
2242
2332
  }
2243
- /** Is current platform little-endian? Most are. Big-Endian platform: IBM */
2333
+ /** Whether the current platform is little-endian. */
2244
2334
  const isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
2245
- /** The byte swap operation for uint32 */
2335
+ /**
2336
+ * Byte-swap operation for uint32 values.
2337
+ * @param word - source word
2338
+ * @returns Word with reversed byte order.
2339
+ * @example
2340
+ * Reverse the byte order of a 32-bit word.
2341
+ * ```ts
2342
+ * byteSwap(0x11223344);
2343
+ * ```
2344
+ */
2246
2345
  function byteSwap(word) {
2247
2346
  return (((word << 24) & 0xff000000) |
2248
2347
  ((word << 8) & 0xff0000) |
2249
2348
  ((word >>> 8) & 0xff00) |
2250
2349
  ((word >>> 24) & 0xff));
2251
2350
  }
2252
- /** Conditionally byte swap if on a big-endian platform */
2351
+ /**
2352
+ * Conditionally byte-swaps one 32-bit word on big-endian platforms.
2353
+ * @param n - source word
2354
+ * @returns Original or byte-swapped word depending on platform endianness.
2355
+ * @example
2356
+ * Normalize a 32-bit word for host endianness.
2357
+ * ```ts
2358
+ * swap8IfBE(0x11223344);
2359
+ * ```
2360
+ */
2253
2361
  const swap8IfBE = isLE
2254
2362
  ? (n) => n
2255
- : (n) => byteSwap(n);
2256
- /** In place byte swap for Uint32Array */
2363
+ : (n) => byteSwap(n) >>> 0;
2364
+ /**
2365
+ * Byte-swaps every word of a Uint32Array in place.
2366
+ * @param arr - array to mutate
2367
+ * @returns The same array after mutation; callers pass live state arrays here.
2368
+ * @example
2369
+ * Reverse the byte order of every word in place.
2370
+ * ```ts
2371
+ * byteSwap32(new Uint32Array([0x11223344]));
2372
+ * ```
2373
+ */
2257
2374
  function byteSwap32(arr) {
2258
2375
  for (let i = 0; i < arr.length; i++) {
2259
2376
  arr[i] = byteSwap(arr[i]);
2260
2377
  }
2261
2378
  return arr;
2262
2379
  }
2380
+ /**
2381
+ * Conditionally byte-swaps a Uint32Array on big-endian platforms.
2382
+ * @param u - array to normalize for host endianness
2383
+ * @returns Original or byte-swapped array depending on platform endianness.
2384
+ * On big-endian runtimes this mutates `u` in place via `byteSwap32(...)`.
2385
+ * @example
2386
+ * Normalize a word array for host endianness.
2387
+ * ```ts
2388
+ * swap32IfBE(new Uint32Array([0x11223344]));
2389
+ * ```
2390
+ */
2263
2391
  const swap32IfBE = isLE
2264
2392
  ? (u) => u
2265
2393
  : byteSwap32;
2266
- /** Creates function with outputLen, blockLen, create properties from a class constructor. */
2394
+ /**
2395
+ * Creates a callable hash function from a stateful class constructor.
2396
+ * @param hashCons - hash constructor or factory
2397
+ * @param info - optional metadata such as DER OID
2398
+ * @returns Frozen callable hash wrapper with `.create()`.
2399
+ * Wrapper construction eagerly calls `hashCons(undefined)` once to read
2400
+ * `outputLen` / `blockLen`, so constructor side effects happen at module
2401
+ * init time.
2402
+ * @example
2403
+ * Wrap a stateful hash constructor into a callable helper.
2404
+ * ```ts
2405
+ * import { createHasher } from '@noble/hashes/utils.js';
2406
+ * import { sha256 } from '@noble/hashes/sha2.js';
2407
+ * const wrapped = createHasher(sha256.create, { oid: sha256.oid });
2408
+ * wrapped(new Uint8Array([1]));
2409
+ * ```
2410
+ */
2267
2411
  function createHasher(hashCons, info = {}) {
2268
- const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
2412
+ const hashC = (msg, opts) => hashCons(opts)
2413
+ .update(msg)
2414
+ .digest();
2269
2415
  const tmp = hashCons(undefined);
2270
2416
  hashC.outputLen = tmp.outputLen;
2271
2417
  hashC.blockLen = tmp.blockLen;
2418
+ hashC.canXOF = tmp.canXOF;
2272
2419
  hashC.create = (opts) => hashCons(opts);
2273
2420
  Object.assign(hashC, info);
2274
2421
  return Object.freeze(hashC);
@@ -2279,8 +2426,10 @@
2279
2426
  * @module
2280
2427
  */
2281
2428
  /**
2282
- * Internal blake variable.
2283
- * For BLAKE2b, the two extra permutations for rounds 10 and 11 are SIGMA[10..11] = SIGMA[0..1].
2429
+ * Internal blake permutation table.
2430
+ * Rows `0..9` serve BLAKE2s, rows `0..11` serve BLAKE2b with `10..11 = 0..1`, and Blake1 also
2431
+ * reuses the later rows shown below. Blake1 expands rounds `10..15` as `SIGMA[i % 10]`, so rows
2432
+ * `10..15` intentionally repeat rows `0..5` for the 14-round (256) and 16-round (512) variants.
2284
2433
  */
2285
2434
  // prettier-ignore
2286
2435
  const BSIGMA = /* @__PURE__ */ Uint8Array.from([
@@ -2303,35 +2452,38 @@
2303
2452
  2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9,
2304
2453
  ]);
2305
2454
 
2306
- /**
2307
- * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
2308
- * @todo re-check https://issues.chromium.org/issues/42212588
2309
- * @module
2310
- */
2311
2455
  const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
2312
2456
  const _32n = /* @__PURE__ */ BigInt(32);
2457
+ // Split bigint into two 32-bit halves. With `le=true`, returned fields become `{ h: low, l: high
2458
+ // }` to match little-endian word order rather than the property names.
2313
2459
  function fromBig(n, le = false) {
2314
2460
  if (le)
2315
2461
  return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
2316
2462
  return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
2317
2463
  }
2318
- // Right rotate for Shift in [1, 32)
2464
+ // High 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.
2319
2465
  const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
2466
+ // Low 32-bit half of a 64-bit right rotate, valid for `s` in `1..31`.
2320
2467
  const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
2321
- // Right rotate for Shift in (32, 64), NOTE: 32 is special case.
2468
+ // High 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
2322
2469
  const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
2470
+ // Low 32-bit half of a 64-bit right rotate, valid for `s` in `33..63`; `32` uses `rotr32*`.
2323
2471
  const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
2324
- // Right rotate for shift===32 (just swaps l&h)
2472
+ // High 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped low half.
2325
2473
  const rotr32H = (_h, l) => l;
2474
+ // Low 32-bit half of a 64-bit right rotate for `s === 32`; this is just the swapped high half.
2326
2475
  const rotr32L = (h, _l) => h;
2327
- // JS uses 32-bit signed integers for bitwise operations which means we cannot
2328
- // simple take carry out of low bit sum by shift, we need to use division.
2476
+ // Add two split 64-bit words and return the split `{ h, l }` sum.
2477
+ // JS uses 32-bit signed integers for bitwise operations, so we cannot simply shift the carry out
2478
+ // of the low sum and instead use division.
2329
2479
  function add(Ah, Al, Bh, Bl) {
2330
2480
  const l = (Al >>> 0) + (Bl >>> 0);
2331
2481
  return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
2332
2482
  }
2333
2483
  // Addition with more than 2 elements
2484
+ // Unmasked low-word accumulator for 3-way addition; pass the raw result into `add3H(...)`.
2334
2485
  const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
2486
+ // High-word finalize step for 3-way addition; `low` must be the untruncated output of `add3L(...)`.
2335
2487
  const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
2336
2488
 
2337
2489
  /**
@@ -2339,14 +2491,15 @@
2339
2491
  * b could have been faster, but there is no fast u64 in js, so s is 1.5x faster.
2340
2492
  * @module
2341
2493
  */
2342
- // Same as SHA512_IV, but swapped endianness: LE instead of BE. iv[1] is iv[0], etc.
2494
+ // Same IV words as `SHA512_IV`, but endian-swapped into LE u32 low/high halves
2495
+ // for the BLAKE2b u64 helpers below.
2343
2496
  const B2B_IV = /* @__PURE__ */ Uint32Array.from([
2344
2497
  0xf3bcc908, 0x6a09e667, 0x84caa73b, 0xbb67ae85, 0xfe94f82b, 0x3c6ef372, 0x5f1d36f1, 0xa54ff53a,
2345
2498
  0xade682d1, 0x510e527f, 0x2b3e6c1f, 0x9b05688c, 0xfb41bd6b, 0x1f83d9ab, 0x137e2179, 0x5be0cd19,
2346
2499
  ]);
2347
- // Temporary buffer
2500
+ // Shared synchronous BLAKE2b work vector as LE u32 low/high halves.
2348
2501
  const BBUF = /* @__PURE__ */ new Uint32Array(32);
2349
- // Mixing function G splitted in two halfs
2502
+ // BLAKE2b G mix split into two half-rounds over LE u32 low/high limbs.
2350
2503
  function G1b(a, b, c, d, msg, x) {
2351
2504
  // NOTE: V is LE here
2352
2505
  const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore
@@ -2371,6 +2524,7 @@
2371
2524
  ((BBUF[2 * c] = Cl), (BBUF[2 * c + 1] = Ch));
2372
2525
  ((BBUF[2 * d] = Dl), (BBUF[2 * d + 1] = Dh));
2373
2526
  }
2527
+ // Second half-round of the same LE-limb BLAKE2b G mix; `x` is the message word offset.
2374
2528
  function G2b(a, b, c, d, msg, x) {
2375
2529
  // NOTE: V is LE here
2376
2530
  const Xl = msg[x], Xh = msg[x + 1]; // prettier-ignore
@@ -2397,9 +2551,11 @@
2397
2551
  }
2398
2552
  function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
2399
2553
  anumber(keyLen);
2400
- if (outputLen < 0 || outputLen > keyLen)
2554
+ // RFC 7693 §2.1 requires digest length nn in 1..keyLen.
2555
+ if (outputLen <= 0 || outputLen > keyLen)
2401
2556
  throw new Error('outputLen bigger than keyLen');
2402
2557
  const { key, salt, personalization } = opts;
2558
+ // This API uses `undefined` for the RFC 7693 `kk = 0` case, so a provided key must be non-empty.
2403
2559
  if (key !== undefined && (key.length < 1 || key.length > keyLen))
2404
2560
  throw new Error('"key" expected to be undefined or of length=1..' + keyLen);
2405
2561
  if (salt !== undefined)
@@ -2417,6 +2573,7 @@
2417
2573
  pos = 0;
2418
2574
  blockLen;
2419
2575
  outputLen;
2576
+ canXOF = false;
2420
2577
  constructor(blockLen, outputLen) {
2421
2578
  anumber(blockLen);
2422
2579
  anumber(outputLen);
@@ -2446,7 +2603,7 @@
2446
2603
  }
2447
2604
  const take = Math.min(blockLen - this.pos, len - pos);
2448
2605
  const dataOffset = offset + pos;
2449
- // full block && aligned to 4 bytes && not last in input
2606
+ // Zero-copy only for full, 4-byte-aligned, non-final blocks.
2450
2607
  if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
2451
2608
  const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
2452
2609
  swap32IfBE(data32);
@@ -2474,18 +2631,33 @@
2474
2631
  swap32IfBE(buffer32);
2475
2632
  this.compress(buffer32, 0, true);
2476
2633
  swap32IfBE(buffer32);
2634
+ // Reject unaligned views explicitly instead of hiding them behind a full scratch copy.
2635
+ if (out.byteOffset & 3)
2636
+ throw new RangeError('"digestInto() output" expected 4-byte aligned byteOffset, got ' + out.byteOffset);
2637
+ const state = this.get();
2477
2638
  const out32 = u32(out);
2478
- this.get().forEach((v, i) => (out32[i] = swap8IfBE(v)));
2639
+ const full = Math.floor(this.outputLen / 4);
2640
+ for (let i = 0; i < full; i++)
2641
+ out32[i] = swap8IfBE(state[i]);
2642
+ const tail = this.outputLen % 4;
2643
+ if (!tail)
2644
+ return;
2645
+ const off = full * 4;
2646
+ const word = state[full];
2647
+ for (let i = 0; i < tail; i++)
2648
+ out[off + i] = word >>> (8 * i);
2479
2649
  }
2480
2650
  digest() {
2481
2651
  const { buffer, outputLen } = this;
2482
2652
  this.digestInto(buffer);
2653
+ // Return a copy so callers do not alias the instance scratch buffer used during finalization.
2483
2654
  const res = buffer.slice(0, outputLen);
2484
2655
  this.destroy();
2485
2656
  return res;
2486
2657
  }
2487
2658
  _cloneInto(to) {
2488
2659
  const { buffer, length, finished, destroyed, outputLen, pos } = this;
2660
+ // Recreate only `dkLen`; key/salt/personalization are already absorbed into the copied state.
2489
2661
  to ||= new this.constructor({ dkLen: outputLen });
2490
2662
  to.set(...this.get());
2491
2663
  to.buffer.set(buffer);
@@ -2501,9 +2673,9 @@
2501
2673
  return this._cloneInto();
2502
2674
  }
2503
2675
  }
2504
- /** Internal blake2b hash class. */
2676
+ /** Internal blake2b hash class with state stored as LE u32 low/high halves. */
2505
2677
  class _BLAKE2b extends _BLAKE2 {
2506
- // Same as SHA-512, but LE
2678
+ // Same IV words as SHA-512 / BLAKE2b, encoded as LE u32 low/high halves.
2507
2679
  v0l = B2B_IV[0] | 0;
2508
2680
  v0h = B2B_IV[1] | 0;
2509
2681
  v1l = B2B_IV[2] | 0;
@@ -2530,6 +2702,8 @@
2530
2702
  abytes(key, undefined, 'key');
2531
2703
  keyLength = key.length;
2532
2704
  }
2705
+ // RFC 7693 §2.5: xor `p[0] = 0x0101kknn` into the low 32 bits of `h[0]`;
2706
+ // the high 32 bits stay at `IV[0]`.
2533
2707
  this.v0l ^= this.outputLen | (keyLength << 8) | (0x01 << 16) | (0x01 << 24);
2534
2708
  if (salt !== undefined) {
2535
2709
  abytes(salt, undefined, 'salt');
@@ -2591,6 +2765,8 @@
2591
2765
  }
2592
2766
  let j = 0;
2593
2767
  const s = BSIGMA;
2768
+ // SIGMA selects 64-bit message words; multiply by 2 because `msg` stores
2769
+ // each word as [low32, high32].
2594
2770
  for (let i = 0; i < 12; i++) {
2595
2771
  G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
2596
2772
  G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
@@ -2636,7 +2812,15 @@
2636
2812
  /**
2637
2813
  * Blake2b hash function. 64-bit. 1.5x slower than blake2s in JS.
2638
2814
  * @param msg - message that would be hashed
2639
- * @param opts - dkLen output length, key for MAC mode, salt, personalization
2815
+ * @param opts - Optional output, MAC, salt, and personalization settings.
2816
+ * `dkLen` must be 1..64 bytes; `salt` and `personalization`, if present,
2817
+ * must be 16 bytes each. See {@link Blake2Opts}.
2818
+ * @returns Digest bytes.
2819
+ * @example
2820
+ * Hash a message with Blake2b.
2821
+ * ```ts
2822
+ * blake2b(new Uint8Array([97, 98, 99]));
2823
+ * ```
2640
2824
  */
2641
2825
  const blake2b = /* @__PURE__ */ createHasher((opts) => new _BLAKE2b(opts));
2642
2826
 
@@ -3428,8 +3612,8 @@
3428
3612
 
3429
3613
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT!
3430
3614
  const VERSION = {
3431
- "commitHash": "9647402fcc62c98bf3907a30214fea8871b30bea",
3432
- "version": "24.3.1-beta.1"
3615
+ "commitHash": "9851c9b7e8387a82f8ff0aa6a34277a9108bb68c",
3616
+ "version": "25.0.0-beta.1"
3433
3617
  };
3434
3618
 
3435
3619
  const BLS12_381_DST = 'BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_';