@nihilium/client-sdk 0.1.2 → 0.2.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.
- package/dist/{browser.esm-kreqNYRZ-CV3K9CfO-DeSbuL7e.js → browser.esm-kreqNYRZ-CV3K9CfO-DA35K2mr.js} +1 -1
- package/dist/{browser.esm-kreqNYRZ-BLoDyLFh.js → browser.esm-kreqNYRZ-CVeNVlwI.js} +18 -17
- package/dist/index-DCjxkCyO.js +48914 -0
- package/dist/{index-DFD-0QrS-BD9Z8naZ.js → index-DFD-0QrS-Ctk7QymM.js} +15 -14
- package/dist/{index-DFD-0QrS-DqRwsoRk-DaSQ-uF-.js → index-DFD-0QrS-Jw1FnMaR-D_K_-juK.js} +118 -118
- package/dist/{index-C3cHMpbE-BjZqbn-8.js → index-ToaS6unp-DgCzjWB-.js} +97 -96
- package/dist/index.d.ts +1616 -1631
- package/dist/index.mjs +35 -38
- package/dist/types-B5eO7zCS.js +78196 -0
- package/dist/types.d.ts +989 -0
- package/dist/types.mjs +29 -0
- package/package.json +5 -1
- package/dist/index-78RSe_cY.js +0 -126823
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { X as Dt, B as Ct } from "./types-B5eO7zCS.js";
|
|
2
|
+
import { b as Lt } from "./index-DCjxkCyO.js";
|
|
2
3
|
var I = Dt();
|
|
3
4
|
/**
|
|
4
5
|
* @module @zk-kit/utils
|
|
@@ -22,19 +23,19 @@ const Zt = [
|
|
|
22
23
|
"bignumber",
|
|
23
24
|
"bignumberish"
|
|
24
25
|
];
|
|
25
|
-
function
|
|
26
|
+
function mt(t) {
|
|
26
27
|
return typeof t == "number";
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
+
function Y(t) {
|
|
29
30
|
return typeof t == "string";
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function Xt(t) {
|
|
32
33
|
return typeof t == "function";
|
|
33
34
|
}
|
|
34
35
|
function kt(t) {
|
|
35
36
|
return typeof t == "object";
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function Vt(t) {
|
|
38
39
|
return kt(t) && Array.isArray(t);
|
|
39
40
|
}
|
|
40
41
|
function It(t) {
|
|
@@ -47,7 +48,7 @@ function F(t) {
|
|
|
47
48
|
return typeof t == "bigint";
|
|
48
49
|
}
|
|
49
50
|
function tt(t) {
|
|
50
|
-
if (!
|
|
51
|
+
if (!Y(t))
|
|
51
52
|
return !1;
|
|
52
53
|
try {
|
|
53
54
|
return BigInt(t), !0;
|
|
@@ -56,24 +57,24 @@ function tt(t) {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
function vt(t, e = !0) {
|
|
59
|
-
return
|
|
60
|
+
return Y(t) ? e ? /^(0x|0X)[0-9a-fA-F]+$/.test(t) : /^[0-9a-fA-F]+$/.test(t) : !1;
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
+
function Nt(t) {
|
|
62
63
|
return F(t) || tt(t);
|
|
63
64
|
}
|
|
64
65
|
function Gt(t) {
|
|
65
|
-
return
|
|
66
|
+
return mt(t) || F(t) || tt(t) || vt(t) || At(t) || It(t);
|
|
66
67
|
}
|
|
67
|
-
function
|
|
68
|
+
function Jt(t, e) {
|
|
68
69
|
switch (e) {
|
|
69
70
|
case "number":
|
|
70
|
-
return
|
|
71
|
+
return mt(t);
|
|
71
72
|
case "string":
|
|
72
|
-
return
|
|
73
|
+
return Y(t);
|
|
73
74
|
case "function":
|
|
74
|
-
return Vt(t);
|
|
75
|
-
case "Array":
|
|
76
75
|
return Xt(t);
|
|
76
|
+
case "Array":
|
|
77
|
+
return Vt(t);
|
|
77
78
|
case "Uint8Array":
|
|
78
79
|
return It(t);
|
|
79
80
|
case "Buffer":
|
|
@@ -87,14 +88,14 @@ function Nt(t, e) {
|
|
|
87
88
|
case "hexadecimal":
|
|
88
89
|
return vt(t);
|
|
89
90
|
case "bignumber":
|
|
90
|
-
return
|
|
91
|
+
return Nt(t);
|
|
91
92
|
case "bignumberish":
|
|
92
93
|
return Gt(t);
|
|
93
94
|
default:
|
|
94
95
|
return !1;
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
|
-
function
|
|
98
|
+
function Qt(t) {
|
|
98
99
|
return Zt.includes(t);
|
|
99
100
|
}
|
|
100
101
|
/**
|
|
@@ -105,16 +106,16 @@ function Jt(t) {
|
|
|
105
106
|
* @license MIT
|
|
106
107
|
* @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/utils}
|
|
107
108
|
*/
|
|
108
|
-
function
|
|
109
|
+
function Wt(t, e) {
|
|
109
110
|
if (!F(t))
|
|
110
111
|
throw new TypeError(`Parameter '${e}' is not a bigint, received type: ${typeof t}`);
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
+
function Yt(t, e, r) {
|
|
113
114
|
for (const n of r)
|
|
114
|
-
if (!
|
|
115
|
+
if (!Qt(n))
|
|
115
116
|
throw new Error(`Type '${n}' is not supported`);
|
|
116
117
|
for (const n of r)
|
|
117
|
-
if (
|
|
118
|
+
if (Jt(t, n))
|
|
118
119
|
return;
|
|
119
120
|
throw new TypeError(`Parameter '${e}' is none of the following types: ${r.join(", ")}`);
|
|
120
121
|
}
|
|
@@ -127,12 +128,12 @@ function Wt(t, e, r) {
|
|
|
127
128
|
* @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/utils}
|
|
128
129
|
*/
|
|
129
130
|
function te(t) {
|
|
130
|
-
|
|
131
|
+
Wt(t, "value");
|
|
131
132
|
let e = t.toString(16);
|
|
132
133
|
return e.length % 2 !== 0 && (e = `0${e}`), e;
|
|
133
134
|
}
|
|
134
135
|
function Ut(t) {
|
|
135
|
-
return
|
|
136
|
+
return Yt(t, "value", ["Buffer", "Uint8Array"]), BigInt(`0x${I.Buffer.from(t).reverse().toString("hex")}`);
|
|
136
137
|
}
|
|
137
138
|
function St(t, e) {
|
|
138
139
|
const r = te(t), n = Math.ceil(r.length / 2);
|
|
@@ -351,7 +352,7 @@ function ie(t, e) {
|
|
|
351
352
|
const l = r.pow(r.mul(r.square(s), t), BigInt(2 ** (n - 1)));
|
|
352
353
|
if (r.eq(l, r._negone))
|
|
353
354
|
return null;
|
|
354
|
-
let c = n,
|
|
355
|
+
let c = n, w = r.mul(t, s), b = r.mul(w, s), g = o;
|
|
355
356
|
for (; !r.eq(b, r.one); ) {
|
|
356
357
|
let _ = r.square(b), k = 1;
|
|
357
358
|
for (; !r.eq(_, r.one); )
|
|
@@ -359,22 +360,22 @@ function ie(t, e) {
|
|
|
359
360
|
s = g;
|
|
360
361
|
for (let a = 0; a < c - k - 1; a += 1)
|
|
361
362
|
s = r.square(s);
|
|
362
|
-
g = r.square(s), b = r.mul(b, g),
|
|
363
|
+
g = r.square(s), b = r.mul(b, g), w = r.mul(w, s), c = k;
|
|
363
364
|
}
|
|
364
|
-
return r.geq(
|
|
365
|
+
return r.geq(w, r.zero) ? w : r.neg(w);
|
|
365
366
|
}
|
|
366
|
-
const
|
|
367
|
+
const J = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"), y = new $t(J), q = [
|
|
367
368
|
y.e(BigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553")),
|
|
368
369
|
y.e(BigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203"))
|
|
369
370
|
], j = y.e(BigInt("168700")), et = y.e(BigInt("168696")), oe = BigInt("21888242871839275222246405745257275088614511777268538073601725287587578984328"), K = xt(oe, BigInt(3));
|
|
370
|
-
function
|
|
371
|
+
function Q(t, e) {
|
|
371
372
|
const r = y.mul(t[0], e[1]), n = y.mul(t[1], e[0]), o = y.mul(y.sub(t[1], y.mul(j, t[0])), y.add(e[0], e[1])), h = y.mul(r, n), s = y.mul(et, h), l = y.div(y.add(r, n), y.add(y.one, s)), c = y.div(y.add(o, y.sub(y.mul(j, r), n)), y.sub(y.one, s));
|
|
372
373
|
return [l, c];
|
|
373
374
|
}
|
|
374
375
|
function $(t, e) {
|
|
375
376
|
let r = [y.e(BigInt(0)), y.e(BigInt(1))], n = e, o = t;
|
|
376
377
|
for (; !Et(n); )
|
|
377
|
-
ee(n) && (r =
|
|
378
|
+
ee(n) && (r = Q(r, o)), o = Q(o, o), n = xt(n, BigInt(1));
|
|
378
379
|
return r;
|
|
379
380
|
}
|
|
380
381
|
function O(t) {
|
|
@@ -388,10 +389,10 @@ function ft(t) {
|
|
|
388
389
|
function ct(t) {
|
|
389
390
|
const e = St(t), r = new Array(2);
|
|
390
391
|
let n = !1;
|
|
391
|
-
if (e[31] & 128 && (n = !0, e[31] &= 127), r[1] = Ut(e), re(r[1],
|
|
392
|
+
if (e[31] & 128 && (n = !0, e[31] &= 127), r[1] = Ut(e), re(r[1], J))
|
|
392
393
|
return null;
|
|
393
394
|
const o = y.square(r[1]);
|
|
394
|
-
let h = ie(y.div(y.sub(y.one, o), y.sub(j, y.mul(et, o))),
|
|
395
|
+
let h = ie(y.div(y.sub(y.one, o), y.sub(j, y.mul(et, o))), J);
|
|
395
396
|
return h == null ? null : (n && (h = y.neg(h)), r[0] = h, r);
|
|
396
397
|
}
|
|
397
398
|
/**
|
|
@@ -589,7 +590,7 @@ function lt(t, e) {
|
|
|
589
590
|
function _e(t, e) {
|
|
590
591
|
return t * e;
|
|
591
592
|
}
|
|
592
|
-
function
|
|
593
|
+
function we(t) {
|
|
593
594
|
const e = [];
|
|
594
595
|
let r = t;
|
|
595
596
|
for (; r; )
|
|
@@ -752,7 +753,7 @@ class Be {
|
|
|
752
753
|
if (de(r))
|
|
753
754
|
return this.one;
|
|
754
755
|
r < 0n && (e = this.inv(e), r = -r);
|
|
755
|
-
const n =
|
|
756
|
+
const n = we(r);
|
|
756
757
|
if (n.length === 0)
|
|
757
758
|
return this.one;
|
|
758
759
|
let o = e;
|
|
@@ -761,7 +762,7 @@ class Be {
|
|
|
761
762
|
return o;
|
|
762
763
|
}
|
|
763
764
|
}
|
|
764
|
-
var at =
|
|
765
|
+
var at = Lt(), C, ht;
|
|
765
766
|
function jt() {
|
|
766
767
|
if (ht) return C;
|
|
767
768
|
ht = 1;
|
|
@@ -785,29 +786,29 @@ function jt() {
|
|
|
785
786
|
return (4294967296 + s).toString(16).substring(1);
|
|
786
787
|
}
|
|
787
788
|
function o(s, l, c) {
|
|
788
|
-
let
|
|
789
|
+
let w = `
|
|
789
790
|
` + s + " = ";
|
|
790
791
|
for (let b = 0; b < l.length; b += 2) {
|
|
791
792
|
if (c === 32)
|
|
792
|
-
|
|
793
|
+
w += n(l[b]).toUpperCase(), w += " ", w += n(l[b + 1]).toUpperCase();
|
|
793
794
|
else if (c === 64)
|
|
794
|
-
|
|
795
|
+
w += n(l[b + 1]).toUpperCase(), w += n(l[b]).toUpperCase();
|
|
795
796
|
else throw new Error("Invalid size " + c);
|
|
796
|
-
b % 6 === 4 ?
|
|
797
|
-
` + new Array(s.length + 4).join(" ") : b < l.length - 2 && (
|
|
797
|
+
b % 6 === 4 ? w += `
|
|
798
|
+
` + new Array(s.length + 4).join(" ") : b < l.length - 2 && (w += " ");
|
|
798
799
|
}
|
|
799
|
-
console.log(
|
|
800
|
+
console.log(w);
|
|
800
801
|
}
|
|
801
802
|
function h(s, l, c) {
|
|
802
|
-
let
|
|
803
|
+
let w = (/* @__PURE__ */ new Date()).getTime();
|
|
803
804
|
const b = new Uint8Array(l);
|
|
804
805
|
for (let _ = 0; _ < l; _++)
|
|
805
806
|
b[_] = _ % 256;
|
|
806
807
|
const g = (/* @__PURE__ */ new Date()).getTime();
|
|
807
|
-
console.log("Generated random input in " + (g -
|
|
808
|
+
console.log("Generated random input in " + (g - w) + "ms"), w = g;
|
|
808
809
|
for (let _ = 0; _ < c; _++) {
|
|
809
|
-
const k = s(b), a = (/* @__PURE__ */ new Date()).getTime(), d = a -
|
|
810
|
-
|
|
810
|
+
const k = s(b), a = (/* @__PURE__ */ new Date()).getTime(), d = a - w;
|
|
811
|
+
w = a, console.log("Hashed in " + d + "ms: " + k.substring(0, 20) + "..."), console.log(
|
|
811
812
|
Math.round(l / (1 << 20) / (d / 1e3) * 100) / 100 + " MB PER SECOND"
|
|
812
813
|
);
|
|
813
814
|
}
|
|
@@ -820,26 +821,26 @@ function jt() {
|
|
|
820
821
|
}, C;
|
|
821
822
|
}
|
|
822
823
|
var L, gt;
|
|
823
|
-
function
|
|
824
|
+
function me() {
|
|
824
825
|
if (gt) return L;
|
|
825
826
|
gt = 1;
|
|
826
827
|
const t = jt();
|
|
827
828
|
function e(i, p, u) {
|
|
828
829
|
const B = i[p] + i[u];
|
|
829
|
-
let
|
|
830
|
-
B >= 4294967296 &&
|
|
830
|
+
let m = i[p + 1] + i[u + 1];
|
|
831
|
+
B >= 4294967296 && m++, i[p] = B, i[p + 1] = m;
|
|
831
832
|
}
|
|
832
833
|
function r(i, p, u, B) {
|
|
833
|
-
let
|
|
834
|
-
u < 0 && (
|
|
834
|
+
let m = i[p] + u;
|
|
835
|
+
u < 0 && (m += 4294967296);
|
|
835
836
|
let A = i[p + 1] + B;
|
|
836
|
-
|
|
837
|
+
m >= 4294967296 && A++, i[p] = m, i[p + 1] = A;
|
|
837
838
|
}
|
|
838
839
|
function n(i, p) {
|
|
839
840
|
return i[p] ^ i[p + 1] << 8 ^ i[p + 2] << 16 ^ i[p + 3] << 24;
|
|
840
841
|
}
|
|
841
|
-
function o(i, p, u, B,
|
|
842
|
-
const Tt = m
|
|
842
|
+
function o(i, p, u, B, m, A) {
|
|
843
|
+
const Tt = w[m], Ft = w[m + 1], Ht = w[A], Mt = w[A + 1];
|
|
843
844
|
e(c, i, p), r(c, i, Tt, Ft);
|
|
844
845
|
let v = c[B] ^ c[i], U = c[B + 1] ^ c[i + 1];
|
|
845
846
|
c[B] = U, c[B + 1] = v, e(c, u, B), v = c[p] ^ c[u], U = c[p + 1] ^ c[u + 1], c[p] = v >>> 24 ^ U << 8, c[p + 1] = U >>> 24 ^ v << 8, e(c, i, p), r(c, i, Ht, Mt), v = c[B] ^ c[i], U = c[B + 1] ^ c[i + 1], c[B] = v >>> 16 ^ U << 16, c[B + 1] = U >>> 16 ^ v << 16, e(c, u, B), v = c[p] ^ c[u], U = c[p + 1] ^ c[u + 1], c[p] = U >>> 31 ^ v << 1, c[p + 1] = v >>> 31 ^ U << 1;
|
|
@@ -1058,13 +1059,13 @@ function we() {
|
|
|
1058
1059
|
s.map(function(i) {
|
|
1059
1060
|
return i * 2;
|
|
1060
1061
|
})
|
|
1061
|
-
), c = new Uint32Array(32),
|
|
1062
|
+
), c = new Uint32Array(32), w = new Uint32Array(32);
|
|
1062
1063
|
function b(i, p) {
|
|
1063
1064
|
let u = 0;
|
|
1064
1065
|
for (u = 0; u < 16; u++)
|
|
1065
1066
|
c[u] = i.h[u], c[u + 16] = h[u];
|
|
1066
1067
|
for (c[24] = c[24] ^ i.t, c[25] = c[25] ^ i.t / 4294967296, p && (c[28] = ~c[28], c[29] = ~c[29]), u = 0; u < 32; u++)
|
|
1067
|
-
|
|
1068
|
+
w[u] = n(i.b, 4 * u);
|
|
1068
1069
|
for (u = 0; u < 12; u++)
|
|
1069
1070
|
o(0, 8, 16, 24, l[u * 16 + 0], l[u * 16 + 1]), o(2, 10, 18, 26, l[u * 16 + 2], l[u * 16 + 3]), o(4, 12, 20, 28, l[u * 16 + 4], l[u * 16 + 5]), o(6, 14, 22, 30, l[u * 16 + 6], l[u * 16 + 7]), o(0, 10, 20, 30, l[u * 16 + 8], l[u * 16 + 9]), o(2, 12, 22, 24, l[u * 16 + 10], l[u * 16 + 11]), o(4, 14, 16, 26, l[u * 16 + 12], l[u * 16 + 13]), o(6, 8, 18, 28, l[u * 16 + 14], l[u * 16 + 15]);
|
|
1070
1071
|
for (u = 0; u < 16; u++)
|
|
@@ -1161,7 +1162,7 @@ function we() {
|
|
|
1161
1162
|
throw new Error("Illegal salt, expected Uint8Array with length is 16");
|
|
1162
1163
|
if (B && B.length !== 16)
|
|
1163
1164
|
throw new Error("Illegal personal, expected Uint8Array with length is 16");
|
|
1164
|
-
const
|
|
1165
|
+
const m = {
|
|
1165
1166
|
b: new Uint8Array(128),
|
|
1166
1167
|
h: new Uint32Array(16),
|
|
1167
1168
|
t: 0,
|
|
@@ -1173,8 +1174,8 @@ function we() {
|
|
|
1173
1174
|
};
|
|
1174
1175
|
g.fill(0), g[0] = i, p && (g[1] = p.length), g[2] = 1, g[3] = 1, u && g.set(u, 32), B && g.set(B, 48);
|
|
1175
1176
|
for (let A = 0; A < 16; A++)
|
|
1176
|
-
|
|
1177
|
-
return p && (k(
|
|
1177
|
+
m.h[A] = h[A] ^ n(g, A * 4);
|
|
1178
|
+
return p && (k(m, p), m.c = 128), m;
|
|
1178
1179
|
}
|
|
1179
1180
|
function k(i, p) {
|
|
1180
1181
|
for (let u = 0; u < p.length; u++)
|
|
@@ -1189,13 +1190,13 @@ function we() {
|
|
|
1189
1190
|
p[u] = i.h[u >> 2] >> 8 * (u & 3);
|
|
1190
1191
|
return p;
|
|
1191
1192
|
}
|
|
1192
|
-
function d(i, p, u, B,
|
|
1193
|
-
u = u || 64, i = t.normalizeInput(i), B && (B = t.normalizeInput(B)),
|
|
1194
|
-
const A = _(u, p, B,
|
|
1193
|
+
function d(i, p, u, B, m) {
|
|
1194
|
+
u = u || 64, i = t.normalizeInput(i), B && (B = t.normalizeInput(B)), m && (m = t.normalizeInput(m));
|
|
1195
|
+
const A = _(u, p, B, m);
|
|
1195
1196
|
return k(A, i), a(A);
|
|
1196
1197
|
}
|
|
1197
|
-
function f(i, p, u, B,
|
|
1198
|
-
const A = d(i, p, u, B,
|
|
1198
|
+
function f(i, p, u, B, m) {
|
|
1199
|
+
const A = d(i, p, u, B, m);
|
|
1199
1200
|
return t.toHex(A);
|
|
1200
1201
|
}
|
|
1201
1202
|
return L = {
|
|
@@ -1402,7 +1403,7 @@ function ke() {
|
|
|
1402
1403
|
for (f = 0; f < 8; f++)
|
|
1403
1404
|
a.h[f] ^= s[f] ^ s[f + 8];
|
|
1404
1405
|
}
|
|
1405
|
-
function
|
|
1406
|
+
function w(a, d) {
|
|
1406
1407
|
if (!(a > 0 && a <= 32))
|
|
1407
1408
|
throw new Error("Incorrect output length, should be in [1, 32]");
|
|
1408
1409
|
const f = d ? d.length : 0;
|
|
@@ -1437,7 +1438,7 @@ function ke() {
|
|
|
1437
1438
|
}
|
|
1438
1439
|
function _(a, d, f) {
|
|
1439
1440
|
f = f || 32, a = t.normalizeInput(a);
|
|
1440
|
-
const i =
|
|
1441
|
+
const i = w(f, d);
|
|
1441
1442
|
return b(i, a), g(i);
|
|
1442
1443
|
}
|
|
1443
1444
|
function k(a, d, f) {
|
|
@@ -1447,17 +1448,17 @@ function ke() {
|
|
|
1447
1448
|
return Z = {
|
|
1448
1449
|
blake2s: _,
|
|
1449
1450
|
blake2sHex: k,
|
|
1450
|
-
blake2sInit:
|
|
1451
|
+
blake2sInit: w,
|
|
1451
1452
|
blake2sUpdate: b,
|
|
1452
1453
|
blake2sFinal: g
|
|
1453
1454
|
}, Z;
|
|
1454
1455
|
}
|
|
1455
|
-
var
|
|
1456
|
+
var X, pt;
|
|
1456
1457
|
function Ie() {
|
|
1457
|
-
if (pt) return
|
|
1458
|
+
if (pt) return X;
|
|
1458
1459
|
pt = 1;
|
|
1459
|
-
const t =
|
|
1460
|
-
return
|
|
1460
|
+
const t = me(), e = ke();
|
|
1461
|
+
return X = {
|
|
1461
1462
|
blake2b: t.blake2b,
|
|
1462
1463
|
blake2bHex: t.blake2bHex,
|
|
1463
1464
|
blake2bInit: t.blake2bInit,
|
|
@@ -1468,9 +1469,9 @@ function Ie() {
|
|
|
1468
1469
|
blake2sInit: e.blake2sInit,
|
|
1469
1470
|
blake2sUpdate: e.blake2sUpdate,
|
|
1470
1471
|
blake2sFinal: e.blake2sFinal
|
|
1471
|
-
},
|
|
1472
|
+
}, X;
|
|
1472
1473
|
}
|
|
1473
|
-
var
|
|
1474
|
+
var V = Ie();
|
|
1474
1475
|
/**
|
|
1475
1476
|
* @module @zk-kit/eddsa-poseidon
|
|
1476
1477
|
* @version 1.1.0
|
|
@@ -1529,7 +1530,7 @@ const Ae = I.Buffer.from([1]), ve = I.Buffer.from([129]), S = [
|
|
|
1529
1530
|
2240740374,
|
|
1530
1531
|
1667834072,
|
|
1531
1532
|
1901547113
|
|
1532
|
-
],
|
|
1533
|
+
], N = I.Buffer.from([
|
|
1533
1534
|
128,
|
|
1534
1535
|
0,
|
|
1535
1536
|
0,
|
|
@@ -1728,7 +1729,7 @@ class Ue {
|
|
|
1728
1729
|
const r = I.Buffer.alloc(16);
|
|
1729
1730
|
for (let n = 0; n < 4; n += 1)
|
|
1730
1731
|
r.writeUInt32BE(e[3 - n], n * 4);
|
|
1731
|
-
this._blockOffset === 111 ? (this._length[0] -= 8, this.update(this._oo)) : (this._blockOffset < 111 ? (this._blockOffset === 0 && (this._nullt = !0), this._length[0] -= (111 - this._blockOffset) * 8, this.update(
|
|
1732
|
+
this._blockOffset === 111 ? (this._length[0] -= 8, this.update(this._oo)) : (this._blockOffset < 111 ? (this._blockOffset === 0 && (this._nullt = !0), this._length[0] -= (111 - this._blockOffset) * 8, this.update(N.subarray(0, 111 - this._blockOffset))) : (this._length[0] -= (128 - this._blockOffset) * 8, this.update(N.subarray(0, 128 - this._blockOffset)), this._length[0] -= 111 * 8, this.update(N.subarray(1, 112)), this._nullt = !0), this.update(this._zo), this._length[0] -= 8), this._length[0] -= 128, this.update(r);
|
|
1732
1733
|
}
|
|
1733
1734
|
/**
|
|
1734
1735
|
* Completes the hash computation and returns the final hash value.
|
|
@@ -1772,7 +1773,7 @@ class Se {
|
|
|
1772
1773
|
constructor(e = 64, r) {
|
|
1773
1774
|
if (this.key = null, this.outlen = 64, r && (this.key = r), e <= 0 || e > 64)
|
|
1774
1775
|
throw new Error("Illegal output length, expected 0 < length <= 64");
|
|
1775
|
-
this.outlen = e, this.context =
|
|
1776
|
+
this.outlen = e, this.context = V.blake2bInit(this.outlen, r);
|
|
1776
1777
|
}
|
|
1777
1778
|
/**
|
|
1778
1779
|
* Updates the hash with new data. This method can be called multiple
|
|
@@ -1781,7 +1782,7 @@ class Se {
|
|
|
1781
1782
|
* @returns The instance, to allow method chaining.
|
|
1782
1783
|
*/
|
|
1783
1784
|
update(e) {
|
|
1784
|
-
return
|
|
1785
|
+
return V.blake2bUpdate(this.context, e), this;
|
|
1785
1786
|
}
|
|
1786
1787
|
/**
|
|
1787
1788
|
* Completes the hash computation and returns the final hash value.
|
|
@@ -1790,19 +1791,19 @@ class Se {
|
|
|
1790
1791
|
* @returns The Blake2b hash of the input data.
|
|
1791
1792
|
*/
|
|
1792
1793
|
digest() {
|
|
1793
|
-
return
|
|
1794
|
+
return Ct.from(V.blake2bFinal(this.context));
|
|
1794
1795
|
}
|
|
1795
1796
|
}
|
|
1796
1797
|
function dt(t) {
|
|
1797
1798
|
return t[0] &= 248, t[31] &= 127, t[31] |= 64, t;
|
|
1798
1799
|
}
|
|
1799
|
-
function
|
|
1800
|
+
function W(t) {
|
|
1800
1801
|
return Pt(t) && t.length === 2 && T(t[0]) && T(t[1]);
|
|
1801
1802
|
}
|
|
1802
1803
|
function _t(t) {
|
|
1803
|
-
return nt(t) && Object.prototype.hasOwnProperty.call(t, "R8") && Object.prototype.hasOwnProperty.call(t, "S") &&
|
|
1804
|
+
return nt(t) && Object.prototype.hasOwnProperty.call(t, "R8") && Object.prototype.hasOwnProperty.call(t, "S") && W(t.R8) && T(t.S);
|
|
1804
1805
|
}
|
|
1805
|
-
function
|
|
1806
|
+
function wt(t) {
|
|
1806
1807
|
return M(t, "privateKey", ["Buffer", "Uint8Array", "string"]), I.Buffer.from(t);
|
|
1807
1808
|
}
|
|
1808
1809
|
function Bt(t) {
|
|
@@ -1830,7 +1831,7 @@ var P;
|
|
|
1830
1831
|
})(P || (P = {}));
|
|
1831
1832
|
const Ee = (t) => {
|
|
1832
1833
|
const e = (b) => {
|
|
1833
|
-
b =
|
|
1834
|
+
b = wt(b);
|
|
1834
1835
|
let g = G(b, t);
|
|
1835
1836
|
return g = g.slice(0, 32), g = dt(g), lt(z(g), BigInt(3)) % K;
|
|
1836
1837
|
};
|
|
@@ -1839,12 +1840,12 @@ const Ee = (t) => {
|
|
|
1839
1840
|
return $(q, g);
|
|
1840
1841
|
}
|
|
1841
1842
|
function n(b, g) {
|
|
1842
|
-
b =
|
|
1843
|
-
const _ = G(b, t), k = dt(_.slice(0, 32)), a = z(k), d = $(q, lt(a, BigInt(3))), f = D(g, 32), i = G(I.Buffer.concat([_.slice(32, 64), f]), t), p = new Be(K), u = p.e(z(i)), B = $(q, u),
|
|
1843
|
+
b = wt(b), g = Bt(g);
|
|
1844
|
+
const _ = G(b, t), k = dt(_.slice(0, 32)), a = z(k), d = $(q, lt(a, BigInt(3))), f = D(g, 32), i = G(I.Buffer.concat([_.slice(32, 64), f]), t), p = new Be(K), u = p.e(z(i)), B = $(q, u), m = at.poseidon5([B[0], B[1], d[0], d[1], g]), A = p.add(u, p.mul(m, a));
|
|
1844
1845
|
return { R8: B, S: A };
|
|
1845
1846
|
}
|
|
1846
1847
|
function o(b, g, _) {
|
|
1847
|
-
if (!
|
|
1848
|
+
if (!W(_) || !_t(g) || !O(g.R8) || !O(_) || BigInt(g.S) >= K)
|
|
1848
1849
|
return !1;
|
|
1849
1850
|
b = Bt(b);
|
|
1850
1851
|
const k = {
|
|
@@ -1852,10 +1853,10 @@ const Ee = (t) => {
|
|
|
1852
1853
|
S: BigInt(g.S)
|
|
1853
1854
|
}, a = [BigInt(_[0]), BigInt(_[1])], d = at.poseidon5([g.R8[0], g.R8[1], _[0], _[1], b]), f = $(q, BigInt(g.S));
|
|
1854
1855
|
let i = $(a, _e(d, BigInt(8)));
|
|
1855
|
-
return i =
|
|
1856
|
+
return i = Q(k.R8, i), y.eq(f[0], i[0]) && y.eq(f[1], i[1]);
|
|
1856
1857
|
}
|
|
1857
1858
|
function h(b) {
|
|
1858
|
-
if (!
|
|
1859
|
+
if (!W(b) || !O(b))
|
|
1859
1860
|
throw new Error("Invalid public key");
|
|
1860
1861
|
const g = [BigInt(b[0]), BigInt(b[1])];
|
|
1861
1862
|
return ft(g);
|
|
@@ -1887,7 +1888,7 @@ const Ee = (t) => {
|
|
|
1887
1888
|
S: z(_)
|
|
1888
1889
|
};
|
|
1889
1890
|
}
|
|
1890
|
-
class
|
|
1891
|
+
class w {
|
|
1891
1892
|
/**
|
|
1892
1893
|
* Initializes a new instance, deriving necessary cryptographic parameters from the provided private key.
|
|
1893
1894
|
* If the private key is not passed as a parameter, a random 32-byte hexadecimal key is generated.
|
|
@@ -1930,17 +1931,17 @@ const Ee = (t) => {
|
|
|
1930
1931
|
unpackPublicKey: s,
|
|
1931
1932
|
packSignature: l,
|
|
1932
1933
|
unpackSignature: c,
|
|
1933
|
-
EdDSAPoseidon:
|
|
1934
|
+
EdDSAPoseidon: w
|
|
1934
1935
|
};
|
|
1935
|
-
}, { EdDSAPoseidon:
|
|
1936
|
+
}, { EdDSAPoseidon: ze, derivePublicKey: Pe, deriveSecretScalar: qe, packPublicKey: Ke, packSignature: Oe, signMessage: Re, unpackPublicKey: je, unpackSignature: Te, verifySignature: Fe } = Ee(P.BLAKE1);
|
|
1936
1937
|
export {
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1938
|
+
ze as EdDSAPoseidon,
|
|
1939
|
+
Pe as derivePublicKey,
|
|
1940
|
+
qe as deriveSecretScalar,
|
|
1941
|
+
Ke as packPublicKey,
|
|
1942
|
+
Oe as packSignature,
|
|
1943
|
+
Re as signMessage,
|
|
1944
|
+
je as unpackPublicKey,
|
|
1945
|
+
Te as unpackSignature,
|
|
1946
|
+
Fe as verifySignature
|
|
1946
1947
|
};
|