@gardenfi/utils 2.5.1 → 2.5.3-beta.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/README.md +9 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +37 -36
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +16 -20
- package/dist/index112.cjs +1 -1
- package/dist/index112.js +15 -15
- package/dist/index121.cjs +1 -1
- package/dist/index121.js +1 -1
- package/dist/index130.cjs +1 -1
- package/dist/index130.js +1 -1
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +20 -9
- package/dist/index197.cjs +1 -1
- package/dist/index197.js +17 -30
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +84 -51
- package/dist/index226.cjs +1 -1
- package/dist/index226.js +2 -2
- package/dist/index229.cjs +1 -1
- package/dist/index229.js +2 -2
- package/dist/index230.cjs +1 -1
- package/dist/index230.js +1 -1
- package/dist/index234.cjs +1 -1
- package/dist/index234.js +7 -8
- package/dist/index235.cjs +1 -1
- package/dist/index235.js +1 -1
- package/dist/index236.cjs +1 -1
- package/dist/index236.js +1 -1
- package/dist/index237.cjs +1 -1
- package/dist/index237.js +2 -2
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +4 -5
- package/dist/index249.cjs +1 -1
- package/dist/index249.js +3 -3
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +3 -5
- package/dist/index250.cjs +1 -1
- package/dist/index250.js +3 -3
- package/dist/index256.cjs +1 -1
- package/dist/index256.js +17 -12
- package/dist/index269.cjs +1 -1
- package/dist/index269.js +4 -4
- package/dist/index270.cjs +1 -1
- package/dist/index270.js +5 -5
- package/dist/index271.cjs +1 -1
- package/dist/index271.js +27 -21
- package/dist/index272.cjs +1 -1
- package/dist/index272.js +54 -20
- package/dist/index273.cjs +1 -1
- package/dist/index273.js +18 -54
- package/dist/index274.cjs +1 -1
- package/dist/index274.js +10 -34
- package/dist/index275.cjs +1 -1
- package/dist/index275.js +7 -10
- package/dist/index276.cjs +1 -1
- package/dist/index276.js +12 -13
- package/dist/index277.cjs +1 -1
- package/dist/index277.js +11 -12
- package/dist/index280.cjs +1 -1
- package/dist/index280.js +103 -11
- package/dist/index281.cjs +1 -1
- package/dist/index281.js +6 -103
- package/dist/index282.cjs +1 -1
- package/dist/index282.js +243 -5
- package/dist/index283.cjs +1 -1
- package/dist/index283.js +6 -224
- package/dist/index284.cjs +1 -1
- package/dist/index284.js +7 -7
- package/dist/index285.cjs +1 -1
- package/dist/index285.js +27 -7
- package/dist/index286.cjs +1 -1
- package/dist/index286.js +18 -25
- package/dist/index287.cjs +1 -1
- package/dist/index287.js +145 -18
- package/dist/index288.cjs +1 -1
- package/dist/index288.js +3 -146
- package/dist/index289.cjs +1 -1
- package/dist/index289.js +155 -3
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +2 -2
- package/dist/index290.cjs +1 -1
- package/dist/index290.js +7 -138
- package/dist/index291.cjs +1 -1
- package/dist/index291.js +128 -143
- package/dist/index292.cjs +1 -1
- package/dist/index292.js +111 -7
- package/dist/index293.cjs +2 -1
- package/dist/index293.js +116 -95
- package/dist/index294.cjs +1 -2
- package/dist/index294.js +35 -127
- package/dist/index295.cjs +1 -1
- package/dist/index295.js +66 -30
- package/dist/index296.cjs +1 -1
- package/dist/index296.js +2 -79
- package/dist/index297.cjs +1 -1
- package/dist/index297.js +12 -2
- package/dist/index298.cjs +1 -1
- package/dist/index298.js +19 -11
- package/dist/index299.cjs +1 -1
- package/dist/index299.js +68 -19
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +10 -8
- package/dist/index300.cjs +1 -1
- package/dist/index300.js +786 -66
- package/dist/index301.cjs +1 -1
- package/dist/index301.js +134 -684
- package/dist/index302.cjs +1 -1
- package/dist/index302.js +185 -124
- package/dist/index303.cjs +2 -1
- package/dist/index303.js +63 -198
- package/dist/index304.cjs +1 -2
- package/dist/index304.js +7 -66
- package/dist/index305.cjs +1 -1
- package/dist/index305.js +62 -4
- package/dist/index306.cjs +1 -1
- package/dist/index306.js +22 -40
- package/dist/index307.cjs +1 -1
- package/dist/index307.js +5 -7
- package/dist/index308.cjs +1 -1
- package/dist/index308.js +72 -57
- package/dist/index309.cjs +1 -1
- package/dist/index309.js +4 -78
- package/dist/index310.cjs +1 -1
- package/dist/index310.js +195 -4
- package/dist/index311.cjs +1 -1
- package/dist/index311.js +4 -194
- package/dist/index312.cjs +1 -1
- package/dist/index312.js +35 -58
- package/dist/index313.cjs +2 -1
- package/dist/index313.js +40 -43
- package/dist/index314.cjs +1 -1
- package/dist/index314.js +2 -5
- package/dist/index315.cjs +1 -1
- package/dist/index315.js +11 -5
- package/dist/index316.cjs +1 -1
- package/dist/index316.js +20 -2
- package/dist/index317.cjs +1 -1
- package/dist/index317.js +8 -21
- package/dist/index318.cjs +1 -0
- package/dist/index318.js +45 -0
- package/dist/index319.cjs +1 -0
- package/dist/index319.js +69 -0
- package/dist/index320.cjs +1 -0
- package/dist/index320.js +68 -0
- package/dist/index321.cjs +1 -0
- package/dist/index321.js +191 -0
- package/dist/index322.cjs +1 -0
- package/dist/index322.js +79 -0
- package/dist/index323.cjs +1 -0
- package/dist/index323.js +43 -0
- package/dist/index324.cjs +1 -0
- package/dist/index324.js +19 -0
- package/dist/index325.cjs +1 -0
- package/dist/index325.js +16 -0
- package/dist/index326.cjs +1 -0
- package/dist/index326.js +7 -0
- package/dist/index327.cjs +1 -0
- package/dist/index327.js +66 -0
- package/dist/index328.cjs +1 -0
- package/dist/index328.js +7 -0
- package/dist/index329.cjs +1 -0
- package/dist/index329.js +47 -0
- package/dist/index330.cjs +1 -0
- package/dist/index330.js +71 -0
- package/dist/index331.cjs +1 -0
- package/dist/index331.js +4 -0
- package/dist/index332.cjs +1 -0
- package/dist/index332.js +24 -0
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +38 -38
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +1 -1
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +35 -34
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +26 -30
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +13 -9
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +19 -19
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +31 -30
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -2
- package/dist/index95.cjs +1 -1
- package/dist/index95.js +73 -73
- package/dist/src/lib/auth/apikey/apikey.d.ts +1 -1
- package/dist/src/lib/auth/auth.types.d.ts +1 -1
- package/dist/src/lib/fetcher/fetcher.d.ts +2 -0
- package/dist/src/lib/utils.d.ts +1 -0
- package/package.json +2 -2
package/dist/index282.js
CHANGED
|
@@ -1,9 +1,247 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { numberToBytesLE as _, numberToBytesBE as S, bitMask as K, bytesToNumberLE as x, bytesToNumberBE as T, _validateObject as Q } from "./index301.js";
|
|
2
|
+
import { anumber as Y } from "./index287.js";
|
|
2
3
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const a = BigInt(0), g = BigInt(1), B = /* @__PURE__ */ BigInt(2), L = /* @__PURE__ */ BigInt(3), M = /* @__PURE__ */ BigInt(4), A = /* @__PURE__ */ BigInt(5), U = /* @__PURE__ */ BigInt(7), V = /* @__PURE__ */ BigInt(8), k = /* @__PURE__ */ BigInt(9), Z = /* @__PURE__ */ BigInt(16);
|
|
5
|
+
function q(t, n) {
|
|
6
|
+
const r = t % n;
|
|
7
|
+
return r >= a ? r : n + r;
|
|
8
|
+
}
|
|
9
|
+
function F(t, n, r) {
|
|
10
|
+
let o = t;
|
|
11
|
+
for (; n-- > a; )
|
|
12
|
+
o *= o, o %= r;
|
|
13
|
+
return o;
|
|
14
|
+
}
|
|
15
|
+
function y(t, n) {
|
|
16
|
+
if (t === a)
|
|
17
|
+
throw new Error("invert: expected non-zero number");
|
|
18
|
+
if (n <= a)
|
|
19
|
+
throw new Error("invert: expected positive modulus, got " + n);
|
|
20
|
+
let r = q(t, n), o = n, l = a, f = g;
|
|
21
|
+
for (; r !== a; ) {
|
|
22
|
+
const i = o / r, s = o % r, u = l - f * i;
|
|
23
|
+
o = r, r = s, l = f, f = u;
|
|
24
|
+
}
|
|
25
|
+
if (o !== g)
|
|
26
|
+
throw new Error("invert: does not exist");
|
|
27
|
+
return q(l, n);
|
|
28
|
+
}
|
|
29
|
+
function b(t, n, r) {
|
|
30
|
+
if (!t.eql(t.sqr(n), r))
|
|
31
|
+
throw new Error("Cannot find square root");
|
|
32
|
+
}
|
|
33
|
+
function j(t, n) {
|
|
34
|
+
const r = (t.ORDER + g) / M, o = t.pow(n, r);
|
|
35
|
+
return b(t, o, n), o;
|
|
36
|
+
}
|
|
37
|
+
function G(t, n) {
|
|
38
|
+
const r = (t.ORDER - A) / V, o = t.mul(n, B), l = t.pow(o, r), f = t.mul(n, l), d = t.mul(t.mul(f, B), l), i = t.mul(f, t.sub(d, t.ONE));
|
|
39
|
+
return b(t, i, n), i;
|
|
40
|
+
}
|
|
41
|
+
function J(t) {
|
|
42
|
+
const n = C(t), r = z(t), o = r(n, n.neg(n.ONE)), l = r(n, o), f = r(n, n.neg(o)), d = (t + U) / Z;
|
|
43
|
+
return (i, s) => {
|
|
44
|
+
let u = i.pow(s, d), h = i.mul(u, o);
|
|
45
|
+
const w = i.mul(u, l), e = i.mul(u, f), c = i.eql(i.sqr(h), s), m = i.eql(i.sqr(w), s);
|
|
46
|
+
u = i.cmov(u, h, c), h = i.cmov(e, w, m);
|
|
47
|
+
const v = i.eql(i.sqr(h), s), E = i.cmov(u, h, v);
|
|
48
|
+
return b(i, E, s), E;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function z(t) {
|
|
52
|
+
if (t < L)
|
|
53
|
+
throw new Error("sqrt is not defined for small field");
|
|
54
|
+
let n = t - g, r = 0;
|
|
55
|
+
for (; n % B === a; )
|
|
56
|
+
n /= B, r++;
|
|
57
|
+
let o = B;
|
|
58
|
+
const l = C(t);
|
|
59
|
+
for (; I(l, o) === 1; )
|
|
60
|
+
if (o++ > 1e3)
|
|
61
|
+
throw new Error("Cannot find square root: probably non-prime P");
|
|
62
|
+
if (r === 1)
|
|
63
|
+
return j;
|
|
64
|
+
let f = l.pow(o, n);
|
|
65
|
+
const d = (n + g) / B;
|
|
66
|
+
return function(s, u) {
|
|
67
|
+
if (s.is0(u))
|
|
68
|
+
return u;
|
|
69
|
+
if (I(s, u) !== 1)
|
|
70
|
+
throw new Error("Cannot find square root");
|
|
71
|
+
let h = r, w = s.mul(s.ONE, f), e = s.pow(u, n), c = s.pow(u, d);
|
|
72
|
+
for (; !s.eql(e, s.ONE); ) {
|
|
73
|
+
if (s.is0(e))
|
|
74
|
+
return s.ZERO;
|
|
75
|
+
let m = 1, v = s.sqr(e);
|
|
76
|
+
for (; !s.eql(v, s.ONE); )
|
|
77
|
+
if (m++, v = s.sqr(v), m === h)
|
|
78
|
+
throw new Error("Cannot find square root");
|
|
79
|
+
const E = g << BigInt(h - m - 1), N = s.pow(w, E);
|
|
80
|
+
h = m, w = s.sqr(N), e = s.mul(e, w), c = s.mul(c, N);
|
|
81
|
+
}
|
|
82
|
+
return c;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function O(t) {
|
|
86
|
+
return t % M === L ? j : t % V === A ? G : t % Z === k ? J(t) : z(t);
|
|
87
|
+
}
|
|
88
|
+
const W = [
|
|
89
|
+
"create",
|
|
90
|
+
"isValid",
|
|
91
|
+
"is0",
|
|
92
|
+
"neg",
|
|
93
|
+
"inv",
|
|
94
|
+
"sqrt",
|
|
95
|
+
"sqr",
|
|
96
|
+
"eql",
|
|
97
|
+
"add",
|
|
98
|
+
"sub",
|
|
99
|
+
"mul",
|
|
100
|
+
"pow",
|
|
101
|
+
"div",
|
|
102
|
+
"addN",
|
|
103
|
+
"subN",
|
|
104
|
+
"mulN",
|
|
105
|
+
"sqrN"
|
|
106
|
+
];
|
|
107
|
+
function tt(t) {
|
|
108
|
+
const n = {
|
|
109
|
+
ORDER: "bigint",
|
|
110
|
+
MASK: "bigint",
|
|
111
|
+
BYTES: "number",
|
|
112
|
+
BITS: "number"
|
|
113
|
+
}, r = W.reduce((o, l) => (o[l] = "function", o), n);
|
|
114
|
+
return Q(t, r), t;
|
|
115
|
+
}
|
|
116
|
+
function X(t, n, r) {
|
|
117
|
+
if (r < a)
|
|
118
|
+
throw new Error("invalid exponent, negatives unsupported");
|
|
119
|
+
if (r === a)
|
|
120
|
+
return t.ONE;
|
|
121
|
+
if (r === g)
|
|
122
|
+
return n;
|
|
123
|
+
let o = t.ONE, l = n;
|
|
124
|
+
for (; r > a; )
|
|
125
|
+
r & g && (o = t.mul(o, l)), l = t.sqr(l), r >>= g;
|
|
126
|
+
return o;
|
|
127
|
+
}
|
|
128
|
+
function $(t, n, r = !1) {
|
|
129
|
+
const o = new Array(n.length).fill(r ? t.ZERO : void 0), l = n.reduce((d, i, s) => t.is0(i) ? d : (o[s] = d, t.mul(d, i)), t.ONE), f = t.inv(l);
|
|
130
|
+
return n.reduceRight((d, i, s) => t.is0(i) ? d : (o[s] = t.mul(d, o[s]), t.mul(d, i)), f), o;
|
|
131
|
+
}
|
|
132
|
+
function I(t, n) {
|
|
133
|
+
const r = (t.ORDER - g) / B, o = t.pow(n, r), l = t.eql(o, t.ONE), f = t.eql(o, t.ZERO), d = t.eql(o, t.neg(t.ONE));
|
|
134
|
+
if (!l && !f && !d)
|
|
135
|
+
throw new Error("invalid Legendre symbol result");
|
|
136
|
+
return l ? 1 : f ? 0 : -1;
|
|
137
|
+
}
|
|
138
|
+
function P(t, n) {
|
|
139
|
+
n !== void 0 && Y(n);
|
|
140
|
+
const r = n !== void 0 ? n : t.toString(2).length, o = Math.ceil(r / 8);
|
|
141
|
+
return { nBitLength: r, nByteLength: o };
|
|
142
|
+
}
|
|
143
|
+
function C(t, n, r = !1, o = {}) {
|
|
144
|
+
if (t <= a)
|
|
145
|
+
throw new Error("invalid field: expected ORDER > 0, got " + t);
|
|
146
|
+
let l, f, d = !1, i;
|
|
147
|
+
if (typeof n == "object" && n != null) {
|
|
148
|
+
if (o.sqrt || r)
|
|
149
|
+
throw new Error("cannot specify opts in two arguments");
|
|
150
|
+
const e = n;
|
|
151
|
+
e.BITS && (l = e.BITS), e.sqrt && (f = e.sqrt), typeof e.isLE == "boolean" && (r = e.isLE), typeof e.modFromBytes == "boolean" && (d = e.modFromBytes), i = e.allowedLengths;
|
|
152
|
+
} else
|
|
153
|
+
typeof n == "number" && (l = n), o.sqrt && (f = o.sqrt);
|
|
154
|
+
const { nBitLength: s, nByteLength: u } = P(t, l);
|
|
155
|
+
if (u > 2048)
|
|
156
|
+
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
157
|
+
let h;
|
|
158
|
+
const w = Object.freeze({
|
|
159
|
+
ORDER: t,
|
|
160
|
+
isLE: r,
|
|
161
|
+
BITS: s,
|
|
162
|
+
BYTES: u,
|
|
163
|
+
MASK: K(s),
|
|
164
|
+
ZERO: a,
|
|
165
|
+
ONE: g,
|
|
166
|
+
allowedLengths: i,
|
|
167
|
+
create: (e) => q(e, t),
|
|
168
|
+
isValid: (e) => {
|
|
169
|
+
if (typeof e != "bigint")
|
|
170
|
+
throw new Error("invalid field element: expected bigint, got " + typeof e);
|
|
171
|
+
return a <= e && e < t;
|
|
172
|
+
},
|
|
173
|
+
is0: (e) => e === a,
|
|
174
|
+
// is valid and invertible
|
|
175
|
+
isValidNot0: (e) => !w.is0(e) && w.isValid(e),
|
|
176
|
+
isOdd: (e) => (e & g) === g,
|
|
177
|
+
neg: (e) => q(-e, t),
|
|
178
|
+
eql: (e, c) => e === c,
|
|
179
|
+
sqr: (e) => q(e * e, t),
|
|
180
|
+
add: (e, c) => q(e + c, t),
|
|
181
|
+
sub: (e, c) => q(e - c, t),
|
|
182
|
+
mul: (e, c) => q(e * c, t),
|
|
183
|
+
pow: (e, c) => X(w, e, c),
|
|
184
|
+
div: (e, c) => q(e * y(c, t), t),
|
|
185
|
+
// Same as above, but doesn't normalize
|
|
186
|
+
sqrN: (e) => e * e,
|
|
187
|
+
addN: (e, c) => e + c,
|
|
188
|
+
subN: (e, c) => e - c,
|
|
189
|
+
mulN: (e, c) => e * c,
|
|
190
|
+
inv: (e) => y(e, t),
|
|
191
|
+
sqrt: f || ((e) => (h || (h = O(t)), h(w, e))),
|
|
192
|
+
toBytes: (e) => r ? _(e, u) : S(e, u),
|
|
193
|
+
fromBytes: (e, c = !0) => {
|
|
194
|
+
if (i) {
|
|
195
|
+
if (!i.includes(e.length) || e.length > u)
|
|
196
|
+
throw new Error("Field.fromBytes: expected " + i + " bytes, got " + e.length);
|
|
197
|
+
const v = new Uint8Array(u);
|
|
198
|
+
v.set(e, r ? 0 : v.length - e.length), e = v;
|
|
199
|
+
}
|
|
200
|
+
if (e.length !== u)
|
|
201
|
+
throw new Error("Field.fromBytes: expected " + u + " bytes, got " + e.length);
|
|
202
|
+
let m = r ? x(e) : T(e);
|
|
203
|
+
if (d && (m = q(m, t)), !c && !w.isValid(m))
|
|
204
|
+
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
205
|
+
return m;
|
|
206
|
+
},
|
|
207
|
+
// TODO: we don't need it here, move out to separate fn
|
|
208
|
+
invertBatch: (e) => $(w, e),
|
|
209
|
+
// We can't move this out because Fp6, Fp12 implement it
|
|
210
|
+
// and it's unclear what to return in there.
|
|
211
|
+
cmov: (e, c, m) => m ? c : e
|
|
212
|
+
});
|
|
213
|
+
return Object.freeze(w);
|
|
214
|
+
}
|
|
215
|
+
function H(t) {
|
|
216
|
+
if (typeof t != "bigint")
|
|
217
|
+
throw new Error("field order must be bigint");
|
|
218
|
+
const n = t.toString(2).length;
|
|
219
|
+
return Math.ceil(n / 8);
|
|
220
|
+
}
|
|
221
|
+
function D(t) {
|
|
222
|
+
const n = H(t);
|
|
223
|
+
return n + Math.ceil(n / 2);
|
|
224
|
+
}
|
|
225
|
+
function et(t, n, r = !1) {
|
|
226
|
+
const o = t.length, l = H(n), f = D(n);
|
|
227
|
+
if (o < 16 || o < f || o > 1024)
|
|
228
|
+
throw new Error("expected " + f + "-1024 bytes of input, got " + o);
|
|
229
|
+
const d = r ? x(t) : T(t), i = q(d, n - g) + g;
|
|
230
|
+
return r ? _(i, l) : S(i, l);
|
|
6
231
|
}
|
|
7
232
|
export {
|
|
8
|
-
|
|
233
|
+
C as Field,
|
|
234
|
+
$ as FpInvertBatch,
|
|
235
|
+
I as FpLegendre,
|
|
236
|
+
X as FpPow,
|
|
237
|
+
O as FpSqrt,
|
|
238
|
+
H as getFieldBytesLength,
|
|
239
|
+
D as getMinHashLength,
|
|
240
|
+
y as invert,
|
|
241
|
+
et as mapHashToField,
|
|
242
|
+
q as mod,
|
|
243
|
+
P as nLength,
|
|
244
|
+
F as pow2,
|
|
245
|
+
z as tonelliShanks,
|
|
246
|
+
tt as validateField
|
|
9
247
|
};
|
package/dist/index283.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index154.cjs"),r=require("./index156.cjs"),c=e=>r.keccak256(t.toBytes(e));function n(e){return c(e)}exports.hashSignature=n;
|
package/dist/index283.js
CHANGED
|
@@ -1,227 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const o = t % n;
|
|
7
|
-
return o >= g ? o : n + o;
|
|
8
|
-
}
|
|
9
|
-
function O(t, n, o) {
|
|
10
|
-
let r = t;
|
|
11
|
-
for (; n-- > g; )
|
|
12
|
-
r *= r, r %= o;
|
|
13
|
-
return r;
|
|
14
|
-
}
|
|
15
|
-
function B(t, n) {
|
|
16
|
-
if (t === g)
|
|
17
|
-
throw new Error("invert: expected non-zero number");
|
|
18
|
-
if (n <= g)
|
|
19
|
-
throw new Error("invert: expected positive modulus, got " + n);
|
|
20
|
-
let o = h(t, n), r = n, s = g, f = d;
|
|
21
|
-
for (; o !== g; ) {
|
|
22
|
-
const u = r / o, i = r % o, w = s - f * u;
|
|
23
|
-
r = o, o = i, s = f, f = w;
|
|
24
|
-
}
|
|
25
|
-
if (r !== d)
|
|
26
|
-
throw new Error("invert: does not exist");
|
|
27
|
-
return h(s, n);
|
|
28
|
-
}
|
|
29
|
-
function M(t, n) {
|
|
30
|
-
const o = (t.ORDER + d) / x, r = t.pow(n, o);
|
|
31
|
-
if (!t.eql(t.sqr(r), n))
|
|
32
|
-
throw new Error("Cannot find square root");
|
|
33
|
-
return r;
|
|
34
|
-
}
|
|
35
|
-
function H(t, n) {
|
|
36
|
-
const o = (t.ORDER - T) / L, r = t.mul(n, q), s = t.pow(r, o), f = t.mul(n, s), c = t.mul(t.mul(f, q), s), u = t.mul(f, t.sub(c, t.ONE));
|
|
37
|
-
if (!t.eql(t.sqr(u), n))
|
|
38
|
-
throw new Error("Cannot find square root");
|
|
39
|
-
return u;
|
|
40
|
-
}
|
|
41
|
-
function K(t) {
|
|
42
|
-
if (t < BigInt(3))
|
|
43
|
-
throw new Error("sqrt is not defined for small field");
|
|
44
|
-
let n = t - d, o = 0;
|
|
45
|
-
for (; n % q === g; )
|
|
46
|
-
n /= q, o++;
|
|
47
|
-
let r = q;
|
|
48
|
-
const s = U(t);
|
|
49
|
-
for (; N(s, r) === 1; )
|
|
50
|
-
if (r++ > 1e3)
|
|
51
|
-
throw new Error("Cannot find square root: probably non-prime P");
|
|
52
|
-
if (o === 1)
|
|
53
|
-
return M;
|
|
54
|
-
let f = s.pow(r, n);
|
|
55
|
-
const c = (n + d) / q;
|
|
56
|
-
return function(i, w) {
|
|
57
|
-
if (i.is0(w))
|
|
58
|
-
return w;
|
|
59
|
-
if (N(i, w) !== 1)
|
|
60
|
-
throw new Error("Cannot find square root");
|
|
61
|
-
let e = o, l = i.mul(i.ONE, f), a = i.pow(w, n), b = i.pow(w, c);
|
|
62
|
-
for (; !i.eql(a, i.ONE); ) {
|
|
63
|
-
if (i.is0(a))
|
|
64
|
-
return i.ZERO;
|
|
65
|
-
let m = 1, E = i.sqr(a);
|
|
66
|
-
for (; !i.eql(E, i.ONE); )
|
|
67
|
-
if (m++, E = i.sqr(E), m === e)
|
|
68
|
-
throw new Error("Cannot find square root");
|
|
69
|
-
const C = d << BigInt(e - m - 1), v = i.pow(l, C);
|
|
70
|
-
e = m, l = i.sqr(v), a = i.mul(a, l), b = i.mul(b, v);
|
|
71
|
-
}
|
|
72
|
-
return b;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
function Q(t) {
|
|
76
|
-
return t % x === V ? M : t % L === T ? H : K(t);
|
|
77
|
-
}
|
|
78
|
-
const Y = [
|
|
79
|
-
"create",
|
|
80
|
-
"isValid",
|
|
81
|
-
"is0",
|
|
82
|
-
"neg",
|
|
83
|
-
"inv",
|
|
84
|
-
"sqrt",
|
|
85
|
-
"sqr",
|
|
86
|
-
"eql",
|
|
87
|
-
"add",
|
|
88
|
-
"sub",
|
|
89
|
-
"mul",
|
|
90
|
-
"pow",
|
|
91
|
-
"div",
|
|
92
|
-
"addN",
|
|
93
|
-
"subN",
|
|
94
|
-
"mulN",
|
|
95
|
-
"sqrN"
|
|
96
|
-
];
|
|
97
|
-
function P(t) {
|
|
98
|
-
const n = {
|
|
99
|
-
ORDER: "bigint",
|
|
100
|
-
MASK: "bigint",
|
|
101
|
-
BYTES: "number",
|
|
102
|
-
BITS: "number"
|
|
103
|
-
}, o = Y.reduce((r, s) => (r[s] = "function", r), n);
|
|
104
|
-
return j(t, o), t;
|
|
105
|
-
}
|
|
106
|
-
function k(t, n, o) {
|
|
107
|
-
if (o < g)
|
|
108
|
-
throw new Error("invalid exponent, negatives unsupported");
|
|
109
|
-
if (o === g)
|
|
110
|
-
return t.ONE;
|
|
111
|
-
if (o === d)
|
|
112
|
-
return n;
|
|
113
|
-
let r = t.ONE, s = n;
|
|
114
|
-
for (; o > g; )
|
|
115
|
-
o & d && (r = t.mul(r, s)), s = t.sqr(s), o >>= d;
|
|
116
|
-
return r;
|
|
117
|
-
}
|
|
118
|
-
function G(t, n, o = !1) {
|
|
119
|
-
const r = new Array(n.length).fill(o ? t.ZERO : void 0), s = n.reduce((c, u, i) => t.is0(u) ? c : (r[i] = c, t.mul(c, u)), t.ONE), f = t.inv(s);
|
|
120
|
-
return n.reduceRight((c, u, i) => t.is0(u) ? c : (r[i] = t.mul(c, r[i]), t.mul(c, u)), f), r;
|
|
121
|
-
}
|
|
122
|
-
function N(t, n) {
|
|
123
|
-
const o = (t.ORDER - d) / q, r = t.pow(n, o), s = t.eql(r, t.ONE), f = t.eql(r, t.ZERO), c = t.eql(r, t.neg(t.ONE));
|
|
124
|
-
if (!s && !f && !c)
|
|
125
|
-
throw new Error("invalid Legendre symbol result");
|
|
126
|
-
return s ? 1 : f ? 0 : -1;
|
|
127
|
-
}
|
|
128
|
-
function J(t, n) {
|
|
129
|
-
n !== void 0 && z(n);
|
|
130
|
-
const o = n !== void 0 ? n : t.toString(2).length, r = Math.ceil(o / 8);
|
|
131
|
-
return { nBitLength: o, nByteLength: r };
|
|
132
|
-
}
|
|
133
|
-
function U(t, n, o = !1, r = {}) {
|
|
134
|
-
if (t <= g)
|
|
135
|
-
throw new Error("invalid field: expected ORDER > 0, got " + t);
|
|
136
|
-
let s, f;
|
|
137
|
-
if (typeof n == "object" && n != null) {
|
|
138
|
-
if (r.sqrt || o)
|
|
139
|
-
throw new Error("cannot specify opts in two arguments");
|
|
140
|
-
const e = n;
|
|
141
|
-
e.BITS && (s = e.BITS), e.sqrt && (f = e.sqrt), typeof e.isLE == "boolean" && (o = e.isLE);
|
|
142
|
-
} else
|
|
143
|
-
typeof n == "number" && (s = n), r.sqrt && (f = r.sqrt);
|
|
144
|
-
const { nBitLength: c, nByteLength: u } = J(t, s);
|
|
145
|
-
if (u > 2048)
|
|
146
|
-
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
147
|
-
let i;
|
|
148
|
-
const w = Object.freeze({
|
|
149
|
-
ORDER: t,
|
|
150
|
-
isLE: o,
|
|
151
|
-
BITS: c,
|
|
152
|
-
BYTES: u,
|
|
153
|
-
MASK: Z(c),
|
|
154
|
-
ZERO: g,
|
|
155
|
-
ONE: d,
|
|
156
|
-
create: (e) => h(e, t),
|
|
157
|
-
isValid: (e) => {
|
|
158
|
-
if (typeof e != "bigint")
|
|
159
|
-
throw new Error("invalid field element: expected bigint, got " + typeof e);
|
|
160
|
-
return g <= e && e < t;
|
|
161
|
-
},
|
|
162
|
-
is0: (e) => e === g,
|
|
163
|
-
// is valid and invertible
|
|
164
|
-
isValidNot0: (e) => !w.is0(e) && w.isValid(e),
|
|
165
|
-
isOdd: (e) => (e & d) === d,
|
|
166
|
-
neg: (e) => h(-e, t),
|
|
167
|
-
eql: (e, l) => e === l,
|
|
168
|
-
sqr: (e) => h(e * e, t),
|
|
169
|
-
add: (e, l) => h(e + l, t),
|
|
170
|
-
sub: (e, l) => h(e - l, t),
|
|
171
|
-
mul: (e, l) => h(e * l, t),
|
|
172
|
-
pow: (e, l) => k(w, e, l),
|
|
173
|
-
div: (e, l) => h(e * B(l, t), t),
|
|
174
|
-
// Same as above, but doesn't normalize
|
|
175
|
-
sqrN: (e) => e * e,
|
|
176
|
-
addN: (e, l) => e + l,
|
|
177
|
-
subN: (e, l) => e - l,
|
|
178
|
-
mulN: (e, l) => e * l,
|
|
179
|
-
inv: (e) => B(e, t),
|
|
180
|
-
sqrt: f || ((e) => (i || (i = Q(t)), i(w, e))),
|
|
181
|
-
toBytes: (e) => o ? y(e, u) : I(e, u),
|
|
182
|
-
fromBytes: (e) => {
|
|
183
|
-
if (e.length !== u)
|
|
184
|
-
throw new Error("Field.fromBytes: expected " + u + " bytes, got " + e.length);
|
|
185
|
-
return o ? S(e) : _(e);
|
|
186
|
-
},
|
|
187
|
-
// TODO: we don't need it here, move out to separate fn
|
|
188
|
-
invertBatch: (e) => G(w, e),
|
|
189
|
-
// We can't move this out because Fp6, Fp12 implement it
|
|
190
|
-
// and it's unclear what to return in there.
|
|
191
|
-
cmov: (e, l, a) => a ? l : e
|
|
192
|
-
});
|
|
193
|
-
return Object.freeze(w);
|
|
194
|
-
}
|
|
195
|
-
function A(t) {
|
|
196
|
-
if (typeof t != "bigint")
|
|
197
|
-
throw new Error("field order must be bigint");
|
|
198
|
-
const n = t.toString(2).length;
|
|
199
|
-
return Math.ceil(n / 8);
|
|
200
|
-
}
|
|
201
|
-
function W(t) {
|
|
202
|
-
const n = A(t);
|
|
203
|
-
return n + Math.ceil(n / 2);
|
|
204
|
-
}
|
|
205
|
-
function D(t, n, o = !1) {
|
|
206
|
-
const r = t.length, s = A(n), f = W(n);
|
|
207
|
-
if (r < 16 || r < f || r > 1024)
|
|
208
|
-
throw new Error("expected " + f + "-1024 bytes of input, got " + r);
|
|
209
|
-
const c = o ? S(t) : _(t), u = h(c, n - d) + d;
|
|
210
|
-
return o ? y(u, s) : I(u, s);
|
|
1
|
+
import { toBytes as o } from "./index154.js";
|
|
2
|
+
import { keccak256 as r } from "./index156.js";
|
|
3
|
+
const e = (t) => r(o(t));
|
|
4
|
+
function c(t) {
|
|
5
|
+
return e(t);
|
|
211
6
|
}
|
|
212
7
|
export {
|
|
213
|
-
|
|
214
|
-
G as FpInvertBatch,
|
|
215
|
-
N as FpLegendre,
|
|
216
|
-
k as FpPow,
|
|
217
|
-
Q as FpSqrt,
|
|
218
|
-
A as getFieldBytesLength,
|
|
219
|
-
W as getMinHashLength,
|
|
220
|
-
B as invert,
|
|
221
|
-
D as mapHashToField,
|
|
222
|
-
h as mod,
|
|
223
|
-
J as nLength,
|
|
224
|
-
O as pow2,
|
|
225
|
-
K as tonelliShanks,
|
|
226
|
-
P as validateField
|
|
8
|
+
c as hashSignature
|
|
227
9
|
};
|
package/dist/index284.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index285.cjs"),n=require("./index264.cjs"),i=t=>{const r=typeof t=="string"?t:n.formatAbiItem(t);return e.normalizeSignature(r)};exports.toSignature=i;
|
package/dist/index284.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
return
|
|
6
|
-
}
|
|
1
|
+
import { normalizeSignature as o } from "./index285.js";
|
|
2
|
+
import { formatAbiItem as n } from "./index264.js";
|
|
3
|
+
const m = (r) => {
|
|
4
|
+
const t = typeof r == "string" ? r : n(r);
|
|
5
|
+
return o(t);
|
|
6
|
+
};
|
|
7
7
|
export {
|
|
8
|
-
|
|
8
|
+
m as toSignature
|
|
9
9
|
};
|
package/dist/index285.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index41.cjs");function a(r){let l=!0,i="",o=0,t="",u=!1;for(let n=0;n<r.length;n++){const e=r[n];if(["(",")",","].includes(e)&&(l=!0),e==="("&&o++,e===")"&&o--,!!l){if(o===0){if(e===" "&&["event","function",""].includes(t))t="";else if(t+=e,e===")"){u=!0;break}continue}if(e===" "){r[n-1]!==","&&i!==","&&i!==",("&&(i="",l=!1);continue}t+=e,i+=e}}if(!u)throw new f.BaseError("Unable to normalize signature.");return t}exports.normalizeSignature=a;
|
package/dist/index285.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { BaseError as u } from "./index41.js";
|
|
2
|
+
function a(r) {
|
|
3
|
+
let l = !0, i = "", f = 0, t = "", o = !1;
|
|
4
|
+
for (let n = 0; n < r.length; n++) {
|
|
5
|
+
const e = r[n];
|
|
6
|
+
if (["(", ")", ","].includes(e) && (l = !0), e === "(" && f++, e === ")" && f--, !!l) {
|
|
7
|
+
if (f === 0) {
|
|
8
|
+
if (e === " " && ["event", "function", ""].includes(t))
|
|
9
|
+
t = "";
|
|
10
|
+
else if (t += e, e === ")") {
|
|
11
|
+
o = !0;
|
|
12
|
+
break;
|
|
13
|
+
}
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (e === " ") {
|
|
17
|
+
r[n - 1] !== "," && i !== "," && i !== ",(" && (i = "", l = !1);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
t += e, i += e;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (!o)
|
|
24
|
+
throw new u("Unable to normalize signature.");
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
7
27
|
export {
|
|
8
|
-
|
|
28
|
+
a as normalizeSignature
|
|
9
29
|
};
|
package/dist/index286.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=BigInt(2**32-1),c=BigInt(32);function u(t,o=!1){return o?{h:Number(t&l),l:Number(t>>c&l)}:{h:Number(t>>c&l)|0,l:Number(t&l)|0}}function B(t,o=!1){const r=t.length;let n=new Uint32Array(r),i=new Uint32Array(r);for(let e=0;e<r;e++){const{h:f,l:s}=u(t[e],o);[n[e],i[e]]=[f,s]}return[n,i]}const g=(t,o,r)=>t<<r|o>>>32-r,m=(t,o,r)=>o<<r|t>>>32-r,S=(t,o,r)=>o<<r-32|t>>>64-r,a=(t,o,r)=>t<<r-32|o>>>64-r;exports.fromBig=u;exports.rotlBH=S;exports.rotlBL=a;exports.rotlSH=g;exports.rotlSL=m;exports.split=B;
|
package/dist/index286.js
CHANGED
|
@@ -1,29 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
function
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o = !0;
|
|
12
|
-
break;
|
|
13
|
-
}
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
if (e === " ") {
|
|
17
|
-
r[n - 1] !== "," && i !== "," && i !== ",(" && (i = "", l = !1);
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
t += e, i += e;
|
|
21
|
-
}
|
|
1
|
+
const o = /* @__PURE__ */ BigInt(4294967295), i = /* @__PURE__ */ BigInt(32);
|
|
2
|
+
function s(t, r = !1) {
|
|
3
|
+
return r ? { h: Number(t & o), l: Number(t >> i & o) } : { h: Number(t >> i & o) | 0, l: Number(t & o) | 0 };
|
|
4
|
+
}
|
|
5
|
+
function h(t, r = !1) {
|
|
6
|
+
const n = t.length;
|
|
7
|
+
let l = new Uint32Array(n), c = new Uint32Array(n);
|
|
8
|
+
for (let e = 0; e < n; e++) {
|
|
9
|
+
const { h: u, l: f } = s(t[e], r);
|
|
10
|
+
[l[e], c[e]] = [u, f];
|
|
22
11
|
}
|
|
23
|
-
|
|
24
|
-
throw new u("Unable to normalize signature.");
|
|
25
|
-
return t;
|
|
12
|
+
return [l, c];
|
|
26
13
|
}
|
|
14
|
+
const m = (t, r, n) => t << n | r >>> 32 - n, A = (t, r, n) => r << n | t >>> 32 - n, B = (t, r, n) => r << n - 32 | t >>> 64 - n, a = (t, r, n) => t << n - 32 | r >>> 64 - n;
|
|
27
15
|
export {
|
|
28
|
-
|
|
16
|
+
s as fromBig,
|
|
17
|
+
B as rotlBH,
|
|
18
|
+
a as rotlBL,
|
|
19
|
+
m as rotlSH,
|
|
20
|
+
A as rotlSL,
|
|
21
|
+
h as split
|
|
29
22
|
};
|
package/dist/index287.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index296.cjs");/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function p(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function s(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function c(t,...e){if(!p(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function m(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");s(t.outputLen),s(t.blockLen)}function B(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function E(t,e){c(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function H(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function U(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function L(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function S(t,e){return t<<32-e|t>>>e}const h=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function w(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function g(t){for(let e=0;e<t.length;e++)t[e]=w(t[e]);return t}const T=h?t=>t:g,d=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",V=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function _(t){if(c(t),d)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=V[t[n]];return e}const f={_0:48,_9:57,A:65,F:70,a:97,f:102};function l(t){if(t>=f._0&&t<=f._9)return t-f._0;if(t>=f.A&&t<=f.F)return t-(f.A-10);if(t>=f.a&&t<=f.f)return t-(f.a-10)}function I(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(d)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const a=l(t.charCodeAt(i)),y=l(t.charCodeAt(i+1));if(a===void 0||y===void 0){const A=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+A+'" at index '+i)}r[o]=a*16+y}return r}function x(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function b(t){return typeof t=="string"&&(t=x(t)),c(t),t}function k(...t){let e=0;for(let r=0;r<t.length;r++){const o=t[r];c(o),e+=o.length}const n=new Uint8Array(e);for(let r=0,o=0;r<t.length;r++){const i=t[r];n.set(i,o),o+=i.length}return n}class O{}function R(t){const e=r=>t().update(b(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function v(t=32){if(u.crypto&&typeof u.crypto.getRandomValues=="function")return u.crypto.getRandomValues(new Uint8Array(t));if(u.crypto&&typeof u.crypto.randomBytes=="function")return Uint8Array.from(u.crypto.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}exports.Hash=O;exports.abytes=c;exports.aexists=B;exports.ahash=m;exports.anumber=s;exports.aoutput=E;exports.byteSwap=w;exports.byteSwap32=g;exports.bytesToHex=_;exports.clean=U;exports.concatBytes=k;exports.createHasher=R;exports.createView=L;exports.hexToBytes=I;exports.isBytes=p;exports.isLE=h;exports.randomBytes=v;exports.rotr=S;exports.swap32IfBE=T;exports.toBytes=b;exports.u32=H;exports.utf8ToBytes=x;
|