@gardenfi/utils 2.1.3-beta.1 → 2.1.3-beta.10

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 (135) hide show
  1. package/dist/index104.cjs +1 -1
  2. package/dist/index104.js +1 -1
  3. package/dist/index107.cjs +1 -1
  4. package/dist/index107.js +71 -42
  5. package/dist/index108.cjs +1 -1
  6. package/dist/index108.js +2 -2
  7. package/dist/index110.cjs +1 -1
  8. package/dist/index110.js +1 -1
  9. package/dist/index111.cjs +1 -1
  10. package/dist/index111.js +1 -1
  11. package/dist/index112.cjs +1 -1
  12. package/dist/index112.js +1 -1
  13. package/dist/index113.cjs +1 -1
  14. package/dist/index113.js +1 -1
  15. package/dist/index125.cjs +1 -1
  16. package/dist/index125.js +1 -1
  17. package/dist/index166.cjs +1 -1
  18. package/dist/index166.js +36 -34
  19. package/dist/index192.cjs +1 -1
  20. package/dist/index192.js +15 -18
  21. package/dist/index222.cjs +1 -1
  22. package/dist/index222.js +2 -2
  23. package/dist/index225.cjs +1 -1
  24. package/dist/index225.js +43 -43
  25. package/dist/index226.cjs +1 -1
  26. package/dist/index226.js +3 -113
  27. package/dist/index231.cjs +1 -1
  28. package/dist/index231.js +1 -1
  29. package/dist/index232.cjs +1 -1
  30. package/dist/index232.js +1 -1
  31. package/dist/index233.cjs +1 -1
  32. package/dist/index233.js +2 -2
  33. package/dist/index245.cjs +1 -1
  34. package/dist/index245.js +3 -3
  35. package/dist/index246.cjs +1 -1
  36. package/dist/index246.js +3 -3
  37. package/dist/index247.cjs +1 -2
  38. package/dist/index247.js +13 -24
  39. package/dist/index248.cjs +1 -1
  40. package/dist/index248.js +15 -13
  41. package/dist/index249.cjs +2 -1
  42. package/dist/index249.js +23 -14
  43. package/dist/index266.cjs +1 -1
  44. package/dist/index266.js +1 -1
  45. package/dist/index277.cjs +1 -1
  46. package/dist/index277.js +103 -16
  47. package/dist/index278.cjs +1 -1
  48. package/dist/index278.js +13 -220
  49. package/dist/index279.cjs +1 -1
  50. package/dist/index279.js +214 -6
  51. package/dist/index28.cjs +1 -1
  52. package/dist/index28.js +2 -2
  53. package/dist/index280.cjs +1 -1
  54. package/dist/index280.js +7 -7
  55. package/dist/index281.cjs +1 -1
  56. package/dist/index281.js +7 -27
  57. package/dist/index282.cjs +1 -1
  58. package/dist/index282.js +26 -34
  59. package/dist/index283.cjs +1 -1
  60. package/dist/index283.js +13 -12
  61. package/dist/index284.cjs +1 -1
  62. package/dist/index284.js +89 -51
  63. package/dist/index285.cjs +1 -1
  64. package/dist/index285.js +3 -67
  65. package/dist/index286.cjs +1 -1
  66. package/dist/index286.js +140 -3
  67. package/dist/index287.cjs +1 -1
  68. package/dist/index287.js +143 -128
  69. package/dist/index288.cjs +1 -1
  70. package/dist/index288.js +9 -155
  71. package/dist/index289.cjs +1 -1
  72. package/dist/index289.js +111 -7
  73. package/dist/index290.cjs +2 -1
  74. package/dist/index290.js +116 -95
  75. package/dist/index291.cjs +1 -2
  76. package/dist/index291.js +8 -131
  77. package/dist/index292.cjs +1 -1
  78. package/dist/index292.js +19 -40
  79. package/dist/index293.cjs +1 -1
  80. package/dist/index293.js +43 -2
  81. package/dist/index294.cjs +1 -1
  82. package/dist/index294.js +74 -202
  83. package/dist/index295.cjs +1 -1
  84. package/dist/index295.js +2 -69
  85. package/dist/index296.cjs +1 -1
  86. package/dist/index296.js +68 -11
  87. package/dist/index297.cjs +1 -1
  88. package/dist/index297.js +656 -18
  89. package/dist/index298.cjs +1 -1
  90. package/dist/index298.js +197 -633
  91. package/dist/index299.cjs +1 -1
  92. package/dist/index299.js +78 -73
  93. package/dist/index300.cjs +2 -2
  94. package/dist/index300.js +7 -7
  95. package/dist/index302.cjs +1 -1
  96. package/dist/index302.js +1 -1
  97. package/dist/index303.cjs +1 -1
  98. package/dist/index303.js +2 -2
  99. package/dist/index305.cjs +1 -1
  100. package/dist/index305.js +1 -1
  101. package/dist/index307.cjs +1 -1
  102. package/dist/index307.js +2 -2
  103. package/dist/index308.cjs +1 -1
  104. package/dist/index308.js +1 -1
  105. package/dist/index310.cjs +1 -1
  106. package/dist/index310.js +1 -1
  107. package/dist/index311.cjs +1 -1
  108. package/dist/index311.js +5 -105
  109. package/dist/index312.cjs +1 -1
  110. package/dist/index312.js +2 -5
  111. package/dist/index313.cjs +1 -1
  112. package/dist/index313.js +22 -2
  113. package/dist/index36.cjs +1 -1
  114. package/dist/index36.js +1 -1
  115. package/dist/index43.cjs +1 -1
  116. package/dist/index43.js +40 -21
  117. package/dist/index44.cjs +1 -1
  118. package/dist/index44.js +24 -24
  119. package/dist/index58.cjs +1 -1
  120. package/dist/index58.js +98 -97
  121. package/dist/index79.cjs +1 -1
  122. package/dist/index79.js +1 -1
  123. package/dist/index84.cjs +1 -1
  124. package/dist/index84.js +53 -51
  125. package/dist/index90.cjs +1 -1
  126. package/dist/index90.js +44 -42
  127. package/dist/index92.cjs +1 -1
  128. package/dist/index92.js +15 -15
  129. package/package.json +1 -1
  130. package/dist/index314.cjs +0 -1
  131. package/dist/index314.js +0 -22
  132. package/dist/index315.cjs +0 -1
  133. package/dist/index315.js +0 -74
  134. package/dist/index316.cjs +0 -1
  135. package/dist/index316.js +0 -24
package/dist/index277.js CHANGED
@@ -1,19 +1,106 @@
1
- import { hmac as c } from "./index292.js";
2
- import { randomBytes as m, concatBytes as n } from "./index284.js";
3
- import { weierstrass as a } from "./index298.js";
4
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5
- function i(r) {
6
- return {
7
- hash: r,
8
- hmac: (e, ...t) => c(r, e, n(...t)),
9
- randomBytes: m
10
- };
11
- }
12
- function p(r, e) {
13
- const t = (o) => a({ ...r, ...i(o) });
14
- return { ...t(e), create: t };
1
+ import { HashMD as D, SHA256_IV as b, Chi as g, Maj as p } from "./index294.js";
2
+ import { createHasher as u, clean as C, rotr as i } from "./index284.js";
3
+ const B = /* @__PURE__ */ Uint32Array.from([
4
+ 1116352408,
5
+ 1899447441,
6
+ 3049323471,
7
+ 3921009573,
8
+ 961987163,
9
+ 1508970993,
10
+ 2453635748,
11
+ 2870763221,
12
+ 3624381080,
13
+ 310598401,
14
+ 607225278,
15
+ 1426881987,
16
+ 1925078388,
17
+ 2162078206,
18
+ 2614888103,
19
+ 3248222580,
20
+ 3835390401,
21
+ 4022224774,
22
+ 264347078,
23
+ 604807628,
24
+ 770255983,
25
+ 1249150122,
26
+ 1555081692,
27
+ 1996064986,
28
+ 2554220882,
29
+ 2821834349,
30
+ 2952996808,
31
+ 3210313671,
32
+ 3336571891,
33
+ 3584528711,
34
+ 113926993,
35
+ 338241895,
36
+ 666307205,
37
+ 773529912,
38
+ 1294757372,
39
+ 1396182291,
40
+ 1695183700,
41
+ 1986661051,
42
+ 2177026350,
43
+ 2456956037,
44
+ 2730485921,
45
+ 2820302411,
46
+ 3259730800,
47
+ 3345764771,
48
+ 3516065817,
49
+ 3600352804,
50
+ 4094571909,
51
+ 275423344,
52
+ 430227734,
53
+ 506948616,
54
+ 659060556,
55
+ 883997877,
56
+ 958139571,
57
+ 1322822218,
58
+ 1537002063,
59
+ 1747873779,
60
+ 1955562222,
61
+ 2024104815,
62
+ 2227730452,
63
+ 2361852424,
64
+ 2428436474,
65
+ 2756734187,
66
+ 3204031479,
67
+ 3329325298
68
+ ]), h = /* @__PURE__ */ new Uint32Array(64);
69
+ class E extends D {
70
+ constructor(o = 32) {
71
+ super(64, o, 8, !1), this.A = b[0] | 0, this.B = b[1] | 0, this.C = b[2] | 0, this.D = b[3] | 0, this.E = b[4] | 0, this.F = b[5] | 0, this.G = b[6] | 0, this.H = b[7] | 0;
72
+ }
73
+ get() {
74
+ const { A: o, B: r, C: t, D: s, E: a, F: f, G: c, H: e } = this;
75
+ return [o, r, t, s, a, f, c, e];
76
+ }
77
+ // prettier-ignore
78
+ set(o, r, t, s, a, f, c, e) {
79
+ this.A = o | 0, this.B = r | 0, this.C = t | 0, this.D = s | 0, this.E = a | 0, this.F = f | 0, this.G = c | 0, this.H = e | 0;
80
+ }
81
+ process(o, r) {
82
+ for (let x = 0; x < 16; x++, r += 4)
83
+ h[x] = o.getUint32(r, !1);
84
+ for (let x = 16; x < 64; x++) {
85
+ const H = h[x - 15], d = h[x - 2], m = i(H, 7) ^ i(H, 18) ^ H >>> 3, l = i(d, 17) ^ i(d, 19) ^ d >>> 10;
86
+ h[x] = l + h[x - 7] + m + h[x - 16] | 0;
87
+ }
88
+ let { A: t, B: s, C: a, D: f, E: c, F: e, G: n, H: A } = this;
89
+ for (let x = 0; x < 64; x++) {
90
+ const H = i(c, 6) ^ i(c, 11) ^ i(c, 25), d = A + H + g(c, e, n) + B[x] + h[x] | 0, l = (i(t, 2) ^ i(t, 13) ^ i(t, 22)) + p(t, s, a) | 0;
91
+ A = n, n = e, e = c, c = f + d | 0, f = a, a = s, s = t, t = d + l | 0;
92
+ }
93
+ t = t + this.A | 0, s = s + this.B | 0, a = a + this.C | 0, f = f + this.D | 0, c = c + this.E | 0, e = e + this.F | 0, n = n + this.G | 0, A = A + this.H | 0, this.set(t, s, a, f, c, e, n, A);
94
+ }
95
+ roundClean() {
96
+ C(h);
97
+ }
98
+ destroy() {
99
+ this.set(0, 0, 0, 0, 0, 0, 0, 0), C(this.buffer);
100
+ }
15
101
  }
102
+ const y = /* @__PURE__ */ u(() => new E());
16
103
  export {
17
- p as createCurve,
18
- i as getHash
104
+ E as SHA256,
105
+ y as sha256
19
106
  };
package/dist/index278.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index294.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const d=BigInt(0),c=BigInt(1),w=BigInt(2),j=BigInt(3),E=BigInt(4),S=BigInt(5),I=BigInt(8);function g(t,i){const r=t%i;return r>=d?r:i+r}function L(t,i,r){if(i<d)throw new Error("invalid exponent, negatives unsupported");if(r<=d)throw new Error("invalid modulus");if(r===c)return d;let n=c;for(;i>d;)i&c&&(n=n*t%r),t=t*t%r,i>>=c;return n}function H(t,i,r){let n=t;for(;i-- >d;)n*=n,n%=r;return n}function m(t,i){if(t===d)throw new Error("invert: expected non-zero number");if(i<=d)throw new Error("invert: expected positive modulus, got "+i);let r=g(t,i),n=i,s=d,u=c;for(;r!==d;){const o=n/r,e=n%r,l=s-u*o;n=r,r=e,s=u,u=l}if(n!==c)throw new Error("invert: does not exist");return g(s,i)}function T(t){const i=(t-c)/w;let r,n,s;for(r=t-c,n=0;r%w===d;r/=w,n++);for(s=w;s<t&&L(s,i,t)!==t-c;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){const f=(t+c)/E;return function(e,l){const h=e.pow(l,f);if(!e.eql(e.sqr(h),l))throw new Error("Cannot find square root");return h}}const u=(r+c)/w;return function(o,e){if(o.pow(e,i)===o.neg(o.ONE))throw new Error("Cannot find square root");let l=n,h=o.pow(o.mul(o.ONE,s),r),v=o.pow(e,u),q=o.pow(e,r);for(;!o.eql(q,o.ONE);){if(o.eql(q,o.ZERO))return o.ZERO;let b=1;for(let B=o.sqr(q);b<l&&!o.eql(B,o.ONE);b++)B=o.sqr(B);const y=o.pow(h,c<<BigInt(l-b-1));h=o.sqr(y),v=o.mul(v,y),q=o.mul(q,h),l=b}return v}}function x(t){if(t%E===j){const i=(t+c)/E;return function(n,s){const u=n.pow(s,i);if(!n.eql(n.sqr(u),s))throw new Error("Cannot find square root");return u}}if(t%I===S){const i=(t-S)/I;return function(n,s){const u=n.mul(s,w),f=n.pow(u,i),o=n.mul(s,f),e=n.mul(n.mul(o,w),f),l=n.mul(o,n.sub(e,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return T(t)}const Z=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function k(t){const i={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Z.reduce((n,s)=>(n[s]="function",n),i);return a.validateObject(t,r)}function M(t,i,r){if(r<d)throw new Error("invalid exponent, negatives unsupported");if(r===d)return t.ONE;if(r===c)return i;let n=t.ONE,s=i;for(;r>d;)r&c&&(n=t.mul(n,s)),s=t.sqr(s),r>>=c;return n}function _(t,i){const r=new Array(i.length),n=i.reduce((u,f,o)=>t.is0(f)?u:(r[o]=u,t.mul(u,f)),t.ONE),s=t.inv(n);return i.reduceRight((u,f,o)=>t.is0(f)?u:(r[o]=t.mul(u,r[o]),t.mul(u,f)),s),r}function p(t,i){const r=i!==void 0?i:t.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function z(t,i,r=!1,n={}){if(t<=d)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:u}=p(t,i);if(u>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const o=Object.freeze({ORDER:t,isLE:r,BITS:s,BYTES:u,MASK:a.bitMask(s),ZERO:d,ONE:c,create:e=>g(e,t),isValid:e=>{if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return d<=e&&e<t},is0:e=>e===d,isOdd:e=>(e&c)===c,neg:e=>g(-e,t),eql:(e,l)=>e===l,sqr:e=>g(e*e,t),add:(e,l)=>g(e+l,t),sub:(e,l)=>g(e-l,t),mul:(e,l)=>g(e*l,t),pow:(e,l)=>M(o,e,l),div:(e,l)=>g(e*m(l,t),t),sqrN:e=>e*e,addN:(e,l)=>e+l,subN:(e,l)=>e-l,mulN:(e,l)=>e*l,inv:e=>m(e,t),sqrt:n.sqrt||(e=>(f||(f=x(t)),f(o,e))),invertBatch:e=>_(o,e),cmov:(e,l,h)=>h?l:e,toBytes:e=>r?a.numberToBytesLE(e,u):a.numberToBytesBE(e,u),fromBytes:e=>{if(e.length!==u)throw new Error("Field.fromBytes: expected "+u+" bytes, got "+e.length);return r?a.bytesToNumberLE(e):a.bytesToNumberBE(e)}});return Object.freeze(o)}function N(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const i=t.toString(2).length;return Math.ceil(i/8)}function C(t){const i=N(t);return i+Math.ceil(i/2)}function A(t,i,r=!1){const n=t.length,s=N(i),u=C(i);if(n<16||n<u||n>1024)throw new Error("expected "+u+"-1024 bytes of input, got "+n);const f=r?a.bytesToNumberLE(t):a.bytesToNumberBE(t),o=g(f,i-c)+c;return r?a.numberToBytesLE(o,s):a.numberToBytesBE(o,s)}exports.Field=z;exports.FpInvertBatch=_;exports.FpPow=M;exports.FpSqrt=x;exports.getFieldBytesLength=N;exports.getMinHashLength=C;exports.invert=m;exports.mapHashToField=A;exports.mod=g;exports.nLength=p;exports.pow=L;exports.pow2=H;exports.tonelliShanks=T;exports.validateField=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index293.cjs"),s=require("./index284.cjs"),o=require("./index297.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function c(e){return{hash:e,hmac:(r,...t)=>a.hmac(e,r,s.concatBytes(...t)),randomBytes:s.randomBytes}}function u(e,r){const t=n=>o.weierstrass({...e,...c(n)});return{...t(r),create:t}}exports.createCurve=u;exports.getHash=c;
package/dist/index278.js CHANGED
@@ -1,226 +1,19 @@
1
- import { numberToBytesLE as S, numberToBytesBE as x, bitMask as _, bytesToNumberLE as y, bytesToNumberBE as L, validateObject as M } from "./index294.js";
1
+ import { hmac as c } from "./index293.js";
2
+ import { randomBytes as m, concatBytes as n } from "./index284.js";
3
+ import { weierstrass as a } from "./index297.js";
2
4
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3
- const d = BigInt(0), c = BigInt(1), w = /* @__PURE__ */ BigInt(2), C = /* @__PURE__ */ BigInt(3), b = /* @__PURE__ */ BigInt(4), N = /* @__PURE__ */ BigInt(5), m = /* @__PURE__ */ BigInt(8);
4
- function g(t, i) {
5
- const r = t % i;
6
- return r >= d ? r : i + r;
7
- }
8
- function Z(t, i, r) {
9
- if (i < d)
10
- throw new Error("invalid exponent, negatives unsupported");
11
- if (r <= d)
12
- throw new Error("invalid modulus");
13
- if (r === c)
14
- return d;
15
- let e = c;
16
- for (; i > d; )
17
- i & c && (e = e * t % r), t = t * t % r, i >>= c;
18
- return e;
19
- }
20
- function V(t, i, r) {
21
- let e = t;
22
- for (; i-- > d; )
23
- e *= e, e %= r;
24
- return e;
25
- }
26
- function I(t, i) {
27
- if (t === d)
28
- throw new Error("invert: expected non-zero number");
29
- if (i <= d)
30
- throw new Error("invert: expected positive modulus, got " + i);
31
- let r = g(t, i), e = i, s = d, u = c;
32
- for (; r !== d; ) {
33
- const o = e / r, n = e % r, l = s - u * o;
34
- e = r, r = n, s = u, u = l;
35
- }
36
- if (e !== c)
37
- throw new Error("invert: does not exist");
38
- return g(s, i);
39
- }
40
- function j(t) {
41
- const i = (t - c) / w;
42
- let r, e, s;
43
- for (r = t - c, e = 0; r % w === d; r /= w, e++)
44
- ;
45
- for (s = w; s < t && Z(s, i, t) !== t - c; s++)
46
- if (s > 1e3)
47
- throw new Error("Cannot find square root: likely non-prime P");
48
- if (e === 1) {
49
- const f = (t + c) / b;
50
- return function(n, l) {
51
- const h = n.pow(l, f);
52
- if (!n.eql(n.sqr(h), l))
53
- throw new Error("Cannot find square root");
54
- return h;
55
- };
56
- }
57
- const u = (r + c) / w;
58
- return function(o, n) {
59
- if (o.pow(n, i) === o.neg(o.ONE))
60
- throw new Error("Cannot find square root");
61
- let l = e, h = o.pow(o.mul(o.ONE, s), r), v = o.pow(n, u), a = o.pow(n, r);
62
- for (; !o.eql(a, o.ONE); ) {
63
- if (o.eql(a, o.ZERO))
64
- return o.ZERO;
65
- let q = 1;
66
- for (let B = o.sqr(a); q < l && !o.eql(B, o.ONE); q++)
67
- B = o.sqr(B);
68
- const E = o.pow(h, c << BigInt(l - q - 1));
69
- h = o.sqr(E), v = o.mul(v, E), a = o.mul(a, h), l = q;
70
- }
71
- return v;
5
+ function i(r) {
6
+ return {
7
+ hash: r,
8
+ hmac: (e, ...t) => c(r, e, n(...t)),
9
+ randomBytes: m
72
10
  };
73
11
  }
74
- function z(t) {
75
- if (t % b === C) {
76
- const i = (t + c) / b;
77
- return function(e, s) {
78
- const u = e.pow(s, i);
79
- if (!e.eql(e.sqr(u), s))
80
- throw new Error("Cannot find square root");
81
- return u;
82
- };
83
- }
84
- if (t % m === N) {
85
- const i = (t - N) / m;
86
- return function(e, s) {
87
- const u = e.mul(s, w), f = e.pow(u, i), o = e.mul(s, f), n = e.mul(e.mul(o, w), f), l = e.mul(o, e.sub(n, e.ONE));
88
- if (!e.eql(e.sqr(l), s))
89
- throw new Error("Cannot find square root");
90
- return l;
91
- };
92
- }
93
- return j(t);
94
- }
95
- const A = [
96
- "create",
97
- "isValid",
98
- "is0",
99
- "neg",
100
- "inv",
101
- "sqrt",
102
- "sqr",
103
- "eql",
104
- "add",
105
- "sub",
106
- "mul",
107
- "pow",
108
- "div",
109
- "addN",
110
- "subN",
111
- "mulN",
112
- "sqrN"
113
- ];
114
- function Y(t) {
115
- const i = {
116
- ORDER: "bigint",
117
- MASK: "bigint",
118
- BYTES: "isSafeInteger",
119
- BITS: "isSafeInteger"
120
- }, r = A.reduce((e, s) => (e[s] = "function", e), i);
121
- return M(t, r);
122
- }
123
- function k(t, i, r) {
124
- if (r < d)
125
- throw new Error("invalid exponent, negatives unsupported");
126
- if (r === d)
127
- return t.ONE;
128
- if (r === c)
129
- return i;
130
- let e = t.ONE, s = i;
131
- for (; r > d; )
132
- r & c && (e = t.mul(e, s)), s = t.sqr(s), r >>= c;
133
- return e;
134
- }
135
- function H(t, i) {
136
- const r = new Array(i.length), e = i.reduce((u, f, o) => t.is0(f) ? u : (r[o] = u, t.mul(u, f)), t.ONE), s = t.inv(e);
137
- return i.reduceRight((u, f, o) => t.is0(f) ? u : (r[o] = t.mul(u, r[o]), t.mul(u, f)), s), r;
138
- }
139
- function K(t, i) {
140
- const r = i !== void 0 ? i : t.toString(2).length, e = Math.ceil(r / 8);
141
- return { nBitLength: r, nByteLength: e };
142
- }
143
- function p(t, i, r = !1, e = {}) {
144
- if (t <= d)
145
- throw new Error("invalid field: expected ORDER > 0, got " + t);
146
- const { nBitLength: s, nByteLength: u } = K(t, i);
147
- if (u > 2048)
148
- throw new Error("invalid field: expected ORDER of <= 2048 bytes");
149
- let f;
150
- const o = Object.freeze({
151
- ORDER: t,
152
- isLE: r,
153
- BITS: s,
154
- BYTES: u,
155
- MASK: _(s),
156
- ZERO: d,
157
- ONE: c,
158
- create: (n) => g(n, t),
159
- isValid: (n) => {
160
- if (typeof n != "bigint")
161
- throw new Error("invalid field element: expected bigint, got " + typeof n);
162
- return d <= n && n < t;
163
- },
164
- is0: (n) => n === d,
165
- isOdd: (n) => (n & c) === c,
166
- neg: (n) => g(-n, t),
167
- eql: (n, l) => n === l,
168
- sqr: (n) => g(n * n, t),
169
- add: (n, l) => g(n + l, t),
170
- sub: (n, l) => g(n - l, t),
171
- mul: (n, l) => g(n * l, t),
172
- pow: (n, l) => k(o, n, l),
173
- div: (n, l) => g(n * I(l, t), t),
174
- // Same as above, but doesn't normalize
175
- sqrN: (n) => n * n,
176
- addN: (n, l) => n + l,
177
- subN: (n, l) => n - l,
178
- mulN: (n, l) => n * l,
179
- inv: (n) => I(n, t),
180
- sqrt: e.sqrt || ((n) => (f || (f = z(t)), f(o, n))),
181
- invertBatch: (n) => H(o, n),
182
- // TODO: do we really need constant cmov?
183
- // We don't have const-time bigints anyway, so probably will be not very useful
184
- cmov: (n, l, h) => h ? l : n,
185
- toBytes: (n) => r ? S(n, u) : x(n, u),
186
- fromBytes: (n) => {
187
- if (n.length !== u)
188
- throw new Error("Field.fromBytes: expected " + u + " bytes, got " + n.length);
189
- return r ? y(n) : L(n);
190
- }
191
- });
192
- return Object.freeze(o);
193
- }
194
- function T(t) {
195
- if (typeof t != "bigint")
196
- throw new Error("field order must be bigint");
197
- const i = t.toString(2).length;
198
- return Math.ceil(i / 8);
199
- }
200
- function O(t) {
201
- const i = T(t);
202
- return i + Math.ceil(i / 2);
203
- }
204
- function G(t, i, r = !1) {
205
- const e = t.length, s = T(i), u = O(i);
206
- if (e < 16 || e < u || e > 1024)
207
- throw new Error("expected " + u + "-1024 bytes of input, got " + e);
208
- const f = r ? y(t) : L(t), o = g(f, i - c) + c;
209
- return r ? S(o, s) : x(o, s);
12
+ function p(r, e) {
13
+ const t = (o) => a({ ...r, ...i(o) });
14
+ return { ...t(e), create: t };
210
15
  }
211
16
  export {
212
- p as Field,
213
- H as FpInvertBatch,
214
- k as FpPow,
215
- z as FpSqrt,
216
- T as getFieldBytesLength,
217
- O as getMinHashLength,
218
- I as invert,
219
- G as mapHashToField,
220
- g as mod,
221
- K as nLength,
222
- Z as pow,
223
- V as pow2,
224
- j as tonelliShanks,
225
- Y as validateField
17
+ p as createCurve,
18
+ i as getHash
226
19
  };
package/dist/index279.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index149.cjs"),r=require("./index151.cjs"),c=e=>r.keccak256(t.toBytes(e));function n(e){return c(e)}exports.hashSignature=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./index284.cjs"),a=require("./index298.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const d=BigInt(0),f=BigInt(1),h=BigInt(2),K=BigInt(3),I=BigInt(4),L=BigInt(5),T=BigInt(8);function g(t,n){const o=t%n;return o>=d?o:n+o}function Q(t,n,o){let r=t;for(;n-- >d;)r*=r,r%=o;return r}function B(t,n){if(t===d)throw new Error("invert: expected non-zero number");if(n<=d)throw new Error("invert: expected positive modulus, got "+n);let o=g(t,n),r=n,s=d,l=f;for(;o!==d;){const c=r/o,e=r%o,i=s-l*c;r=o,o=e,s=l,l=i}if(r!==f)throw new Error("invert: does not exist");return g(s,n)}function x(t,n){const o=(t.ORDER+f)/I,r=t.pow(n,o);if(!t.eql(t.sqr(r),n))throw new Error("Cannot find square root");return r}function V(t,n){const o=(t.ORDER-L)/T,r=t.mul(n,h),s=t.pow(r,o),l=t.mul(n,s),u=t.mul(t.mul(l,h),s),c=t.mul(l,t.sub(u,t.ONE));if(!t.eql(t.sqr(c),n))throw new Error("Cannot find square root");return c}function _(t){if(t<BigInt(3))throw new Error("sqrt is not defined for small field");let n=t-f,o=0;for(;n%h===d;)n/=h,o++;let r=h;const s=Z(t);for(;y(s,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(o===1)return x;let l=s.pow(r,n);const u=(n+f)/h;return function(e,i){if(e.is0(i))return i;if(y(e,i)!==1)throw new Error("Cannot find square root");let w=o,v=e.mul(e.ONE,l),b=e.pow(i,n),E=e.pow(i,u);for(;!e.eql(b,e.ONE);){if(e.is0(b))return e.ZERO;let q=1,m=e.sqr(b);for(;!e.eql(m,e.ONE);)if(q++,m=e.sqr(m),q===w)throw new Error("Cannot find square root");const z=f<<BigInt(w-q-1),S=e.pow(v,z);w=q,v=e.sqr(S),b=e.mul(b,v),E=e.mul(E,S)}return E}}function M(t){return t%I===K?x:t%T===L?V:_(t)}const Y=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function k(t){const n={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},o=Y.reduce((r,s)=>(r[s]="function",r),n);return a.validateObject(t,o)}function O(t,n,o){if(o<d)throw new Error("invalid exponent, negatives unsupported");if(o===d)return t.ONE;if(o===f)return n;let r=t.ONE,s=n;for(;o>d;)o&f&&(r=t.mul(r,s)),s=t.sqr(s),o>>=f;return r}function A(t,n,o=!1){const r=new Array(n.length).fill(o?t.ZERO:void 0),s=n.reduce((u,c,e)=>t.is0(c)?u:(r[e]=u,t.mul(u,c)),t.ONE),l=t.inv(s);return n.reduceRight((u,c,e)=>t.is0(c)?u:(r[e]=t.mul(u,r[e]),t.mul(u,c)),l),r}function y(t,n){const o=(t.ORDER-f)/h,r=t.pow(n,o),s=t.eql(r,t.ONE),l=t.eql(r,t.ZERO),u=t.eql(r,t.neg(t.ONE));if(!s&&!l&&!u)throw new Error("invalid Legendre symbol result");return s?1:l?0:-1}function C(t,n){n!==void 0&&H.anumber(n);const o=n!==void 0?n:t.toString(2).length,r=Math.ceil(o/8);return{nBitLength:o,nByteLength:r}}function Z(t,n,o=!1,r={}){if(t<=d)throw new Error("invalid field: expected ORDER > 0, got "+t);const{nBitLength:s,nByteLength:l}=C(t,n);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const c=Object.freeze({ORDER:t,isLE:o,BITS:s,BYTES:l,MASK:a.bitMask(s),ZERO:d,ONE:f,create:e=>g(e,t),isValid:e=>{if(typeof e!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof e);return d<=e&&e<t},is0:e=>e===d,isOdd:e=>(e&f)===f,neg:e=>g(-e,t),eql:(e,i)=>e===i,sqr:e=>g(e*e,t),add:(e,i)=>g(e+i,t),sub:(e,i)=>g(e-i,t),mul:(e,i)=>g(e*i,t),pow:(e,i)=>O(c,e,i),div:(e,i)=>g(e*B(i,t),t),sqrN:e=>e*e,addN:(e,i)=>e+i,subN:(e,i)=>e-i,mulN:(e,i)=>e*i,inv:e=>B(e,t),sqrt:r.sqrt||(e=>(u||(u=M(t)),u(c,e))),toBytes:e=>o?a.numberToBytesLE(e,l):a.numberToBytesBE(e,l),fromBytes:e=>{if(e.length!==l)throw new Error("Field.fromBytes: expected "+l+" bytes, got "+e.length);return o?a.bytesToNumberLE(e):a.bytesToNumberBE(e)},invertBatch:e=>A(c,e),cmov:(e,i,w)=>w?i:e});return Object.freeze(c)}function N(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const n=t.toString(2).length;return Math.ceil(n/8)}function j(t){const n=N(t);return n+Math.ceil(n/2)}function P(t,n,o=!1){const r=t.length,s=N(n),l=j(n);if(r<16||r<l||r>1024)throw new Error("expected "+l+"-1024 bytes of input, got "+r);const u=o?a.bytesToNumberLE(t):a.bytesToNumberBE(t),c=g(u,n-f)+f;return o?a.numberToBytesLE(c,s):a.numberToBytesBE(c,s)}exports.Field=Z;exports.FpInvertBatch=A;exports.FpLegendre=y;exports.FpPow=O;exports.FpSqrt=M;exports.getFieldBytesLength=N;exports.getMinHashLength=j;exports.invert=B;exports.mapHashToField=P;exports.mod=g;exports.nLength=C;exports.pow2=Q;exports.tonelliShanks=_;exports.validateField=k;
package/dist/index279.js CHANGED
@@ -1,9 +1,217 @@
1
- import { toBytes as o } from "./index149.js";
2
- import { keccak256 as r } from "./index151.js";
3
- const e = (t) => r(o(t));
4
- function c(t) {
5
- return e(t);
1
+ import { anumber as C } from "./index284.js";
2
+ import { numberToBytesLE as I, numberToBytesBE as y, bitMask as Z, bytesToNumberLE as S, bytesToNumberBE as x, validateObject as z } from "./index298.js";
3
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
+ const d = BigInt(0), f = BigInt(1), g = /* @__PURE__ */ BigInt(2), j = /* @__PURE__ */ BigInt(3), L = /* @__PURE__ */ BigInt(4), _ = /* @__PURE__ */ BigInt(5), T = /* @__PURE__ */ BigInt(8);
5
+ function w(t, n) {
6
+ const o = t % n;
7
+ return o >= d ? o : n + o;
8
+ }
9
+ function $(t, n, o) {
10
+ let r = t;
11
+ for (; n-- > d; )
12
+ r *= r, r %= o;
13
+ return r;
14
+ }
15
+ function B(t, n) {
16
+ if (t === d)
17
+ throw new Error("invert: expected non-zero number");
18
+ if (n <= d)
19
+ throw new Error("invert: expected positive modulus, got " + n);
20
+ let o = w(t, n), r = n, s = d, l = f;
21
+ for (; o !== d; ) {
22
+ const c = r / o, e = r % o, i = s - l * c;
23
+ r = o, o = e, s = l, l = i;
24
+ }
25
+ if (r !== f)
26
+ throw new Error("invert: does not exist");
27
+ return w(s, n);
28
+ }
29
+ function M(t, n) {
30
+ const o = (t.ORDER + f) / L, 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, r = t.mul(n, g), s = t.pow(r, o), l = t.mul(n, s), u = t.mul(t.mul(l, g), s), c = t.mul(l, t.sub(u, t.ONE));
37
+ if (!t.eql(t.sqr(c), n))
38
+ throw new Error("Cannot find square root");
39
+ return c;
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 - f, o = 0;
45
+ for (; n % g === d; )
46
+ n /= g, o++;
47
+ let r = g;
48
+ const s = J(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 l = s.pow(r, n);
55
+ const u = (n + f) / g;
56
+ return function(e, i) {
57
+ if (e.is0(i))
58
+ return i;
59
+ if (N(e, i) !== 1)
60
+ throw new Error("Cannot find square root");
61
+ let h = o, b = e.mul(e.ONE, l), a = e.pow(i, n), m = e.pow(i, u);
62
+ for (; !e.eql(a, e.ONE); ) {
63
+ if (e.is0(a))
64
+ return e.ZERO;
65
+ let q = 1, v = e.sqr(a);
66
+ for (; !e.eql(v, e.ONE); )
67
+ if (q++, v = e.sqr(v), q === h)
68
+ throw new Error("Cannot find square root");
69
+ const A = f << BigInt(h - q - 1), E = e.pow(b, A);
70
+ h = q, b = e.sqr(E), a = e.mul(a, b), m = e.mul(m, E);
71
+ }
72
+ return m;
73
+ };
74
+ }
75
+ function Q(t) {
76
+ return t % L === j ? M : t % T === _ ? H : K(t);
77
+ }
78
+ const V = [
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: "isSafeInteger",
102
+ BITS: "isSafeInteger"
103
+ }, o = V.reduce((r, s) => (r[s] = "function", r), n);
104
+ return z(t, o);
105
+ }
106
+ function Y(t, n, o) {
107
+ if (o < d)
108
+ throw new Error("invalid exponent, negatives unsupported");
109
+ if (o === d)
110
+ return t.ONE;
111
+ if (o === f)
112
+ return n;
113
+ let r = t.ONE, s = n;
114
+ for (; o > d; )
115
+ o & f && (r = t.mul(r, s)), s = t.sqr(s), o >>= f;
116
+ return r;
117
+ }
118
+ function k(t, n, o = !1) {
119
+ const r = new Array(n.length).fill(o ? t.ZERO : void 0), s = n.reduce((u, c, e) => t.is0(c) ? u : (r[e] = u, t.mul(u, c)), t.ONE), l = t.inv(s);
120
+ return n.reduceRight((u, c, e) => t.is0(c) ? u : (r[e] = t.mul(u, r[e]), t.mul(u, c)), l), r;
121
+ }
122
+ function N(t, n) {
123
+ const o = (t.ORDER - f) / g, r = t.pow(n, o), s = t.eql(r, t.ONE), l = t.eql(r, t.ZERO), u = t.eql(r, t.neg(t.ONE));
124
+ if (!s && !l && !u)
125
+ throw new Error("invalid Legendre symbol result");
126
+ return s ? 1 : l ? 0 : -1;
127
+ }
128
+ function G(t, n) {
129
+ n !== void 0 && C(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 J(t, n, o = !1, r = {}) {
134
+ if (t <= d)
135
+ throw new Error("invalid field: expected ORDER > 0, got " + t);
136
+ const { nBitLength: s, nByteLength: l } = G(t, n);
137
+ if (l > 2048)
138
+ throw new Error("invalid field: expected ORDER of <= 2048 bytes");
139
+ let u;
140
+ const c = Object.freeze({
141
+ ORDER: t,
142
+ isLE: o,
143
+ BITS: s,
144
+ BYTES: l,
145
+ MASK: Z(s),
146
+ ZERO: d,
147
+ ONE: f,
148
+ create: (e) => w(e, t),
149
+ isValid: (e) => {
150
+ if (typeof e != "bigint")
151
+ throw new Error("invalid field element: expected bigint, got " + typeof e);
152
+ return d <= e && e < t;
153
+ },
154
+ is0: (e) => e === d,
155
+ isOdd: (e) => (e & f) === f,
156
+ neg: (e) => w(-e, t),
157
+ eql: (e, i) => e === i,
158
+ sqr: (e) => w(e * e, t),
159
+ add: (e, i) => w(e + i, t),
160
+ sub: (e, i) => w(e - i, t),
161
+ mul: (e, i) => w(e * i, t),
162
+ pow: (e, i) => Y(c, e, i),
163
+ div: (e, i) => w(e * B(i, t), t),
164
+ // Same as above, but doesn't normalize
165
+ sqrN: (e) => e * e,
166
+ addN: (e, i) => e + i,
167
+ subN: (e, i) => e - i,
168
+ mulN: (e, i) => e * i,
169
+ inv: (e) => B(e, t),
170
+ sqrt: r.sqrt || ((e) => (u || (u = Q(t)), u(c, e))),
171
+ toBytes: (e) => o ? I(e, l) : y(e, l),
172
+ fromBytes: (e) => {
173
+ if (e.length !== l)
174
+ throw new Error("Field.fromBytes: expected " + l + " bytes, got " + e.length);
175
+ return o ? S(e) : x(e);
176
+ },
177
+ // TODO: we don't need it here, move out to separate fn
178
+ invertBatch: (e) => k(c, e),
179
+ // We can't move this out because Fp6, Fp12 implement it
180
+ // and it's unclear what to return in there.
181
+ cmov: (e, i, h) => h ? i : e
182
+ });
183
+ return Object.freeze(c);
184
+ }
185
+ function O(t) {
186
+ if (typeof t != "bigint")
187
+ throw new Error("field order must be bigint");
188
+ const n = t.toString(2).length;
189
+ return Math.ceil(n / 8);
190
+ }
191
+ function U(t) {
192
+ const n = O(t);
193
+ return n + Math.ceil(n / 2);
194
+ }
195
+ function D(t, n, o = !1) {
196
+ const r = t.length, s = O(n), l = U(n);
197
+ if (r < 16 || r < l || r > 1024)
198
+ throw new Error("expected " + l + "-1024 bytes of input, got " + r);
199
+ const u = o ? S(t) : x(t), c = w(u, n - f) + f;
200
+ return o ? I(c, s) : y(c, s);
6
201
  }
7
202
  export {
8
- c as hashSignature
203
+ J as Field,
204
+ k as FpInvertBatch,
205
+ N as FpLegendre,
206
+ Y as FpPow,
207
+ Q as FpSqrt,
208
+ O as getFieldBytesLength,
209
+ U as getMinHashLength,
210
+ B as invert,
211
+ D as mapHashToField,
212
+ w as mod,
213
+ G as nLength,
214
+ $ as pow2,
215
+ K as tonelliShanks,
216
+ P as validateField
9
217
  };
package/dist/index28.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index296.cjs"),M=require("./index159.cjs"),h=require("./index297.cjs");function R(r){const{chainId:o,domain:s,expirationTime:l,issuedAt:m=new Date,nonce:a,notBefore:f,requestId:w,resources:g,scheme:i,uri:c,version:d}=r;{if(o!==Math.floor(o))throw new e.SiweInvalidMessageFieldError({field:"chainId",metaMessages:["- Chain ID must be a EIP-155 chain ID.","- See https://eips.ethereum.org/EIPS/eip-155","",`Provided value: ${o}`]});if(!(E.test(s)||F.test(s)||b.test(s)))throw new e.SiweInvalidMessageFieldError({field:"domain",metaMessages:["- Domain must be an RFC 3986 authority.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${s}`]});if(!A.test(a))throw new e.SiweInvalidMessageFieldError({field:"nonce",metaMessages:["- Nonce must be at least 8 characters.","- Nonce must be alphanumeric.","",`Provided value: ${a}`]});if(!h.isUri(c))throw new e.SiweInvalidMessageFieldError({field:"uri",metaMessages:["- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${c}`]});if(d!=="1")throw new e.SiweInvalidMessageFieldError({field:"version",metaMessages:["- Version must be '1'.","",`Provided value: ${d}`]});if(i&&!P.test(i))throw new e.SiweInvalidMessageFieldError({field:"scheme",metaMessages:["- Scheme must be an RFC 3986 URI scheme.","- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1","",`Provided value: ${i}`]});const t=r.statement;if(t!=null&&t.includes(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index291.cjs"),M=require("./index159.cjs"),h=require("./index292.cjs");function R(r){const{chainId:o,domain:s,expirationTime:l,issuedAt:m=new Date,nonce:a,notBefore:f,requestId:w,resources:g,scheme:i,uri:c,version:d}=r;{if(o!==Math.floor(o))throw new e.SiweInvalidMessageFieldError({field:"chainId",metaMessages:["- Chain ID must be a EIP-155 chain ID.","- See https://eips.ethereum.org/EIPS/eip-155","",`Provided value: ${o}`]});if(!(E.test(s)||F.test(s)||b.test(s)))throw new e.SiweInvalidMessageFieldError({field:"domain",metaMessages:["- Domain must be an RFC 3986 authority.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${s}`]});if(!A.test(a))throw new e.SiweInvalidMessageFieldError({field:"nonce",metaMessages:["- Nonce must be at least 8 characters.","- Nonce must be alphanumeric.","",`Provided value: ${a}`]});if(!h.isUri(c))throw new e.SiweInvalidMessageFieldError({field:"uri",metaMessages:["- URI must be a RFC 3986 URI referring to the resource that is the subject of the signing.","- See https://www.rfc-editor.org/rfc/rfc3986","",`Provided value: ${c}`]});if(d!=="1")throw new e.SiweInvalidMessageFieldError({field:"version",metaMessages:["- Version must be '1'.","",`Provided value: ${d}`]});if(i&&!P.test(i))throw new e.SiweInvalidMessageFieldError({field:"scheme",metaMessages:["- Scheme must be an RFC 3986 URI scheme.","- See https://www.rfc-editor.org/rfc/rfc3986#section-3.1","",`Provided value: ${i}`]});const t=r.statement;if(t!=null&&t.includes(`
2
2
  `))throw new e.SiweInvalidMessageFieldError({field:"statement",metaMessages:["- Statement must not include '\\n'.","",`Provided value: ${t}`]})}const $=M.getAddress(r.address),v=i?`${i}://${s}`:s,I=r.statement?`${r.statement}
3
3
  `:"",S=`${v} wants you to sign in with your Ethereum account:
4
4
  ${$}
package/dist/index28.js CHANGED
@@ -1,6 +1,6 @@
1
- import { SiweInvalidMessageFieldError as e } from "./index296.js";
1
+ import { SiweInvalidMessageFieldError as e } from "./index291.js";
2
2
  import { getAddress as S } from "./index159.js";
3
- import { isUri as $ } from "./index297.js";
3
+ import { isUri as $ } from "./index292.js";
4
4
  function C(n) {
5
5
  const { chainId: i, domain: s, expirationTime: u, issuedAt: g = /* @__PURE__ */ new Date(), nonce: a, notBefore: m, requestId: h, resources: w, scheme: o, uri: c, version: f } = n;
6
6
  {
package/dist/index280.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index281.cjs"),n=require("./index260.cjs"),i=t=>{const r=typeof t=="string"?t:n.formatAbiItem(t);return e.normalizeSignature(r)};exports.toSignature=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index149.cjs"),r=require("./index151.cjs"),c=e=>r.keccak256(t.toBytes(e));function n(e){return c(e)}exports.hashSignature=n;
package/dist/index280.js CHANGED
@@ -1,9 +1,9 @@
1
- import { normalizeSignature as o } from "./index281.js";
2
- import { formatAbiItem as n } from "./index260.js";
3
- const m = (r) => {
4
- const t = typeof r == "string" ? r : n(r);
5
- return o(t);
6
- };
1
+ import { toBytes as o } from "./index149.js";
2
+ import { keccak256 as r } from "./index151.js";
3
+ const e = (t) => r(o(t));
4
+ function c(t) {
5
+ return e(t);
6
+ }
7
7
  export {
8
- m as toSignature
8
+ c as hashSignature
9
9
  };
package/dist/index281.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index38.cjs");function a(r){let l=!0,i="",o=0,t="",u=!1;for(let n=0;n<r.length;n++){const e=r[n];if(["(",")",","].includes(e)&&(l=!0),e==="("&&o++,e===")"&&o--,!!l){if(o===0){if(e===" "&&["event","function",""].includes(t))t="";else if(t+=e,e===")"){u=!0;break}continue}if(e===" "){r[n-1]!==","&&i!==","&&i!==",("&&(i="",l=!1);continue}t+=e,i+=e}}if(!u)throw new f.BaseError("Unable to normalize signature.");return t}exports.normalizeSignature=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index282.cjs"),n=require("./index260.cjs"),i=t=>{const r=typeof t=="string"?t:n.formatAbiItem(t);return e.normalizeSignature(r)};exports.toSignature=i;