@nihilium/client-sdk 0.1.1 → 0.1.2
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-BLoDyLFh.js +16271 -0
- package/dist/{browser/browser.esm-kreqNYRZ-CV3K9CfO-I-qnoSbY.mjs → browser.esm-kreqNYRZ-CV3K9CfO-DeSbuL7e.js} +1 -1
- package/dist/{browser/index-BbrmIoGc.mjs → index-78RSe_cY.js} +69008 -39334
- package/dist/{browser/index-CaU6sT7E-DPVApZD5.mjs → index-C3cHMpbE-BjZqbn-8.js} +38 -38
- package/dist/index-DFD-0QrS-BD9Z8naZ.js +1551 -0
- package/dist/index-DFD-0QrS-DqRwsoRk-DaSQ-uF-.js +1551 -0
- package/dist/index.d.ts +7079 -10
- package/dist/index.mjs +43 -0
- package/package.json +15 -12
- package/dist/api-endpoints/index.d.ts +0 -7
- package/dist/api-endpoints/index.js +0 -7
- package/dist/browser/index.es.js +0 -40
- package/dist/browser/index.umd.js +0 -614
- package/dist/index.js +0 -51
- package/dist/lib/endpoint-selection.d.ts +0 -14
- package/dist/lib/endpoint-selection.js +0 -79
- package/dist/lib/nihiliumapi.d.ts +0 -19
- package/dist/lib/nihiliumapi.js +0 -49
- package/dist/lib/server-client.d.ts +0 -7
- package/dist/lib/server-client.js +0 -31
- package/dist/lib/types.d.ts +0 -12
- package/dist/lib/types.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
var I =
|
|
1
|
+
import { A as Dt, Y as Ct, B as Lt } from "./index-78RSe_cY.js";
|
|
2
|
+
var I = Dt();
|
|
3
3
|
/**
|
|
4
4
|
* @module @zk-kit/utils
|
|
5
5
|
* @version 1.2.1
|
|
@@ -25,7 +25,7 @@ const Zt = [
|
|
|
25
25
|
function wt(t) {
|
|
26
26
|
return typeof t == "number";
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function W(t) {
|
|
29
29
|
return typeof t == "string";
|
|
30
30
|
}
|
|
31
31
|
function Vt(t) {
|
|
@@ -47,7 +47,7 @@ function F(t) {
|
|
|
47
47
|
return typeof t == "bigint";
|
|
48
48
|
}
|
|
49
49
|
function tt(t) {
|
|
50
|
-
if (!
|
|
50
|
+
if (!W(t))
|
|
51
51
|
return !1;
|
|
52
52
|
try {
|
|
53
53
|
return BigInt(t), !0;
|
|
@@ -56,20 +56,20 @@ function tt(t) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
function vt(t, e = !0) {
|
|
59
|
-
return
|
|
59
|
+
return W(t) ? e ? /^(0x|0X)[0-9a-fA-F]+$/.test(t) : /^[0-9a-fA-F]+$/.test(t) : !1;
|
|
60
60
|
}
|
|
61
|
-
function
|
|
61
|
+
function Yt(t) {
|
|
62
62
|
return F(t) || tt(t);
|
|
63
63
|
}
|
|
64
64
|
function Gt(t) {
|
|
65
65
|
return wt(t) || F(t) || tt(t) || vt(t) || At(t) || It(t);
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function Nt(t, e) {
|
|
68
68
|
switch (e) {
|
|
69
69
|
case "number":
|
|
70
70
|
return wt(t);
|
|
71
71
|
case "string":
|
|
72
|
-
return
|
|
72
|
+
return W(t);
|
|
73
73
|
case "function":
|
|
74
74
|
return Vt(t);
|
|
75
75
|
case "Array":
|
|
@@ -87,14 +87,14 @@ function Jt(t, e) {
|
|
|
87
87
|
case "hexadecimal":
|
|
88
88
|
return vt(t);
|
|
89
89
|
case "bignumber":
|
|
90
|
-
return
|
|
90
|
+
return Yt(t);
|
|
91
91
|
case "bignumberish":
|
|
92
92
|
return Gt(t);
|
|
93
93
|
default:
|
|
94
94
|
return !1;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function Jt(t) {
|
|
98
98
|
return Zt.includes(t);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
@@ -105,16 +105,16 @@ function Qt(t) {
|
|
|
105
105
|
* @license MIT
|
|
106
106
|
* @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/utils}
|
|
107
107
|
*/
|
|
108
|
-
function
|
|
108
|
+
function Qt(t, e) {
|
|
109
109
|
if (!F(t))
|
|
110
110
|
throw new TypeError(`Parameter '${e}' is not a bigint, received type: ${typeof t}`);
|
|
111
111
|
}
|
|
112
|
-
function
|
|
112
|
+
function Wt(t, e, r) {
|
|
113
113
|
for (const n of r)
|
|
114
|
-
if (!
|
|
114
|
+
if (!Jt(n))
|
|
115
115
|
throw new Error(`Type '${n}' is not supported`);
|
|
116
116
|
for (const n of r)
|
|
117
|
-
if (
|
|
117
|
+
if (Nt(t, n))
|
|
118
118
|
return;
|
|
119
119
|
throw new TypeError(`Parameter '${e}' is none of the following types: ${r.join(", ")}`);
|
|
120
120
|
}
|
|
@@ -127,12 +127,12 @@ function Yt(t, e, r) {
|
|
|
127
127
|
* @see [Github]{@link https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/utils}
|
|
128
128
|
*/
|
|
129
129
|
function te(t) {
|
|
130
|
-
|
|
130
|
+
Qt(t, "value");
|
|
131
131
|
let e = t.toString(16);
|
|
132
132
|
return e.length % 2 !== 0 && (e = `0${e}`), e;
|
|
133
133
|
}
|
|
134
134
|
function Ut(t) {
|
|
135
|
-
return
|
|
135
|
+
return Wt(t, "value", ["Buffer", "Uint8Array"]), BigInt(`0x${I.Buffer.from(t).reverse().toString("hex")}`);
|
|
136
136
|
}
|
|
137
137
|
function St(t, e) {
|
|
138
138
|
const r = te(t), n = Math.ceil(r.length / 2);
|
|
@@ -363,18 +363,18 @@ function ie(t, e) {
|
|
|
363
363
|
}
|
|
364
364
|
return r.geq(m, r.zero) ? m : r.neg(m);
|
|
365
365
|
}
|
|
366
|
-
const
|
|
366
|
+
const N = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"), y = new $t(N), q = [
|
|
367
367
|
y.e(BigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553")),
|
|
368
368
|
y.e(BigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203"))
|
|
369
369
|
], j = y.e(BigInt("168700")), et = y.e(BigInt("168696")), oe = BigInt("21888242871839275222246405745257275088614511777268538073601725287587578984328"), K = xt(oe, BigInt(3));
|
|
370
|
-
function
|
|
370
|
+
function J(t, e) {
|
|
371
371
|
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
372
|
return [l, c];
|
|
373
373
|
}
|
|
374
374
|
function $(t, e) {
|
|
375
375
|
let r = [y.e(BigInt(0)), y.e(BigInt(1))], n = e, o = t;
|
|
376
376
|
for (; !Et(n); )
|
|
377
|
-
ee(n) && (r =
|
|
377
|
+
ee(n) && (r = J(r, o)), o = J(o, o), n = xt(n, BigInt(1));
|
|
378
378
|
return r;
|
|
379
379
|
}
|
|
380
380
|
function O(t) {
|
|
@@ -388,10 +388,10 @@ function ft(t) {
|
|
|
388
388
|
function ct(t) {
|
|
389
389
|
const e = St(t), r = new Array(2);
|
|
390
390
|
let n = !1;
|
|
391
|
-
if (e[31] & 128 && (n = !0, e[31] &= 127), r[1] = Ut(e), re(r[1],
|
|
391
|
+
if (e[31] & 128 && (n = !0, e[31] &= 127), r[1] = Ut(e), re(r[1], N))
|
|
392
392
|
return null;
|
|
393
393
|
const o = y.square(r[1]);
|
|
394
|
-
let h = ie(y.div(y.sub(y.one, o), y.sub(j, y.mul(et, o))),
|
|
394
|
+
let h = ie(y.div(y.sub(y.one, o), y.sub(j, y.mul(et, o))), N);
|
|
395
395
|
return h == null ? null : (n && (h = y.neg(h)), r[0] = h, r);
|
|
396
396
|
}
|
|
397
397
|
/**
|
|
@@ -531,7 +531,7 @@ function Kt(t, e) {
|
|
|
531
531
|
if (!st(t))
|
|
532
532
|
throw new TypeError(`Parameter '${e}' is not a bignumber-ish`);
|
|
533
533
|
}
|
|
534
|
-
function
|
|
534
|
+
function M(t, e, r) {
|
|
535
535
|
for (const n of r)
|
|
536
536
|
if (!ge(n))
|
|
537
537
|
throw new Error(`Type '${n}' is not supported`);
|
|
@@ -554,15 +554,15 @@ function pe(t) {
|
|
|
554
554
|
return e.length % 2 !== 0 && (e = `0${e}`), e;
|
|
555
555
|
}
|
|
556
556
|
function ye(t) {
|
|
557
|
-
return
|
|
557
|
+
return M(t, "value", ["Buffer", "Uint8Array"]), BigInt(`0x${I.Buffer.from(t).toString("hex")}`);
|
|
558
558
|
}
|
|
559
559
|
function z(t) {
|
|
560
|
-
return
|
|
560
|
+
return M(t, "value", ["Buffer", "Uint8Array"]), BigInt(`0x${I.Buffer.from(t).reverse().toString("hex")}`);
|
|
561
561
|
}
|
|
562
562
|
function Ot(t) {
|
|
563
563
|
return ye(t);
|
|
564
564
|
}
|
|
565
|
-
function
|
|
565
|
+
function D(t, e) {
|
|
566
566
|
const r = pe(t), n = Math.ceil(r.length / 2);
|
|
567
567
|
if (e < n)
|
|
568
568
|
throw Error(`Size ${e} is too small, need at least ${n} bytes`);
|
|
@@ -839,10 +839,10 @@ function we() {
|
|
|
839
839
|
return i[p] ^ i[p + 1] << 8 ^ i[p + 2] << 16 ^ i[p + 3] << 24;
|
|
840
840
|
}
|
|
841
841
|
function o(i, p, u, B, w, A) {
|
|
842
|
-
const Tt = m[w], Ft = m[w + 1], Ht = m[A],
|
|
842
|
+
const Tt = m[w], Ft = m[w + 1], Ht = m[A], Mt = m[A + 1];
|
|
843
843
|
e(c, i, p), r(c, i, Tt, Ft);
|
|
844
844
|
let v = c[B] ^ c[i], U = c[B + 1] ^ c[i + 1];
|
|
845
|
-
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,
|
|
845
|
+
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;
|
|
846
846
|
}
|
|
847
847
|
const h = new Uint32Array([
|
|
848
848
|
4089235720,
|
|
@@ -1529,7 +1529,7 @@ const Ae = I.Buffer.from([1]), ve = I.Buffer.from([129]), S = [
|
|
|
1529
1529
|
2240740374,
|
|
1530
1530
|
1667834072,
|
|
1531
1531
|
1901547113
|
|
1532
|
-
],
|
|
1532
|
+
], Y = I.Buffer.from([
|
|
1533
1533
|
128,
|
|
1534
1534
|
0,
|
|
1535
1535
|
0,
|
|
@@ -1728,7 +1728,7 @@ class Ue {
|
|
|
1728
1728
|
const r = I.Buffer.alloc(16);
|
|
1729
1729
|
for (let n = 0; n < 4; n += 1)
|
|
1730
1730
|
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(
|
|
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(Y.subarray(0, 111 - this._blockOffset))) : (this._length[0] -= (128 - this._blockOffset) * 8, this.update(Y.subarray(0, 128 - this._blockOffset)), this._length[0] -= 111 * 8, this.update(Y.subarray(1, 112)), this._nullt = !0), this.update(this._zo), this._length[0] -= 8), this._length[0] -= 128, this.update(r);
|
|
1732
1732
|
}
|
|
1733
1733
|
/**
|
|
1734
1734
|
* Completes the hash computation and returns the final hash value.
|
|
@@ -1796,17 +1796,17 @@ class Se {
|
|
|
1796
1796
|
function dt(t) {
|
|
1797
1797
|
return t[0] &= 248, t[31] &= 127, t[31] |= 64, t;
|
|
1798
1798
|
}
|
|
1799
|
-
function
|
|
1799
|
+
function Q(t) {
|
|
1800
1800
|
return Pt(t) && t.length === 2 && T(t[0]) && T(t[1]);
|
|
1801
1801
|
}
|
|
1802
1802
|
function _t(t) {
|
|
1803
|
-
return nt(t) && Object.prototype.hasOwnProperty.call(t, "R8") && Object.prototype.hasOwnProperty.call(t, "S") &&
|
|
1803
|
+
return nt(t) && Object.prototype.hasOwnProperty.call(t, "R8") && Object.prototype.hasOwnProperty.call(t, "S") && Q(t.R8) && T(t.S);
|
|
1804
1804
|
}
|
|
1805
1805
|
function mt(t) {
|
|
1806
|
-
return
|
|
1806
|
+
return M(t, "privateKey", ["Buffer", "Uint8Array", "string"]), I.Buffer.from(t);
|
|
1807
1807
|
}
|
|
1808
1808
|
function Bt(t) {
|
|
1809
|
-
return
|
|
1809
|
+
return M(t, "message", ["bignumberish", "string"]), st(t) ? Rt(t) : Ot(I.Buffer.from(t));
|
|
1810
1810
|
}
|
|
1811
1811
|
function G(t, e) {
|
|
1812
1812
|
let r;
|
|
@@ -1840,11 +1840,11 @@ const Ee = (t) => {
|
|
|
1840
1840
|
}
|
|
1841
1841
|
function n(b, g) {
|
|
1842
1842
|
b = mt(b), g = Bt(g);
|
|
1843
|
-
const _ = G(b, t), k = dt(_.slice(0, 32)), a = z(k), d = $(q, lt(a, BigInt(3))), f =
|
|
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), w = at.poseidon5([B[0], B[1], d[0], d[1], g]), A = p.add(u, p.mul(w, a));
|
|
1844
1844
|
return { R8: B, S: A };
|
|
1845
1845
|
}
|
|
1846
1846
|
function o(b, g, _) {
|
|
1847
|
-
if (!
|
|
1847
|
+
if (!Q(_) || !_t(g) || !O(g.R8) || !O(_) || BigInt(g.S) >= K)
|
|
1848
1848
|
return !1;
|
|
1849
1849
|
b = Bt(b);
|
|
1850
1850
|
const k = {
|
|
@@ -1852,10 +1852,10 @@ const Ee = (t) => {
|
|
|
1852
1852
|
S: BigInt(g.S)
|
|
1853
1853
|
}, a = [BigInt(_[0]), BigInt(_[1])], d = at.poseidon5([g.R8[0], g.R8[1], _[0], _[1], b]), f = $(q, BigInt(g.S));
|
|
1854
1854
|
let i = $(a, _e(d, BigInt(8)));
|
|
1855
|
-
return i =
|
|
1855
|
+
return i = J(k.R8, i), y.eq(f[0], i[0]) && y.eq(f[1], i[1]);
|
|
1856
1856
|
}
|
|
1857
1857
|
function h(b) {
|
|
1858
|
-
if (!
|
|
1858
|
+
if (!Q(b) || !O(b))
|
|
1859
1859
|
throw new Error("Invalid public key");
|
|
1860
1860
|
const g = [BigInt(b[0]), BigInt(b[1])];
|
|
1861
1861
|
return ft(g);
|
|
@@ -1874,7 +1874,7 @@ const Ee = (t) => {
|
|
|
1874
1874
|
R8: b.R8.map((a) => BigInt(a)),
|
|
1875
1875
|
S: BigInt(b.S)
|
|
1876
1876
|
}, _ = ft(g.R8), k = I.Buffer.alloc(64);
|
|
1877
|
-
return k.set(
|
|
1877
|
+
return k.set(D(_, 32), 0), k.set(D(g.S, 32), 32), k;
|
|
1878
1878
|
}
|
|
1879
1879
|
function c(b) {
|
|
1880
1880
|
if (se(b, "packedSignature"), b.length !== 64)
|