cafe-utility 27.3.0 → 27.4.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 +2 -0
- package/index.js +37 -28
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -523,6 +523,7 @@ declare function privateKeyToPublicKey(privateKey: bigint): [bigint, bigint];
|
|
|
523
523
|
declare function compressPublicKey(publicKey: [bigint, bigint]): Uint8Array;
|
|
524
524
|
declare function publicKeyFromCompressed(compressed: Uint8Array): [bigint, bigint];
|
|
525
525
|
declare function publicKeyToAddress(publicKey: [bigint, bigint]): Uint8Array;
|
|
526
|
+
declare function checksumEncode(addressBytes: Uint8Array): string;
|
|
526
527
|
declare function signMessage(message: Uint8Array, privateKey: bigint, nonce?: bigint): [bigint, bigint, 27n | 28n];
|
|
527
528
|
declare function signHash(hash: bigint, privateKey: bigint, nonce?: bigint): [bigint, bigint, 27n | 28n];
|
|
528
529
|
declare function recoverPublicKey(message: Uint8Array, r: bigint, s: bigint, v: 27n | 28n): [bigint, bigint];
|
|
@@ -673,6 +674,7 @@ export declare const Elliptic: {
|
|
|
673
674
|
signHash: typeof signHash;
|
|
674
675
|
verifySignature: typeof verifySignature;
|
|
675
676
|
recoverPublicKey: typeof recoverPublicKey;
|
|
677
|
+
checksumEncode: typeof checksumEncode;
|
|
676
678
|
};
|
|
677
679
|
export declare const Random: {
|
|
678
680
|
intBetween: typeof intBetween;
|
package/index.js
CHANGED
|
@@ -2267,21 +2267,21 @@ function keccakPermutate(n) {
|
|
|
2267
2267
|
T = (n[5] << 30) | (n[4] >>> 2),
|
|
2268
2268
|
S = (n[4] << 30) | (n[5] >>> 2),
|
|
2269
2269
|
R = (n[6] << 28) | (n[7] >>> 4),
|
|
2270
|
-
|
|
2271
|
-
|
|
2270
|
+
C = (n[7] << 28) | (n[6] >>> 4),
|
|
2271
|
+
D = (n[8] << 27) | (n[9] >>> 5),
|
|
2272
2272
|
I = (n[9] << 27) | (n[8] >>> 5),
|
|
2273
2273
|
B = (n[11] << 4) | (n[10] >>> 28),
|
|
2274
2274
|
P = (n[10] << 4) | (n[11] >>> 28),
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2275
|
+
U = (n[13] << 12) | (n[12] >>> 20),
|
|
2276
|
+
v = (n[12] << 12) | (n[13] >>> 20),
|
|
2277
|
+
L = (n[14] << 6) | (n[15] >>> 26),
|
|
2278
2278
|
N = (n[15] << 6) | (n[14] >>> 26),
|
|
2279
2279
|
j = (n[17] << 23) | (n[16] >>> 9),
|
|
2280
2280
|
z = (n[16] << 23) | (n[17] >>> 9),
|
|
2281
2281
|
F = (n[18] << 20) | (n[19] >>> 12),
|
|
2282
2282
|
q = (n[19] << 20) | (n[18] >>> 12),
|
|
2283
|
-
|
|
2284
|
-
|
|
2283
|
+
H = (n[20] << 3) | (n[21] >>> 29),
|
|
2284
|
+
W = (n[21] << 3) | (n[20] >>> 29),
|
|
2285
2285
|
V = (n[22] << 10) | (n[23] >>> 22),
|
|
2286
2286
|
J = (n[23] << 10) | (n[22] >>> 22),
|
|
2287
2287
|
K = (n[25] << 11) | (n[24] >>> 21),
|
|
@@ -2310,45 +2310,45 @@ function keccakPermutate(n) {
|
|
|
2310
2310
|
wn = (n[46] << 24) | (n[47] >>> 8),
|
|
2311
2311
|
yn = (n[48] << 14) | (n[49] >>> 18),
|
|
2312
2312
|
xn = (n[49] << 14) | (n[48] >>> 18)
|
|
2313
|
-
;(n[0] = E ^ (~
|
|
2314
|
-
(n[1] = M ^ (~
|
|
2315
|
-
(n[2] =
|
|
2316
|
-
(n[3] =
|
|
2313
|
+
;(n[0] = E ^ (~U & K)),
|
|
2314
|
+
(n[1] = M ^ (~v & Z)),
|
|
2315
|
+
(n[2] = U ^ (~K & un)),
|
|
2316
|
+
(n[3] = v ^ (~Z & cn)),
|
|
2317
2317
|
(n[4] = K ^ (~un & yn)),
|
|
2318
2318
|
(n[5] = Z ^ (~cn & xn)),
|
|
2319
2319
|
(n[6] = un ^ (~yn & E)),
|
|
2320
2320
|
(n[7] = cn ^ (~xn & M)),
|
|
2321
|
-
(n[8] = yn ^ (~E &
|
|
2322
|
-
(n[9] = xn ^ (~M &
|
|
2323
|
-
(n[10] = R ^ (~F &
|
|
2324
|
-
(n[11] =
|
|
2325
|
-
(n[12] = F ^ (~
|
|
2326
|
-
(n[13] = q ^ (~
|
|
2327
|
-
(n[14] =
|
|
2328
|
-
(n[15] =
|
|
2321
|
+
(n[8] = yn ^ (~E & U)),
|
|
2322
|
+
(n[9] = xn ^ (~M & v)),
|
|
2323
|
+
(n[10] = R ^ (~F & H)),
|
|
2324
|
+
(n[11] = C ^ (~q & W)),
|
|
2325
|
+
(n[12] = F ^ (~H & en)),
|
|
2326
|
+
(n[13] = q ^ (~W & tn)),
|
|
2327
|
+
(n[14] = H ^ (~en & dn)),
|
|
2328
|
+
(n[15] = W ^ (~tn & mn)),
|
|
2329
2329
|
(n[16] = en ^ (~dn & R)),
|
|
2330
|
-
(n[17] = tn ^ (~mn &
|
|
2330
|
+
(n[17] = tn ^ (~mn & C)),
|
|
2331
2331
|
(n[18] = dn ^ (~R & F)),
|
|
2332
|
-
(n[19] = mn ^ (~
|
|
2333
|
-
(n[20] = O ^ (~
|
|
2332
|
+
(n[19] = mn ^ (~C & q)),
|
|
2333
|
+
(n[20] = O ^ (~L & _)),
|
|
2334
2334
|
(n[21] = k ^ (~N & Q)),
|
|
2335
|
-
(n[22] =
|
|
2335
|
+
(n[22] = L ^ (~_ & sn)),
|
|
2336
2336
|
(n[23] = N ^ (~Q & fn)),
|
|
2337
2337
|
(n[24] = _ ^ (~sn & ln)),
|
|
2338
2338
|
(n[25] = Q ^ (~fn & an)),
|
|
2339
2339
|
(n[26] = sn ^ (~ln & O)),
|
|
2340
2340
|
(n[27] = fn ^ (~an & k)),
|
|
2341
|
-
(n[28] = ln ^ (~O &
|
|
2341
|
+
(n[28] = ln ^ (~O & L)),
|
|
2342
2342
|
(n[29] = an ^ (~k & N)),
|
|
2343
|
-
(n[30] =
|
|
2343
|
+
(n[30] = D ^ (~B & V)),
|
|
2344
2344
|
(n[31] = I ^ (~P & J)),
|
|
2345
2345
|
(n[32] = B ^ (~V & rn)),
|
|
2346
2346
|
(n[33] = P ^ (~J & on)),
|
|
2347
2347
|
(n[34] = V ^ (~rn & gn)),
|
|
2348
2348
|
(n[35] = J ^ (~on & wn)),
|
|
2349
|
-
(n[36] = rn ^ (~gn &
|
|
2349
|
+
(n[36] = rn ^ (~gn & D)),
|
|
2350
2350
|
(n[37] = on ^ (~wn & I)),
|
|
2351
|
-
(n[38] = gn ^ (~
|
|
2351
|
+
(n[38] = gn ^ (~D & B)),
|
|
2352
2352
|
(n[39] = wn ^ (~I & P)),
|
|
2353
2353
|
(n[40] = T ^ (~j & G)),
|
|
2354
2354
|
(n[41] = S ^ (~z & Y)),
|
|
@@ -2556,6 +2556,14 @@ function publicKeyToAddress(n) {
|
|
|
2556
2556
|
t = keccak256(concatBytes(numberToUint256(n[0], 'BE'), numberToUint256(n[1], 'BE')))
|
|
2557
2557
|
return e.set(t.subarray(12)), e
|
|
2558
2558
|
}
|
|
2559
|
+
function checksumEncode(n) {
|
|
2560
|
+
const e = exports.Binary.uint8ArrayToHex(n),
|
|
2561
|
+
t = exports.Binary.uint8ArrayToHex(exports.Binary.keccak256(new Uint8Array([...e].map(o => o.charCodeAt(0)))))
|
|
2562
|
+
console.log({ address: e, hash: t })
|
|
2563
|
+
let r = '0x'
|
|
2564
|
+
for (let o = 0; o < e.length; o++) parseInt(t[o], 16) > 7 ? (r += e[o].toUpperCase()) : (r += e[o])
|
|
2565
|
+
return r
|
|
2566
|
+
}
|
|
2559
2567
|
function doubleAndAdd(n, e, t, r) {
|
|
2560
2568
|
let o = [0n, 0n],
|
|
2561
2569
|
i = [n, e]
|
|
@@ -3038,7 +3046,8 @@ class AsyncQueue {
|
|
|
3038
3046
|
signMessage,
|
|
3039
3047
|
signHash,
|
|
3040
3048
|
verifySignature,
|
|
3041
|
-
recoverPublicKey
|
|
3049
|
+
recoverPublicKey,
|
|
3050
|
+
checksumEncode
|
|
3042
3051
|
}),
|
|
3043
3052
|
(exports.Random = {
|
|
3044
3053
|
intBetween,
|