@gardenfi/utils 2.0.6-beta.5 → 2.0.6-beta.6
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/index100.cjs +1 -1
- package/dist/index100.js +35 -2
- package/dist/index101.cjs +1 -1
- package/dist/index101.js +40 -34
- package/dist/index102.cjs +1 -1
- package/dist/index102.js +642 -39
- package/dist/index103.cjs +1 -1
- package/dist/index103.js +222 -634
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +167 -226
- package/dist/index105.cjs +1 -1
- package/dist/index105.js +6 -170
- package/dist/index106.cjs +1 -1
- package/dist/index106.js +1 -1
- package/dist/index112.cjs +1 -1
- package/dist/index112.js +1 -1
- package/dist/index113.cjs +1 -1
- package/dist/index113.js +2 -2
- package/dist/index116.cjs +1 -1
- package/dist/index116.js +1 -1
- package/dist/index117.cjs +1 -1
- package/dist/index117.js +1 -1
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +1 -1
- package/dist/index21.cjs +1 -1
- package/dist/index21.js +2 -2
- package/dist/index22.cjs +1 -1
- package/dist/index22.js +1 -1
- 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/index44.cjs +1 -1
- package/dist/index44.js +1 -1
- package/dist/index49.cjs +1 -1
- package/dist/index49.js +1 -1
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +2 -2
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +3 -3
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +1 -1
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +1 -1
- package/dist/index65.cjs +1 -2
- package/dist/index65.js +4 -59
- package/dist/index66.cjs +2 -1
- package/dist/index66.js +53 -15
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +3 -8
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +8 -18
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +20 -41
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +16 -102
- package/dist/index71.cjs +1 -1
- package/dist/index71.js +42 -3
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +104 -8
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +8 -10
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +10 -11
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +11 -13
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +13 -6
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +6 -17
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +16 -77
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +78 -14
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +14 -18
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +16 -189
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +185 -58
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +64 -4
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +1 -1
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +2 -2
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +1 -1
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +1 -1
- package/dist/index93.cjs +1 -1
- package/dist/index93.js +1 -1
- package/dist/index95.cjs +1 -1
- package/dist/index95.js +11 -8
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +19 -11
- package/dist/index97.cjs +1 -1
- package/dist/index97.js +66 -18
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +63 -61
- package/dist/index99.cjs +1 -1
- package/dist/index99.js +2 -70
- package/package.json +1 -1
package/dist/index104.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./index62.cjs"),y=require("./index103.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const I=BigInt(0),p=BigInt(1);function m(e,r){const t=r.negate();return e?t:r}function E(e,r){if(!Number.isSafeInteger(e)||e<=0||e>r)throw new Error("invalid window size, expected [1.."+r+"], got W="+e)}function b(e,r){E(e,r);const t=Math.ceil(r/e)+1,n=2**(e-1);return{windows:t,windowSize:n}}function O(e,r){if(!Array.isArray(e))throw new Error("array expected");e.forEach((t,n)=>{if(!(t instanceof r))throw new Error("invalid point at index "+n)})}function x(e,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((t,n)=>{if(!r.isValid(t))throw new Error("invalid scalar at index "+n)})}const B=new WeakMap,N=new WeakMap;function S(e){return N.get(e)||1}function L(e,r){return{constTimeNegate:m,hasPrecomputes(t){return S(t)!==1},unsafeLadder(t,n,o=e.ZERO){let i=t;for(;n>I;)n&p&&(o=o.add(i)),i=i.double(),n>>=p;return o},precomputeWindow(t,n){const{windows:o,windowSize:i}=b(n,r),a=[];let c=t,d=c;for(let g=0;g<o;g++){d=c,a.push(d);for(let l=1;l<i;l++)d=d.add(c),a.push(d);c=d.double()}return a},wNAF(t,n,o){const{windows:i,windowSize:a}=b(t,r);let c=e.ZERO,d=e.BASE;const g=BigInt(2**t-1),l=2**t,w=BigInt(t);for(let u=0;u<i;u++){const s=u*a;let f=Number(o&g);o>>=w,f>a&&(f-=l,o+=p);const h=s,M=s+Math.abs(f)-1,F=u%2!==0,z=f<0;f===0?d=d.add(m(F,n[h])):c=c.add(m(z,n[M]))}return{p:c,f:d}},wNAFUnsafe(t,n,o,i=e.ZERO){const{windows:a,windowSize:c}=b(t,r),d=BigInt(2**t-1),g=2**t,l=BigInt(t);for(let w=0;w<a;w++){const u=w*c;if(o===I)break;let s=Number(o&d);if(o>>=l,s>c&&(s-=g,o+=p),s===0)continue;let f=n[u+Math.abs(s)-1];s<0&&(f=f.negate()),i=i.add(f)}return i},getPrecomputes(t,n,o){let i=B.get(n);return i||(i=this.precomputeWindow(n,t),t!==1&&B.set(n,o(i))),i},wNAFCached(t,n,o){const i=S(t);return this.wNAF(i,this.getPrecomputes(i,t,o),n)},wNAFCachedUnsafe(t,n,o,i){const a=S(t);return a===1?this.unsafeLadder(t,n,i):this.wNAFUnsafe(a,this.getPrecomputes(a,t,o),n,i)},setWindowSize(t,n){E(n,r),N.set(t,n),B.delete(t)}}}function j(e,r,t,n){if(O(t,e),x(n,r),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");const o=e.ZERO,i=y.bitLen(BigInt(t.length)),a=i>12?i-3:i>4?i-2:i?2:1,c=(1<<a)-1,d=new Array(c+1).fill(o),g=Math.floor((r.BITS-1)/a)*a;let l=o;for(let w=g;w>=0;w-=a){d.fill(o);for(let s=0;s<n.length;s++){const f=n[s],h=Number(f>>BigInt(w)&BigInt(c));d[h]=d[h].add(t[s])}let u=o;for(let s=d.length-1,f=o;s>0;s--)f=f.add(d[s]),u=u.add(f);if(l=l.add(u),w!==0)for(let s=0;s<a;s++)l=l.double()}return l}function k(e){return A.validateField(e.Fp),y.validateObject(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...A.nLength(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}exports.pippenger=j;exports.validateBasic=k;exports.wNAF=L;
|
package/dist/index104.js
CHANGED
|
@@ -1,234 +1,175 @@
|
|
|
1
|
+
import { validateField as z, nLength as F } from "./index62.js";
|
|
2
|
+
import { validateObject as x, bitLen as O } from "./index103.js";
|
|
1
3
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2
|
-
const
|
|
3
|
-
function
|
|
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
|
-
|
|
4
|
+
const I = BigInt(0), p = BigInt(1);
|
|
5
|
+
function m(e, r) {
|
|
6
|
+
const t = r.negate();
|
|
7
|
+
return e ? t : r;
|
|
8
|
+
}
|
|
9
|
+
function A(e, r) {
|
|
10
|
+
if (!Number.isSafeInteger(e) || e <= 0 || e > r)
|
|
11
|
+
throw new Error("invalid window size, expected [1.." + r + "], got W=" + e);
|
|
12
|
+
}
|
|
13
|
+
function b(e, r) {
|
|
14
|
+
A(e, r);
|
|
15
|
+
const t = Math.ceil(r / e) + 1, n = 2 ** (e - 1);
|
|
16
|
+
return { windows: t, windowSize: n };
|
|
17
|
+
}
|
|
18
|
+
function L(e, r) {
|
|
19
|
+
if (!Array.isArray(e))
|
|
20
|
+
throw new Error("array expected");
|
|
21
|
+
e.forEach((t, n) => {
|
|
22
|
+
if (!(t instanceof r))
|
|
23
|
+
throw new Error("invalid point at index " + n);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function k(e, r) {
|
|
27
|
+
if (!Array.isArray(e))
|
|
28
|
+
throw new Error("array of scalars expected");
|
|
29
|
+
e.forEach((t, n) => {
|
|
30
|
+
if (!r.isValid(t))
|
|
31
|
+
throw new Error("invalid scalar at index " + n);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const B = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
function S(e) {
|
|
36
|
+
return E.get(e) || 1;
|
|
37
|
+
}
|
|
38
|
+
function v(e, r) {
|
|
39
|
+
return {
|
|
40
|
+
constTimeNegate: m,
|
|
41
|
+
hasPrecomputes(t) {
|
|
42
|
+
return S(t) !== 1;
|
|
43
|
+
},
|
|
44
|
+
// non-const time multiplication ladder
|
|
45
|
+
unsafeLadder(t, n, i = e.ZERO) {
|
|
46
|
+
let o = t;
|
|
47
|
+
for (; n > I; )
|
|
48
|
+
n & p && (i = i.add(o)), o = o.double(), n >>= p;
|
|
49
|
+
return i;
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* Creates a wNAF precomputation window. Used for caching.
|
|
53
|
+
* Default window size is set by `utils.precompute()` and is equal to 8.
|
|
54
|
+
* Number of precomputed points depends on the curve size:
|
|
55
|
+
* 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
|
|
56
|
+
* - 𝑊 is the window size
|
|
57
|
+
* - 𝑛 is the bitlength of the curve order.
|
|
58
|
+
* For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
|
|
59
|
+
* @param elm Point instance
|
|
60
|
+
* @param W window size
|
|
61
|
+
* @returns precomputed point tables flattened to a single array
|
|
62
|
+
*/
|
|
63
|
+
precomputeWindow(t, n) {
|
|
64
|
+
const { windows: i, windowSize: o } = b(n, r), a = [];
|
|
65
|
+
let c = t, d = c;
|
|
66
|
+
for (let h = 0; h < i; h++) {
|
|
67
|
+
d = c, a.push(d);
|
|
68
|
+
for (let w = 1; w < o; w++)
|
|
69
|
+
d = d.add(c), a.push(d);
|
|
70
|
+
c = d.double();
|
|
71
|
+
}
|
|
72
|
+
return a;
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
|
|
76
|
+
* @param W window size
|
|
77
|
+
* @param precomputes precomputed tables
|
|
78
|
+
* @param n scalar (we don't check here, but should be less than curve order)
|
|
79
|
+
* @returns real and fake (for const-time) points
|
|
80
|
+
*/
|
|
81
|
+
wNAF(t, n, i) {
|
|
82
|
+
const { windows: o, windowSize: a } = b(t, r);
|
|
83
|
+
let c = e.ZERO, d = e.BASE;
|
|
84
|
+
const h = BigInt(2 ** t - 1), w = 2 ** t, l = BigInt(t);
|
|
85
|
+
for (let u = 0; u < o; u++) {
|
|
86
|
+
const s = u * a;
|
|
87
|
+
let f = Number(i & h);
|
|
88
|
+
i >>= l, f > a && (f -= w, i += p);
|
|
89
|
+
const g = s, N = s + Math.abs(f) - 1, y = u % 2 !== 0, M = f < 0;
|
|
90
|
+
f === 0 ? d = d.add(m(y, n[g])) : c = c.add(m(M, n[N]));
|
|
91
|
+
}
|
|
92
|
+
return { p: c, f: d };
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
96
|
+
* @param W window size
|
|
97
|
+
* @param precomputes precomputed tables
|
|
98
|
+
* @param n scalar (we don't check here, but should be less than curve order)
|
|
99
|
+
* @param acc accumulator point to add result of multiplication
|
|
100
|
+
* @returns point
|
|
101
|
+
*/
|
|
102
|
+
wNAFUnsafe(t, n, i, o = e.ZERO) {
|
|
103
|
+
const { windows: a, windowSize: c } = b(t, r), d = BigInt(2 ** t - 1), h = 2 ** t, w = BigInt(t);
|
|
104
|
+
for (let l = 0; l < a; l++) {
|
|
105
|
+
const u = l * c;
|
|
106
|
+
if (i === I)
|
|
107
|
+
break;
|
|
108
|
+
let s = Number(i & d);
|
|
109
|
+
if (i >>= w, s > c && (s -= h, i += p), s === 0)
|
|
110
|
+
continue;
|
|
111
|
+
let f = n[u + Math.abs(s) - 1];
|
|
112
|
+
s < 0 && (f = f.negate()), o = o.add(f);
|
|
113
|
+
}
|
|
114
|
+
return o;
|
|
115
|
+
},
|
|
116
|
+
getPrecomputes(t, n, i) {
|
|
117
|
+
let o = B.get(n);
|
|
118
|
+
return o || (o = this.precomputeWindow(n, t), t !== 1 && B.set(n, i(o))), o;
|
|
119
|
+
},
|
|
120
|
+
wNAFCached(t, n, i) {
|
|
121
|
+
const o = S(t);
|
|
122
|
+
return this.wNAF(o, this.getPrecomputes(o, t, i), n);
|
|
123
|
+
},
|
|
124
|
+
wNAFCachedUnsafe(t, n, i, o) {
|
|
125
|
+
const a = S(t);
|
|
126
|
+
return a === 1 ? this.unsafeLadder(t, n, o) : this.wNAFUnsafe(a, this.getPrecomputes(a, t, i), n, o);
|
|
127
|
+
},
|
|
128
|
+
// We calculate precomputes for elliptic curve point multiplication
|
|
129
|
+
// using windowed method. This specifies window size and
|
|
130
|
+
// stores precomputed values. Usually only base point would be precomputed.
|
|
131
|
+
setWindowSize(t, n) {
|
|
132
|
+
A(n, r), E.set(t, n), B.delete(t);
|
|
52
133
|
}
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
return e;
|
|
56
|
-
}
|
|
57
|
-
function V(t) {
|
|
58
|
-
return U(B(t));
|
|
59
|
-
}
|
|
60
|
-
function H(t) {
|
|
61
|
-
return b(t), U(B(Uint8Array.from(t).reverse()));
|
|
62
|
-
}
|
|
63
|
-
function v(t, n) {
|
|
64
|
-
return m(t.toString(16).padStart(n * 2, "0"));
|
|
65
|
-
}
|
|
66
|
-
function C(t, n) {
|
|
67
|
-
return v(t, n).reverse();
|
|
68
|
-
}
|
|
69
|
-
function M(t) {
|
|
70
|
-
return m(S(t));
|
|
134
|
+
};
|
|
71
135
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
136
|
+
function Z(e, r, t, n) {
|
|
137
|
+
if (L(t, e), k(n, r), t.length !== n.length)
|
|
138
|
+
throw new Error("arrays of points and scalars must have equal length");
|
|
139
|
+
const i = e.ZERO, o = O(BigInt(t.length)), a = o > 12 ? o - 3 : o > 4 ? o - 2 : o ? 2 : 1, c = (1 << a) - 1, d = new Array(c + 1).fill(i), h = Math.floor((r.BITS - 1) / a) * a;
|
|
140
|
+
let w = i;
|
|
141
|
+
for (let l = h; l >= 0; l -= a) {
|
|
142
|
+
d.fill(i);
|
|
143
|
+
for (let s = 0; s < n.length; s++) {
|
|
144
|
+
const f = n[s], g = Number(f >> BigInt(l) & BigInt(c));
|
|
145
|
+
d[g] = d[g].add(t[s]);
|
|
79
146
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
throw new Error(t + " of length " + r + " expected, got " + o);
|
|
87
|
-
return e;
|
|
88
|
-
}
|
|
89
|
-
function _(...t) {
|
|
90
|
-
let n = 0;
|
|
91
|
-
for (let e = 0; e < t.length; e++) {
|
|
92
|
-
const o = t[e];
|
|
93
|
-
b(o), n += o.length;
|
|
147
|
+
let u = i;
|
|
148
|
+
for (let s = d.length - 1, f = i; s > 0; s--)
|
|
149
|
+
f = f.add(d[s]), u = u.add(f);
|
|
150
|
+
if (w = w.add(u), l !== 0)
|
|
151
|
+
for (let s = 0; s < a; s++)
|
|
152
|
+
w = w.double();
|
|
94
153
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (typeof t != "string")
|
|
112
|
-
throw new Error("string expected");
|
|
113
|
-
return new Uint8Array(new TextEncoder().encode(t));
|
|
114
|
-
}
|
|
115
|
-
const w = (t) => typeof t == "bigint" && d <= t;
|
|
116
|
-
function N(t, n, r) {
|
|
117
|
-
return w(t) && w(n) && w(r) && n <= t && t < r;
|
|
118
|
-
}
|
|
119
|
-
function D(t, n, r, e) {
|
|
120
|
-
if (!N(n, r, e))
|
|
121
|
-
throw new Error("expected valid " + t + ": " + r + " <= n < " + e + ", got " + n);
|
|
122
|
-
}
|
|
123
|
-
function G(t) {
|
|
124
|
-
let n;
|
|
125
|
-
for (n = 0; t > d; t >>= y, n += 1)
|
|
126
|
-
;
|
|
127
|
-
return n;
|
|
128
|
-
}
|
|
129
|
-
function P(t, n) {
|
|
130
|
-
return t >> BigInt(n) & y;
|
|
131
|
-
}
|
|
132
|
-
function W(t, n, r) {
|
|
133
|
-
return t | (r ? y : d) << BigInt(n);
|
|
134
|
-
}
|
|
135
|
-
const q = (t) => (I << BigInt(t - 1)) - y, p = (t) => new Uint8Array(t), A = (t) => Uint8Array.from(t);
|
|
136
|
-
function J(t, n, r) {
|
|
137
|
-
if (typeof t != "number" || t < 2)
|
|
138
|
-
throw new Error("hashLen must be a number");
|
|
139
|
-
if (typeof n != "number" || n < 2)
|
|
140
|
-
throw new Error("qByteLen must be a number");
|
|
141
|
-
if (typeof r != "function")
|
|
142
|
-
throw new Error("hmacFn must be a function");
|
|
143
|
-
let e = p(t), o = p(t), i = 0;
|
|
144
|
-
const a = () => {
|
|
145
|
-
e.fill(1), o.fill(0), i = 0;
|
|
146
|
-
}, f = (...u) => r(o, e, ...u), c = (u = p()) => {
|
|
147
|
-
o = f(A([0]), u), e = f(), u.length !== 0 && (o = f(A([1]), u), e = f());
|
|
148
|
-
}, x = () => {
|
|
149
|
-
if (i++ >= 1e3)
|
|
150
|
-
throw new Error("drbg: tried 1000 values");
|
|
151
|
-
let u = 0;
|
|
152
|
-
const l = [];
|
|
153
|
-
for (; u < n; ) {
|
|
154
|
-
e = f();
|
|
155
|
-
const g = e.slice();
|
|
156
|
-
l.push(g), u += e.length;
|
|
157
|
-
}
|
|
158
|
-
return _(...l);
|
|
159
|
-
};
|
|
160
|
-
return (u, l) => {
|
|
161
|
-
a(), c(u);
|
|
162
|
-
let g;
|
|
163
|
-
for (; !(g = l(x())); )
|
|
164
|
-
c();
|
|
165
|
-
return a(), g;
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
const k = {
|
|
169
|
-
bigint: (t) => typeof t == "bigint",
|
|
170
|
-
function: (t) => typeof t == "function",
|
|
171
|
-
boolean: (t) => typeof t == "boolean",
|
|
172
|
-
string: (t) => typeof t == "string",
|
|
173
|
-
stringOrUint8Array: (t) => typeof t == "string" || h(t),
|
|
174
|
-
isSafeInteger: (t) => Number.isSafeInteger(t),
|
|
175
|
-
array: (t) => Array.isArray(t),
|
|
176
|
-
field: (t, n) => n.Fp.isValid(t),
|
|
177
|
-
hash: (t) => typeof t == "function" && Number.isSafeInteger(t.outputLen)
|
|
178
|
-
};
|
|
179
|
-
function K(t, n, r = {}) {
|
|
180
|
-
const e = (o, i, a) => {
|
|
181
|
-
const f = k[i];
|
|
182
|
-
if (typeof f != "function")
|
|
183
|
-
throw new Error("invalid validator function");
|
|
184
|
-
const c = t[o];
|
|
185
|
-
if (!(a && c === void 0) && !f(c, t))
|
|
186
|
-
throw new Error("param " + String(o) + " is invalid. Expected " + i + ", got " + c);
|
|
187
|
-
};
|
|
188
|
-
for (const [o, i] of Object.entries(n))
|
|
189
|
-
e(o, i, !1);
|
|
190
|
-
for (const [o, i] of Object.entries(r))
|
|
191
|
-
e(o, i, !0);
|
|
192
|
-
return t;
|
|
193
|
-
}
|
|
194
|
-
const Q = () => {
|
|
195
|
-
throw new Error("not implemented");
|
|
196
|
-
};
|
|
197
|
-
function X(t) {
|
|
198
|
-
const n = /* @__PURE__ */ new WeakMap();
|
|
199
|
-
return (r, ...e) => {
|
|
200
|
-
const o = n.get(r);
|
|
201
|
-
if (o !== void 0)
|
|
202
|
-
return o;
|
|
203
|
-
const i = t(r, ...e);
|
|
204
|
-
return n.set(r, i), i;
|
|
205
|
-
};
|
|
154
|
+
return w;
|
|
155
|
+
}
|
|
156
|
+
function U(e) {
|
|
157
|
+
return z(e.Fp), x(e, {
|
|
158
|
+
n: "bigint",
|
|
159
|
+
h: "bigint",
|
|
160
|
+
Gx: "field",
|
|
161
|
+
Gy: "field"
|
|
162
|
+
}, {
|
|
163
|
+
nBitLength: "isSafeInteger",
|
|
164
|
+
nByteLength: "isSafeInteger"
|
|
165
|
+
}), Object.freeze({
|
|
166
|
+
...F(e.n, e.nBitLength),
|
|
167
|
+
...e,
|
|
168
|
+
p: e.Fp.ORDER
|
|
169
|
+
});
|
|
206
170
|
}
|
|
207
171
|
export {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
P as bitGet,
|
|
212
|
-
G as bitLen,
|
|
213
|
-
q as bitMask,
|
|
214
|
-
W as bitSet,
|
|
215
|
-
B as bytesToHex,
|
|
216
|
-
V as bytesToNumberBE,
|
|
217
|
-
H as bytesToNumberLE,
|
|
218
|
-
_ as concatBytes,
|
|
219
|
-
J as createHmacDrbg,
|
|
220
|
-
R as ensureBytes,
|
|
221
|
-
j as equalBytes,
|
|
222
|
-
m as hexToBytes,
|
|
223
|
-
U as hexToNumber,
|
|
224
|
-
N as inRange,
|
|
225
|
-
h as isBytes,
|
|
226
|
-
X as memoized,
|
|
227
|
-
Q as notImplemented,
|
|
228
|
-
v as numberToBytesBE,
|
|
229
|
-
C as numberToBytesLE,
|
|
230
|
-
S as numberToHexUnpadded,
|
|
231
|
-
M as numberToVarBytesBE,
|
|
232
|
-
z as utf8ToBytes,
|
|
233
|
-
K as validateObject
|
|
172
|
+
Z as pippenger,
|
|
173
|
+
U as validateBasic,
|
|
174
|
+
v as wNAF
|
|
234
175
|
};
|
package/dist/index105.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}exports.defineChain=n;
|
package/dist/index105.js
CHANGED
|
@@ -1,175 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { validateObject as x, bitLen as O } from "./index104.js";
|
|
3
|
-
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
4
|
-
const I = BigInt(0), p = BigInt(1);
|
|
5
|
-
function m(e, r) {
|
|
6
|
-
const t = r.negate();
|
|
7
|
-
return e ? t : r;
|
|
8
|
-
}
|
|
9
|
-
function A(e, r) {
|
|
10
|
-
if (!Number.isSafeInteger(e) || e <= 0 || e > r)
|
|
11
|
-
throw new Error("invalid window size, expected [1.." + r + "], got W=" + e);
|
|
12
|
-
}
|
|
13
|
-
function b(e, r) {
|
|
14
|
-
A(e, r);
|
|
15
|
-
const t = Math.ceil(r / e) + 1, n = 2 ** (e - 1);
|
|
16
|
-
return { windows: t, windowSize: n };
|
|
17
|
-
}
|
|
18
|
-
function L(e, r) {
|
|
19
|
-
if (!Array.isArray(e))
|
|
20
|
-
throw new Error("array expected");
|
|
21
|
-
e.forEach((t, n) => {
|
|
22
|
-
if (!(t instanceof r))
|
|
23
|
-
throw new Error("invalid point at index " + n);
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
function k(e, r) {
|
|
27
|
-
if (!Array.isArray(e))
|
|
28
|
-
throw new Error("array of scalars expected");
|
|
29
|
-
e.forEach((t, n) => {
|
|
30
|
-
if (!r.isValid(t))
|
|
31
|
-
throw new Error("invalid scalar at index " + n);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
const B = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap();
|
|
35
|
-
function S(e) {
|
|
36
|
-
return E.get(e) || 1;
|
|
37
|
-
}
|
|
38
|
-
function v(e, r) {
|
|
1
|
+
function n(e) {
|
|
39
2
|
return {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// non-const time multiplication ladder
|
|
45
|
-
unsafeLadder(t, n, i = e.ZERO) {
|
|
46
|
-
let o = t;
|
|
47
|
-
for (; n > I; )
|
|
48
|
-
n & p && (i = i.add(o)), o = o.double(), n >>= p;
|
|
49
|
-
return i;
|
|
50
|
-
},
|
|
51
|
-
/**
|
|
52
|
-
* Creates a wNAF precomputation window. Used for caching.
|
|
53
|
-
* Default window size is set by `utils.precompute()` and is equal to 8.
|
|
54
|
-
* Number of precomputed points depends on the curve size:
|
|
55
|
-
* 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
|
|
56
|
-
* - 𝑊 is the window size
|
|
57
|
-
* - 𝑛 is the bitlength of the curve order.
|
|
58
|
-
* For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
|
|
59
|
-
* @param elm Point instance
|
|
60
|
-
* @param W window size
|
|
61
|
-
* @returns precomputed point tables flattened to a single array
|
|
62
|
-
*/
|
|
63
|
-
precomputeWindow(t, n) {
|
|
64
|
-
const { windows: i, windowSize: o } = b(n, r), a = [];
|
|
65
|
-
let c = t, d = c;
|
|
66
|
-
for (let h = 0; h < i; h++) {
|
|
67
|
-
d = c, a.push(d);
|
|
68
|
-
for (let w = 1; w < o; w++)
|
|
69
|
-
d = d.add(c), a.push(d);
|
|
70
|
-
c = d.double();
|
|
71
|
-
}
|
|
72
|
-
return a;
|
|
73
|
-
},
|
|
74
|
-
/**
|
|
75
|
-
* Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
|
|
76
|
-
* @param W window size
|
|
77
|
-
* @param precomputes precomputed tables
|
|
78
|
-
* @param n scalar (we don't check here, but should be less than curve order)
|
|
79
|
-
* @returns real and fake (for const-time) points
|
|
80
|
-
*/
|
|
81
|
-
wNAF(t, n, i) {
|
|
82
|
-
const { windows: o, windowSize: a } = b(t, r);
|
|
83
|
-
let c = e.ZERO, d = e.BASE;
|
|
84
|
-
const h = BigInt(2 ** t - 1), w = 2 ** t, l = BigInt(t);
|
|
85
|
-
for (let u = 0; u < o; u++) {
|
|
86
|
-
const s = u * a;
|
|
87
|
-
let f = Number(i & h);
|
|
88
|
-
i >>= l, f > a && (f -= w, i += p);
|
|
89
|
-
const g = s, N = s + Math.abs(f) - 1, y = u % 2 !== 0, M = f < 0;
|
|
90
|
-
f === 0 ? d = d.add(m(y, n[g])) : c = c.add(m(M, n[N]));
|
|
91
|
-
}
|
|
92
|
-
return { p: c, f: d };
|
|
93
|
-
},
|
|
94
|
-
/**
|
|
95
|
-
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
96
|
-
* @param W window size
|
|
97
|
-
* @param precomputes precomputed tables
|
|
98
|
-
* @param n scalar (we don't check here, but should be less than curve order)
|
|
99
|
-
* @param acc accumulator point to add result of multiplication
|
|
100
|
-
* @returns point
|
|
101
|
-
*/
|
|
102
|
-
wNAFUnsafe(t, n, i, o = e.ZERO) {
|
|
103
|
-
const { windows: a, windowSize: c } = b(t, r), d = BigInt(2 ** t - 1), h = 2 ** t, w = BigInt(t);
|
|
104
|
-
for (let l = 0; l < a; l++) {
|
|
105
|
-
const u = l * c;
|
|
106
|
-
if (i === I)
|
|
107
|
-
break;
|
|
108
|
-
let s = Number(i & d);
|
|
109
|
-
if (i >>= w, s > c && (s -= h, i += p), s === 0)
|
|
110
|
-
continue;
|
|
111
|
-
let f = n[u + Math.abs(s) - 1];
|
|
112
|
-
s < 0 && (f = f.negate()), o = o.add(f);
|
|
113
|
-
}
|
|
114
|
-
return o;
|
|
115
|
-
},
|
|
116
|
-
getPrecomputes(t, n, i) {
|
|
117
|
-
let o = B.get(n);
|
|
118
|
-
return o || (o = this.precomputeWindow(n, t), t !== 1 && B.set(n, i(o))), o;
|
|
119
|
-
},
|
|
120
|
-
wNAFCached(t, n, i) {
|
|
121
|
-
const o = S(t);
|
|
122
|
-
return this.wNAF(o, this.getPrecomputes(o, t, i), n);
|
|
123
|
-
},
|
|
124
|
-
wNAFCachedUnsafe(t, n, i, o) {
|
|
125
|
-
const a = S(t);
|
|
126
|
-
return a === 1 ? this.unsafeLadder(t, n, o) : this.wNAFUnsafe(a, this.getPrecomputes(a, t, i), n, o);
|
|
127
|
-
},
|
|
128
|
-
// We calculate precomputes for elliptic curve point multiplication
|
|
129
|
-
// using windowed method. This specifies window size and
|
|
130
|
-
// stores precomputed values. Usually only base point would be precomputed.
|
|
131
|
-
setWindowSize(t, n) {
|
|
132
|
-
A(n, r), E.set(t, n), B.delete(t);
|
|
133
|
-
}
|
|
3
|
+
formatters: void 0,
|
|
4
|
+
fees: void 0,
|
|
5
|
+
serializers: void 0,
|
|
6
|
+
...e
|
|
134
7
|
};
|
|
135
8
|
}
|
|
136
|
-
function Z(e, r, t, n) {
|
|
137
|
-
if (L(t, e), k(n, r), t.length !== n.length)
|
|
138
|
-
throw new Error("arrays of points and scalars must have equal length");
|
|
139
|
-
const i = e.ZERO, o = O(BigInt(t.length)), a = o > 12 ? o - 3 : o > 4 ? o - 2 : o ? 2 : 1, c = (1 << a) - 1, d = new Array(c + 1).fill(i), h = Math.floor((r.BITS - 1) / a) * a;
|
|
140
|
-
let w = i;
|
|
141
|
-
for (let l = h; l >= 0; l -= a) {
|
|
142
|
-
d.fill(i);
|
|
143
|
-
for (let s = 0; s < n.length; s++) {
|
|
144
|
-
const f = n[s], g = Number(f >> BigInt(l) & BigInt(c));
|
|
145
|
-
d[g] = d[g].add(t[s]);
|
|
146
|
-
}
|
|
147
|
-
let u = i;
|
|
148
|
-
for (let s = d.length - 1, f = i; s > 0; s--)
|
|
149
|
-
f = f.add(d[s]), u = u.add(f);
|
|
150
|
-
if (w = w.add(u), l !== 0)
|
|
151
|
-
for (let s = 0; s < a; s++)
|
|
152
|
-
w = w.double();
|
|
153
|
-
}
|
|
154
|
-
return w;
|
|
155
|
-
}
|
|
156
|
-
function U(e) {
|
|
157
|
-
return z(e.Fp), x(e, {
|
|
158
|
-
n: "bigint",
|
|
159
|
-
h: "bigint",
|
|
160
|
-
Gx: "field",
|
|
161
|
-
Gy: "field"
|
|
162
|
-
}, {
|
|
163
|
-
nBitLength: "isSafeInteger",
|
|
164
|
-
nByteLength: "isSafeInteger"
|
|
165
|
-
}), Object.freeze({
|
|
166
|
-
...F(e.n, e.nBitLength),
|
|
167
|
-
...e,
|
|
168
|
-
p: e.Fp.ORDER
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
9
|
export {
|
|
172
|
-
|
|
173
|
-
U as validateBasic,
|
|
174
|
-
v as wNAF
|
|
10
|
+
n as defineChain
|
|
175
11
|
};
|
package/dist/index106.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index66.cjs");class i extends t.BaseError{constructor({offset:r,position:s,size:e}){super(`Slice ${s==="start"?"starting":"ending"} at offset "${r}" is out-of-bounds (size: ${e}).`,{name:"SliceOffsetOutOfBoundsError"})}}class d extends t.BaseError{constructor({size:r,targetSize:s,type:e}){super(`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()} size (${r}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}exports.SizeExceedsPaddingSizeError=d;exports.SliceOffsetOutOfBoundsError=i;
|
package/dist/index106.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseError as o } from "./
|
|
1
|
+
import { BaseError as o } from "./index66.js";
|
|
2
2
|
class d extends o {
|
|
3
3
|
constructor({ offset: r, position: s, size: e }) {
|
|
4
4
|
super(`Slice ${s === "start" ? "starting" : "ending"} at offset "${r}" is out-of-bounds (size: ${e}).`, { name: "SliceOffsetOutOfBoundsError" });
|
package/dist/index112.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index110.cjs"),s=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index110.cjs"),s=require("./index66.cjs");class i extends s.BaseError{constructor({maxSize:e,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class n extends s.BaseError{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class t extends s.BaseError{constructor({hash:e,size:r}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class d extends s.BaseError{constructor({hash:e,version:r}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${a.versionedHashVersionKzg}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}exports.BlobSizeTooLargeError=i;exports.EmptyBlobError=n;exports.InvalidVersionedHashSizeError=t;exports.InvalidVersionedHashVersionError=d;
|
package/dist/index112.js
CHANGED