cafe-utility 26.11.0 → 26.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -513,8 +513,10 @@ declare function commonPrefix(one: Uint8Array, other: Uint8Array): Uint8Array;
513
513
  declare function setBit(bytes: Uint8Array, index: number, value: 0 | 1): void;
514
514
  declare function getBit(bytes: Uint8Array, index: number): 0 | 1;
515
515
  declare function binaryIndexOf(bytes: Uint8Array, value: Uint8Array, start?: number): number;
516
- declare function binaryPad(bytes: Uint8Array, size: number): Uint8Array;
517
- declare function binaryPadToMultiple(bytes: Uint8Array, multiple: number): Uint8Array;
516
+ declare function binaryPadStart(bytes: Uint8Array, size: number): Uint8Array;
517
+ declare function binaryPadStartToMultiple(bytes: Uint8Array, multiple: number): Uint8Array;
518
+ declare function binaryPadEnd(bytes: Uint8Array, size: number): Uint8Array;
519
+ declare function binaryPadEndToMultiple(bytes: Uint8Array, multiple: number): Uint8Array;
518
520
  declare function xorCypher(bytes: Uint8Array, key: Uint8Array): Uint8Array;
519
521
  declare function binaryEquals(a: Uint8Array, b: Uint8Array): boolean;
520
522
  declare function privateKeyToPublicKey(privateKey: bigint): [bigint, bigint];
@@ -523,17 +525,14 @@ declare function signMessage(message: Uint8Array, privateKey: bigint, nonce?: bi
523
525
  declare function signHash(hash: bigint, privateKey: bigint, nonce?: bigint): [bigint, bigint, 27n | 28n];
524
526
  declare function recoverPublicKey(message: Uint8Array, r: bigint, s: bigint, v: 27n | 28n): [bigint, bigint];
525
527
  declare function verifySignature(message: Uint8Array, publicKey: [bigint, bigint], r: bigint, s: bigint): boolean;
526
- interface Uint8ArrayIO {
527
- max: () => number;
528
- }
529
- declare class Uint8ArrayReader implements Uint8ArrayIO {
528
+ export declare class Uint8ArrayReader {
530
529
  cursor: number;
531
530
  buffer: Uint8Array;
532
531
  constructor(buffer: Uint8Array);
533
532
  read(size: number): Uint8Array;
534
533
  max(): number;
535
534
  }
536
- declare class Uint8ArrayWriter implements Uint8ArrayIO {
535
+ export declare class Uint8ArrayWriter {
537
536
  cursor: number;
538
537
  buffer: Uint8Array;
539
538
  constructor(buffer: Uint8Array);
@@ -637,8 +636,10 @@ export declare const Binary: {
637
636
  getBit: typeof getBit;
638
637
  indexOf: typeof binaryIndexOf;
639
638
  equals: typeof binaryEquals;
640
- pad: typeof binaryPad;
641
- padToMultiple: typeof binaryPadToMultiple;
639
+ padStart: typeof binaryPadStart;
640
+ padStartToMultiple: typeof binaryPadStartToMultiple;
641
+ padEnd: typeof binaryPadEnd;
642
+ padEndToMultiple: typeof binaryPadEndToMultiple;
642
643
  xorCypher: typeof xorCypher;
643
644
  };
644
645
  export declare const Elliptic: {
package/index.js CHANGED
@@ -17,6 +17,8 @@ Object.defineProperty(exports, '__esModule', { value: !0 }),
17
17
  exports.AsyncQueue =
18
18
  exports.PubSubChannel =
19
19
  exports.Chunk =
20
+ exports.Uint8ArrayWriter =
21
+ exports.Uint8ArrayReader =
20
22
  exports.AsyncLazy =
21
23
  exports.Lazy =
22
24
  exports.Optional =
@@ -2187,8 +2189,8 @@ function keccakPermutate(n) {
2187
2189
  a = n[9] ^ n[19] ^ n[29] ^ n[39] ^ n[49],
2188
2190
  h = (o << 1) | (i >>> 31),
2189
2191
  bn = (i << 1) | (o >>> 31),
2190
- p = l ^ h,
2191
- d = a ^ bn,
2192
+ d = l ^ h,
2193
+ p = a ^ bn,
2192
2194
  $n = (u << 1) | (f >>> 31),
2193
2195
  An = (f << 1) | (u >>> 31),
2194
2196
  m = t ^ $n,
@@ -2205,8 +2207,8 @@ function keccakPermutate(n) {
2205
2207
  Sn = (r << 1) | (t >>> 31),
2206
2208
  $ = c ^ kn,
2207
2209
  A = s ^ Sn
2208
- ;(n[0] ^= p),
2209
- (n[1] ^= d),
2210
+ ;(n[0] ^= d),
2211
+ (n[1] ^= p),
2210
2212
  (n[2] ^= m),
2211
2213
  (n[3] ^= g),
2212
2214
  (n[4] ^= w),
@@ -2215,8 +2217,8 @@ function keccakPermutate(n) {
2215
2217
  (n[7] ^= b),
2216
2218
  (n[8] ^= $),
2217
2219
  (n[9] ^= A),
2218
- (n[10] ^= p),
2219
- (n[11] ^= d),
2220
+ (n[10] ^= d),
2221
+ (n[11] ^= p),
2220
2222
  (n[12] ^= m),
2221
2223
  (n[13] ^= g),
2222
2224
  (n[14] ^= w),
@@ -2225,8 +2227,8 @@ function keccakPermutate(n) {
2225
2227
  (n[17] ^= b),
2226
2228
  (n[18] ^= $),
2227
2229
  (n[19] ^= A),
2228
- (n[20] ^= p),
2229
- (n[21] ^= d),
2230
+ (n[20] ^= d),
2231
+ (n[21] ^= p),
2230
2232
  (n[22] ^= m),
2231
2233
  (n[23] ^= g),
2232
2234
  (n[24] ^= w),
@@ -2235,8 +2237,8 @@ function keccakPermutate(n) {
2235
2237
  (n[27] ^= b),
2236
2238
  (n[28] ^= $),
2237
2239
  (n[29] ^= A),
2238
- (n[30] ^= p),
2239
- (n[31] ^= d),
2240
+ (n[30] ^= d),
2241
+ (n[31] ^= p),
2240
2242
  (n[32] ^= m),
2241
2243
  (n[33] ^= g),
2242
2244
  (n[34] ^= w),
@@ -2245,8 +2247,8 @@ function keccakPermutate(n) {
2245
2247
  (n[37] ^= b),
2246
2248
  (n[38] ^= $),
2247
2249
  (n[39] ^= A),
2248
- (n[40] ^= p),
2249
- (n[41] ^= d),
2250
+ (n[40] ^= d),
2251
+ (n[41] ^= p),
2250
2252
  (n[42] ^= m),
2251
2253
  (n[43] ^= g),
2252
2254
  (n[44] ^= w),
@@ -2268,15 +2270,15 @@ function keccakPermutate(n) {
2268
2270
  P = (n[11] << 4) | (n[10] >>> 28),
2269
2271
  B = (n[10] << 4) | (n[11] >>> 28),
2270
2272
  L = (n[13] << 12) | (n[12] >>> 20),
2271
- N = (n[12] << 12) | (n[13] >>> 20),
2272
- U = (n[14] << 6) | (n[15] >>> 26),
2273
+ U = (n[12] << 12) | (n[13] >>> 20),
2274
+ N = (n[14] << 6) | (n[15] >>> 26),
2273
2275
  j = (n[15] << 6) | (n[14] >>> 26),
2274
2276
  F = (n[17] << 23) | (n[16] >>> 9),
2275
2277
  z = (n[16] << 23) | (n[17] >>> 9),
2276
2278
  q = (n[18] << 20) | (n[19] >>> 12),
2277
2279
  v = (n[19] << 20) | (n[18] >>> 12),
2278
- H = (n[20] << 3) | (n[21] >>> 29),
2279
- W = (n[21] << 3) | (n[20] >>> 29),
2280
+ W = (n[20] << 3) | (n[21] >>> 29),
2281
+ H = (n[21] << 3) | (n[20] >>> 29),
2280
2282
  V = (n[22] << 10) | (n[23] >>> 22),
2281
2283
  _ = (n[23] << 10) | (n[22] >>> 22),
2282
2284
  J = (n[25] << 11) | (n[24] >>> 21),
@@ -2298,42 +2300,42 @@ function keccakPermutate(n) {
2298
2300
  ln = (n[40] << 18) | (n[41] >>> 14),
2299
2301
  an = (n[41] << 18) | (n[40] >>> 14),
2300
2302
  hn = (n[42] << 2) | (n[43] >>> 30),
2301
- pn = (n[43] << 2) | (n[42] >>> 30),
2302
- dn = (n[45] << 29) | (n[44] >>> 3),
2303
+ dn = (n[43] << 2) | (n[42] >>> 30),
2304
+ pn = (n[45] << 29) | (n[44] >>> 3),
2303
2305
  mn = (n[44] << 29) | (n[45] >>> 3),
2304
2306
  gn = (n[47] << 24) | (n[46] >>> 8),
2305
2307
  wn = (n[46] << 24) | (n[47] >>> 8),
2306
2308
  yn = (n[48] << 14) | (n[49] >>> 18),
2307
2309
  xn = (n[49] << 14) | (n[48] >>> 18)
2308
2310
  ;(n[0] = E ^ (~L & J)),
2309
- (n[1] = M ^ (~N & K)),
2311
+ (n[1] = M ^ (~U & K)),
2310
2312
  (n[2] = L ^ (~J & un)),
2311
- (n[3] = N ^ (~K & cn)),
2313
+ (n[3] = U ^ (~K & cn)),
2312
2314
  (n[4] = J ^ (~un & yn)),
2313
2315
  (n[5] = K ^ (~cn & xn)),
2314
2316
  (n[6] = un ^ (~yn & E)),
2315
2317
  (n[7] = cn ^ (~xn & M)),
2316
2318
  (n[8] = yn ^ (~E & L)),
2317
- (n[9] = xn ^ (~M & N)),
2318
- (n[10] = R ^ (~q & H)),
2319
- (n[11] = D ^ (~v & W)),
2320
- (n[12] = q ^ (~H & en)),
2321
- (n[13] = v ^ (~W & tn)),
2322
- (n[14] = H ^ (~en & dn)),
2323
- (n[15] = W ^ (~tn & mn)),
2324
- (n[16] = en ^ (~dn & R)),
2319
+ (n[9] = xn ^ (~M & U)),
2320
+ (n[10] = R ^ (~q & W)),
2321
+ (n[11] = D ^ (~v & H)),
2322
+ (n[12] = q ^ (~W & en)),
2323
+ (n[13] = v ^ (~H & tn)),
2324
+ (n[14] = W ^ (~en & pn)),
2325
+ (n[15] = H ^ (~tn & mn)),
2326
+ (n[16] = en ^ (~pn & R)),
2325
2327
  (n[17] = tn ^ (~mn & D)),
2326
- (n[18] = dn ^ (~R & q)),
2328
+ (n[18] = pn ^ (~R & q)),
2327
2329
  (n[19] = mn ^ (~D & v)),
2328
- (n[20] = O ^ (~U & Z)),
2330
+ (n[20] = O ^ (~N & Z)),
2329
2331
  (n[21] = T ^ (~j & Q)),
2330
- (n[22] = U ^ (~Z & fn)),
2332
+ (n[22] = N ^ (~Z & fn)),
2331
2333
  (n[23] = j ^ (~Q & sn)),
2332
2334
  (n[24] = Z ^ (~fn & ln)),
2333
2335
  (n[25] = Q ^ (~sn & an)),
2334
2336
  (n[26] = fn ^ (~ln & O)),
2335
2337
  (n[27] = sn ^ (~an & T)),
2336
- (n[28] = ln ^ (~O & U)),
2338
+ (n[28] = ln ^ (~O & N)),
2337
2339
  (n[29] = an ^ (~T & j)),
2338
2340
  (n[30] = I ^ (~P & V)),
2339
2341
  (n[31] = C ^ (~B & _)),
@@ -2350,11 +2352,11 @@ function keccakPermutate(n) {
2350
2352
  (n[42] = F ^ (~G & X)),
2351
2353
  (n[43] = z ^ (~Y & nn)),
2352
2354
  (n[44] = G ^ (~X & hn)),
2353
- (n[45] = Y ^ (~nn & pn)),
2355
+ (n[45] = Y ^ (~nn & dn)),
2354
2356
  (n[46] = X ^ (~hn & k)),
2355
- (n[47] = nn ^ (~pn & S)),
2357
+ (n[47] = nn ^ (~dn & S)),
2356
2358
  (n[48] = hn ^ (~k & F)),
2357
- (n[49] = pn ^ (~S & z)),
2359
+ (n[49] = dn ^ (~S & z)),
2358
2360
  (n[0] ^= IOTA_CONSTANTS[e * 2]),
2359
2361
  (n[1] ^= IOTA_CONSTANTS[e * 2 + 1])
2360
2362
  }
@@ -2458,14 +2460,23 @@ function binaryIndexOf(n, e, t = 0) {
2458
2460
  for (let o = 0; o < e.length && n[r + o] === e[o]; o++) if (o === e.length - 1) return r
2459
2461
  return -1
2460
2462
  }
2461
- function binaryPad(n, e) {
2463
+ function binaryPadStart(n, e) {
2464
+ if (n.length >= e) return n
2465
+ const t = new Uint8Array(e)
2466
+ return t.set(n, e - n.length), t
2467
+ }
2468
+ function binaryPadStartToMultiple(n, e) {
2469
+ const t = n.length % e
2470
+ return t === 0 ? n : binaryPadStart(n, n.length + e - t)
2471
+ }
2472
+ function binaryPadEnd(n, e) {
2462
2473
  if (n.length >= e) return n
2463
2474
  const t = new Uint8Array(e)
2464
2475
  return t.set(n, 0), t
2465
2476
  }
2466
- function binaryPadToMultiple(n, e) {
2477
+ function binaryPadEndToMultiple(n, e) {
2467
2478
  const t = n.length % e
2468
- return t === 0 ? n : binaryPad(n, n.length + e - t)
2479
+ return t === 0 ? n : binaryPadEnd(n, n.length + e - t)
2469
2480
  }
2470
2481
  function xorCypher(n, e) {
2471
2482
  const t = new Uint8Array(n.length)
@@ -2597,6 +2608,7 @@ class Uint8ArrayReader {
2597
2608
  return this.buffer.length - this.cursor
2598
2609
  }
2599
2610
  }
2611
+ exports.Uint8ArrayReader = Uint8ArrayReader
2600
2612
  class Uint8ArrayWriter {
2601
2613
  constructor(e) {
2602
2614
  ;(this.buffer = e), (this.cursor = 0)
@@ -2609,6 +2621,7 @@ class Uint8ArrayWriter {
2609
2621
  return this.buffer.length - this.cursor
2610
2622
  }
2611
2623
  }
2624
+ exports.Uint8ArrayWriter = Uint8ArrayWriter
2612
2625
  class Chunk {
2613
2626
  constructor(e, t = 0n) {
2614
2627
  ;(this.span = t), (this.writer = new Uint8ArrayWriter(new Uint8Array(e)))
@@ -2946,8 +2959,10 @@ class AsyncQueue {
2946
2959
  getBit,
2947
2960
  indexOf: binaryIndexOf,
2948
2961
  equals: binaryEquals,
2949
- pad: binaryPad,
2950
- padToMultiple: binaryPadToMultiple,
2962
+ padStart: binaryPadStart,
2963
+ padStartToMultiple: binaryPadStartToMultiple,
2964
+ padEnd: binaryPadEnd,
2965
+ padEndToMultiple: binaryPadEndToMultiple,
2951
2966
  xorCypher
2952
2967
  }),
2953
2968
  (exports.Elliptic = {
package/module.mjs CHANGED
@@ -21,3 +21,5 @@ export const Chunk = utility.Chunk
21
21
  export const Lazy = utility.Lazy
22
22
  export const AsyncLazy = utility.AsyncLazy
23
23
  export const AsyncQueue = utility.AsyncQueue
24
+ export const Uint8ArrayReader = utility.Uint8ArrayReader
25
+ export const Uint8ArrayWriter = utility.Uint8ArrayWriter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "26.11.0",
3
+ "version": "26.13.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {