cafe-utility 26.12.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 +8 -4
- package/index.js +42 -31
- package/package.json +1 -1
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
|
|
517
|
-
declare function
|
|
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];
|
|
@@ -634,8 +636,10 @@ export declare const Binary: {
|
|
|
634
636
|
getBit: typeof getBit;
|
|
635
637
|
indexOf: typeof binaryIndexOf;
|
|
636
638
|
equals: typeof binaryEquals;
|
|
637
|
-
|
|
638
|
-
|
|
639
|
+
padStart: typeof binaryPadStart;
|
|
640
|
+
padStartToMultiple: typeof binaryPadStartToMultiple;
|
|
641
|
+
padEnd: typeof binaryPadEnd;
|
|
642
|
+
padEndToMultiple: typeof binaryPadEndToMultiple;
|
|
639
643
|
xorCypher: typeof xorCypher;
|
|
640
644
|
};
|
|
641
645
|
export declare const Elliptic: {
|
package/index.js
CHANGED
|
@@ -2189,8 +2189,8 @@ function keccakPermutate(n) {
|
|
|
2189
2189
|
a = n[9] ^ n[19] ^ n[29] ^ n[39] ^ n[49],
|
|
2190
2190
|
h = (o << 1) | (i >>> 31),
|
|
2191
2191
|
bn = (i << 1) | (o >>> 31),
|
|
2192
|
-
|
|
2193
|
-
|
|
2192
|
+
d = l ^ h,
|
|
2193
|
+
p = a ^ bn,
|
|
2194
2194
|
$n = (u << 1) | (f >>> 31),
|
|
2195
2195
|
An = (f << 1) | (u >>> 31),
|
|
2196
2196
|
m = t ^ $n,
|
|
@@ -2204,11 +2204,11 @@ function keccakPermutate(n) {
|
|
|
2204
2204
|
x = u ^ On,
|
|
2205
2205
|
b = f ^ Tn,
|
|
2206
2206
|
kn = (t << 1) | (r >>> 31),
|
|
2207
|
-
|
|
2207
|
+
Sn = (r << 1) | (t >>> 31),
|
|
2208
2208
|
$ = c ^ kn,
|
|
2209
|
-
A = s ^
|
|
2210
|
-
;(n[0] ^=
|
|
2211
|
-
(n[1] ^=
|
|
2209
|
+
A = s ^ Sn
|
|
2210
|
+
;(n[0] ^= d),
|
|
2211
|
+
(n[1] ^= p),
|
|
2212
2212
|
(n[2] ^= m),
|
|
2213
2213
|
(n[3] ^= g),
|
|
2214
2214
|
(n[4] ^= w),
|
|
@@ -2217,8 +2217,8 @@ function keccakPermutate(n) {
|
|
|
2217
2217
|
(n[7] ^= b),
|
|
2218
2218
|
(n[8] ^= $),
|
|
2219
2219
|
(n[9] ^= A),
|
|
2220
|
-
(n[10] ^=
|
|
2221
|
-
(n[11] ^=
|
|
2220
|
+
(n[10] ^= d),
|
|
2221
|
+
(n[11] ^= p),
|
|
2222
2222
|
(n[12] ^= m),
|
|
2223
2223
|
(n[13] ^= g),
|
|
2224
2224
|
(n[14] ^= w),
|
|
@@ -2227,8 +2227,8 @@ function keccakPermutate(n) {
|
|
|
2227
2227
|
(n[17] ^= b),
|
|
2228
2228
|
(n[18] ^= $),
|
|
2229
2229
|
(n[19] ^= A),
|
|
2230
|
-
(n[20] ^=
|
|
2231
|
-
(n[21] ^=
|
|
2230
|
+
(n[20] ^= d),
|
|
2231
|
+
(n[21] ^= p),
|
|
2232
2232
|
(n[22] ^= m),
|
|
2233
2233
|
(n[23] ^= g),
|
|
2234
2234
|
(n[24] ^= w),
|
|
@@ -2237,8 +2237,8 @@ function keccakPermutate(n) {
|
|
|
2237
2237
|
(n[27] ^= b),
|
|
2238
2238
|
(n[28] ^= $),
|
|
2239
2239
|
(n[29] ^= A),
|
|
2240
|
-
(n[30] ^=
|
|
2241
|
-
(n[31] ^=
|
|
2240
|
+
(n[30] ^= d),
|
|
2241
|
+
(n[31] ^= p),
|
|
2242
2242
|
(n[32] ^= m),
|
|
2243
2243
|
(n[33] ^= g),
|
|
2244
2244
|
(n[34] ^= w),
|
|
@@ -2247,8 +2247,8 @@ function keccakPermutate(n) {
|
|
|
2247
2247
|
(n[37] ^= b),
|
|
2248
2248
|
(n[38] ^= $),
|
|
2249
2249
|
(n[39] ^= A),
|
|
2250
|
-
(n[40] ^=
|
|
2251
|
-
(n[41] ^=
|
|
2250
|
+
(n[40] ^= d),
|
|
2251
|
+
(n[41] ^= p),
|
|
2252
2252
|
(n[42] ^= m),
|
|
2253
2253
|
(n[43] ^= g),
|
|
2254
2254
|
(n[44] ^= w),
|
|
@@ -2262,8 +2262,8 @@ function keccakPermutate(n) {
|
|
|
2262
2262
|
O = (n[2] << 1) | (n[3] >>> 31),
|
|
2263
2263
|
T = (n[3] << 1) | (n[2] >>> 31),
|
|
2264
2264
|
k = (n[5] << 30) | (n[4] >>> 2),
|
|
2265
|
-
|
|
2266
|
-
|
|
2265
|
+
S = (n[4] << 30) | (n[5] >>> 2),
|
|
2266
|
+
R = (n[6] << 28) | (n[7] >>> 4),
|
|
2267
2267
|
D = (n[7] << 28) | (n[6] >>> 4),
|
|
2268
2268
|
I = (n[8] << 27) | (n[9] >>> 5),
|
|
2269
2269
|
C = (n[9] << 27) | (n[8] >>> 5),
|
|
@@ -2300,8 +2300,8 @@ function keccakPermutate(n) {
|
|
|
2300
2300
|
ln = (n[40] << 18) | (n[41] >>> 14),
|
|
2301
2301
|
an = (n[41] << 18) | (n[40] >>> 14),
|
|
2302
2302
|
hn = (n[42] << 2) | (n[43] >>> 30),
|
|
2303
|
-
|
|
2304
|
-
|
|
2303
|
+
dn = (n[43] << 2) | (n[42] >>> 30),
|
|
2304
|
+
pn = (n[45] << 29) | (n[44] >>> 3),
|
|
2305
2305
|
mn = (n[44] << 29) | (n[45] >>> 3),
|
|
2306
2306
|
gn = (n[47] << 24) | (n[46] >>> 8),
|
|
2307
2307
|
wn = (n[46] << 24) | (n[47] >>> 8),
|
|
@@ -2317,15 +2317,15 @@ function keccakPermutate(n) {
|
|
|
2317
2317
|
(n[7] = cn ^ (~xn & M)),
|
|
2318
2318
|
(n[8] = yn ^ (~E & L)),
|
|
2319
2319
|
(n[9] = xn ^ (~M & U)),
|
|
2320
|
-
(n[10] =
|
|
2320
|
+
(n[10] = R ^ (~q & W)),
|
|
2321
2321
|
(n[11] = D ^ (~v & H)),
|
|
2322
2322
|
(n[12] = q ^ (~W & en)),
|
|
2323
2323
|
(n[13] = v ^ (~H & tn)),
|
|
2324
|
-
(n[14] = W ^ (~en &
|
|
2324
|
+
(n[14] = W ^ (~en & pn)),
|
|
2325
2325
|
(n[15] = H ^ (~tn & mn)),
|
|
2326
|
-
(n[16] = en ^ (~
|
|
2326
|
+
(n[16] = en ^ (~pn & R)),
|
|
2327
2327
|
(n[17] = tn ^ (~mn & D)),
|
|
2328
|
-
(n[18] =
|
|
2328
|
+
(n[18] = pn ^ (~R & q)),
|
|
2329
2329
|
(n[19] = mn ^ (~D & v)),
|
|
2330
2330
|
(n[20] = O ^ (~N & Z)),
|
|
2331
2331
|
(n[21] = T ^ (~j & Q)),
|
|
@@ -2348,15 +2348,15 @@ function keccakPermutate(n) {
|
|
|
2348
2348
|
(n[38] = gn ^ (~I & P)),
|
|
2349
2349
|
(n[39] = wn ^ (~C & B)),
|
|
2350
2350
|
(n[40] = k ^ (~F & G)),
|
|
2351
|
-
(n[41] =
|
|
2351
|
+
(n[41] = S ^ (~z & Y)),
|
|
2352
2352
|
(n[42] = F ^ (~G & X)),
|
|
2353
2353
|
(n[43] = z ^ (~Y & nn)),
|
|
2354
2354
|
(n[44] = G ^ (~X & hn)),
|
|
2355
|
-
(n[45] = Y ^ (~nn &
|
|
2355
|
+
(n[45] = Y ^ (~nn & dn)),
|
|
2356
2356
|
(n[46] = X ^ (~hn & k)),
|
|
2357
|
-
(n[47] = nn ^ (~
|
|
2357
|
+
(n[47] = nn ^ (~dn & S)),
|
|
2358
2358
|
(n[48] = hn ^ (~k & F)),
|
|
2359
|
-
(n[49] =
|
|
2359
|
+
(n[49] = dn ^ (~S & z)),
|
|
2360
2360
|
(n[0] ^= IOTA_CONSTANTS[e * 2]),
|
|
2361
2361
|
(n[1] ^= IOTA_CONSTANTS[e * 2 + 1])
|
|
2362
2362
|
}
|
|
@@ -2460,14 +2460,23 @@ function binaryIndexOf(n, e, t = 0) {
|
|
|
2460
2460
|
for (let o = 0; o < e.length && n[r + o] === e[o]; o++) if (o === e.length - 1) return r
|
|
2461
2461
|
return -1
|
|
2462
2462
|
}
|
|
2463
|
-
function
|
|
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) {
|
|
2464
2473
|
if (n.length >= e) return n
|
|
2465
2474
|
const t = new Uint8Array(e)
|
|
2466
2475
|
return t.set(n, 0), t
|
|
2467
2476
|
}
|
|
2468
|
-
function
|
|
2477
|
+
function binaryPadEndToMultiple(n, e) {
|
|
2469
2478
|
const t = n.length % e
|
|
2470
|
-
return t === 0 ? n :
|
|
2479
|
+
return t === 0 ? n : binaryPadEnd(n, n.length + e - t)
|
|
2471
2480
|
}
|
|
2472
2481
|
function xorCypher(n, e) {
|
|
2473
2482
|
const t = new Uint8Array(n.length)
|
|
@@ -2950,8 +2959,10 @@ class AsyncQueue {
|
|
|
2950
2959
|
getBit,
|
|
2951
2960
|
indexOf: binaryIndexOf,
|
|
2952
2961
|
equals: binaryEquals,
|
|
2953
|
-
|
|
2954
|
-
|
|
2962
|
+
padStart: binaryPadStart,
|
|
2963
|
+
padStartToMultiple: binaryPadStartToMultiple,
|
|
2964
|
+
padEnd: binaryPadEnd,
|
|
2965
|
+
padEndToMultiple: binaryPadEndToMultiple,
|
|
2955
2966
|
xorCypher
|
|
2956
2967
|
}),
|
|
2957
2968
|
(exports.Elliptic = {
|