@gardenfi/utils 2.2.0-beta.1 → 2.2.1-beta.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/index195.cjs +1 -1
- package/dist/index195.js +3 -3
- package/dist/index225.cjs +1 -1
- package/dist/index225.js +2 -2
- package/dist/index228.cjs +1 -1
- package/dist/index228.js +2 -2
- package/dist/index229.cjs +1 -1
- package/dist/index229.js +1 -1
- package/dist/index234.cjs +1 -1
- package/dist/index234.js +1 -1
- package/dist/index235.cjs +1 -1
- package/dist/index235.js +1 -1
- package/dist/index236.cjs +1 -1
- package/dist/index236.js +2 -2
- package/dist/index248.cjs +1 -1
- package/dist/index248.js +1 -1
- package/dist/index249.cjs +1 -1
- package/dist/index249.js +1 -1
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +2 -2
- package/dist/index280.cjs +1 -1
- package/dist/index280.js +103 -6
- package/dist/index281.cjs +1 -1
- package/dist/index281.js +7 -7
- package/dist/index282.cjs +1 -1
- package/dist/index282.js +223 -25
- package/dist/index283.cjs +1 -1
- package/dist/index283.js +6 -19
- package/dist/index284.cjs +1 -1
- package/dist/index284.js +7 -147
- package/dist/index285.cjs +1 -1
- package/dist/index285.js +24 -101
- package/dist/index286.cjs +1 -1
- package/dist/index286.js +19 -3
- package/dist/index287.cjs +1 -1
- package/dist/index287.js +140 -134
- package/dist/index288.cjs +1 -1
- package/dist/index288.js +3 -155
- package/dist/index289.cjs +1 -1
- package/dist/index289.js +138 -7
- package/dist/index290.cjs +1 -1
- package/dist/index290.js +155 -6
- package/dist/index291.cjs +1 -1
- package/dist/index291.js +8 -223
- package/dist/index292.cjs +1 -1
- package/dist/index292.js +2 -2
- package/dist/index293.cjs +1 -1
- package/dist/index293.js +2 -2
- package/dist/index294.cjs +1 -1
- package/dist/index294.js +138 -10
- package/dist/index295.cjs +1 -1
- package/dist/index295.js +42 -19
- package/dist/index296.cjs +1 -1
- package/dist/index296.js +73 -134
- package/dist/index297.cjs +1 -1
- package/dist/index297.js +2 -43
- package/dist/index298.cjs +1 -1
- package/dist/index298.js +10 -77
- package/dist/index299.cjs +1 -1
- package/dist/index299.js +20 -2
- package/dist/index301.cjs +1 -2
- package/dist/index301.js +695 -63
- package/dist/index302.cjs +1 -1
- package/dist/index302.js +201 -4
- package/dist/index303.cjs +2 -1
- package/dist/index303.js +65 -39
- package/dist/index304.cjs +1 -1
- package/dist/index304.js +4 -698
- package/dist/index305.cjs +1 -1
- package/dist/index305.js +40 -201
- package/dist/index306.cjs +1 -1
- package/dist/index306.js +1 -1
- package/dist/index307.cjs +1 -1
- package/dist/index307.js +1 -1
- package/dist/index308.cjs +1 -1
- package/dist/index308.js +1 -1
- package/dist/index310.cjs +1 -1
- package/dist/index310.js +2 -2
- package/dist/index311.cjs +1 -1
- package/dist/index311.js +3 -3
- package/package.json +1 -1
package/dist/index291.js
CHANGED
|
@@ -1,227 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
1
|
+
import { fromNumber as e } from "./index290.js";
|
|
2
|
+
function r(o) {
|
|
3
|
+
return {
|
|
4
|
+
address: o.address,
|
|
5
|
+
amount: e(o.amount),
|
|
6
|
+
index: e(o.index),
|
|
7
|
+
validatorIndex: e(o.validatorIndex)
|
|
73
8
|
};
|
|
74
9
|
}
|
|
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);
|
|
211
|
-
}
|
|
212
10
|
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
|
|
11
|
+
r as toRpc
|
|
227
12
|
};
|
package/dist/index292.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("./index303.cjs"),$=require("./index306.cjs"),g=require("./index290.cjs"),c=require("./index307.cjs"),y=require("./index270.cjs"),h=require("./index263.cjs");function I(t,r={}){const{prepare:i=!0}=r,n=Array.isArray(t)||typeof t=="string"?y.parseAbiItem(t):t;return{...n,...i?{hash:o(n)}:{}}}function q(t,r,i){const{args:n=[],prepare:a=!0}=i??{},v=g.validate(r,{strict:!1}),s=t.filter(e=>v?e.type==="function"||e.type==="error"?A(e)===g.slice(r,0,4):e.type==="event"?o(e)===r:!1:"name"in e&&e.name===r);if(s.length===0)throw new l({name:r});if(s.length===1)return{...s[0],...a?{hash:o(s[0])}:{}};let u;for(const e of s){if(!("inputs"in e))continue;if(!n||n.length===0){if(!e.inputs||e.inputs.length===0)return{...e,...a?{hash:o(e)}:{}};continue}if(!e.inputs||e.inputs.length===0||e.inputs.length!==n.length)continue;if(n.every((f,E)=>{const d="inputs"in e&&e.inputs[E];return d?c.isArgOfType(f,d):!1})){if(u&&"inputs"in u&&u.inputs){const f=c.getAmbiguousTypes(e.inputs,u.inputs,n);if(f)throw new w({abiItem:e,type:f[0]},{abiItem:u,type:f[1]})}u=e}}const p=(()=>{if(u)return u;const[e,...m]=s;return{...e,overloads:m}})();if(!p)throw new l({name:r});return{...p,...a?{hash:o(p)}:{}}}function A(t){return g.slice(o(t),0,4)}function S(t){const r=typeof t=="string"?t:h.formatAbiItem(t);return c.normalizeSignature(r)}function o(t){return typeof t!="string"&&"hash"in t&&t.hash?t.hash:$.keccak256(g.fromString(S(t)))}class w extends b.BaseError{constructor(r,i){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${r.type}\` in \`${c.normalizeSignature(h.formatAbiItem(r.abiItem))}\`, and`,`\`${i.type}\` in \`${c.normalizeSignature(h.formatAbiItem(i.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}class l extends b.BaseError{constructor({name:r,data:i,type:n="item"}){const a=r?` with name "${r}"`:i?` with data "${i}"`:"";super(`ABI ${n}${a} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}exports.AmbiguityError=w;exports.NotFoundError=l;exports.from=I;exports.fromAbi=q;exports.getSelector=A;exports.getSignature=S;exports.getSignatureHash=o;
|
package/dist/index292.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseError as y } from "./
|
|
1
|
+
import { BaseError as y } from "./index303.js";
|
|
2
2
|
import { keccak256 as v } from "./index306.js";
|
|
3
|
-
import { validate as $, slice as A, fromString as S } from "./
|
|
3
|
+
import { validate as $, slice as A, fromString as S } from "./index290.js";
|
|
4
4
|
import { isArgOfType as E, normalizeSignature as p, getAmbiguousTypes as B } from "./index307.js";
|
|
5
5
|
import { parseAbiItem as l } from "./index270.js";
|
|
6
6
|
import { formatAbiItem as h } from "./index263.js";
|
package/dist/index293.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./index308.cjs"),d=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./index308.cjs"),d=require("./index303.cjs"),a=require("./index290.cjs"),g=require("./index309.cjs"),p=require("./index310.cjs");function P(n,e,t){const{checksumAddress:r=!1}={};if(n.length!==e.length)throw new m({expectedLength:n.length,givenLength:e.length});const s=p.prepareParameters({checksumAddress:r,parameters:n,values:e}),o=p.encode(s);return o.length===0?"0x":o}function l(n,e){if(n.length!==e.length)throw new m({expectedLength:n.length,givenLength:e.length});const t=[];for(let r=0;r<n.length;r++){const s=n[r],o=e[r];t.push(l.encode(s,o))}return a.concat(...t)}(function(n){function e(t,r,s=!1){if(t==="address"){const c=r;return x.assert(c),a.padLeft(c.toLowerCase(),s?32:0)}if(t==="string")return a.fromString(r);if(t==="bytes")return r;if(t==="bool")return a.padLeft(a.fromBoolean(r),s?32:1);const o=t.match(g.integerRegex);if(o){const[c,i,u="256"]=o,h=Number.parseInt(u)/8;return a.fromNumber(r,{size:s?32:h,signed:i==="int"})}const b=t.match(g.bytesRegex);if(b){const[c,i]=b;if(Number.parseInt(i)!==(r.length-2)/2)throw new y({expectedSize:Number.parseInt(i),value:r});return a.padRight(r,s?32:0)}const f=t.match(g.arrayRegex);if(f&&Array.isArray(r)){const[c,i]=f,u=[];for(let h=0;h<r.length;h++)u.push(e(i,r[h],!0));return u.length===0?"0x":a.concat(...u)}throw new E(t)}n.encode=e})(l||(l={}));class A extends d.BaseError{constructor({expectedLength:e,givenLength:t,type:r}){super(`Array length mismatch for type \`${r}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class y extends d.BaseError{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${a.size(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class m extends d.BaseError{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join(`
|
|
2
2
|
`)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class w extends d.BaseError{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class E extends d.BaseError{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}exports.ArrayLengthMismatchError=A;exports.BytesSizeMismatchError=y;exports.InvalidArrayError=w;exports.InvalidTypeError=E;exports.LengthMismatchError=m;exports.encode=P;exports.encodePacked=l;
|
package/dist/index293.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assert as p } from "./index308.js";
|
|
2
|
-
import { BaseError as u } from "./
|
|
3
|
-
import { size as y, padLeft as f, fromString as x, fromBoolean as w, fromNumber as E, padRight as P, concat as g } from "./
|
|
2
|
+
import { BaseError as u } from "./index303.js";
|
|
3
|
+
import { size as y, padLeft as f, fromString as x, fromBoolean as w, fromNumber as E, padRight as P, concat as g } from "./index290.js";
|
|
4
4
|
import { integerRegex as A, bytesRegex as $, arrayRegex as L } from "./index309.js";
|
|
5
5
|
import { prepareParameters as z, encode as I } from "./index310.js";
|
|
6
6
|
function N(n, e, t) {
|
package/dist/index294.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 i=require("./index287.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const d=BigInt(0),g=BigInt(1);function T(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function x(e){const t=e.toString(16);return t.length&1?"0"+t:t}function w(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?d:BigInt("0x"+e)}function v(e){return w(i.bytesToHex(e))}function U(e){return i.abytes(e),w(i.bytesToHex(Uint8Array.from(e).reverse()))}function h(e,t){return i.hexToBytes(e.toString(16).padStart(t*2,"0"))}function H(e,t){return h(e,t).reverse()}function A(e,t,r){let o;if(typeof t=="string")try{o=i.hexToBytes(t)}catch(n){throw new Error(e+" must be hex string or Uint8Array, cause: "+n)}else if(i.isBytes(t))o=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const s=o.length;if(typeof r=="number"&&s!==r)throw new Error(e+" of length "+r+" expected, got "+s);return o}const m=e=>typeof e=="bigint"&&d<=e;function p(e,t,r){return m(e)&&m(t)&&m(r)&&t<=e&&e<r}function I(e,t,r,o){if(!p(t,r,o))throw new Error("expected valid "+e+": "+r+" <= n < "+o+", got "+t)}function j(e){let t;for(t=0;e>d;e>>=g,t+=1);return t}const k=e=>(g<<BigInt(e))-g;function N(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");const o=u=>new Uint8Array(u),s=u=>Uint8Array.of(u);let n=o(e),c=o(e),f=0;const a=()=>{n.fill(1),c.fill(0),f=0},b=(...u)=>r(c,n,...u),B=(u=o(0))=>{c=b(s(0),u),n=b(),u.length!==0&&(c=b(s(1),u),n=b())},E=()=>{if(f++>=1e3)throw new Error("drbg: tried 1000 values");let u=0;const y=[];for(;u<t;){n=b();const l=n.slice();y.push(l),u+=n.length}return i.concatBytes(...y)};return(u,y)=>{a(),B(u);let l;for(;!(l=y(E()));)B();return a(),l}}function O(e,t,r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function o(s,n,c){const f=e[s];if(c&&f===void 0)return;const a=typeof f;if(a!==n||f===null)throw new Error(`param "${s}" is invalid: expected ${n}, got ${a}`)}Object.entries(t).forEach(([s,n])=>o(s,n,!1)),Object.entries(r).forEach(([s,n])=>o(s,n,!0))}function S(e){const t=new WeakMap;return(r,...o)=>{const s=t.get(r);if(s!==void 0)return s;const n=e(r,...o);return t.set(r,n),n}}exports.abytes=i.abytes;exports.anumber=i.anumber;exports.bytesToHex=i.bytesToHex;exports.concatBytes=i.concatBytes;exports.hexToBytes=i.hexToBytes;exports.isBytes=i.isBytes;exports.randomBytes=i.randomBytes;exports.utf8ToBytes=i.utf8ToBytes;exports._validateObject=O;exports.aInRange=I;exports.abool=T;exports.bitLen=j;exports.bitMask=k;exports.bytesToNumberBE=v;exports.bytesToNumberLE=U;exports.createHmacDrbg=N;exports.ensureBytes=A;exports.hexToNumber=w;exports.inRange=p;exports.memoized=S;exports.numberToBytesBE=h;exports.numberToBytesLE=H;exports.numberToHexUnpadded=x;
|
package/dist/index294.js
CHANGED
|
@@ -1,14 +1,142 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { hexToBytes as p, isBytes as B, abytes as v, bytesToHex as d, concatBytes as U } from "./index287.js";
|
|
2
|
+
import { anumber as W, randomBytes as C, utf8ToBytes as G } from "./index287.js";
|
|
3
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
4
|
+
const y = /* @__PURE__ */ BigInt(0), g = /* @__PURE__ */ BigInt(1);
|
|
5
|
+
function k(t, r) {
|
|
6
|
+
if (typeof r != "boolean")
|
|
7
|
+
throw new Error(t + " boolean expected, got " + r);
|
|
8
|
+
}
|
|
9
|
+
function j(t) {
|
|
10
|
+
const r = t.toString(16);
|
|
11
|
+
return r.length & 1 ? "0" + r : r;
|
|
12
|
+
}
|
|
13
|
+
function h(t) {
|
|
14
|
+
if (typeof t != "string")
|
|
15
|
+
throw new Error("hex string expected, got " + typeof t);
|
|
16
|
+
return t === "" ? y : BigInt("0x" + t);
|
|
17
|
+
}
|
|
18
|
+
function H(t) {
|
|
19
|
+
return h(d(t));
|
|
20
|
+
}
|
|
21
|
+
function O(t) {
|
|
22
|
+
return v(t), h(d(Uint8Array.from(t).reverse()));
|
|
23
|
+
}
|
|
24
|
+
function x(t, r) {
|
|
25
|
+
return p(t.toString(16).padStart(r * 2, "0"));
|
|
26
|
+
}
|
|
27
|
+
function S(t, r) {
|
|
28
|
+
return x(t, r).reverse();
|
|
29
|
+
}
|
|
30
|
+
function _(t, r, n) {
|
|
31
|
+
let o;
|
|
32
|
+
if (typeof r == "string")
|
|
33
|
+
try {
|
|
34
|
+
o = p(r);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
throw new Error(t + " must be hex string or Uint8Array, cause: " + e);
|
|
37
|
+
}
|
|
38
|
+
else if (B(r))
|
|
39
|
+
o = Uint8Array.from(r);
|
|
40
|
+
else
|
|
41
|
+
throw new Error(t + " must be hex string or Uint8Array");
|
|
42
|
+
const i = o.length;
|
|
43
|
+
if (typeof n == "number" && i !== n)
|
|
44
|
+
throw new Error(t + " of length " + n + " expected, got " + i);
|
|
45
|
+
return o;
|
|
46
|
+
}
|
|
47
|
+
const w = (t) => typeof t == "bigint" && y <= t;
|
|
48
|
+
function T(t, r, n) {
|
|
49
|
+
return w(t) && w(r) && w(n) && r <= t && t < n;
|
|
50
|
+
}
|
|
51
|
+
function $(t, r, n, o) {
|
|
52
|
+
if (!T(r, n, o))
|
|
53
|
+
throw new Error("expected valid " + t + ": " + n + " <= n < " + o + ", got " + r);
|
|
54
|
+
}
|
|
55
|
+
function M(t) {
|
|
56
|
+
let r;
|
|
57
|
+
for (r = 0; t > y; t >>= g, r += 1)
|
|
58
|
+
;
|
|
59
|
+
return r;
|
|
60
|
+
}
|
|
61
|
+
const N = (t) => (g << BigInt(t)) - g;
|
|
62
|
+
function R(t, r, n) {
|
|
63
|
+
if (typeof t != "number" || t < 2)
|
|
64
|
+
throw new Error("hashLen must be a number");
|
|
65
|
+
if (typeof r != "number" || r < 2)
|
|
66
|
+
throw new Error("qByteLen must be a number");
|
|
67
|
+
if (typeof n != "function")
|
|
68
|
+
throw new Error("hmacFn must be a function");
|
|
69
|
+
const o = (u) => new Uint8Array(u), i = (u) => Uint8Array.of(u);
|
|
70
|
+
let e = o(t), s = o(t), f = 0;
|
|
71
|
+
const c = () => {
|
|
72
|
+
e.fill(1), s.fill(0), f = 0;
|
|
73
|
+
}, l = (...u) => n(s, e, ...u), m = (u = o(0)) => {
|
|
74
|
+
s = l(i(0), u), e = l(), u.length !== 0 && (s = l(i(1), u), e = l());
|
|
75
|
+
}, E = () => {
|
|
76
|
+
if (f++ >= 1e3)
|
|
77
|
+
throw new Error("drbg: tried 1000 values");
|
|
78
|
+
let u = 0;
|
|
79
|
+
const a = [];
|
|
80
|
+
for (; u < r; ) {
|
|
81
|
+
e = l();
|
|
82
|
+
const b = e.slice();
|
|
83
|
+
a.push(b), u += e.length;
|
|
84
|
+
}
|
|
85
|
+
return U(...a);
|
|
86
|
+
};
|
|
87
|
+
return (u, a) => {
|
|
88
|
+
c(), m(u);
|
|
89
|
+
let b;
|
|
90
|
+
for (; !(b = a(E())); )
|
|
91
|
+
m();
|
|
92
|
+
return c(), b;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function z(t, r, n = {}) {
|
|
96
|
+
if (!t || typeof t != "object")
|
|
97
|
+
throw new Error("expected valid options object");
|
|
98
|
+
function o(i, e, s) {
|
|
99
|
+
const f = t[i];
|
|
100
|
+
if (s && f === void 0)
|
|
101
|
+
return;
|
|
102
|
+
const c = typeof f;
|
|
103
|
+
if (c !== e || f === null)
|
|
104
|
+
throw new Error(`param "${i}" is invalid: expected ${e}, got ${c}`);
|
|
10
105
|
}
|
|
106
|
+
Object.entries(r).forEach(([i, e]) => o(i, e, !1)), Object.entries(n).forEach(([i, e]) => o(i, e, !0));
|
|
107
|
+
}
|
|
108
|
+
function D(t) {
|
|
109
|
+
const r = /* @__PURE__ */ new WeakMap();
|
|
110
|
+
return (n, ...o) => {
|
|
111
|
+
const i = r.get(n);
|
|
112
|
+
if (i !== void 0)
|
|
113
|
+
return i;
|
|
114
|
+
const e = t(n, ...o);
|
|
115
|
+
return r.set(n, e), e;
|
|
116
|
+
};
|
|
11
117
|
}
|
|
12
118
|
export {
|
|
13
|
-
|
|
119
|
+
z as _validateObject,
|
|
120
|
+
$ as aInRange,
|
|
121
|
+
k as abool,
|
|
122
|
+
v as abytes,
|
|
123
|
+
W as anumber,
|
|
124
|
+
M as bitLen,
|
|
125
|
+
N as bitMask,
|
|
126
|
+
d as bytesToHex,
|
|
127
|
+
H as bytesToNumberBE,
|
|
128
|
+
O as bytesToNumberLE,
|
|
129
|
+
U as concatBytes,
|
|
130
|
+
R as createHmacDrbg,
|
|
131
|
+
_ as ensureBytes,
|
|
132
|
+
p as hexToBytes,
|
|
133
|
+
h as hexToNumber,
|
|
134
|
+
T as inRange,
|
|
135
|
+
B as isBytes,
|
|
136
|
+
D as memoized,
|
|
137
|
+
x as numberToBytesBE,
|
|
138
|
+
S as numberToBytesLE,
|
|
139
|
+
j as numberToHexUnpadded,
|
|
140
|
+
C as randomBytes,
|
|
141
|
+
G as utf8ToBytes
|
|
14
142
|
};
|
package/dist/index295.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index287.cjs");class r extends i.Hash{constructor(t,h){super(),this.finished=!1,this.destroyed=!1,i.ahash(t);const n=i.toBytes(h);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const a=this.blockLen,e=new Uint8Array(a);e.set(n.length>a?t.create().update(n).digest():n);for(let s=0;s<e.length;s++)e[s]^=54;this.iHash.update(e),this.oHash=t.create();for(let s=0;s<e.length;s++)e[s]^=106;this.oHash.update(e),i.clean(e)}update(t){return i.aexists(this),this.iHash.update(t),this}digestInto(t){i.aexists(this),i.abytes(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:h,iHash:n,finished:a,destroyed:e,blockLen:s,outputLen:d}=this;return t=t,t.finished=a,t.destroyed=e,t.blockLen=s,t.outputLen=d,t.oHash=h._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const c=(o,t,h)=>new r(o,t).update(h).digest();c.create=(o,t)=>new r(o,t);exports.HMAC=r;exports.hmac=c;
|
package/dist/index295.js
CHANGED
|
@@ -1,22 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { Hash as d, ahash as u, toBytes as H, clean as l, aexists as a, abytes as p } from "./index287.js";
|
|
2
|
+
class r extends d {
|
|
3
|
+
constructor(t, i) {
|
|
4
|
+
super(), this.finished = !1, this.destroyed = !1, u(t);
|
|
5
|
+
const h = H(i);
|
|
6
|
+
if (this.iHash = t.create(), typeof this.iHash.update != "function")
|
|
7
|
+
throw new Error("Expected instance of class which extends utils.Hash");
|
|
8
|
+
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
9
|
+
const o = this.blockLen, e = new Uint8Array(o);
|
|
10
|
+
e.set(h.length > o ? t.create().update(h).digest() : h);
|
|
11
|
+
for (let s = 0; s < e.length; s++)
|
|
12
|
+
e[s] ^= 54;
|
|
13
|
+
this.iHash.update(e), this.oHash = t.create();
|
|
14
|
+
for (let s = 0; s < e.length; s++)
|
|
15
|
+
e[s] ^= 106;
|
|
16
|
+
this.oHash.update(e), l(e);
|
|
17
|
+
}
|
|
18
|
+
update(t) {
|
|
19
|
+
return a(this), this.iHash.update(t), this;
|
|
20
|
+
}
|
|
21
|
+
digestInto(t) {
|
|
22
|
+
a(this), p(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
|
|
23
|
+
}
|
|
24
|
+
digest() {
|
|
25
|
+
const t = new Uint8Array(this.oHash.outputLen);
|
|
26
|
+
return this.digestInto(t), t;
|
|
27
|
+
}
|
|
28
|
+
_cloneInto(t) {
|
|
29
|
+
t || (t = Object.create(Object.getPrototypeOf(this), {}));
|
|
30
|
+
const { oHash: i, iHash: h, finished: o, destroyed: e, blockLen: s, outputLen: c } = this;
|
|
31
|
+
return t = t, t.finished = o, t.destroyed = e, t.blockLen = s, t.outputLen = c, t.oHash = i._cloneInto(t.oHash), t.iHash = h._cloneInto(t.iHash), t;
|
|
32
|
+
}
|
|
33
|
+
clone() {
|
|
34
|
+
return this._cloneInto();
|
|
35
|
+
}
|
|
36
|
+
destroy() {
|
|
37
|
+
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
38
|
+
}
|
|
19
39
|
}
|
|
40
|
+
const y = (n, t, i) => new r(n, t).update(i).digest();
|
|
41
|
+
y.create = (n, t) => new r(n, t);
|
|
20
42
|
export {
|
|
21
|
-
|
|
43
|
+
r as HMAC,
|
|
44
|
+
y as hmac
|
|
22
45
|
};
|
package/dist/index296.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("./index287.cjs");function p(o,t,s,i){if(typeof o.setBigUint64=="function")return o.setBigUint64(t,s,i);const n=BigInt(32),r=BigInt(4294967295),e=Number(s>>n&r),h=Number(s&r),u=i?4:0,l=i?0:4;o.setUint32(t+u,e,i),o.setUint32(t+l,h,i)}function g(o,t,s){return o&t^~o&s}function b(o,t,s){return o&t^o&s^t&s}class d extends f.Hash{constructor(t,s,i,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=s,this.padOffset=i,this.isLE=n,this.buffer=new Uint8Array(t),this.view=f.createView(this.buffer)}update(t){f.aexists(this),t=f.toBytes(t),f.abytes(t);const{view:s,buffer:i,blockLen:n}=this,r=t.length;for(let e=0;e<r;){const h=Math.min(n-this.pos,r-e);if(h===n){const u=f.createView(t);for(;n<=r-e;e+=n)this.process(u,e);continue}i.set(t.subarray(e,e+h),this.pos),this.pos+=h,e+=h,this.pos===n&&(this.process(s,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){f.aexists(this),f.aoutput(t,this),this.finished=!0;const{buffer:s,view:i,blockLen:n,isLE:r}=this;let{pos:e}=this;s[e++]=128,f.clean(this.buffer.subarray(e)),this.padOffset>n-e&&(this.process(i,0),e=0);for(let c=e;c<n;c++)s[c]=0;p(i,n-8,BigInt(this.length*8),r),this.process(i,0);const h=f.createView(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,a=this.get();if(l>a.length)throw new Error("_sha2: outputLen bigger than state");for(let c=0;c<l;c++)h.setUint32(4*c,a[c],r)}digest(){const{buffer:t,outputLen:s}=this;this.digestInto(t);const i=t.slice(0,s);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:s,buffer:i,length:n,finished:r,destroyed:e,pos:h}=this;return t.destroyed=e,t.finished=r,t.length=n,t.pos=h,n%s&&t.buffer.set(i),t}clone(){return this._cloneInto()}}const w=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);exports.Chi=g;exports.HashMD=d;exports.Maj=b;exports.SHA256_IV=w;exports.setBigUint64=p;
|