@gardenfi/utils 2.1.2-beta.7 → 2.1.2-beta.9
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/index102.cjs +1 -1
- package/dist/index102.js +2 -2
- package/dist/index103.cjs +1 -1
- package/dist/index103.js +1 -1
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +2 -2
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +17 -18
- package/dist/index21.cjs +1 -16
- package/dist/index21.js +30 -112
- package/dist/index22.cjs +16 -1
- package/dist/index22.js +113 -30
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +3 -3
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +1 -1
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +1 -1
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +1 -1
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +2 -2
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +2 -2
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +1 -1
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +2 -2
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +11 -11
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +3 -3
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +1 -1
- package/dist/index43.cjs +1 -1
- package/dist/index43.js +1 -1
- package/dist/index45.cjs +1 -1
- package/dist/index45.js +1 -1
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +1 -1
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +105 -33
- package/dist/index48.cjs +1 -1
- package/dist/index48.js +15 -33
- package/dist/index49.cjs +1 -1
- package/dist/index49.js +213 -59
- package/dist/index50.cjs +2 -1
- package/dist/index50.js +57 -110
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +18 -64
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +105 -2
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +3 -16
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +16 -222
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +8 -231
- package/dist/index56.cjs +1 -2
- package/dist/index56.js +9 -58
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +11 -21
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +13 -104
- package/dist/index59.cjs +1 -1
- package/dist/index59.js +18 -3
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +6 -17
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +42 -8
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +77 -9
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +14 -11
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +18 -13
- package/dist/index65.cjs +1 -1
- package/dist/index65.js +8 -18
- package/dist/index66.cjs +1 -1
- package/dist/index66.js +191 -6
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +60 -38
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +4 -78
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +40 -14
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +34 -18
- package/dist/index71.cjs +1 -1
- package/dist/index71.js +69 -8
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +58 -182
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +2 -65
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +231 -4
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +1 -1
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +2 -2
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +1 -1
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +2 -2
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +1 -1
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +1 -1
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +12 -8
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -2
- package/dist/index90.cjs +1 -1
- package/dist/index90.js +8 -12
- package/dist/index91.cjs +1 -1
- package/dist/index91.js +641 -16
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +153 -624
- package/dist/index93.cjs +1 -1
- package/dist/index93.js +17 -171
- package/dist/index95.cjs +1 -2
- package/dist/index95.js +2 -3
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +2 -2
- package/dist/index97.cjs +1 -1
- package/dist/index97.js +38 -2
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +34 -33
- package/dist/index99.cjs +2 -1
- package/dist/index99.js +3 -39
- package/package.json +1 -1
package/dist/index49.js
CHANGED
|
@@ -1,72 +1,226 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function g(t) {
|
|
5
|
-
|
|
1
|
+
import { numberToBytesLE as S, numberToBytesBE as x, bitMask as _, bytesToNumberLE as y, bytesToNumberBE as L, validateObject as M } from "./index74.js";
|
|
2
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
|
+
const d = BigInt(0), c = BigInt(1), w = /* @__PURE__ */ BigInt(2), C = /* @__PURE__ */ BigInt(3), b = /* @__PURE__ */ BigInt(4), N = /* @__PURE__ */ BigInt(5), m = /* @__PURE__ */ BigInt(8);
|
|
4
|
+
function g(t, i) {
|
|
5
|
+
const r = t % i;
|
|
6
|
+
return r >= d ? r : i + r;
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
8
|
+
function Z(t, i, r) {
|
|
9
|
+
if (i < d)
|
|
10
|
+
throw new Error("invalid exponent, negatives unsupported");
|
|
11
|
+
if (r <= d)
|
|
12
|
+
throw new Error("invalid modulus");
|
|
13
|
+
if (r === c)
|
|
14
|
+
return d;
|
|
15
|
+
let e = c;
|
|
16
|
+
for (; i > d; )
|
|
17
|
+
i & c && (e = e * t % r), t = t * t % r, i >>= c;
|
|
18
|
+
return e;
|
|
9
19
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
20
|
+
function V(t, i, r) {
|
|
21
|
+
let e = t;
|
|
22
|
+
for (; i-- > d; )
|
|
23
|
+
e *= e, e %= r;
|
|
24
|
+
return e;
|
|
12
25
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
function I(t, i) {
|
|
27
|
+
if (t === d)
|
|
28
|
+
throw new Error("invert: expected non-zero number");
|
|
29
|
+
if (i <= d)
|
|
30
|
+
throw new Error("invert: expected positive modulus, got " + i);
|
|
31
|
+
let r = g(t, i), e = i, s = d, u = c;
|
|
32
|
+
for (; r !== d; ) {
|
|
33
|
+
const o = e / r, n = e % r, l = s - u * o;
|
|
34
|
+
e = r, r = n, s = u, u = l;
|
|
35
|
+
}
|
|
36
|
+
if (e !== c)
|
|
37
|
+
throw new Error("invert: does not exist");
|
|
38
|
+
return g(s, i);
|
|
25
39
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
40
|
+
function j(t) {
|
|
41
|
+
const i = (t - c) / w;
|
|
42
|
+
let r, e, s;
|
|
43
|
+
for (r = t - c, e = 0; r % w === d; r /= w, e++)
|
|
44
|
+
;
|
|
45
|
+
for (s = w; s < t && Z(s, i, t) !== t - c; s++)
|
|
46
|
+
if (s > 1e3)
|
|
47
|
+
throw new Error("Cannot find square root: likely non-prime P");
|
|
48
|
+
if (e === 1) {
|
|
49
|
+
const f = (t + c) / b;
|
|
50
|
+
return function(n, l) {
|
|
51
|
+
const h = n.pow(l, f);
|
|
52
|
+
if (!n.eql(n.sqr(h), l))
|
|
53
|
+
throw new Error("Cannot find square root");
|
|
54
|
+
return h;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const u = (r + c) / w;
|
|
58
|
+
return function(o, n) {
|
|
59
|
+
if (o.pow(n, i) === o.neg(o.ONE))
|
|
60
|
+
throw new Error("Cannot find square root");
|
|
61
|
+
let l = e, h = o.pow(o.mul(o.ONE, s), r), v = o.pow(n, u), a = o.pow(n, r);
|
|
62
|
+
for (; !o.eql(a, o.ONE); ) {
|
|
63
|
+
if (o.eql(a, o.ZERO))
|
|
64
|
+
return o.ZERO;
|
|
65
|
+
let q = 1;
|
|
66
|
+
for (let B = o.sqr(a); q < l && !o.eql(B, o.ONE); q++)
|
|
67
|
+
B = o.sqr(B);
|
|
68
|
+
const E = o.pow(h, c << BigInt(l - q - 1));
|
|
69
|
+
h = o.sqr(E), v = o.mul(v, E), a = o.mul(a, h), l = q;
|
|
70
|
+
}
|
|
71
|
+
return v;
|
|
72
|
+
};
|
|
28
73
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
74
|
+
function z(t) {
|
|
75
|
+
if (t % b === C) {
|
|
76
|
+
const i = (t + c) / b;
|
|
77
|
+
return function(e, s) {
|
|
78
|
+
const u = e.pow(s, i);
|
|
79
|
+
if (!e.eql(e.sqr(u), s))
|
|
80
|
+
throw new Error("Cannot find square root");
|
|
81
|
+
return u;
|
|
82
|
+
};
|
|
34
83
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
84
|
+
if (t % m === N) {
|
|
85
|
+
const i = (t - N) / m;
|
|
86
|
+
return function(e, s) {
|
|
87
|
+
const u = e.mul(s, w), f = e.pow(u, i), o = e.mul(s, f), n = e.mul(e.mul(o, w), f), l = e.mul(o, e.sub(n, e.ONE));
|
|
88
|
+
if (!e.eql(e.sqr(l), s))
|
|
89
|
+
throw new Error("Cannot find square root");
|
|
90
|
+
return l;
|
|
91
|
+
};
|
|
39
92
|
}
|
|
40
|
-
return
|
|
93
|
+
return j(t);
|
|
41
94
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
95
|
+
const A = [
|
|
96
|
+
"create",
|
|
97
|
+
"isValid",
|
|
98
|
+
"is0",
|
|
99
|
+
"neg",
|
|
100
|
+
"inv",
|
|
101
|
+
"sqrt",
|
|
102
|
+
"sqr",
|
|
103
|
+
"eql",
|
|
104
|
+
"add",
|
|
105
|
+
"sub",
|
|
106
|
+
"mul",
|
|
107
|
+
"pow",
|
|
108
|
+
"div",
|
|
109
|
+
"addN",
|
|
110
|
+
"subN",
|
|
111
|
+
"mulN",
|
|
112
|
+
"sqrN"
|
|
113
|
+
];
|
|
114
|
+
function Y(t) {
|
|
115
|
+
const i = {
|
|
116
|
+
ORDER: "bigint",
|
|
117
|
+
MASK: "bigint",
|
|
118
|
+
BYTES: "isSafeInteger",
|
|
119
|
+
BITS: "isSafeInteger"
|
|
120
|
+
}, r = A.reduce((e, s) => (e[s] = "function", e), i);
|
|
121
|
+
return M(t, r);
|
|
122
|
+
}
|
|
123
|
+
function k(t, i, r) {
|
|
124
|
+
if (r < d)
|
|
125
|
+
throw new Error("invalid exponent, negatives unsupported");
|
|
126
|
+
if (r === d)
|
|
127
|
+
return t.ONE;
|
|
128
|
+
if (r === c)
|
|
129
|
+
return i;
|
|
130
|
+
let e = t.ONE, s = i;
|
|
131
|
+
for (; r > d; )
|
|
132
|
+
r & c && (e = t.mul(e, s)), s = t.sqr(s), r >>= c;
|
|
133
|
+
return e;
|
|
134
|
+
}
|
|
135
|
+
function H(t, i) {
|
|
136
|
+
const r = new Array(i.length), e = i.reduce((u, f, o) => t.is0(f) ? u : (r[o] = u, t.mul(u, f)), t.ONE), s = t.inv(e);
|
|
137
|
+
return i.reduceRight((u, f, o) => t.is0(f) ? u : (r[o] = t.mul(u, r[o]), t.mul(u, f)), s), r;
|
|
138
|
+
}
|
|
139
|
+
function K(t, i) {
|
|
140
|
+
const r = i !== void 0 ? i : t.toString(2).length, e = Math.ceil(r / 8);
|
|
141
|
+
return { nBitLength: r, nByteLength: e };
|
|
142
|
+
}
|
|
143
|
+
function p(t, i, r = !1, e = {}) {
|
|
144
|
+
if (t <= d)
|
|
145
|
+
throw new Error("invalid field: expected ORDER > 0, got " + t);
|
|
146
|
+
const { nBitLength: s, nByteLength: u } = K(t, i);
|
|
147
|
+
if (u > 2048)
|
|
148
|
+
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
149
|
+
let f;
|
|
150
|
+
const o = Object.freeze({
|
|
151
|
+
ORDER: t,
|
|
152
|
+
isLE: r,
|
|
153
|
+
BITS: s,
|
|
154
|
+
BYTES: u,
|
|
155
|
+
MASK: _(s),
|
|
156
|
+
ZERO: d,
|
|
157
|
+
ONE: c,
|
|
158
|
+
create: (n) => g(n, t),
|
|
159
|
+
isValid: (n) => {
|
|
160
|
+
if (typeof n != "bigint")
|
|
161
|
+
throw new Error("invalid field element: expected bigint, got " + typeof n);
|
|
162
|
+
return d <= n && n < t;
|
|
163
|
+
},
|
|
164
|
+
is0: (n) => n === d,
|
|
165
|
+
isOdd: (n) => (n & c) === c,
|
|
166
|
+
neg: (n) => g(-n, t),
|
|
167
|
+
eql: (n, l) => n === l,
|
|
168
|
+
sqr: (n) => g(n * n, t),
|
|
169
|
+
add: (n, l) => g(n + l, t),
|
|
170
|
+
sub: (n, l) => g(n - l, t),
|
|
171
|
+
mul: (n, l) => g(n * l, t),
|
|
172
|
+
pow: (n, l) => k(o, n, l),
|
|
173
|
+
div: (n, l) => g(n * I(l, t), t),
|
|
174
|
+
// Same as above, but doesn't normalize
|
|
175
|
+
sqrN: (n) => n * n,
|
|
176
|
+
addN: (n, l) => n + l,
|
|
177
|
+
subN: (n, l) => n - l,
|
|
178
|
+
mulN: (n, l) => n * l,
|
|
179
|
+
inv: (n) => I(n, t),
|
|
180
|
+
sqrt: e.sqrt || ((n) => (f || (f = z(t)), f(o, n))),
|
|
181
|
+
invertBatch: (n) => H(o, n),
|
|
182
|
+
// TODO: do we really need constant cmov?
|
|
183
|
+
// We don't have const-time bigints anyway, so probably will be not very useful
|
|
184
|
+
cmov: (n, l, h) => h ? l : n,
|
|
185
|
+
toBytes: (n) => r ? S(n, u) : x(n, u),
|
|
186
|
+
fromBytes: (n) => {
|
|
187
|
+
if (n.length !== u)
|
|
188
|
+
throw new Error("Field.fromBytes: expected " + u + " bytes, got " + n.length);
|
|
189
|
+
return r ? y(n) : L(n);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
return Object.freeze(o);
|
|
193
|
+
}
|
|
194
|
+
function T(t) {
|
|
195
|
+
if (typeof t != "bigint")
|
|
196
|
+
throw new Error("field order must be bigint");
|
|
197
|
+
const i = t.toString(2).length;
|
|
198
|
+
return Math.ceil(i / 8);
|
|
47
199
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
return
|
|
200
|
+
function O(t) {
|
|
201
|
+
const i = T(t);
|
|
202
|
+
return i + Math.ceil(i / 2);
|
|
51
203
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
204
|
+
function G(t, i, r = !1) {
|
|
205
|
+
const e = t.length, s = T(i), u = O(i);
|
|
206
|
+
if (e < 16 || e < u || e > 1024)
|
|
207
|
+
throw new Error("expected " + u + "-1024 bytes of input, got " + e);
|
|
208
|
+
const f = r ? y(t) : L(t), o = g(f, i - c) + c;
|
|
209
|
+
return r ? S(o, s) : x(o, s);
|
|
58
210
|
}
|
|
59
211
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
212
|
+
p as Field,
|
|
213
|
+
H as FpInvertBatch,
|
|
214
|
+
k as FpPow,
|
|
215
|
+
z as FpSqrt,
|
|
216
|
+
T as getFieldBytesLength,
|
|
217
|
+
O as getMinHashLength,
|
|
218
|
+
I as invert,
|
|
219
|
+
G as mapHashToField,
|
|
220
|
+
g as mod,
|
|
221
|
+
K as nLength,
|
|
222
|
+
Z as pow,
|
|
223
|
+
V as pow2,
|
|
224
|
+
j as tonelliShanks,
|
|
225
|
+
Y as validateField
|
|
72
226
|
};
|
package/dist/index50.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index75.cjs");let i={getDocsUrl:({docsBaseUrl:s,docsPath:t="",docsSlug:e})=>t?`${s??"https://viem.sh"}${t}${e?`#${e}`:""}`:void 0,version:`viem@${l.version}`};class u extends Error{constructor(t,e={}){var o;const r=(()=>{var c;return e.cause instanceof u?e.cause.details:(c=e.cause)!=null&&c.message?e.cause.message:e.details})(),n=e.cause instanceof u&&e.cause.docsPath||e.docsPath,a=(o=i.getDocsUrl)==null?void 0:o.call(i,{...e,docsPath:n}),b=[t||"An error occurred.","",...e.metaMessages?[...e.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...r?[`Details: ${r}`]:[],...i.version?[`Version: ${i.version}`]:[]].join(`
|
|
2
|
+
`);super(b,e.cause?{cause:e.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=n,this.metaMessages=e.metaMessages,this.name=e.name??this.name,this.shortMessage=t,this.version=l.version}walk(t){return d(this,t)}}function d(s,t){return t!=null&&t(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?d(s.cause,t):t?null:s}exports.BaseError=u;
|
package/dist/index50.js
CHANGED
|
@@ -1,115 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
430227734,
|
|
53
|
-
506948616,
|
|
54
|
-
659060556,
|
|
55
|
-
883997877,
|
|
56
|
-
958139571,
|
|
57
|
-
1322822218,
|
|
58
|
-
1537002063,
|
|
59
|
-
1747873779,
|
|
60
|
-
1955562222,
|
|
61
|
-
2024104815,
|
|
62
|
-
2227730452,
|
|
63
|
-
2361852424,
|
|
64
|
-
2428436474,
|
|
65
|
-
2756734187,
|
|
66
|
-
3204031479,
|
|
67
|
-
3329325298
|
|
68
|
-
]), b = /* @__PURE__ */ new Uint32Array([
|
|
69
|
-
1779033703,
|
|
70
|
-
3144134277,
|
|
71
|
-
1013904242,
|
|
72
|
-
2773480762,
|
|
73
|
-
1359893119,
|
|
74
|
-
2600822924,
|
|
75
|
-
528734635,
|
|
76
|
-
1541459225
|
|
77
|
-
]), h = /* @__PURE__ */ new Uint32Array(64);
|
|
78
|
-
class w extends m {
|
|
79
|
-
constructor() {
|
|
80
|
-
super(64, 32, 8, !1), this.A = b[0] | 0, this.B = b[1] | 0, this.C = b[2] | 0, this.D = b[3] | 0, this.E = b[4] | 0, this.F = b[5] | 0, this.G = b[6] | 0, this.H = b[7] | 0;
|
|
81
|
-
}
|
|
82
|
-
get() {
|
|
83
|
-
const { A: d, B: o, C: t, D: s, E: a, F: f, G: c, H: e } = this;
|
|
84
|
-
return [d, o, t, s, a, f, c, e];
|
|
85
|
-
}
|
|
86
|
-
// prettier-ignore
|
|
87
|
-
set(d, o, t, s, a, f, c, e) {
|
|
88
|
-
this.A = d | 0, this.B = o | 0, this.C = t | 0, this.D = s | 0, this.E = a | 0, this.F = f | 0, this.G = c | 0, this.H = e | 0;
|
|
89
|
-
}
|
|
90
|
-
process(d, o) {
|
|
91
|
-
for (let x = 0; x < 16; x++, o += 4)
|
|
92
|
-
h[x] = d.getUint32(o, !1);
|
|
93
|
-
for (let x = 16; x < 64; x++) {
|
|
94
|
-
const A = h[x - 15], n = h[x - 2], C = i(A, 7) ^ i(A, 18) ^ A >>> 3, H = i(n, 17) ^ i(n, 19) ^ n >>> 10;
|
|
95
|
-
h[x] = H + h[x - 7] + C + h[x - 16] | 0;
|
|
96
|
-
}
|
|
97
|
-
let { A: t, B: s, C: a, D: f, E: c, F: e, G: r, H: l } = this;
|
|
98
|
-
for (let x = 0; x < 64; x++) {
|
|
99
|
-
const A = i(c, 6) ^ i(c, 11) ^ i(c, 25), n = l + A + p(c, e, r) + g[x] + h[x] | 0, H = (i(t, 2) ^ i(t, 13) ^ i(t, 22)) + u(t, s, a) | 0;
|
|
100
|
-
l = r, r = e, e = c, c = f + n | 0, f = a, a = s, s = t, t = n + H | 0;
|
|
101
|
-
}
|
|
102
|
-
t = t + this.A | 0, s = s + this.B | 0, a = a + this.C | 0, f = f + this.D | 0, c = c + this.E | 0, e = e + this.F | 0, r = r + this.G | 0, l = l + this.H | 0, this.set(t, s, a, f, c, e, r, l);
|
|
103
|
-
}
|
|
104
|
-
roundClean() {
|
|
105
|
-
h.fill(0);
|
|
1
|
+
import { version as l } from "./index75.js";
|
|
2
|
+
let i = {
|
|
3
|
+
getDocsUrl: ({ docsBaseUrl: s, docsPath: t = "", docsSlug: e }) => t ? `${s ?? "https://viem.sh"}${t}${e ? `#${e}` : ""}` : void 0,
|
|
4
|
+
version: `viem@${l}`
|
|
5
|
+
};
|
|
6
|
+
class r extends Error {
|
|
7
|
+
constructor(t, e = {}) {
|
|
8
|
+
var o;
|
|
9
|
+
const u = (() => {
|
|
10
|
+
var c;
|
|
11
|
+
return e.cause instanceof r ? e.cause.details : (c = e.cause) != null && c.message ? e.cause.message : e.details;
|
|
12
|
+
})(), a = e.cause instanceof r && e.cause.docsPath || e.docsPath, n = (o = i.getDocsUrl) == null ? void 0 : o.call(i, { ...e, docsPath: a }), b = [
|
|
13
|
+
t || "An error occurred.",
|
|
14
|
+
"",
|
|
15
|
+
...e.metaMessages ? [...e.metaMessages, ""] : [],
|
|
16
|
+
...n ? [`Docs: ${n}`] : [],
|
|
17
|
+
...u ? [`Details: ${u}`] : [],
|
|
18
|
+
...i.version ? [`Version: ${i.version}`] : []
|
|
19
|
+
].join(`
|
|
20
|
+
`);
|
|
21
|
+
super(b, e.cause ? { cause: e.cause } : void 0), Object.defineProperty(this, "details", {
|
|
22
|
+
enumerable: !0,
|
|
23
|
+
configurable: !0,
|
|
24
|
+
writable: !0,
|
|
25
|
+
value: void 0
|
|
26
|
+
}), Object.defineProperty(this, "docsPath", {
|
|
27
|
+
enumerable: !0,
|
|
28
|
+
configurable: !0,
|
|
29
|
+
writable: !0,
|
|
30
|
+
value: void 0
|
|
31
|
+
}), Object.defineProperty(this, "metaMessages", {
|
|
32
|
+
enumerable: !0,
|
|
33
|
+
configurable: !0,
|
|
34
|
+
writable: !0,
|
|
35
|
+
value: void 0
|
|
36
|
+
}), Object.defineProperty(this, "shortMessage", {
|
|
37
|
+
enumerable: !0,
|
|
38
|
+
configurable: !0,
|
|
39
|
+
writable: !0,
|
|
40
|
+
value: void 0
|
|
41
|
+
}), Object.defineProperty(this, "version", {
|
|
42
|
+
enumerable: !0,
|
|
43
|
+
configurable: !0,
|
|
44
|
+
writable: !0,
|
|
45
|
+
value: void 0
|
|
46
|
+
}), Object.defineProperty(this, "name", {
|
|
47
|
+
enumerable: !0,
|
|
48
|
+
configurable: !0,
|
|
49
|
+
writable: !0,
|
|
50
|
+
value: "BaseError"
|
|
51
|
+
}), this.details = u, this.docsPath = a, this.metaMessages = e.metaMessages, this.name = e.name ?? this.name, this.shortMessage = t, this.version = l;
|
|
106
52
|
}
|
|
107
|
-
|
|
108
|
-
this
|
|
53
|
+
walk(t) {
|
|
54
|
+
return d(this, t);
|
|
109
55
|
}
|
|
110
56
|
}
|
|
111
|
-
|
|
57
|
+
function d(s, t) {
|
|
58
|
+
return t != null && t(s) ? s : s && typeof s == "object" && "cause" in s && s.cause !== void 0 ? d(s.cause, t) : t ? null : s;
|
|
59
|
+
}
|
|
112
60
|
export {
|
|
113
|
-
|
|
114
|
-
G as sha256
|
|
61
|
+
r as BaseError
|
|
115
62
|
};
|
package/dist/index51.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class i extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const s=this.keys().next().value;s&&this.delete(s)}return this}}exports.LruMap=i;
|
package/dist/index51.js
CHANGED
|
@@ -1,70 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
function B(o, t, s) {
|
|
10
|
-
return o & t ^ ~o & s;
|
|
11
|
-
}
|
|
12
|
-
function L(o, t, s) {
|
|
13
|
-
return o & t ^ o & s ^ t & s;
|
|
14
|
-
}
|
|
15
|
-
class U extends b {
|
|
16
|
-
constructor(t, s, i, n) {
|
|
17
|
-
super(), this.blockLen = t, this.outputLen = s, this.padOffset = i, this.isLE = n, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = p(this.buffer);
|
|
1
|
+
class r extends Map {
|
|
2
|
+
constructor(e) {
|
|
3
|
+
super(), Object.defineProperty(this, "maxSize", {
|
|
4
|
+
enumerable: !0,
|
|
5
|
+
configurable: !0,
|
|
6
|
+
writable: !0,
|
|
7
|
+
value: void 0
|
|
8
|
+
}), this.maxSize = e;
|
|
18
9
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
t = a(t);
|
|
23
|
-
const h = t.length;
|
|
24
|
-
for (let e = 0; e < h; ) {
|
|
25
|
-
const r = Math.min(n - this.pos, h - e);
|
|
26
|
-
if (r === n) {
|
|
27
|
-
const u = p(t);
|
|
28
|
-
for (; n <= h - e; e += n)
|
|
29
|
-
this.process(u, e);
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
i.set(t.subarray(e, e + r), this.pos), this.pos += r, e += r, this.pos === n && (this.process(s, 0), this.pos = 0);
|
|
33
|
-
}
|
|
34
|
-
return this.length += t.length, this.roundClean(), this;
|
|
10
|
+
get(e) {
|
|
11
|
+
const t = super.get(e);
|
|
12
|
+
return super.has(e) && t !== void 0 && (this.delete(e), super.set(e, t)), t;
|
|
35
13
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
s[f] = 0;
|
|
43
|
-
w(i, n - 8, BigInt(this.length * 8), h), this.process(i, 0);
|
|
44
|
-
const r = p(t), u = this.outputLen;
|
|
45
|
-
if (u % 4)
|
|
46
|
-
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
47
|
-
const c = u / 4, l = this.get();
|
|
48
|
-
if (c > l.length)
|
|
49
|
-
throw new Error("_sha2: outputLen bigger than state");
|
|
50
|
-
for (let f = 0; f < c; f++)
|
|
51
|
-
r.setUint32(4 * f, l[f], h);
|
|
52
|
-
}
|
|
53
|
-
digest() {
|
|
54
|
-
const { buffer: t, outputLen: s } = this;
|
|
55
|
-
this.digestInto(t);
|
|
56
|
-
const i = t.slice(0, s);
|
|
57
|
-
return this.destroy(), i;
|
|
58
|
-
}
|
|
59
|
-
_cloneInto(t) {
|
|
60
|
-
t || (t = new this.constructor()), t.set(...this.get());
|
|
61
|
-
const { blockLen: s, buffer: i, length: n, finished: h, destroyed: e, pos: r } = this;
|
|
62
|
-
return t.length = n, t.pos = r, t.finished = h, t.destroyed = e, n % s && t.buffer.set(i), t;
|
|
14
|
+
set(e, t) {
|
|
15
|
+
if (super.set(e, t), this.maxSize && this.size > this.maxSize) {
|
|
16
|
+
const s = this.keys().next().value;
|
|
17
|
+
s && this.delete(s);
|
|
18
|
+
}
|
|
19
|
+
return this;
|
|
63
20
|
}
|
|
64
21
|
}
|
|
65
22
|
export {
|
|
66
|
-
|
|
67
|
-
U as HashMD,
|
|
68
|
-
L as Maj,
|
|
69
|
-
w as setBigUint64
|
|
23
|
+
r as LruMap
|
|
70
24
|
};
|
package/dist/index52.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index70.cjs"),f=require("./index93.cjs"),c=require("./index71.cjs"),I=[],O=[],w=[],B=BigInt(0),a=BigInt(1),A=BigInt(2),S=BigInt(7),H=BigInt(256),T=BigInt(113);for(let i=0,t=a,s=1,n=0;i<24;i++){[s,n]=[n,(2*s+3*n)%5],I.push(2*(5*n+s)),O.push((i+1)*(i+2)/2%64);let o=B;for(let r=0;r<7;r++)t=(t<<a^(t>>S)*T)%H,t&A&&(o^=a<<(a<<BigInt(r))-a);w.push(o)}const[m,E]=f.split(w,!0),y=(i,t,s)=>s>32?f.rotlBH(i,t,s):f.rotlSH(i,t,s),b=(i,t,s)=>s>32?f.rotlBL(i,t,s):f.rotlSL(i,t,s);function L(i,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let e=0;e<10;e++)s[e]=i[e]^i[e+10]^i[e+20]^i[e+30]^i[e+40];for(let e=0;e<10;e+=2){const h=(e+8)%10,p=(e+2)%10,d=s[p],u=s[p+1],_=y(d,u,1)^s[h],g=b(d,u,1)^s[h+1];for(let k=0;k<50;k+=10)i[e+k]^=_,i[e+k+1]^=g}let o=i[2],r=i[3];for(let e=0;e<24;e++){const h=O[e],p=y(o,r,h),d=b(o,r,h),u=I[e];o=i[u],r=i[u+1],i[u]=p,i[u+1]=d}for(let e=0;e<50;e+=10){for(let h=0;h<10;h++)s[h]=i[e+h];for(let h=0;h<10;h++)i[e+h]^=~s[(h+2)%10]&s[(h+4)%10]}i[0]^=m[n],i[1]^=E[n]}s.fill(0)}class x extends c.Hash{constructor(t,s,n,o=!1,r=24){if(super(),this.blockLen=t,this.suffix=s,this.outputLen=n,this.enableXOF=o,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,l.anumber(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=c.u32(this.state)}keccak(){c.isLE||c.byteSwap32(this.state32),L(this.state32,this.rounds),c.isLE||c.byteSwap32(this.state32),this.posOut=0,this.pos=0}update(t){l.aexists(this);const{blockLen:s,state:n}=this;t=c.toBytes(t);const o=t.length;for(let r=0;r<o;){const e=Math.min(s-this.pos,o-r);for(let h=0;h<e;h++)n[this.pos++]^=t[r++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:o}=this;t[n]^=s,s&128&&n===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){l.aexists(this,!1),l.abytes(t),this.finish();const s=this.state,{blockLen:n}=this;for(let o=0,r=t.length;o<r;){this.posOut>=n&&this.keccak();const e=Math.min(n-this.posOut,r-o);t.set(s.subarray(this.posOut,this.posOut+e),o),this.posOut+=e,o+=e}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return l.anumber(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(l.aoutput(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:o,rounds:r,enableXOF:e}=this;return t||(t=new x(s,n,o,e,r)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=r,t.suffix=n,t.outputLen=o,t.enableXOF=e,t.destroyed=this.destroyed,t}}const F=(i,t,s)=>c.wrapConstructor(()=>new x(t,i,s)),P=F(1,136,256/8);exports.Keccak=x;exports.keccakP=L;exports.keccak_256=P;
|