@chainflip/utils 0.8.5 → 0.8.7
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/dist/consts.cjs +12 -0
- package/dist/consts.js +12 -0
- package/dist/ss58.cjs +159 -190
- package/dist/ss58.js +159 -190
- package/package.json +3 -3
package/dist/consts.cjs
CHANGED
|
@@ -130,6 +130,10 @@ var brokerAliasMap = {
|
|
|
130
130
|
name: "SwapKit",
|
|
131
131
|
twitter: "@SwapKitPowered"
|
|
132
132
|
},
|
|
133
|
+
cFPDEjR88FyRi7V5NDatoMAyMCczgiyoXwiJA4LZLrR7e6RW4: {
|
|
134
|
+
name: "Bitget",
|
|
135
|
+
twitter: "@BitgetWallet"
|
|
136
|
+
},
|
|
133
137
|
cFL4To8Uow6B1hk4dNrhWhvKpkBtnUTrVdWCEKCaXiXMMztjM: {
|
|
134
138
|
name: "SwapKit",
|
|
135
139
|
twitter: "@SwapKitPowered"
|
|
@@ -153,6 +157,14 @@ var brokerAliasMap = {
|
|
|
153
157
|
cFPD5DrrsHb7Wi5nmBcFuPDcGRsWhv5Bz6vvzGqFYPFhbR3Sw: {
|
|
154
158
|
name: "Squid",
|
|
155
159
|
twitter: "@squidrouter"
|
|
160
|
+
},
|
|
161
|
+
cFJZvt5AiEGwUiFFNxhDuLRcgC1WBR6tE7gaQQfe8dqbzoYkx: {
|
|
162
|
+
name: "Symbiosis",
|
|
163
|
+
twitter: "@symbiosis_fi"
|
|
164
|
+
},
|
|
165
|
+
cFLvH2ZA3J5dsDdrDuV1Eyh9Jk6yasijtKQagGhMDKoKBU3pc: {
|
|
166
|
+
name: "LeoDex",
|
|
167
|
+
twitter: "@leodexio"
|
|
156
168
|
}
|
|
157
169
|
};
|
|
158
170
|
var lpAliasMap = {
|
package/dist/consts.js
CHANGED
|
@@ -96,6 +96,10 @@ var brokerAliasMap = {
|
|
|
96
96
|
name: "SwapKit",
|
|
97
97
|
twitter: "@SwapKitPowered"
|
|
98
98
|
},
|
|
99
|
+
cFPDEjR88FyRi7V5NDatoMAyMCczgiyoXwiJA4LZLrR7e6RW4: {
|
|
100
|
+
name: "Bitget",
|
|
101
|
+
twitter: "@BitgetWallet"
|
|
102
|
+
},
|
|
99
103
|
cFL4To8Uow6B1hk4dNrhWhvKpkBtnUTrVdWCEKCaXiXMMztjM: {
|
|
100
104
|
name: "SwapKit",
|
|
101
105
|
twitter: "@SwapKitPowered"
|
|
@@ -119,6 +123,14 @@ var brokerAliasMap = {
|
|
|
119
123
|
cFPD5DrrsHb7Wi5nmBcFuPDcGRsWhv5Bz6vvzGqFYPFhbR3Sw: {
|
|
120
124
|
name: "Squid",
|
|
121
125
|
twitter: "@squidrouter"
|
|
126
|
+
},
|
|
127
|
+
cFJZvt5AiEGwUiFFNxhDuLRcgC1WBR6tE7gaQQfe8dqbzoYkx: {
|
|
128
|
+
name: "Symbiosis",
|
|
129
|
+
twitter: "@symbiosis_fi"
|
|
130
|
+
},
|
|
131
|
+
cFLvH2ZA3J5dsDdrDuV1Eyh9Jk6yasijtKQagGhMDKoKBU3pc: {
|
|
132
|
+
name: "LeoDex",
|
|
133
|
+
twitter: "@leodexio"
|
|
122
134
|
}
|
|
123
135
|
};
|
|
124
136
|
var lpAliasMap = {
|
package/dist/ss58.cjs
CHANGED
|
@@ -26,14 +26,14 @@ __export(ss58_exports, {
|
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(ss58_exports);
|
|
28
28
|
|
|
29
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
29
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
|
|
30
|
+
function isBytes(a) {
|
|
31
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
32
|
+
}
|
|
30
33
|
function anumber(n) {
|
|
31
34
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
32
35
|
throw new Error("positive integer expected, got " + n);
|
|
33
36
|
}
|
|
34
|
-
function isBytes(a) {
|
|
35
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
36
|
-
}
|
|
37
37
|
function abytes(b, ...lengths) {
|
|
38
38
|
if (!isBytes(b))
|
|
39
39
|
throw new Error("Uint8Array expected");
|
|
@@ -53,24 +53,29 @@ function aoutput(out, instance) {
|
|
|
53
53
|
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/utils.js
|
|
58
56
|
function u32(arr) {
|
|
59
57
|
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
60
58
|
}
|
|
59
|
+
function clean(...arrays) {
|
|
60
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
61
|
+
arrays[i].fill(0);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
61
64
|
var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
62
65
|
function byteSwap(word) {
|
|
63
66
|
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
64
67
|
}
|
|
65
|
-
var
|
|
68
|
+
var swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n);
|
|
66
69
|
function byteSwap32(arr) {
|
|
67
70
|
for (let i = 0; i < arr.length; i++) {
|
|
68
71
|
arr[i] = byteSwap(arr[i]);
|
|
69
72
|
}
|
|
73
|
+
return arr;
|
|
70
74
|
}
|
|
75
|
+
var swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
71
76
|
function utf8ToBytes(str) {
|
|
72
77
|
if (typeof str !== "string")
|
|
73
|
-
throw new Error("
|
|
78
|
+
throw new Error("string expected");
|
|
74
79
|
return new Uint8Array(new TextEncoder().encode(str));
|
|
75
80
|
}
|
|
76
81
|
function toBytes(data) {
|
|
@@ -80,12 +85,8 @@ function toBytes(data) {
|
|
|
80
85
|
return data;
|
|
81
86
|
}
|
|
82
87
|
var Hash = class {
|
|
83
|
-
// Safe version that clones internal state
|
|
84
|
-
clone() {
|
|
85
|
-
return this._cloneInto();
|
|
86
|
-
}
|
|
87
88
|
};
|
|
88
|
-
function
|
|
89
|
+
function createOptHasher(hashCons) {
|
|
89
90
|
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
90
91
|
const tmp = hashCons({});
|
|
91
92
|
hashC.outputLen = tmp.outputLen;
|
|
@@ -94,8 +95,8 @@ function wrapConstructorWithOpts(hashCons) {
|
|
|
94
95
|
return hashC;
|
|
95
96
|
}
|
|
96
97
|
|
|
97
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
98
|
-
var
|
|
98
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_blake.js
|
|
99
|
+
var BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
99
100
|
0,
|
|
100
101
|
1,
|
|
101
102
|
2,
|
|
@@ -354,102 +355,8 @@ var SIGMA = /* @__PURE__ */ new Uint8Array([
|
|
|
354
355
|
1,
|
|
355
356
|
9
|
|
356
357
|
]);
|
|
357
|
-
var BLAKE = class extends Hash {
|
|
358
|
-
constructor(blockLen, outputLen, opts = {}, keyLen, saltLen, persLen) {
|
|
359
|
-
super();
|
|
360
|
-
this.blockLen = blockLen;
|
|
361
|
-
this.outputLen = outputLen;
|
|
362
|
-
this.length = 0;
|
|
363
|
-
this.pos = 0;
|
|
364
|
-
this.finished = false;
|
|
365
|
-
this.destroyed = false;
|
|
366
|
-
anumber(blockLen);
|
|
367
|
-
anumber(outputLen);
|
|
368
|
-
anumber(keyLen);
|
|
369
|
-
if (outputLen < 0 || outputLen > keyLen)
|
|
370
|
-
throw new Error("outputLen bigger than keyLen");
|
|
371
|
-
if (opts.key !== void 0 && (opts.key.length < 1 || opts.key.length > keyLen))
|
|
372
|
-
throw new Error("key length must be undefined or 1.." + keyLen);
|
|
373
|
-
if (opts.salt !== void 0 && opts.salt.length !== saltLen)
|
|
374
|
-
throw new Error("salt must be undefined or " + saltLen);
|
|
375
|
-
if (opts.personalization !== void 0 && opts.personalization.length !== persLen)
|
|
376
|
-
throw new Error("personalization must be undefined or " + persLen);
|
|
377
|
-
this.buffer = new Uint8Array(blockLen);
|
|
378
|
-
this.buffer32 = u32(this.buffer);
|
|
379
|
-
}
|
|
380
|
-
update(data) {
|
|
381
|
-
aexists(this);
|
|
382
|
-
const { blockLen, buffer, buffer32 } = this;
|
|
383
|
-
data = toBytes(data);
|
|
384
|
-
const len = data.length;
|
|
385
|
-
const offset = data.byteOffset;
|
|
386
|
-
const buf = data.buffer;
|
|
387
|
-
for (let pos = 0; pos < len; ) {
|
|
388
|
-
if (this.pos === blockLen) {
|
|
389
|
-
if (!isLE)
|
|
390
|
-
byteSwap32(buffer32);
|
|
391
|
-
this.compress(buffer32, 0, false);
|
|
392
|
-
if (!isLE)
|
|
393
|
-
byteSwap32(buffer32);
|
|
394
|
-
this.pos = 0;
|
|
395
|
-
}
|
|
396
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
397
|
-
const dataOffset = offset + pos;
|
|
398
|
-
if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
|
|
399
|
-
const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
|
|
400
|
-
if (!isLE)
|
|
401
|
-
byteSwap32(data32);
|
|
402
|
-
for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
|
|
403
|
-
this.length += blockLen;
|
|
404
|
-
this.compress(data32, pos32, false);
|
|
405
|
-
}
|
|
406
|
-
if (!isLE)
|
|
407
|
-
byteSwap32(data32);
|
|
408
|
-
continue;
|
|
409
|
-
}
|
|
410
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
411
|
-
this.pos += take;
|
|
412
|
-
this.length += take;
|
|
413
|
-
pos += take;
|
|
414
|
-
}
|
|
415
|
-
return this;
|
|
416
|
-
}
|
|
417
|
-
digestInto(out) {
|
|
418
|
-
aexists(this);
|
|
419
|
-
aoutput(out, this);
|
|
420
|
-
const { pos, buffer32 } = this;
|
|
421
|
-
this.finished = true;
|
|
422
|
-
this.buffer.subarray(pos).fill(0);
|
|
423
|
-
if (!isLE)
|
|
424
|
-
byteSwap32(buffer32);
|
|
425
|
-
this.compress(buffer32, 0, true);
|
|
426
|
-
if (!isLE)
|
|
427
|
-
byteSwap32(buffer32);
|
|
428
|
-
const out32 = u32(out);
|
|
429
|
-
this.get().forEach((v, i) => out32[i] = byteSwapIfBE(v));
|
|
430
|
-
}
|
|
431
|
-
digest() {
|
|
432
|
-
const { buffer, outputLen } = this;
|
|
433
|
-
this.digestInto(buffer);
|
|
434
|
-
const res = buffer.slice(0, outputLen);
|
|
435
|
-
this.destroy();
|
|
436
|
-
return res;
|
|
437
|
-
}
|
|
438
|
-
_cloneInto(to) {
|
|
439
|
-
const { buffer, length, finished, destroyed, outputLen, pos } = this;
|
|
440
|
-
to || (to = new this.constructor({ dkLen: outputLen }));
|
|
441
|
-
to.set(...this.get());
|
|
442
|
-
to.length = length;
|
|
443
|
-
to.finished = finished;
|
|
444
|
-
to.destroyed = destroyed;
|
|
445
|
-
to.outputLen = outputLen;
|
|
446
|
-
to.buffer.set(buffer);
|
|
447
|
-
to.pos = pos;
|
|
448
|
-
return to;
|
|
449
|
-
}
|
|
450
|
-
};
|
|
451
358
|
|
|
452
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
359
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
|
|
453
360
|
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
454
361
|
var _32n = /* @__PURE__ */ BigInt(32);
|
|
455
362
|
function fromBig(n, le = false) {
|
|
@@ -457,66 +364,21 @@ function fromBig(n, le = false) {
|
|
|
457
364
|
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
458
365
|
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
459
366
|
}
|
|
460
|
-
function split(lst, le = false) {
|
|
461
|
-
let Ah = new Uint32Array(lst.length);
|
|
462
|
-
let Al = new Uint32Array(lst.length);
|
|
463
|
-
for (let i = 0; i < lst.length; i++) {
|
|
464
|
-
const { h, l } = fromBig(lst[i], le);
|
|
465
|
-
[Ah[i], Al[i]] = [h, l];
|
|
466
|
-
}
|
|
467
|
-
return [Ah, Al];
|
|
468
|
-
}
|
|
469
|
-
var toBig = (h, l) => BigInt(h >>> 0) << _32n | BigInt(l >>> 0);
|
|
470
|
-
var shrSH = (h, _l, s) => h >>> s;
|
|
471
|
-
var shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
472
367
|
var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
473
368
|
var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
474
369
|
var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
475
370
|
var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
476
371
|
var rotr32H = (_h, l) => l;
|
|
477
372
|
var rotr32L = (h, _l) => h;
|
|
478
|
-
var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
479
|
-
var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
480
|
-
var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
481
|
-
var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
482
373
|
function add(Ah, Al, Bh, Bl) {
|
|
483
374
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
484
375
|
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
485
376
|
}
|
|
486
377
|
var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
487
378
|
var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
488
|
-
var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
489
|
-
var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
490
|
-
var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
491
|
-
var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
492
|
-
var u64 = {
|
|
493
|
-
fromBig,
|
|
494
|
-
split,
|
|
495
|
-
toBig,
|
|
496
|
-
shrSH,
|
|
497
|
-
shrSL,
|
|
498
|
-
rotrSH,
|
|
499
|
-
rotrSL,
|
|
500
|
-
rotrBH,
|
|
501
|
-
rotrBL,
|
|
502
|
-
rotr32H,
|
|
503
|
-
rotr32L,
|
|
504
|
-
rotlSH,
|
|
505
|
-
rotlSL,
|
|
506
|
-
rotlBH,
|
|
507
|
-
rotlBL,
|
|
508
|
-
add,
|
|
509
|
-
add3L,
|
|
510
|
-
add3H,
|
|
511
|
-
add4L,
|
|
512
|
-
add4H,
|
|
513
|
-
add5H,
|
|
514
|
-
add5L
|
|
515
|
-
};
|
|
516
|
-
var u64_default = u64;
|
|
517
379
|
|
|
518
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
519
|
-
var B2B_IV = /* @__PURE__ */
|
|
380
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/blake2.js
|
|
381
|
+
var B2B_IV = /* @__PURE__ */ Uint32Array.from([
|
|
520
382
|
4089235720,
|
|
521
383
|
1779033703,
|
|
522
384
|
2227873595,
|
|
@@ -541,14 +403,14 @@ function G1b(a, b, c, d, msg, x) {
|
|
|
541
403
|
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
542
404
|
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
543
405
|
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
544
|
-
let ll =
|
|
545
|
-
Ah =
|
|
406
|
+
let ll = add3L(Al, Bl, Xl);
|
|
407
|
+
Ah = add3H(ll, Ah, Bh, Xh);
|
|
546
408
|
Al = ll | 0;
|
|
547
409
|
({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
|
|
548
|
-
({ Dh, Dl } = { Dh:
|
|
549
|
-
({ h: Ch, l: Cl } =
|
|
410
|
+
({ Dh, Dl } = { Dh: rotr32H(Dh, Dl), Dl: rotr32L(Dh, Dl) });
|
|
411
|
+
({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
|
|
550
412
|
({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
|
|
551
|
-
({ Bh, Bl } = { Bh:
|
|
413
|
+
({ Bh, Bl } = { Bh: rotrSH(Bh, Bl, 24), Bl: rotrSL(Bh, Bl, 24) });
|
|
552
414
|
BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
|
|
553
415
|
BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
|
|
554
416
|
BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
|
|
@@ -560,22 +422,118 @@ function G2b(a, b, c, d, msg, x) {
|
|
|
560
422
|
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
561
423
|
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
562
424
|
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
563
|
-
let ll =
|
|
564
|
-
Ah =
|
|
425
|
+
let ll = add3L(Al, Bl, Xl);
|
|
426
|
+
Ah = add3H(ll, Ah, Bh, Xh);
|
|
565
427
|
Al = ll | 0;
|
|
566
428
|
({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
|
|
567
|
-
({ Dh, Dl } = { Dh:
|
|
568
|
-
({ h: Ch, l: Cl } =
|
|
429
|
+
({ Dh, Dl } = { Dh: rotrSH(Dh, Dl, 16), Dl: rotrSL(Dh, Dl, 16) });
|
|
430
|
+
({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
|
|
569
431
|
({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
|
|
570
|
-
({ Bh, Bl } = { Bh:
|
|
432
|
+
({ Bh, Bl } = { Bh: rotrBH(Bh, Bl, 63), Bl: rotrBL(Bh, Bl, 63) });
|
|
571
433
|
BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
|
|
572
434
|
BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
|
|
573
435
|
BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
|
|
574
436
|
BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
|
|
575
437
|
}
|
|
576
|
-
|
|
438
|
+
function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
|
|
439
|
+
anumber(keyLen);
|
|
440
|
+
if (outputLen < 0 || outputLen > keyLen)
|
|
441
|
+
throw new Error("outputLen bigger than keyLen");
|
|
442
|
+
const { key, salt, personalization } = opts;
|
|
443
|
+
if (key !== void 0 && (key.length < 1 || key.length > keyLen))
|
|
444
|
+
throw new Error("key length must be undefined or 1.." + keyLen);
|
|
445
|
+
if (salt !== void 0 && salt.length !== saltLen)
|
|
446
|
+
throw new Error("salt must be undefined or " + saltLen);
|
|
447
|
+
if (personalization !== void 0 && personalization.length !== persLen)
|
|
448
|
+
throw new Error("personalization must be undefined or " + persLen);
|
|
449
|
+
}
|
|
450
|
+
var BLAKE2 = class extends Hash {
|
|
451
|
+
constructor(blockLen, outputLen) {
|
|
452
|
+
super();
|
|
453
|
+
this.finished = false;
|
|
454
|
+
this.destroyed = false;
|
|
455
|
+
this.length = 0;
|
|
456
|
+
this.pos = 0;
|
|
457
|
+
anumber(blockLen);
|
|
458
|
+
anumber(outputLen);
|
|
459
|
+
this.blockLen = blockLen;
|
|
460
|
+
this.outputLen = outputLen;
|
|
461
|
+
this.buffer = new Uint8Array(blockLen);
|
|
462
|
+
this.buffer32 = u32(this.buffer);
|
|
463
|
+
}
|
|
464
|
+
update(data) {
|
|
465
|
+
aexists(this);
|
|
466
|
+
data = toBytes(data);
|
|
467
|
+
abytes(data);
|
|
468
|
+
const { blockLen, buffer, buffer32 } = this;
|
|
469
|
+
const len = data.length;
|
|
470
|
+
const offset = data.byteOffset;
|
|
471
|
+
const buf = data.buffer;
|
|
472
|
+
for (let pos = 0; pos < len; ) {
|
|
473
|
+
if (this.pos === blockLen) {
|
|
474
|
+
swap32IfBE(buffer32);
|
|
475
|
+
this.compress(buffer32, 0, false);
|
|
476
|
+
swap32IfBE(buffer32);
|
|
477
|
+
this.pos = 0;
|
|
478
|
+
}
|
|
479
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
480
|
+
const dataOffset = offset + pos;
|
|
481
|
+
if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
|
|
482
|
+
const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
|
|
483
|
+
swap32IfBE(data32);
|
|
484
|
+
for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
|
|
485
|
+
this.length += blockLen;
|
|
486
|
+
this.compress(data32, pos32, false);
|
|
487
|
+
}
|
|
488
|
+
swap32IfBE(data32);
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
492
|
+
this.pos += take;
|
|
493
|
+
this.length += take;
|
|
494
|
+
pos += take;
|
|
495
|
+
}
|
|
496
|
+
return this;
|
|
497
|
+
}
|
|
498
|
+
digestInto(out) {
|
|
499
|
+
aexists(this);
|
|
500
|
+
aoutput(out, this);
|
|
501
|
+
const { pos, buffer32 } = this;
|
|
502
|
+
this.finished = true;
|
|
503
|
+
clean(this.buffer.subarray(pos));
|
|
504
|
+
swap32IfBE(buffer32);
|
|
505
|
+
this.compress(buffer32, 0, true);
|
|
506
|
+
swap32IfBE(buffer32);
|
|
507
|
+
const out32 = u32(out);
|
|
508
|
+
this.get().forEach((v, i) => out32[i] = swap8IfBE(v));
|
|
509
|
+
}
|
|
510
|
+
digest() {
|
|
511
|
+
const { buffer, outputLen } = this;
|
|
512
|
+
this.digestInto(buffer);
|
|
513
|
+
const res = buffer.slice(0, outputLen);
|
|
514
|
+
this.destroy();
|
|
515
|
+
return res;
|
|
516
|
+
}
|
|
517
|
+
_cloneInto(to) {
|
|
518
|
+
const { buffer, length, finished, destroyed, outputLen, pos } = this;
|
|
519
|
+
to || (to = new this.constructor({ dkLen: outputLen }));
|
|
520
|
+
to.set(...this.get());
|
|
521
|
+
to.buffer.set(buffer);
|
|
522
|
+
to.destroyed = destroyed;
|
|
523
|
+
to.finished = finished;
|
|
524
|
+
to.length = length;
|
|
525
|
+
to.pos = pos;
|
|
526
|
+
to.outputLen = outputLen;
|
|
527
|
+
return to;
|
|
528
|
+
}
|
|
529
|
+
clone() {
|
|
530
|
+
return this._cloneInto();
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
var BLAKE2b = class extends BLAKE2 {
|
|
577
534
|
constructor(opts = {}) {
|
|
578
|
-
|
|
535
|
+
const olen = opts.dkLen === void 0 ? 64 : opts.dkLen;
|
|
536
|
+
super(128, olen);
|
|
579
537
|
this.v0l = B2B_IV[0] | 0;
|
|
580
538
|
this.v0h = B2B_IV[1] | 0;
|
|
581
539
|
this.v1l = B2B_IV[2] | 0;
|
|
@@ -592,25 +550,33 @@ var BLAKE2b = class extends BLAKE {
|
|
|
592
550
|
this.v6h = B2B_IV[13] | 0;
|
|
593
551
|
this.v7l = B2B_IV[14] | 0;
|
|
594
552
|
this.v7h = B2B_IV[15] | 0;
|
|
595
|
-
|
|
553
|
+
checkBlake2Opts(olen, opts, 64, 16, 16);
|
|
554
|
+
let { key, personalization, salt } = opts;
|
|
555
|
+
let keyLength = 0;
|
|
556
|
+
if (key !== void 0) {
|
|
557
|
+
key = toBytes(key);
|
|
558
|
+
keyLength = key.length;
|
|
559
|
+
}
|
|
596
560
|
this.v0l ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
|
|
597
|
-
if (
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
this.
|
|
601
|
-
this.
|
|
602
|
-
this.
|
|
561
|
+
if (salt !== void 0) {
|
|
562
|
+
salt = toBytes(salt);
|
|
563
|
+
const slt = u32(salt);
|
|
564
|
+
this.v4l ^= swap8IfBE(slt[0]);
|
|
565
|
+
this.v4h ^= swap8IfBE(slt[1]);
|
|
566
|
+
this.v5l ^= swap8IfBE(slt[2]);
|
|
567
|
+
this.v5h ^= swap8IfBE(slt[3]);
|
|
603
568
|
}
|
|
604
|
-
if (
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
this.
|
|
608
|
-
this.
|
|
609
|
-
this.
|
|
569
|
+
if (personalization !== void 0) {
|
|
570
|
+
personalization = toBytes(personalization);
|
|
571
|
+
const pers = u32(personalization);
|
|
572
|
+
this.v6l ^= swap8IfBE(pers[0]);
|
|
573
|
+
this.v6h ^= swap8IfBE(pers[1]);
|
|
574
|
+
this.v7l ^= swap8IfBE(pers[2]);
|
|
575
|
+
this.v7h ^= swap8IfBE(pers[3]);
|
|
610
576
|
}
|
|
611
|
-
if (
|
|
577
|
+
if (key !== void 0) {
|
|
612
578
|
const tmp = new Uint8Array(this.blockLen);
|
|
613
|
-
tmp.set(
|
|
579
|
+
tmp.set(key);
|
|
614
580
|
this.update(tmp);
|
|
615
581
|
}
|
|
616
582
|
}
|
|
@@ -641,7 +607,7 @@ var BLAKE2b = class extends BLAKE {
|
|
|
641
607
|
compress(msg, offset, isLast) {
|
|
642
608
|
this.get().forEach((v, i) => BBUF[i] = v);
|
|
643
609
|
BBUF.set(B2B_IV, 16);
|
|
644
|
-
let { h, l } =
|
|
610
|
+
let { h, l } = fromBig(BigInt(this.length));
|
|
645
611
|
BBUF[24] = B2B_IV[8] ^ l;
|
|
646
612
|
BBUF[25] = B2B_IV[9] ^ h;
|
|
647
613
|
if (isLast) {
|
|
@@ -649,7 +615,7 @@ var BLAKE2b = class extends BLAKE {
|
|
|
649
615
|
BBUF[29] = ~BBUF[29];
|
|
650
616
|
}
|
|
651
617
|
let j = 0;
|
|
652
|
-
const s =
|
|
618
|
+
const s = BSIGMA;
|
|
653
619
|
for (let i = 0; i < 12; i++) {
|
|
654
620
|
G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
|
|
655
621
|
G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
|
|
@@ -684,15 +650,18 @@ var BLAKE2b = class extends BLAKE {
|
|
|
684
650
|
this.v6h ^= BBUF[13] ^ BBUF[29];
|
|
685
651
|
this.v7l ^= BBUF[14] ^ BBUF[30];
|
|
686
652
|
this.v7h ^= BBUF[15] ^ BBUF[31];
|
|
687
|
-
BBUF
|
|
653
|
+
clean(BBUF);
|
|
688
654
|
}
|
|
689
655
|
destroy() {
|
|
690
656
|
this.destroyed = true;
|
|
691
|
-
this.buffer32
|
|
657
|
+
clean(this.buffer32);
|
|
692
658
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
693
659
|
}
|
|
694
660
|
};
|
|
695
|
-
var blake2b = /* @__PURE__ */
|
|
661
|
+
var blake2b = /* @__PURE__ */ createOptHasher((opts) => new BLAKE2b(opts));
|
|
662
|
+
|
|
663
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/blake2b.js
|
|
664
|
+
var blake2b2 = blake2b;
|
|
696
665
|
|
|
697
666
|
// src/guard.ts
|
|
698
667
|
var createIsGuard = (type) => (value) => typeof value === type;
|
|
@@ -768,7 +737,7 @@ var MAX_PREFIX = 16383;
|
|
|
768
737
|
var RESERVED_PREFIXES = [46, 47];
|
|
769
738
|
var computeChecksum = (data) => {
|
|
770
739
|
const checksumPrefix = [83, 83, 53, 56, 80, 82, 69];
|
|
771
|
-
const checksum =
|
|
740
|
+
const checksum = blake2b2(new Uint8Array([...checksumPrefix, ...data]));
|
|
772
741
|
return checksum.slice(0, CHECKSUM_BYTE_LENGTH);
|
|
773
742
|
};
|
|
774
743
|
var decode2 = (input) => {
|
package/dist/ss58.js
CHANGED
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
} from "./chunk-ZHIKNZLU.js";
|
|
12
12
|
import "./chunk-HBIFE4XN.js";
|
|
13
13
|
|
|
14
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
14
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
|
|
15
|
+
function isBytes(a) {
|
|
16
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
17
|
+
}
|
|
15
18
|
function anumber(n) {
|
|
16
19
|
if (!Number.isSafeInteger(n) || n < 0)
|
|
17
20
|
throw new Error("positive integer expected, got " + n);
|
|
18
21
|
}
|
|
19
|
-
function isBytes(a) {
|
|
20
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
21
|
-
}
|
|
22
22
|
function abytes(b, ...lengths) {
|
|
23
23
|
if (!isBytes(b))
|
|
24
24
|
throw new Error("Uint8Array expected");
|
|
@@ -38,24 +38,29 @@ function aoutput(out, instance) {
|
|
|
38
38
|
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.7.1/node_modules/@noble/hashes/esm/utils.js
|
|
43
41
|
function u32(arr) {
|
|
44
42
|
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
45
43
|
}
|
|
44
|
+
function clean(...arrays) {
|
|
45
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
46
|
+
arrays[i].fill(0);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
46
49
|
var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
47
50
|
function byteSwap(word) {
|
|
48
51
|
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
49
52
|
}
|
|
50
|
-
var
|
|
53
|
+
var swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n);
|
|
51
54
|
function byteSwap32(arr) {
|
|
52
55
|
for (let i = 0; i < arr.length; i++) {
|
|
53
56
|
arr[i] = byteSwap(arr[i]);
|
|
54
57
|
}
|
|
58
|
+
return arr;
|
|
55
59
|
}
|
|
60
|
+
var swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
56
61
|
function utf8ToBytes(str) {
|
|
57
62
|
if (typeof str !== "string")
|
|
58
|
-
throw new Error("
|
|
63
|
+
throw new Error("string expected");
|
|
59
64
|
return new Uint8Array(new TextEncoder().encode(str));
|
|
60
65
|
}
|
|
61
66
|
function toBytes(data) {
|
|
@@ -65,12 +70,8 @@ function toBytes(data) {
|
|
|
65
70
|
return data;
|
|
66
71
|
}
|
|
67
72
|
var Hash = class {
|
|
68
|
-
// Safe version that clones internal state
|
|
69
|
-
clone() {
|
|
70
|
-
return this._cloneInto();
|
|
71
|
-
}
|
|
72
73
|
};
|
|
73
|
-
function
|
|
74
|
+
function createOptHasher(hashCons) {
|
|
74
75
|
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
75
76
|
const tmp = hashCons({});
|
|
76
77
|
hashC.outputLen = tmp.outputLen;
|
|
@@ -79,8 +80,8 @@ function wrapConstructorWithOpts(hashCons) {
|
|
|
79
80
|
return hashC;
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
83
|
-
var
|
|
83
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_blake.js
|
|
84
|
+
var BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
84
85
|
0,
|
|
85
86
|
1,
|
|
86
87
|
2,
|
|
@@ -339,102 +340,8 @@ var SIGMA = /* @__PURE__ */ new Uint8Array([
|
|
|
339
340
|
1,
|
|
340
341
|
9
|
|
341
342
|
]);
|
|
342
|
-
var BLAKE = class extends Hash {
|
|
343
|
-
constructor(blockLen, outputLen, opts = {}, keyLen, saltLen, persLen) {
|
|
344
|
-
super();
|
|
345
|
-
this.blockLen = blockLen;
|
|
346
|
-
this.outputLen = outputLen;
|
|
347
|
-
this.length = 0;
|
|
348
|
-
this.pos = 0;
|
|
349
|
-
this.finished = false;
|
|
350
|
-
this.destroyed = false;
|
|
351
|
-
anumber(blockLen);
|
|
352
|
-
anumber(outputLen);
|
|
353
|
-
anumber(keyLen);
|
|
354
|
-
if (outputLen < 0 || outputLen > keyLen)
|
|
355
|
-
throw new Error("outputLen bigger than keyLen");
|
|
356
|
-
if (opts.key !== void 0 && (opts.key.length < 1 || opts.key.length > keyLen))
|
|
357
|
-
throw new Error("key length must be undefined or 1.." + keyLen);
|
|
358
|
-
if (opts.salt !== void 0 && opts.salt.length !== saltLen)
|
|
359
|
-
throw new Error("salt must be undefined or " + saltLen);
|
|
360
|
-
if (opts.personalization !== void 0 && opts.personalization.length !== persLen)
|
|
361
|
-
throw new Error("personalization must be undefined or " + persLen);
|
|
362
|
-
this.buffer = new Uint8Array(blockLen);
|
|
363
|
-
this.buffer32 = u32(this.buffer);
|
|
364
|
-
}
|
|
365
|
-
update(data) {
|
|
366
|
-
aexists(this);
|
|
367
|
-
const { blockLen, buffer, buffer32 } = this;
|
|
368
|
-
data = toBytes(data);
|
|
369
|
-
const len = data.length;
|
|
370
|
-
const offset = data.byteOffset;
|
|
371
|
-
const buf = data.buffer;
|
|
372
|
-
for (let pos = 0; pos < len; ) {
|
|
373
|
-
if (this.pos === blockLen) {
|
|
374
|
-
if (!isLE)
|
|
375
|
-
byteSwap32(buffer32);
|
|
376
|
-
this.compress(buffer32, 0, false);
|
|
377
|
-
if (!isLE)
|
|
378
|
-
byteSwap32(buffer32);
|
|
379
|
-
this.pos = 0;
|
|
380
|
-
}
|
|
381
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
382
|
-
const dataOffset = offset + pos;
|
|
383
|
-
if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
|
|
384
|
-
const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
|
|
385
|
-
if (!isLE)
|
|
386
|
-
byteSwap32(data32);
|
|
387
|
-
for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
|
|
388
|
-
this.length += blockLen;
|
|
389
|
-
this.compress(data32, pos32, false);
|
|
390
|
-
}
|
|
391
|
-
if (!isLE)
|
|
392
|
-
byteSwap32(data32);
|
|
393
|
-
continue;
|
|
394
|
-
}
|
|
395
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
396
|
-
this.pos += take;
|
|
397
|
-
this.length += take;
|
|
398
|
-
pos += take;
|
|
399
|
-
}
|
|
400
|
-
return this;
|
|
401
|
-
}
|
|
402
|
-
digestInto(out) {
|
|
403
|
-
aexists(this);
|
|
404
|
-
aoutput(out, this);
|
|
405
|
-
const { pos, buffer32 } = this;
|
|
406
|
-
this.finished = true;
|
|
407
|
-
this.buffer.subarray(pos).fill(0);
|
|
408
|
-
if (!isLE)
|
|
409
|
-
byteSwap32(buffer32);
|
|
410
|
-
this.compress(buffer32, 0, true);
|
|
411
|
-
if (!isLE)
|
|
412
|
-
byteSwap32(buffer32);
|
|
413
|
-
const out32 = u32(out);
|
|
414
|
-
this.get().forEach((v, i) => out32[i] = byteSwapIfBE(v));
|
|
415
|
-
}
|
|
416
|
-
digest() {
|
|
417
|
-
const { buffer, outputLen } = this;
|
|
418
|
-
this.digestInto(buffer);
|
|
419
|
-
const res = buffer.slice(0, outputLen);
|
|
420
|
-
this.destroy();
|
|
421
|
-
return res;
|
|
422
|
-
}
|
|
423
|
-
_cloneInto(to) {
|
|
424
|
-
const { buffer, length, finished, destroyed, outputLen, pos } = this;
|
|
425
|
-
to || (to = new this.constructor({ dkLen: outputLen }));
|
|
426
|
-
to.set(...this.get());
|
|
427
|
-
to.length = length;
|
|
428
|
-
to.finished = finished;
|
|
429
|
-
to.destroyed = destroyed;
|
|
430
|
-
to.outputLen = outputLen;
|
|
431
|
-
to.buffer.set(buffer);
|
|
432
|
-
to.pos = pos;
|
|
433
|
-
return to;
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
343
|
|
|
437
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
344
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
|
|
438
345
|
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
439
346
|
var _32n = /* @__PURE__ */ BigInt(32);
|
|
440
347
|
function fromBig(n, le = false) {
|
|
@@ -442,66 +349,21 @@ function fromBig(n, le = false) {
|
|
|
442
349
|
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
443
350
|
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
444
351
|
}
|
|
445
|
-
function split(lst, le = false) {
|
|
446
|
-
let Ah = new Uint32Array(lst.length);
|
|
447
|
-
let Al = new Uint32Array(lst.length);
|
|
448
|
-
for (let i = 0; i < lst.length; i++) {
|
|
449
|
-
const { h, l } = fromBig(lst[i], le);
|
|
450
|
-
[Ah[i], Al[i]] = [h, l];
|
|
451
|
-
}
|
|
452
|
-
return [Ah, Al];
|
|
453
|
-
}
|
|
454
|
-
var toBig = (h, l) => BigInt(h >>> 0) << _32n | BigInt(l >>> 0);
|
|
455
|
-
var shrSH = (h, _l, s) => h >>> s;
|
|
456
|
-
var shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
457
352
|
var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
458
353
|
var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
459
354
|
var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
460
355
|
var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
461
356
|
var rotr32H = (_h, l) => l;
|
|
462
357
|
var rotr32L = (h, _l) => h;
|
|
463
|
-
var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
464
|
-
var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
465
|
-
var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
466
|
-
var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
467
358
|
function add(Ah, Al, Bh, Bl) {
|
|
468
359
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
469
360
|
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
470
361
|
}
|
|
471
362
|
var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
472
363
|
var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
473
|
-
var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
474
|
-
var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
475
|
-
var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
476
|
-
var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
477
|
-
var u64 = {
|
|
478
|
-
fromBig,
|
|
479
|
-
split,
|
|
480
|
-
toBig,
|
|
481
|
-
shrSH,
|
|
482
|
-
shrSL,
|
|
483
|
-
rotrSH,
|
|
484
|
-
rotrSL,
|
|
485
|
-
rotrBH,
|
|
486
|
-
rotrBL,
|
|
487
|
-
rotr32H,
|
|
488
|
-
rotr32L,
|
|
489
|
-
rotlSH,
|
|
490
|
-
rotlSL,
|
|
491
|
-
rotlBH,
|
|
492
|
-
rotlBL,
|
|
493
|
-
add,
|
|
494
|
-
add3L,
|
|
495
|
-
add3H,
|
|
496
|
-
add4L,
|
|
497
|
-
add4H,
|
|
498
|
-
add5H,
|
|
499
|
-
add5L
|
|
500
|
-
};
|
|
501
|
-
var u64_default = u64;
|
|
502
364
|
|
|
503
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.
|
|
504
|
-
var B2B_IV = /* @__PURE__ */
|
|
365
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/blake2.js
|
|
366
|
+
var B2B_IV = /* @__PURE__ */ Uint32Array.from([
|
|
505
367
|
4089235720,
|
|
506
368
|
1779033703,
|
|
507
369
|
2227873595,
|
|
@@ -526,14 +388,14 @@ function G1b(a, b, c, d, msg, x) {
|
|
|
526
388
|
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
527
389
|
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
528
390
|
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
529
|
-
let ll =
|
|
530
|
-
Ah =
|
|
391
|
+
let ll = add3L(Al, Bl, Xl);
|
|
392
|
+
Ah = add3H(ll, Ah, Bh, Xh);
|
|
531
393
|
Al = ll | 0;
|
|
532
394
|
({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
|
|
533
|
-
({ Dh, Dl } = { Dh:
|
|
534
|
-
({ h: Ch, l: Cl } =
|
|
395
|
+
({ Dh, Dl } = { Dh: rotr32H(Dh, Dl), Dl: rotr32L(Dh, Dl) });
|
|
396
|
+
({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
|
|
535
397
|
({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
|
|
536
|
-
({ Bh, Bl } = { Bh:
|
|
398
|
+
({ Bh, Bl } = { Bh: rotrSH(Bh, Bl, 24), Bl: rotrSL(Bh, Bl, 24) });
|
|
537
399
|
BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
|
|
538
400
|
BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
|
|
539
401
|
BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
|
|
@@ -545,22 +407,118 @@ function G2b(a, b, c, d, msg, x) {
|
|
|
545
407
|
let Bl = BBUF[2 * b], Bh = BBUF[2 * b + 1];
|
|
546
408
|
let Cl = BBUF[2 * c], Ch = BBUF[2 * c + 1];
|
|
547
409
|
let Dl = BBUF[2 * d], Dh = BBUF[2 * d + 1];
|
|
548
|
-
let ll =
|
|
549
|
-
Ah =
|
|
410
|
+
let ll = add3L(Al, Bl, Xl);
|
|
411
|
+
Ah = add3H(ll, Ah, Bh, Xh);
|
|
550
412
|
Al = ll | 0;
|
|
551
413
|
({ Dh, Dl } = { Dh: Dh ^ Ah, Dl: Dl ^ Al });
|
|
552
|
-
({ Dh, Dl } = { Dh:
|
|
553
|
-
({ h: Ch, l: Cl } =
|
|
414
|
+
({ Dh, Dl } = { Dh: rotrSH(Dh, Dl, 16), Dl: rotrSL(Dh, Dl, 16) });
|
|
415
|
+
({ h: Ch, l: Cl } = add(Ch, Cl, Dh, Dl));
|
|
554
416
|
({ Bh, Bl } = { Bh: Bh ^ Ch, Bl: Bl ^ Cl });
|
|
555
|
-
({ Bh, Bl } = { Bh:
|
|
417
|
+
({ Bh, Bl } = { Bh: rotrBH(Bh, Bl, 63), Bl: rotrBL(Bh, Bl, 63) });
|
|
556
418
|
BBUF[2 * a] = Al, BBUF[2 * a + 1] = Ah;
|
|
557
419
|
BBUF[2 * b] = Bl, BBUF[2 * b + 1] = Bh;
|
|
558
420
|
BBUF[2 * c] = Cl, BBUF[2 * c + 1] = Ch;
|
|
559
421
|
BBUF[2 * d] = Dl, BBUF[2 * d + 1] = Dh;
|
|
560
422
|
}
|
|
561
|
-
|
|
423
|
+
function checkBlake2Opts(outputLen, opts = {}, keyLen, saltLen, persLen) {
|
|
424
|
+
anumber(keyLen);
|
|
425
|
+
if (outputLen < 0 || outputLen > keyLen)
|
|
426
|
+
throw new Error("outputLen bigger than keyLen");
|
|
427
|
+
const { key, salt, personalization } = opts;
|
|
428
|
+
if (key !== void 0 && (key.length < 1 || key.length > keyLen))
|
|
429
|
+
throw new Error("key length must be undefined or 1.." + keyLen);
|
|
430
|
+
if (salt !== void 0 && salt.length !== saltLen)
|
|
431
|
+
throw new Error("salt must be undefined or " + saltLen);
|
|
432
|
+
if (personalization !== void 0 && personalization.length !== persLen)
|
|
433
|
+
throw new Error("personalization must be undefined or " + persLen);
|
|
434
|
+
}
|
|
435
|
+
var BLAKE2 = class extends Hash {
|
|
436
|
+
constructor(blockLen, outputLen) {
|
|
437
|
+
super();
|
|
438
|
+
this.finished = false;
|
|
439
|
+
this.destroyed = false;
|
|
440
|
+
this.length = 0;
|
|
441
|
+
this.pos = 0;
|
|
442
|
+
anumber(blockLen);
|
|
443
|
+
anumber(outputLen);
|
|
444
|
+
this.blockLen = blockLen;
|
|
445
|
+
this.outputLen = outputLen;
|
|
446
|
+
this.buffer = new Uint8Array(blockLen);
|
|
447
|
+
this.buffer32 = u32(this.buffer);
|
|
448
|
+
}
|
|
449
|
+
update(data) {
|
|
450
|
+
aexists(this);
|
|
451
|
+
data = toBytes(data);
|
|
452
|
+
abytes(data);
|
|
453
|
+
const { blockLen, buffer, buffer32 } = this;
|
|
454
|
+
const len = data.length;
|
|
455
|
+
const offset = data.byteOffset;
|
|
456
|
+
const buf = data.buffer;
|
|
457
|
+
for (let pos = 0; pos < len; ) {
|
|
458
|
+
if (this.pos === blockLen) {
|
|
459
|
+
swap32IfBE(buffer32);
|
|
460
|
+
this.compress(buffer32, 0, false);
|
|
461
|
+
swap32IfBE(buffer32);
|
|
462
|
+
this.pos = 0;
|
|
463
|
+
}
|
|
464
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
465
|
+
const dataOffset = offset + pos;
|
|
466
|
+
if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
|
|
467
|
+
const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
|
|
468
|
+
swap32IfBE(data32);
|
|
469
|
+
for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
|
|
470
|
+
this.length += blockLen;
|
|
471
|
+
this.compress(data32, pos32, false);
|
|
472
|
+
}
|
|
473
|
+
swap32IfBE(data32);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
477
|
+
this.pos += take;
|
|
478
|
+
this.length += take;
|
|
479
|
+
pos += take;
|
|
480
|
+
}
|
|
481
|
+
return this;
|
|
482
|
+
}
|
|
483
|
+
digestInto(out) {
|
|
484
|
+
aexists(this);
|
|
485
|
+
aoutput(out, this);
|
|
486
|
+
const { pos, buffer32 } = this;
|
|
487
|
+
this.finished = true;
|
|
488
|
+
clean(this.buffer.subarray(pos));
|
|
489
|
+
swap32IfBE(buffer32);
|
|
490
|
+
this.compress(buffer32, 0, true);
|
|
491
|
+
swap32IfBE(buffer32);
|
|
492
|
+
const out32 = u32(out);
|
|
493
|
+
this.get().forEach((v, i) => out32[i] = swap8IfBE(v));
|
|
494
|
+
}
|
|
495
|
+
digest() {
|
|
496
|
+
const { buffer, outputLen } = this;
|
|
497
|
+
this.digestInto(buffer);
|
|
498
|
+
const res = buffer.slice(0, outputLen);
|
|
499
|
+
this.destroy();
|
|
500
|
+
return res;
|
|
501
|
+
}
|
|
502
|
+
_cloneInto(to) {
|
|
503
|
+
const { buffer, length, finished, destroyed, outputLen, pos } = this;
|
|
504
|
+
to || (to = new this.constructor({ dkLen: outputLen }));
|
|
505
|
+
to.set(...this.get());
|
|
506
|
+
to.buffer.set(buffer);
|
|
507
|
+
to.destroyed = destroyed;
|
|
508
|
+
to.finished = finished;
|
|
509
|
+
to.length = length;
|
|
510
|
+
to.pos = pos;
|
|
511
|
+
to.outputLen = outputLen;
|
|
512
|
+
return to;
|
|
513
|
+
}
|
|
514
|
+
clone() {
|
|
515
|
+
return this._cloneInto();
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
var BLAKE2b = class extends BLAKE2 {
|
|
562
519
|
constructor(opts = {}) {
|
|
563
|
-
|
|
520
|
+
const olen = opts.dkLen === void 0 ? 64 : opts.dkLen;
|
|
521
|
+
super(128, olen);
|
|
564
522
|
this.v0l = B2B_IV[0] | 0;
|
|
565
523
|
this.v0h = B2B_IV[1] | 0;
|
|
566
524
|
this.v1l = B2B_IV[2] | 0;
|
|
@@ -577,25 +535,33 @@ var BLAKE2b = class extends BLAKE {
|
|
|
577
535
|
this.v6h = B2B_IV[13] | 0;
|
|
578
536
|
this.v7l = B2B_IV[14] | 0;
|
|
579
537
|
this.v7h = B2B_IV[15] | 0;
|
|
580
|
-
|
|
538
|
+
checkBlake2Opts(olen, opts, 64, 16, 16);
|
|
539
|
+
let { key, personalization, salt } = opts;
|
|
540
|
+
let keyLength = 0;
|
|
541
|
+
if (key !== void 0) {
|
|
542
|
+
key = toBytes(key);
|
|
543
|
+
keyLength = key.length;
|
|
544
|
+
}
|
|
581
545
|
this.v0l ^= this.outputLen | keyLength << 8 | 1 << 16 | 1 << 24;
|
|
582
|
-
if (
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
this.
|
|
586
|
-
this.
|
|
587
|
-
this.
|
|
546
|
+
if (salt !== void 0) {
|
|
547
|
+
salt = toBytes(salt);
|
|
548
|
+
const slt = u32(salt);
|
|
549
|
+
this.v4l ^= swap8IfBE(slt[0]);
|
|
550
|
+
this.v4h ^= swap8IfBE(slt[1]);
|
|
551
|
+
this.v5l ^= swap8IfBE(slt[2]);
|
|
552
|
+
this.v5h ^= swap8IfBE(slt[3]);
|
|
588
553
|
}
|
|
589
|
-
if (
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
this.
|
|
593
|
-
this.
|
|
594
|
-
this.
|
|
554
|
+
if (personalization !== void 0) {
|
|
555
|
+
personalization = toBytes(personalization);
|
|
556
|
+
const pers = u32(personalization);
|
|
557
|
+
this.v6l ^= swap8IfBE(pers[0]);
|
|
558
|
+
this.v6h ^= swap8IfBE(pers[1]);
|
|
559
|
+
this.v7l ^= swap8IfBE(pers[2]);
|
|
560
|
+
this.v7h ^= swap8IfBE(pers[3]);
|
|
595
561
|
}
|
|
596
|
-
if (
|
|
562
|
+
if (key !== void 0) {
|
|
597
563
|
const tmp = new Uint8Array(this.blockLen);
|
|
598
|
-
tmp.set(
|
|
564
|
+
tmp.set(key);
|
|
599
565
|
this.update(tmp);
|
|
600
566
|
}
|
|
601
567
|
}
|
|
@@ -626,7 +592,7 @@ var BLAKE2b = class extends BLAKE {
|
|
|
626
592
|
compress(msg, offset, isLast) {
|
|
627
593
|
this.get().forEach((v, i) => BBUF[i] = v);
|
|
628
594
|
BBUF.set(B2B_IV, 16);
|
|
629
|
-
let { h, l } =
|
|
595
|
+
let { h, l } = fromBig(BigInt(this.length));
|
|
630
596
|
BBUF[24] = B2B_IV[8] ^ l;
|
|
631
597
|
BBUF[25] = B2B_IV[9] ^ h;
|
|
632
598
|
if (isLast) {
|
|
@@ -634,7 +600,7 @@ var BLAKE2b = class extends BLAKE {
|
|
|
634
600
|
BBUF[29] = ~BBUF[29];
|
|
635
601
|
}
|
|
636
602
|
let j = 0;
|
|
637
|
-
const s =
|
|
603
|
+
const s = BSIGMA;
|
|
638
604
|
for (let i = 0; i < 12; i++) {
|
|
639
605
|
G1b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
|
|
640
606
|
G2b(0, 4, 8, 12, msg, offset + 2 * s[j++]);
|
|
@@ -669,15 +635,18 @@ var BLAKE2b = class extends BLAKE {
|
|
|
669
635
|
this.v6h ^= BBUF[13] ^ BBUF[29];
|
|
670
636
|
this.v7l ^= BBUF[14] ^ BBUF[30];
|
|
671
637
|
this.v7h ^= BBUF[15] ^ BBUF[31];
|
|
672
|
-
BBUF
|
|
638
|
+
clean(BBUF);
|
|
673
639
|
}
|
|
674
640
|
destroy() {
|
|
675
641
|
this.destroyed = true;
|
|
676
|
-
this.buffer32
|
|
642
|
+
clean(this.buffer32);
|
|
677
643
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
678
644
|
}
|
|
679
645
|
};
|
|
680
|
-
var blake2b = /* @__PURE__ */
|
|
646
|
+
var blake2b = /* @__PURE__ */ createOptHasher((opts) => new BLAKE2b(opts));
|
|
647
|
+
|
|
648
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/blake2b.js
|
|
649
|
+
var blake2b2 = blake2b;
|
|
681
650
|
|
|
682
651
|
// src/ss58.ts
|
|
683
652
|
var CHECKSUM_BYTE_LENGTH = 2;
|
|
@@ -687,7 +656,7 @@ var MAX_PREFIX = 16383;
|
|
|
687
656
|
var RESERVED_PREFIXES = [46, 47];
|
|
688
657
|
var computeChecksum = (data) => {
|
|
689
658
|
const checksumPrefix = [83, 83, 53, 56, 80, 82, 69];
|
|
690
|
-
const checksum =
|
|
659
|
+
const checksum = blake2b2(new Uint8Array([...checksumPrefix, ...data]));
|
|
691
660
|
return checksum.slice(0, CHECKSUM_BYTE_LENGTH);
|
|
692
661
|
};
|
|
693
662
|
var decode2 = (input) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/utils",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@noble/hashes": "^1.
|
|
22
|
+
"@noble/hashes": "^1.8.0",
|
|
23
23
|
"@vitest/ui": "3.1.1"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@date-fns/utc": "^2.1.0",
|
|
27
|
-
"bignumber.js": "^9.
|
|
27
|
+
"bignumber.js": "^9.3.0",
|
|
28
28
|
"date-fns": "4.1.0"
|
|
29
29
|
},
|
|
30
30
|
"repository": "https://github.com/chainflip-io/chainflip-product-toolkit.git",
|