cafe-utility 26.1.0 → 26.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +2 -3
  2. package/index.js +23 -26
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -524,12 +524,11 @@ declare class Uint8ArrayWriter implements Uint8ArrayIO {
524
524
  declare class Chunk {
525
525
  span: bigint;
526
526
  writer: Uint8ArrayWriter;
527
- hashFn: (a: Uint8Array, b: Uint8Array) => Uint8Array;
528
- constructor(capacity: number, hashFn: (a: Uint8Array, b: Uint8Array) => Uint8Array, span?: bigint);
527
+ constructor(capacity: number, span?: bigint);
529
528
  build(): Uint8Array;
530
529
  hash(): Uint8Array;
531
530
  }
532
- declare function merkleStart(capacity: number, hashFn: (a: Uint8Array, b: Uint8Array) => Uint8Array): Chunk[];
531
+ declare function merkleStart(capacity: number): Chunk[];
533
532
  declare function merkleAppend(levels: Chunk[], data: Uint8Array, onChunk: (chunk: Chunk) => Promise<void>, level?: number): Promise<Chunk[]>;
534
533
  declare function merkleFinalize(levels: Chunk[], onChunk: (chunk: Chunk) => Promise<void>, level?: number): Promise<Chunk>;
535
534
  type Playbook<T> = {
package/index.js CHANGED
@@ -2146,9 +2146,9 @@ function keccakPermutate(n) {
2146
2146
  x = u ^ En,
2147
2147
  b = s ^ Tn,
2148
2148
  kn = (t << 1) | (r >>> 31),
2149
- Sn = (r << 1) | (t >>> 31),
2149
+ Dn = (r << 1) | (t >>> 31),
2150
2150
  $ = c ^ kn,
2151
- A = f ^ Sn
2151
+ A = f ^ Dn
2152
2152
  ;(n[0] ^= p),
2153
2153
  (n[1] ^= d),
2154
2154
  (n[2] ^= m),
@@ -2204,9 +2204,9 @@ function keccakPermutate(n) {
2204
2204
  E = (n[2] << 1) | (n[3] >>> 31),
2205
2205
  T = (n[3] << 1) | (n[2] >>> 31),
2206
2206
  k = (n[5] << 30) | (n[4] >>> 2),
2207
- S = (n[4] << 30) | (n[5] >>> 2),
2208
- D = (n[6] << 28) | (n[7] >>> 4),
2209
- R = (n[7] << 28) | (n[6] >>> 4),
2207
+ D = (n[4] << 30) | (n[5] >>> 2),
2208
+ R = (n[6] << 28) | (n[7] >>> 4),
2209
+ S = (n[7] << 28) | (n[6] >>> 4),
2210
2210
  C = (n[8] << 27) | (n[9] >>> 5),
2211
2211
  I = (n[9] << 27) | (n[8] >>> 5),
2212
2212
  L = (n[11] << 4) | (n[10] >>> 28),
@@ -2259,16 +2259,16 @@ function keccakPermutate(n) {
2259
2259
  (n[7] = cn ^ (~xn & O)),
2260
2260
  (n[8] = yn ^ (~M & B)),
2261
2261
  (n[9] = xn ^ (~O & N)),
2262
- (n[10] = D ^ (~W & H)),
2263
- (n[11] = R ^ (~q & V)),
2262
+ (n[10] = R ^ (~W & H)),
2263
+ (n[11] = S ^ (~q & V)),
2264
2264
  (n[12] = W ^ (~H & en)),
2265
2265
  (n[13] = q ^ (~V & tn)),
2266
2266
  (n[14] = H ^ (~en & dn)),
2267
2267
  (n[15] = V ^ (~tn & mn)),
2268
- (n[16] = en ^ (~dn & D)),
2269
- (n[17] = tn ^ (~mn & R)),
2270
- (n[18] = dn ^ (~D & W)),
2271
- (n[19] = mn ^ (~R & q)),
2268
+ (n[16] = en ^ (~dn & R)),
2269
+ (n[17] = tn ^ (~mn & S)),
2270
+ (n[18] = dn ^ (~R & W)),
2271
+ (n[19] = mn ^ (~S & q)),
2272
2272
  (n[20] = E ^ (~j & _)),
2273
2273
  (n[21] = T ^ (~U & Q)),
2274
2274
  (n[22] = j ^ (~_ & sn)),
@@ -2290,15 +2290,15 @@ function keccakPermutate(n) {
2290
2290
  (n[38] = gn ^ (~C & L)),
2291
2291
  (n[39] = wn ^ (~I & P)),
2292
2292
  (n[40] = k ^ (~F & G)),
2293
- (n[41] = S ^ (~z & Y)),
2293
+ (n[41] = D ^ (~z & Y)),
2294
2294
  (n[42] = F ^ (~G & X)),
2295
2295
  (n[43] = z ^ (~Y & nn)),
2296
2296
  (n[44] = G ^ (~X & hn)),
2297
2297
  (n[45] = Y ^ (~nn & pn)),
2298
2298
  (n[46] = X ^ (~hn & k)),
2299
- (n[47] = nn ^ (~pn & S)),
2299
+ (n[47] = nn ^ (~pn & D)),
2300
2300
  (n[48] = hn ^ (~k & F)),
2301
- (n[49] = pn ^ (~S & z)),
2301
+ (n[49] = pn ^ (~D & z)),
2302
2302
  (n[0] ^= IOTA_CONSTANTS[e * 2]),
2303
2303
  (n[1] ^= IOTA_CONSTANTS[e * 2 + 1])
2304
2304
  }
@@ -2399,25 +2399,25 @@ class Uint8ArrayWriter {
2399
2399
  }
2400
2400
  }
2401
2401
  class Chunk {
2402
- constructor(e, t, r = 0n) {
2403
- ;(this.span = r), (this.writer = new Uint8ArrayWriter(new Uint8Array(e))), (this.hashFn = t)
2402
+ constructor(e, t = 0n) {
2403
+ ;(this.span = t), (this.writer = new Uint8ArrayWriter(new Uint8Array(e)))
2404
2404
  }
2405
2405
  build() {
2406
2406
  return concatBytes(numberToUint64(this.span, 'LE'), this.writer.buffer)
2407
2407
  }
2408
2408
  hash() {
2409
- const e = log2Reduce(partition(this.writer.buffer, 32), this.hashFn)
2410
- return this.hashFn(numberToUint64(this.span, 'LE'), e)
2409
+ const e = log2Reduce(partition(this.writer.buffer, 32), keccak256)
2410
+ return keccak256(concatBytes(numberToUint64(this.span, 'LE'), e))
2411
2411
  }
2412
2412
  }
2413
- function merkleStart(n, e) {
2414
- return [new Chunk(n, e)]
2413
+ function merkleStart(n) {
2414
+ return [new Chunk(n)]
2415
2415
  }
2416
2416
  async function merkleElevate(n, e, t) {
2417
2417
  await e(n[t]),
2418
- n[t + 1] || n.push(new Chunk(n[t].writer.buffer.length, n[t].hashFn, n[t].span)),
2418
+ n[t + 1] || n.push(new Chunk(n[t].writer.buffer.length, n[t].span)),
2419
2419
  merkleAppend(n, n[t].hash(), e, t + 1),
2420
- (n[t] = new Chunk(n[t].writer.buffer.length, n[t].hashFn))
2420
+ (n[t] = new Chunk(n[t].writer.buffer.length))
2421
2421
  }
2422
2422
  async function merkleAppend(n, e, t, r = 0) {
2423
2423
  n[r].writer.max() === 0 && (await merkleElevate(n, t, r))
@@ -3047,7 +3047,4 @@ class AsyncQueue {
3047
3047
  raycast,
3048
3048
  raycastCircle,
3049
3049
  getLineIntersectionPoint
3050
- }),
3051
- console.log(exports.Strings.randomAlphanumeric(135)),
3052
- console.log(exports.Strings.randomAlphanumeric(136)),
3053
- console.log(exports.Strings.randomAlphanumeric(137))
3050
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "26.1.0",
3
+ "version": "26.1.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {