@gardenfi/utils 2.1.2-beta.7 → 2.1.2-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/index102.cjs +1 -1
  2. package/dist/index102.js +2 -2
  3. package/dist/index103.cjs +1 -1
  4. package/dist/index103.js +1 -1
  5. package/dist/index15.cjs +1 -1
  6. package/dist/index15.js +2 -2
  7. package/dist/index20.cjs +1 -1
  8. package/dist/index20.js +17 -18
  9. package/dist/index21.cjs +1 -16
  10. package/dist/index21.js +30 -112
  11. package/dist/index22.cjs +16 -1
  12. package/dist/index22.js +113 -30
  13. package/dist/index23.cjs +1 -1
  14. package/dist/index23.js +3 -3
  15. package/dist/index32.cjs +1 -1
  16. package/dist/index32.js +1 -1
  17. package/dist/index33.cjs +1 -1
  18. package/dist/index33.js +1 -1
  19. package/dist/index35.cjs +1 -1
  20. package/dist/index35.js +1 -1
  21. package/dist/index36.cjs +1 -1
  22. package/dist/index36.js +2 -2
  23. package/dist/index37.cjs +1 -1
  24. package/dist/index37.js +2 -2
  25. package/dist/index38.cjs +1 -1
  26. package/dist/index38.js +1 -1
  27. package/dist/index39.cjs +1 -1
  28. package/dist/index39.js +2 -2
  29. package/dist/index40.cjs +1 -1
  30. package/dist/index40.js +11 -11
  31. package/dist/index41.cjs +1 -1
  32. package/dist/index41.js +3 -3
  33. package/dist/index42.cjs +1 -1
  34. package/dist/index42.js +1 -1
  35. package/dist/index43.cjs +1 -1
  36. package/dist/index43.js +1 -1
  37. package/dist/index45.cjs +1 -1
  38. package/dist/index45.js +1 -1
  39. package/dist/index46.cjs +1 -1
  40. package/dist/index46.js +1 -1
  41. package/dist/index47.cjs +1 -1
  42. package/dist/index47.js +105 -33
  43. package/dist/index48.cjs +1 -1
  44. package/dist/index48.js +15 -33
  45. package/dist/index49.cjs +1 -1
  46. package/dist/index49.js +213 -59
  47. package/dist/index50.cjs +2 -1
  48. package/dist/index50.js +57 -110
  49. package/dist/index51.cjs +1 -1
  50. package/dist/index51.js +18 -64
  51. package/dist/index52.cjs +1 -1
  52. package/dist/index52.js +105 -2
  53. package/dist/index53.cjs +1 -1
  54. package/dist/index53.js +3 -16
  55. package/dist/index54.cjs +1 -1
  56. package/dist/index54.js +16 -222
  57. package/dist/index55.cjs +1 -1
  58. package/dist/index55.js +8 -231
  59. package/dist/index56.cjs +1 -2
  60. package/dist/index56.js +9 -58
  61. package/dist/index57.cjs +1 -1
  62. package/dist/index57.js +11 -21
  63. package/dist/index58.cjs +1 -1
  64. package/dist/index58.js +13 -104
  65. package/dist/index59.cjs +1 -1
  66. package/dist/index59.js +18 -3
  67. package/dist/index60.cjs +1 -1
  68. package/dist/index60.js +6 -17
  69. package/dist/index61.cjs +1 -1
  70. package/dist/index61.js +42 -8
  71. package/dist/index62.cjs +1 -1
  72. package/dist/index62.js +77 -9
  73. package/dist/index63.cjs +1 -1
  74. package/dist/index63.js +14 -11
  75. package/dist/index64.cjs +1 -1
  76. package/dist/index64.js +18 -13
  77. package/dist/index65.cjs +1 -1
  78. package/dist/index65.js +8 -18
  79. package/dist/index66.cjs +1 -1
  80. package/dist/index66.js +191 -6
  81. package/dist/index67.cjs +1 -1
  82. package/dist/index67.js +60 -38
  83. package/dist/index68.cjs +1 -1
  84. package/dist/index68.js +4 -78
  85. package/dist/index69.cjs +1 -1
  86. package/dist/index69.js +40 -14
  87. package/dist/index70.cjs +1 -1
  88. package/dist/index70.js +34 -18
  89. package/dist/index71.cjs +1 -1
  90. package/dist/index71.js +69 -8
  91. package/dist/index72.cjs +1 -1
  92. package/dist/index72.js +58 -182
  93. package/dist/index73.cjs +1 -1
  94. package/dist/index73.js +2 -65
  95. package/dist/index74.cjs +1 -1
  96. package/dist/index74.js +231 -4
  97. package/dist/index76.cjs +1 -1
  98. package/dist/index76.js +1 -1
  99. package/dist/index79.cjs +1 -1
  100. package/dist/index79.js +2 -2
  101. package/dist/index80.cjs +1 -1
  102. package/dist/index80.js +1 -1
  103. package/dist/index84.cjs +1 -1
  104. package/dist/index84.js +2 -2
  105. package/dist/index85.cjs +1 -1
  106. package/dist/index85.js +1 -1
  107. package/dist/index87.cjs +1 -1
  108. package/dist/index87.js +1 -1
  109. package/dist/index89.cjs +1 -1
  110. package/dist/index89.js +12 -8
  111. package/dist/index9.cjs +1 -1
  112. package/dist/index9.js +2 -2
  113. package/dist/index90.cjs +1 -1
  114. package/dist/index90.js +8 -12
  115. package/dist/index91.cjs +1 -1
  116. package/dist/index91.js +641 -16
  117. package/dist/index92.cjs +1 -1
  118. package/dist/index92.js +153 -624
  119. package/dist/index93.cjs +1 -1
  120. package/dist/index93.js +17 -171
  121. package/dist/index95.cjs +1 -2
  122. package/dist/index95.js +2 -3
  123. package/dist/index96.cjs +1 -1
  124. package/dist/index96.js +2 -2
  125. package/dist/index97.cjs +1 -1
  126. package/dist/index97.js +38 -2
  127. package/dist/index98.cjs +1 -1
  128. package/dist/index98.js +34 -33
  129. package/dist/index99.cjs +2 -1
  130. package/dist/index99.js +3 -39
  131. package/package.json +1 -1
package/dist/index93.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./index54.cjs"),y=require("./index55.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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=BigInt(2**32-1),i=BigInt(32);function u(t,e=!1){return e?{h:Number(t&n),l:Number(t>>i&n)}:{h:Number(t>>i&n)|0,l:Number(t&n)|0}}function g(t,e=!1){let r=new Uint32Array(t.length),l=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:c,l:f}=u(t[o],e);[r[o],l[o]]=[c,f]}return[r,l]}const B=(t,e,r)=>t<<r|e>>>32-r,h=(t,e,r)=>e<<r|t>>>32-r,m=(t,e,r)=>e<<r-32|t>>>64-r,S=(t,e,r)=>t<<r-32|e>>>64-r;exports.fromBig=u;exports.rotlBH=m;exports.rotlBL=S;exports.rotlSH=B;exports.rotlSL=h;exports.split=g;
package/dist/index93.js CHANGED
@@ -1,175 +1,21 @@
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();
1
+ const o = /* @__PURE__ */ BigInt(4294967295), i = /* @__PURE__ */ BigInt(32);
2
+ function f(t, r = !1) {
3
+ return r ? { h: Number(t & o), l: Number(t >> i & o) } : { h: Number(t >> i & o) | 0, l: Number(t & o) | 0 };
4
+ }
5
+ function h(t, r = !1) {
6
+ let n = new Uint32Array(t.length), l = new Uint32Array(t.length);
7
+ for (let e = 0; e < t.length; e++) {
8
+ const { h: c, l: u } = f(t[e], r);
9
+ [n[e], l[e]] = [c, u];
153
10
  }
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
+ return [n, l];
170
12
  }
13
+ const g = (t, r, n) => t << n | r >>> 32 - n, m = (t, r, n) => r << n | t >>> 32 - n, A = (t, r, n) => r << n - 32 | t >>> 64 - n, B = (t, r, n) => t << n - 32 | r >>> 64 - n;
171
14
  export {
172
- Z as pippenger,
173
- U as validateBasic,
174
- v as wNAF
15
+ f as fromBig,
16
+ A as rotlBH,
17
+ B as rotlBL,
18
+ g as rotlSH,
19
+ m as rotlSL,
20
+ h as split
175
21
  };
package/dist/index95.cjs CHANGED
@@ -1,2 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`Ethereum Signed Message:
2
- `;exports.presignMessagePrefix=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=1;exports.versionedHashVersionKzg=e;
package/dist/index95.js CHANGED
@@ -1,5 +1,4 @@
1
- const e = `Ethereum Signed Message:
2
- `;
1
+ const e = 1;
3
2
  export {
4
- e as presignMessagePrefix
3
+ e as versionedHashVersionKzg
5
4
  };
package/dist/index96.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=1;exports.versionedHashVersionKzg=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=2n**256n-1n;exports.maxUint256=t;
package/dist/index96.js CHANGED
@@ -1,4 +1,4 @@
1
- const e = 1;
1
+ const n = 2n ** 256n - 1n;
2
2
  export {
3
- e as versionedHashVersionKzg
3
+ n as maxUint256
4
4
  };
package/dist/index97.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=2n**256n-1n;exports.maxUint256=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index95.cjs"),s=require("./index50.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/index97.js CHANGED
@@ -1,4 +1,40 @@
1
- const n = 2n ** 256n - 1n;
1
+ import { versionedHashVersionKzg as a } from "./index95.js";
2
+ import { BaseError as s } from "./index50.js";
3
+ class t extends s {
4
+ constructor({ maxSize: e, size: r }) {
5
+ super("Blob size is too large.", {
6
+ metaMessages: [`Max: ${e} bytes`, `Given: ${r} bytes`],
7
+ name: "BlobSizeTooLargeError"
8
+ });
9
+ }
10
+ }
11
+ class d extends s {
12
+ constructor() {
13
+ super("Blob data must not be empty.", { name: "EmptyBlobError" });
14
+ }
15
+ }
16
+ class l extends s {
17
+ constructor({ hash: e, size: r }) {
18
+ super(`Versioned hash "${e}" size is invalid.`, {
19
+ metaMessages: ["Expected: 32", `Received: ${r}`],
20
+ name: "InvalidVersionedHashSizeError"
21
+ });
22
+ }
23
+ }
24
+ class c extends s {
25
+ constructor({ hash: e, version: r }) {
26
+ super(`Versioned hash "${e}" version is invalid.`, {
27
+ metaMessages: [
28
+ `Expected: ${a}`,
29
+ `Received: ${r}`
30
+ ],
31
+ name: "InvalidVersionedHashVersionError"
32
+ });
33
+ }
34
+ }
2
35
  export {
3
- n as maxUint256
36
+ t as BlobSizeTooLargeError,
37
+ d as EmptyBlobError,
38
+ l as InvalidVersionedHashSizeError,
39
+ c as InvalidVersionedHashVersionError
4
40
  };
package/dist/index98.cjs CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index89.cjs"),O=require("./index53.cjs"),n=require("./index68.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/index98.js CHANGED
@@ -1,40 +1,41 @@
1
- import { versionedHashVersionKzg as a } from "./index96.js";
2
- import { BaseError as s } from "./index56.js";
3
- class t extends s {
4
- constructor({ maxSize: e, size: r }) {
5
- super("Blob size is too large.", {
6
- metaMessages: [`Max: ${e} bytes`, `Given: ${r} bytes`],
7
- name: "BlobSizeTooLargeError"
8
- });
9
- }
10
- }
11
- class d extends s {
12
- constructor() {
13
- super("Blob data must not be empty.", { name: "EmptyBlobError" });
14
- }
1
+ import { SliceOffsetOutOfBoundsError as t } from "./index89.js";
2
+ import { isHex as p } from "./index53.js";
3
+ import { size as r } from "./index68.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
+ });
15
10
  }
16
- class l extends s {
17
- constructor({ hash: e, size: r }) {
18
- super(`Versioned hash "${e}" size is invalid.`, {
19
- metaMessages: ["Expected: 32", `Received: ${r}`],
20
- name: "InvalidVersionedHashSizeError"
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)
21
17
  });
22
- }
23
18
  }
24
- class c extends s {
25
- constructor({ hash: e, version: r }) {
26
- super(`Versioned hash "${e}" version is invalid.`, {
27
- metaMessages: [
28
- `Expected: ${a}`,
29
- `Received: ${r}`
30
- ],
31
- name: "InvalidVersionedHashVersionError"
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)
32
25
  });
33
- }
26
+ }
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;
31
+ }
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;
34
36
  }
35
37
  export {
36
- t as BlobSizeTooLargeError,
37
- d as EmptyBlobError,
38
- l as InvalidVersionedHashSizeError,
39
- c as InvalidVersionedHashVersionError
38
+ w as slice,
39
+ m as sliceBytes,
40
+ u as sliceHex
40
41
  };
package/dist/index99.cjs CHANGED
@@ -1 +1,2 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`Ethereum Signed Message:
2
+ `;exports.presignMessagePrefix=e;
package/dist/index99.js CHANGED
@@ -1,41 +1,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)
25
- });
26
- }
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;
31
- }
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;
36
- }
1
+ const e = `Ethereum Signed Message:
2
+ `;
37
3
  export {
38
- w as slice,
39
- m as sliceBytes,
40
- u as sliceHex
4
+ e as presignMessagePrefix
41
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/utils",
3
- "version": "2.1.2-beta.7",
3
+ "version": "2.1.2-beta.9",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "vite build",