@gardenfi/utils 2.1.2-beta.5 → 2.1.2-beta.7
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 +5 -5
- package/dist/index101.cjs +1 -2
- package/dist/index101.js +11 -3
- package/dist/index102.cjs +1 -1
- package/dist/index102.js +6 -18
- package/dist/index103.cjs +1 -1
- package/dist/index103.js +15 -638
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +5 -173
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +2 -2
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +2 -2
- package/dist/index19.cjs +1 -1
- package/dist/index19.js +9 -9
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +18 -17
- package/dist/index21.cjs +16 -1
- package/dist/index21.js +112 -30
- package/dist/index22.cjs +1 -16
- package/dist/index22.js +30 -113
- package/dist/index23.cjs +1 -2
- package/dist/index23.js +40 -49
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +45 -24
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +25 -41
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +6 -45
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +12 -24
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +15 -6
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +5 -13
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +12 -14
- package/dist/index31.cjs +1 -1
- package/dist/index31.js +10 -5
- package/dist/index32.cjs +1 -1
- package/dist/index32.js +12 -13
- package/dist/index33.cjs +1 -1
- package/dist/index33.js +11 -10
- package/dist/index34.cjs +1 -1
- package/dist/index34.js +13 -12
- package/dist/index35.cjs +1 -1
- package/dist/index35.js +23 -11
- package/dist/index36.cjs +1 -1
- package/dist/index36.js +55 -13
- package/dist/index37.cjs +1 -1
- package/dist/index37.js +16 -23
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +5 -55
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +8 -16
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +3 -5
- package/dist/index40.cjs +1 -1
- package/dist/index40.js +171 -5
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +103 -8
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +20 -170
- package/dist/index43.cjs +2 -1
- package/dist/index43.js +44 -97
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +24 -21
- 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 +40 -6
- package/dist/index48.cjs +1 -2
- package/dist/index48.js +33 -58
- package/dist/index49.cjs +1 -1
- package/dist/index49.js +70 -2
- package/dist/index50.cjs +1 -1
- package/dist/index50.js +111 -5
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +67 -4
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +2 -12
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +17 -8
- package/dist/index54.cjs +1 -5
- package/dist/index54.js +215 -48
- package/dist/index55.cjs +1 -2
- package/dist/index55.js +228 -31
- package/dist/index56.cjs +2 -1
- package/dist/index56.js +59 -5
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +22 -2
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +101 -18
- package/dist/index59.cjs +1 -1
- package/dist/index59.js +3 -8
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +16 -9
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +8 -11
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +10 -6
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +11 -13
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +12 -31
- package/dist/index65.cjs +1 -1
- package/dist/index65.js +18 -14
- package/dist/index66.cjs +1 -1
- package/dist/index66.js +6 -64
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +40 -25
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +79 -3
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +14 -3
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +18 -8
- package/dist/index71.cjs +1 -1
- package/dist/index71.js +8 -191
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +191 -18
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +63 -7
- package/dist/index74.cjs +1 -1
- package/dist/index74.js +4 -40
- package/dist/index75.cjs +1 -1
- package/dist/index75.js +2 -35
- package/dist/index76.cjs +1 -1
- package/dist/index76.js +5 -68
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +11 -112
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +8 -68
- package/dist/index79.cjs +5 -1
- package/dist/index79.js +57 -2
- package/dist/index80.cjs +2 -1
- package/dist/index80.js +33 -15
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +5 -223
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +2 -232
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +6 -42
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +30 -102
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +26 -16
- package/dist/index86.cjs +1 -1
- package/dist/index86.js +3 -79
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +10 -17
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +18 -11
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +8 -38
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +2 -2
- package/dist/index90.cjs +1 -1
- package/dist/index90.js +13 -2
- package/dist/index91.cjs +1 -1
- package/dist/index91.js +19 -5
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +643 -10
- package/dist/index93.cjs +1 -1
- package/dist/index93.js +171 -10
- package/dist/index94.cjs +1 -1
- package/dist/index94.js +127 -19
- package/dist/index95.cjs +2 -1
- package/dist/index95.js +3 -128
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +2 -7
- package/dist/index97.cjs +1 -1
- package/dist/index97.js +2 -2
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +2 -2
- package/dist/index99.cjs +1 -1
- package/dist/index99.js +35 -17
- package/package.json +1 -1
package/dist/index93.js
CHANGED
|
@@ -1,14 +1,175 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { validateField as z, nLength as F } from "./index54.js";
|
|
2
|
+
import { validateObject as x, bitLen as O } from "./index55.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) {
|
|
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);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
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();
|
|
10
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
|
+
});
|
|
11
170
|
}
|
|
12
171
|
export {
|
|
13
|
-
|
|
172
|
+
Z as pippenger,
|
|
173
|
+
U as validateBasic,
|
|
174
|
+
v as wNAF
|
|
14
175
|
};
|
package/dist/index94.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 o=require("./index103.cjs"),e={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new o.RecursiveReadLimitExceededError({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new o.PositionOutOfBoundsError({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new o.NegativeOffsetError({offset:t});const i=this.position-t;this.assertPosition(i),this.position=i},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new o.NegativeOffsetError({offset:t});const i=this.position+t;this.assertPosition(i),this.position=i},inspectByte(t){const i=t??this.position;return this.assertPosition(i),this.bytes[i]},inspectBytes(t,i){const s=i??this.position;return this.assertPosition(s+t-1),this.bytes.subarray(s,s+t)},inspectUint8(t){const i=t??this.position;return this.assertPosition(i),this.bytes[i]},inspectUint16(t){const i=t??this.position;return this.assertPosition(i+1),this.dataView.getUint16(i)},inspectUint24(t){const i=t??this.position;return this.assertPosition(i+2),(this.dataView.getUint16(i)<<8)+this.dataView.getUint8(i+2)},inspectUint32(t){const i=t??this.position;return this.assertPosition(i+3),this.dataView.getUint32(i)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,i){this.assertReadLimit(),this._touch();const s=this.inspectBytes(t);return this.position+=i??t,s},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const i=this.position;return this.assertPosition(t),this.position=t,()=>this.position=i},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function n(t,{recursiveReadLimit:i=8192}={}){const s=Object.create(e);return s.bytes=t,s.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),s.positionReadCount=new Map,s.recursiveReadLimit=i,s}exports.createCursor=n;
|
package/dist/index94.js
CHANGED
|
@@ -1,22 +1,130 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { NegativeOffsetError as o, PositionOutOfBoundsError as e, RecursiveReadLimitExceededError as n } from "./index103.js";
|
|
2
|
+
const h = {
|
|
3
|
+
bytes: new Uint8Array(),
|
|
4
|
+
dataView: new DataView(new ArrayBuffer(0)),
|
|
5
|
+
position: 0,
|
|
6
|
+
positionReadCount: /* @__PURE__ */ new Map(),
|
|
7
|
+
recursiveReadCount: 0,
|
|
8
|
+
recursiveReadLimit: Number.POSITIVE_INFINITY,
|
|
9
|
+
assertReadLimit() {
|
|
10
|
+
if (this.recursiveReadCount >= this.recursiveReadLimit)
|
|
11
|
+
throw new n({
|
|
12
|
+
count: this.recursiveReadCount + 1,
|
|
13
|
+
limit: this.recursiveReadLimit
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
assertPosition(t) {
|
|
17
|
+
if (t < 0 || t > this.bytes.length - 1)
|
|
18
|
+
throw new e({
|
|
19
|
+
length: this.bytes.length,
|
|
20
|
+
position: t
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
decrementPosition(t) {
|
|
24
|
+
if (t < 0)
|
|
25
|
+
throw new o({ offset: t });
|
|
26
|
+
const i = this.position - t;
|
|
27
|
+
this.assertPosition(i), this.position = i;
|
|
28
|
+
},
|
|
29
|
+
getReadCount(t) {
|
|
30
|
+
return this.positionReadCount.get(t || this.position) || 0;
|
|
31
|
+
},
|
|
32
|
+
incrementPosition(t) {
|
|
33
|
+
if (t < 0)
|
|
34
|
+
throw new o({ offset: t });
|
|
35
|
+
const i = this.position + t;
|
|
36
|
+
this.assertPosition(i), this.position = i;
|
|
37
|
+
},
|
|
38
|
+
inspectByte(t) {
|
|
39
|
+
const i = t ?? this.position;
|
|
40
|
+
return this.assertPosition(i), this.bytes[i];
|
|
41
|
+
},
|
|
42
|
+
inspectBytes(t, i) {
|
|
43
|
+
const s = i ?? this.position;
|
|
44
|
+
return this.assertPosition(s + t - 1), this.bytes.subarray(s, s + t);
|
|
45
|
+
},
|
|
46
|
+
inspectUint8(t) {
|
|
47
|
+
const i = t ?? this.position;
|
|
48
|
+
return this.assertPosition(i), this.bytes[i];
|
|
49
|
+
},
|
|
50
|
+
inspectUint16(t) {
|
|
51
|
+
const i = t ?? this.position;
|
|
52
|
+
return this.assertPosition(i + 1), this.dataView.getUint16(i);
|
|
53
|
+
},
|
|
54
|
+
inspectUint24(t) {
|
|
55
|
+
const i = t ?? this.position;
|
|
56
|
+
return this.assertPosition(i + 2), (this.dataView.getUint16(i) << 8) + this.dataView.getUint8(i + 2);
|
|
57
|
+
},
|
|
58
|
+
inspectUint32(t) {
|
|
59
|
+
const i = t ?? this.position;
|
|
60
|
+
return this.assertPosition(i + 3), this.dataView.getUint32(i);
|
|
61
|
+
},
|
|
62
|
+
pushByte(t) {
|
|
63
|
+
this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
|
|
64
|
+
},
|
|
65
|
+
pushBytes(t) {
|
|
66
|
+
this.assertPosition(this.position + t.length - 1), this.bytes.set(t, this.position), this.position += t.length;
|
|
67
|
+
},
|
|
68
|
+
pushUint8(t) {
|
|
69
|
+
this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
|
|
70
|
+
},
|
|
71
|
+
pushUint16(t) {
|
|
72
|
+
this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, t), this.position += 2;
|
|
73
|
+
},
|
|
74
|
+
pushUint24(t) {
|
|
75
|
+
this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, t >> 8), this.dataView.setUint8(this.position + 2, t & 255), this.position += 3;
|
|
76
|
+
},
|
|
77
|
+
pushUint32(t) {
|
|
78
|
+
this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, t), this.position += 4;
|
|
79
|
+
},
|
|
80
|
+
readByte() {
|
|
81
|
+
this.assertReadLimit(), this._touch();
|
|
82
|
+
const t = this.inspectByte();
|
|
83
|
+
return this.position++, t;
|
|
84
|
+
},
|
|
85
|
+
readBytes(t, i) {
|
|
86
|
+
this.assertReadLimit(), this._touch();
|
|
87
|
+
const s = this.inspectBytes(t);
|
|
88
|
+
return this.position += i ?? t, s;
|
|
89
|
+
},
|
|
90
|
+
readUint8() {
|
|
91
|
+
this.assertReadLimit(), this._touch();
|
|
92
|
+
const t = this.inspectUint8();
|
|
93
|
+
return this.position += 1, t;
|
|
94
|
+
},
|
|
95
|
+
readUint16() {
|
|
96
|
+
this.assertReadLimit(), this._touch();
|
|
97
|
+
const t = this.inspectUint16();
|
|
98
|
+
return this.position += 2, t;
|
|
99
|
+
},
|
|
100
|
+
readUint24() {
|
|
101
|
+
this.assertReadLimit(), this._touch();
|
|
102
|
+
const t = this.inspectUint24();
|
|
103
|
+
return this.position += 3, t;
|
|
104
|
+
},
|
|
105
|
+
readUint32() {
|
|
106
|
+
this.assertReadLimit(), this._touch();
|
|
107
|
+
const t = this.inspectUint32();
|
|
108
|
+
return this.position += 4, t;
|
|
109
|
+
},
|
|
110
|
+
get remaining() {
|
|
111
|
+
return this.bytes.length - this.position;
|
|
112
|
+
},
|
|
113
|
+
setPosition(t) {
|
|
114
|
+
const i = this.position;
|
|
115
|
+
return this.assertPosition(t), this.position = t, () => this.position = i;
|
|
116
|
+
},
|
|
117
|
+
_touch() {
|
|
118
|
+
if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
|
|
119
|
+
return;
|
|
120
|
+
const t = this.getReadCount();
|
|
121
|
+
this.positionReadCount.set(this.position, t + 1), t > 0 && this.recursiveReadCount++;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
function a(t, { recursiveReadLimit: i = 8192 } = {}) {
|
|
125
|
+
const s = Object.create(h);
|
|
126
|
+
return s.bytes = t, s.dataView = new DataView(t.buffer, t.byteOffset, t.byteLength), s.positionReadCount = /* @__PURE__ */ new Map(), s.recursiveReadLimit = i, s;
|
|
19
127
|
}
|
|
20
128
|
export {
|
|
21
|
-
|
|
129
|
+
a as createCursor
|
|
22
130
|
};
|
package/dist/index95.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 e=`Ethereum Signed Message:
|
|
2
|
+
`;exports.presignMessagePrefix=e;
|
package/dist/index95.js
CHANGED
|
@@ -1,130 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
bytes: new Uint8Array(),
|
|
4
|
-
dataView: new DataView(new ArrayBuffer(0)),
|
|
5
|
-
position: 0,
|
|
6
|
-
positionReadCount: /* @__PURE__ */ new Map(),
|
|
7
|
-
recursiveReadCount: 0,
|
|
8
|
-
recursiveReadLimit: Number.POSITIVE_INFINITY,
|
|
9
|
-
assertReadLimit() {
|
|
10
|
-
if (this.recursiveReadCount >= this.recursiveReadLimit)
|
|
11
|
-
throw new n({
|
|
12
|
-
count: this.recursiveReadCount + 1,
|
|
13
|
-
limit: this.recursiveReadLimit
|
|
14
|
-
});
|
|
15
|
-
},
|
|
16
|
-
assertPosition(t) {
|
|
17
|
-
if (t < 0 || t > this.bytes.length - 1)
|
|
18
|
-
throw new e({
|
|
19
|
-
length: this.bytes.length,
|
|
20
|
-
position: t
|
|
21
|
-
});
|
|
22
|
-
},
|
|
23
|
-
decrementPosition(t) {
|
|
24
|
-
if (t < 0)
|
|
25
|
-
throw new o({ offset: t });
|
|
26
|
-
const i = this.position - t;
|
|
27
|
-
this.assertPosition(i), this.position = i;
|
|
28
|
-
},
|
|
29
|
-
getReadCount(t) {
|
|
30
|
-
return this.positionReadCount.get(t || this.position) || 0;
|
|
31
|
-
},
|
|
32
|
-
incrementPosition(t) {
|
|
33
|
-
if (t < 0)
|
|
34
|
-
throw new o({ offset: t });
|
|
35
|
-
const i = this.position + t;
|
|
36
|
-
this.assertPosition(i), this.position = i;
|
|
37
|
-
},
|
|
38
|
-
inspectByte(t) {
|
|
39
|
-
const i = t ?? this.position;
|
|
40
|
-
return this.assertPosition(i), this.bytes[i];
|
|
41
|
-
},
|
|
42
|
-
inspectBytes(t, i) {
|
|
43
|
-
const s = i ?? this.position;
|
|
44
|
-
return this.assertPosition(s + t - 1), this.bytes.subarray(s, s + t);
|
|
45
|
-
},
|
|
46
|
-
inspectUint8(t) {
|
|
47
|
-
const i = t ?? this.position;
|
|
48
|
-
return this.assertPosition(i), this.bytes[i];
|
|
49
|
-
},
|
|
50
|
-
inspectUint16(t) {
|
|
51
|
-
const i = t ?? this.position;
|
|
52
|
-
return this.assertPosition(i + 1), this.dataView.getUint16(i);
|
|
53
|
-
},
|
|
54
|
-
inspectUint24(t) {
|
|
55
|
-
const i = t ?? this.position;
|
|
56
|
-
return this.assertPosition(i + 2), (this.dataView.getUint16(i) << 8) + this.dataView.getUint8(i + 2);
|
|
57
|
-
},
|
|
58
|
-
inspectUint32(t) {
|
|
59
|
-
const i = t ?? this.position;
|
|
60
|
-
return this.assertPosition(i + 3), this.dataView.getUint32(i);
|
|
61
|
-
},
|
|
62
|
-
pushByte(t) {
|
|
63
|
-
this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
|
|
64
|
-
},
|
|
65
|
-
pushBytes(t) {
|
|
66
|
-
this.assertPosition(this.position + t.length - 1), this.bytes.set(t, this.position), this.position += t.length;
|
|
67
|
-
},
|
|
68
|
-
pushUint8(t) {
|
|
69
|
-
this.assertPosition(this.position), this.bytes[this.position] = t, this.position++;
|
|
70
|
-
},
|
|
71
|
-
pushUint16(t) {
|
|
72
|
-
this.assertPosition(this.position + 1), this.dataView.setUint16(this.position, t), this.position += 2;
|
|
73
|
-
},
|
|
74
|
-
pushUint24(t) {
|
|
75
|
-
this.assertPosition(this.position + 2), this.dataView.setUint16(this.position, t >> 8), this.dataView.setUint8(this.position + 2, t & 255), this.position += 3;
|
|
76
|
-
},
|
|
77
|
-
pushUint32(t) {
|
|
78
|
-
this.assertPosition(this.position + 3), this.dataView.setUint32(this.position, t), this.position += 4;
|
|
79
|
-
},
|
|
80
|
-
readByte() {
|
|
81
|
-
this.assertReadLimit(), this._touch();
|
|
82
|
-
const t = this.inspectByte();
|
|
83
|
-
return this.position++, t;
|
|
84
|
-
},
|
|
85
|
-
readBytes(t, i) {
|
|
86
|
-
this.assertReadLimit(), this._touch();
|
|
87
|
-
const s = this.inspectBytes(t);
|
|
88
|
-
return this.position += i ?? t, s;
|
|
89
|
-
},
|
|
90
|
-
readUint8() {
|
|
91
|
-
this.assertReadLimit(), this._touch();
|
|
92
|
-
const t = this.inspectUint8();
|
|
93
|
-
return this.position += 1, t;
|
|
94
|
-
},
|
|
95
|
-
readUint16() {
|
|
96
|
-
this.assertReadLimit(), this._touch();
|
|
97
|
-
const t = this.inspectUint16();
|
|
98
|
-
return this.position += 2, t;
|
|
99
|
-
},
|
|
100
|
-
readUint24() {
|
|
101
|
-
this.assertReadLimit(), this._touch();
|
|
102
|
-
const t = this.inspectUint24();
|
|
103
|
-
return this.position += 3, t;
|
|
104
|
-
},
|
|
105
|
-
readUint32() {
|
|
106
|
-
this.assertReadLimit(), this._touch();
|
|
107
|
-
const t = this.inspectUint32();
|
|
108
|
-
return this.position += 4, t;
|
|
109
|
-
},
|
|
110
|
-
get remaining() {
|
|
111
|
-
return this.bytes.length - this.position;
|
|
112
|
-
},
|
|
113
|
-
setPosition(t) {
|
|
114
|
-
const i = this.position;
|
|
115
|
-
return this.assertPosition(t), this.position = t, () => this.position = i;
|
|
116
|
-
},
|
|
117
|
-
_touch() {
|
|
118
|
-
if (this.recursiveReadLimit === Number.POSITIVE_INFINITY)
|
|
119
|
-
return;
|
|
120
|
-
const t = this.getReadCount();
|
|
121
|
-
this.positionReadCount.set(this.position, t + 1), t > 0 && this.recursiveReadCount++;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
function a(t, { recursiveReadLimit: i = 8192 } = {}) {
|
|
125
|
-
const s = Object.create(h);
|
|
126
|
-
return s.bytes = t, s.dataView = new DataView(t.buffer, t.byteOffset, t.byteLength), s.positionReadCount = /* @__PURE__ */ new Map(), s.recursiveReadLimit = i, s;
|
|
127
|
-
}
|
|
1
|
+
const e = `Ethereum Signed Message:
|
|
2
|
+
`;
|
|
128
3
|
export {
|
|
129
|
-
|
|
4
|
+
e as presignMessagePrefix
|
|
130
5
|
};
|
package/dist/index96.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=1;exports.versionedHashVersionKzg=e;
|
package/dist/index96.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { isHex as s } from "./index69.js";
|
|
3
|
-
import { toBytes as r } from "./index38.js";
|
|
4
|
-
function p(t, i) {
|
|
5
|
-
return o(s(t, { strict: !1 }) ? r(t) : t);
|
|
6
|
-
}
|
|
1
|
+
const e = 1;
|
|
7
2
|
export {
|
|
8
|
-
|
|
3
|
+
e as versionedHashVersionKzg
|
|
9
4
|
};
|
package/dist/index97.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=2n**256n-1n;exports.maxUint256=t;
|
package/dist/index97.js
CHANGED
package/dist/index98.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index96.cjs"),s=require("./index56.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/index98.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { versionedHashVersionKzg as a } from "./
|
|
2
|
-
import { BaseError as s } from "./
|
|
1
|
+
import { versionedHashVersionKzg as a } from "./index96.js";
|
|
2
|
+
import { BaseError as s } from "./index56.js";
|
|
3
3
|
class t extends s {
|
|
4
4
|
constructor({ maxSize: e, size: r }) {
|
|
5
5
|
super("Blob size is too large.", {
|
package/dist/index99.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("./index90.cjs"),O=require("./index59.cjs"),n=require("./index74.cjs");function p(i,e,s,{strict:f}={}){return O.isHex(i,{strict:!1})?l(i,e,s,{strict:f}):u(i,e,s,{strict:f})}function r(i,e){if(typeof e=="number"&&e>0&&e>n.size(i)-1)throw new t.SliceOffsetOutOfBoundsError({offset:e,position:"start",size:n.size(i)})}function c(i,e,s){if(typeof e=="number"&&typeof s=="number"&&n.size(i)!==s-e)throw new t.SliceOffsetOutOfBoundsError({offset:s,position:"end",size:n.size(i)})}function u(i,e,s,{strict:f}={}){r(i,e);const o=i.slice(e,s);return f&&c(o,e,s),o}function l(i,e,s,{strict:f}={}){r(i,e);const o=`0x${i.replace("0x","").slice((e??0)*2,(s??i.length)*2)}`;return f&&c(o,e,s),o}exports.slice=p;exports.sliceBytes=u;exports.sliceHex=l;
|
package/dist/index99.js
CHANGED
|
@@ -1,23 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { SliceOffsetOutOfBoundsError as t } from "./index90.js";
|
|
2
|
+
import { isHex as p } from "./index59.js";
|
|
3
|
+
import { size as r } from "./index74.js";
|
|
4
|
+
function w(e, f, i, { strict: o } = {}) {
|
|
5
|
+
return p(e, { strict: !1 }) ? u(e, f, i, {
|
|
6
|
+
strict: o
|
|
7
|
+
}) : m(e, f, i, {
|
|
8
|
+
strict: o
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function s(e, f) {
|
|
12
|
+
if (typeof f == "number" && f > 0 && f > r(e) - 1)
|
|
13
|
+
throw new t({
|
|
14
|
+
offset: f,
|
|
15
|
+
position: "start",
|
|
16
|
+
size: r(e)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function c(e, f, i) {
|
|
20
|
+
if (typeof f == "number" && typeof i == "number" && r(e) !== i - f)
|
|
21
|
+
throw new t({
|
|
22
|
+
offset: i,
|
|
23
|
+
position: "end",
|
|
24
|
+
size: r(e)
|
|
6
25
|
});
|
|
7
|
-
}
|
|
8
26
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
27
|
+
function m(e, f, i, { strict: o } = {}) {
|
|
28
|
+
s(e, f);
|
|
29
|
+
const n = e.slice(f, i);
|
|
30
|
+
return o && c(n, f, i), n;
|
|
13
31
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
32
|
+
function u(e, f, i, { strict: o } = {}) {
|
|
33
|
+
s(e, f);
|
|
34
|
+
const n = `0x${e.replace("0x", "").slice((f ?? 0) * 2, (i ?? e.length) * 2)}`;
|
|
35
|
+
return o && c(n, f, i), n;
|
|
18
36
|
}
|
|
19
37
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
38
|
+
w as slice,
|
|
39
|
+
m as sliceBytes,
|
|
40
|
+
u as sliceHex
|
|
23
41
|
};
|