@protontech/openpgp 6.0.0-beta.0.patch.0 → 6.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/lightweight/argon2id.min.mjs +2 -2
  2. package/dist/lightweight/argon2id.min.mjs.map +1 -1
  3. package/dist/lightweight/argon2id.mjs +5 -28
  4. package/dist/lightweight/legacy_ciphers.min.mjs +2 -2
  5. package/dist/lightweight/legacy_ciphers.min.mjs.map +1 -1
  6. package/dist/lightweight/legacy_ciphers.mjs +6 -51
  7. package/dist/lightweight/noble_curves.min.mjs +11 -11
  8. package/dist/lightweight/noble_curves.min.mjs.map +1 -1
  9. package/dist/lightweight/noble_curves.mjs +477 -465
  10. package/dist/lightweight/noble_hashes.min.mjs +2 -2
  11. package/dist/lightweight/noble_hashes.min.mjs.map +1 -1
  12. package/dist/lightweight/noble_hashes.mjs +19 -31
  13. package/dist/lightweight/openpgp.min.mjs +2 -2
  14. package/dist/lightweight/openpgp.min.mjs.map +1 -1
  15. package/dist/lightweight/openpgp.mjs +591 -457
  16. package/dist/lightweight/sha3.min.mjs +3 -3
  17. package/dist/lightweight/sha3.min.mjs.map +1 -1
  18. package/dist/lightweight/sha3.mjs +80 -80
  19. package/dist/node/openpgp.cjs +1245 -5442
  20. package/dist/node/openpgp.min.cjs +11 -12
  21. package/dist/node/openpgp.min.cjs.map +1 -1
  22. package/dist/node/openpgp.min.mjs +11 -12
  23. package/dist/node/openpgp.min.mjs.map +1 -1
  24. package/dist/node/openpgp.mjs +1245 -5442
  25. package/dist/openpgp.js +1238 -5435
  26. package/dist/openpgp.min.js +11 -12
  27. package/dist/openpgp.min.js.map +1 -1
  28. package/dist/openpgp.min.mjs +11 -12
  29. package/dist/openpgp.min.mjs.map +1 -1
  30. package/dist/openpgp.mjs +1238 -5435
  31. package/openpgp.d.ts +61 -60
  32. package/package.json +16 -10
  33. package/dist/lightweight/bn.interface.min.mjs +0 -3
  34. package/dist/lightweight/bn.interface.min.mjs.map +0 -1
  35. package/dist/lightweight/bn.interface.mjs +0 -3807
  36. package/dist/lightweight/interface.min.mjs +0 -3
  37. package/dist/lightweight/interface.min.mjs.map +0 -1
  38. package/dist/lightweight/interface.mjs +0 -16
  39. package/dist/lightweight/native.interface.min.mjs +0 -3
  40. package/dist/lightweight/native.interface.min.mjs.map +0 -1
  41. package/dist/lightweight/native.interface.mjs +0 -456
@@ -1,4 +1,4 @@
1
- /*! OpenPGP.js v6.0.0-beta.0.patch.0 - 2024-04-19 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
1
+ /*! OpenPGP.js v6.0.0-beta.1 - 2024-05-17 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
2
  const globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
3
3
 
4
4
  import { enums } from './openpgp.mjs';
@@ -104,10 +104,6 @@ function des(keys, message, encrypt, mode, iv, padding) {
104
104
  let left;
105
105
  let right;
106
106
  let looping;
107
- let cbcleft;
108
- let cbcleft2;
109
- let cbcright;
110
- let cbcright2;
111
107
  let endloop;
112
108
  let loopinc;
113
109
  let len = message.length;
@@ -123,7 +119,7 @@ function des(keys, message, encrypt, mode, iv, padding) {
123
119
  //pad the message depending on the padding parameter
124
120
  //only add padding if encrypting - note that you need to use the same padding option for both encrypt and decrypt
125
121
  if (encrypt) {
126
- message = desAddPadding(message, padding);
122
+ message = desAddPadding(message);
127
123
  len = message.length;
128
124
  }
129
125
 
@@ -131,30 +127,11 @@ function des(keys, message, encrypt, mode, iv, padding) {
131
127
  let result = new Uint8Array(len);
132
128
  let k = 0;
133
129
 
134
- if (mode === 1) { //CBC mode
135
- cbcleft = (iv[m++] << 24) | (iv[m++] << 16) | (iv[m++] << 8) | iv[m++];
136
- cbcright = (iv[m++] << 24) | (iv[m++] << 16) | (iv[m++] << 8) | iv[m++];
137
- m = 0;
138
- }
139
-
140
130
  //loop through each 64 bit chunk of the message
141
131
  while (m < len) {
142
132
  left = (message[m++] << 24) | (message[m++] << 16) | (message[m++] << 8) | message[m++];
143
133
  right = (message[m++] << 24) | (message[m++] << 16) | (message[m++] << 8) | message[m++];
144
134
 
145
- //for Cipher Block Chaining mode, xor the message with the previous result
146
- if (mode === 1) {
147
- if (encrypt) {
148
- left ^= cbcleft;
149
- right ^= cbcright;
150
- } else {
151
- cbcleft2 = cbcleft;
152
- cbcright2 = cbcright;
153
- cbcleft = left;
154
- cbcright = right;
155
- }
156
- }
157
-
158
135
  //first each 64 but chunk of the message must be permuted according to IP
159
136
  temp = ((left >>> 4) ^ right) & 0x0f0f0f0f;
160
137
  right ^= temp;
@@ -216,17 +193,6 @@ function des(keys, message, encrypt, mode, iv, padding) {
216
193
  right ^= temp;
217
194
  left ^= (temp << 4);
218
195
 
219
- //for Cipher Block Chaining mode, xor the message with the previous result
220
- if (mode === 1) {
221
- if (encrypt) {
222
- cbcleft = left;
223
- cbcright = right;
224
- } else {
225
- left ^= cbcleft2;
226
- right ^= cbcright2;
227
- }
228
- }
229
-
230
196
  result[k++] = (left >>> 24);
231
197
  result[k++] = ((left >>> 16) & 0xff);
232
198
  result[k++] = ((left >>> 8) & 0xff);
@@ -239,7 +205,7 @@ function des(keys, message, encrypt, mode, iv, padding) {
239
205
 
240
206
  //only remove padding if decrypting - note that you need to use the same padding option for both encrypt and decrypt
241
207
  if (!encrypt) {
242
- result = desRemovePadding(result, padding);
208
+ result = desRemovePadding(result);
243
209
  }
244
210
 
245
211
  return result;
@@ -388,11 +354,7 @@ function desAddPadding(message, padding) {
388
354
  const padLength = 8 - (message.length % 8);
389
355
 
390
356
  let pad;
391
- if (padding === 2 && (padLength < 8)) { //pad the message with spaces
392
- pad = ' '.charCodeAt(0);
393
- } else if (padding === 1) { //PKCS7 padding
394
- pad = padLength;
395
- } else if (!padding && (padLength < 8)) { //pad the message out with null bytes
357
+ if ((padLength < 8)) { //pad the message out with null bytes
396
358
  pad = 0;
397
359
  } else if (padLength === 8) {
398
360
  return message;
@@ -414,14 +376,8 @@ function desAddPadding(message, padding) {
414
376
  function desRemovePadding(message, padding) {
415
377
  let padLength = null;
416
378
  let pad;
417
- if (padding === 2) { // space padded
418
- pad = ' '.charCodeAt(0);
419
- } else if (padding === 1) { // PKCS7
420
- padLength = message[message.length - 1];
421
- } else if (!padding) { // null padding
379
+ { // null padding
422
380
  pad = 0;
423
- } else {
424
- throw new Error('des: invalid padding');
425
381
  }
426
382
 
427
383
  if (!padLength) {
@@ -454,8 +410,7 @@ function TripleDES(key) {
454
410
  block, true, 0, null, null
455
411
  ),
456
412
  false, 0, null, null
457
- ), true, 0, null, null
458
- );
413
+ ), true);
459
414
  };
460
415
  }
461
416
 
@@ -1,14 +1,14 @@
1
- /*! OpenPGP.js v6.0.0-beta.0.patch.0 - 2024-04-19 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
- "undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;import{H as e,h as t,t as n,e as r,b as f,c as i,r as o,s,a,d as c,w as u,u as d,f as l}from"./sha3.min.mjs";import{B as h}from"./interface.min.mjs";import"./native.interface.min.mjs";import"./bn.interface.min.mjs";class b extends e{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,t(e);const f=n(r);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(f.length>i?e.create().update(f).digest():f);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),o.fill(0)}update(e){return r(this),this.iHash.update(e),this}digestInto(e){r(this),f(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:f,blockLen:i,outputLen:o}=this;return e.finished=r,e.destroyed=f,e.blockLen=i,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const m=(e,t,n)=>new b(e,t).update(n).digest();m.create=(e,t)=>new b(e,t)
3
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const w=Object.freeze(h.new(2));function y(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}const p=/* @__PURE__ */Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function g(e){if(!y(e))throw Error("Uint8Array expected");let t="";for(let n=0;n<e.length;n++)t+=p[e[n]];return t}function E(e){const t=e instanceof h?g(e.toUint8Array()):e.toString(16);return 1&t.length?"0"+t:t}const x={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function B(e){return e>=x._0&&e<=x._9?e-x._0:e>=x._A&&e<=x._F?e-(x._A-10):e>=x._a&&e<=x._f?e-(x._a-10):void 0}function S(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,f=0;t<n;t++,f+=2){const n=B(e.charCodeAt(f)),i=B(e.charCodeAt(f+1));if(void 0===n||void 0===i){const t=e[f]+e[f+1];throw Error('hex string expected, got non-hex character "'+t+'" at index '+f)}r[t]=16*n+i}return r}function v(e){return h.new(e)}function O(e){if(!y(e))throw Error("Uint8Array expected");return h.new(e.slice().reverse())}function A(e,t){return e.toUint8Array("be",t)}function z(e,t){return e.toUint8Array("le",t)}function q(e,t,n){let r;if("string"==typeof t)try{r=S(t)}catch(n){throw Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!y(t))throw Error(e+" must be hex string or Uint8Array");r=new Uint8Array(t)}const f=r.length;if("number"==typeof n&&f!==n)throw Error(`${e} expected ${n} bytes, got ${f}`);return r}function R(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];if(!y(r))throw Error("Uint8Array expected");t+=r.length}let n=new Uint8Array(t),r=0;for(let t=0;t<e.length;t++){const f=e[t];n.set(f,r),r+=f.length}return n}const j=e=>w.leftShift(h.new(e-1)).idec(),N=e=>new Uint8Array(e),P=e=>Uint8Array.from(e);function I(e,t,n){if("number"!=typeof e||e<2)throw Error("hashLen must be a number");if("number"!=typeof t||t<2)throw Error("qByteLen must be a number");if("function"!=typeof n)throw Error("hmacFn must be a function");let r=N(e),f=N(e),i=0;const o=()=>{r.fill(1),f.fill(0),i=0},s=(...e)=>n(f,r,...e),a=(e=N())=>{f=s(P([0]),e),r=s(),0!==e.length&&(f=s(P([1]),e),r=s())},c=()=>{if(i++>=1e3)throw Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=s();const t=r.slice();n.push(t),e+=r.length}return R(...n)};return(e,t)=>{let n;for(o(),a(e);!(n=t(c()));)a();return o(),n}}const L={BigInteger:e=>e instanceof h,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||y(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function Z(e,t,n={}){const r=(t,n,r)=>{const f=L[n];if("function"!=typeof f)throw Error(`Invalid validator "${n}", expected function`);const i=e[t];if(!(r&&void 0===i||f(i,e)))throw Error(`Invalid param ${t+""}=${i} (${typeof i}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}var H=/*#__PURE__*/Object.freeze({__proto__:null,bitGet:(e,t)=>e.getBit(t),bitLen:function(e){return e.bitLength()},bitMask:j,bitSet:(e,t,n)=>{throw Error("unsupported bitSet")},bytesToHex:g,bytesToNumberBE:v,bytesToNumberLE:O,concatBytes:R,createHmacDrbg:I,ensureBytes:q,equalBytes:function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n},hexToBytes:S,hexToNumber:function(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);return h.new(""===e?"0":"0x"+e)},isBytes:y,numberToBytesBE:A,numberToBytesLE:z,numberToHexUnpadded:E,numberToVarBytesBE:function(e){return S(E(e))},utf8ToBytes:function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},validateObject:Z});
4
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const T=Object.freeze(h.new(0)),U=Object.freeze(h.new(1)),F=Object.freeze(h.new(2)),_=Object.freeze(h.new(3)),G=Object.freeze(h.new(4)),k=Object.freeze(h.new(5)),C=Object.freeze(h.new(8)),$=Object.freeze(h.new(9)),V=Object.freeze(h.new(16));function K(e,t){return e.mod(t)}function D(e,t,n){return e.modExp(t,n)}function Y(e,t,n){return e.modExp(F.leftShift(t.dec()),n)}function W(e,t){return e.modInv(t)}function M(e){if(e.mod(G).equal(_)){const t=e.add(U).irightShift(F);return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error("Cannot find square root");return r}}if(e.mod(C).equal(k)){const t=e.sub(k).irightShift(_);return function(e,n){const r=e.mul(n,F),f=e.pow(r,t),i=e.mul(n,f),o=e.mul(e.mul(i,F),f),s=e.mul(i,e.sub(o,e.ONE));if(!e.eql(e.sqr(s),n))throw Error("Cannot find square root");return s}}return e.mod(V).equal($),function(e){const t=e.dec().rightShift(U);let n=e.dec(),r=h.new(0);for(;n.isEven();)n.irightShift(U),r.iinc();let f=h.new(2);const i=e.dec();for(;f.lt(e)&&!D(f,t,e).equal(i);)f.iinc();if(r.isOne()){const t=e.inc().irightShift(F);return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw Error("Cannot find square root");return r}}const o=n.inc().irightShift(U);return function(e,i){if(e.eql(e.pow(i,t),e.neg(e.ONE)))throw Error("Cannot find square root");let s=r,a=e.pow(e.mul(e.ONE,f),n),c=e.pow(i,o),u=e.pow(i,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=h.new(1);for(let n=e.sqr(u);t.lt(s)&&!e.eql(n,e.ONE);t.iinc())n=e.sqr(n);const n=e.pow(a,U.leftShift(s.sub(t).idec()));a=e.sqr(n),c=e.mul(c,n),u=e.mul(u,a),s=t}return c}}(e)}const J=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Q(e,t){const n=void 0!==t?t:e.bitLength();return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function X(e,t,n=!1,r={}){if(e.lte(T))throw Error("Expected Field ORDER > 0, got "+e);const{nBitLength:f,nByteLength:i}=Q(e,t);if(i>2048)throw Error("Field lengths over 2048 bytes are not supported");const o=M(e),s=Object.freeze({ORDER:e,BITS:f,BYTES:i,MASK:j(f),ZERO:T,ONE:U,create:t=>K(t,e),isValid:t=>{if(!(t instanceof h))throw Error("Invalid field element: expected bigint, got "+typeof t);return T.lte(t)&&t.lt(e)},is0:e=>e.isZero(),isOdd:e=>!e.isEven(),neg:t=>K(t.negate(),e),eql:(e,t)=>e.equal(t),sqr:t=>K(t.mul(t),e),add:(t,n)=>K(t.add(n),e),sub:(t,n)=>K(t.sub(n),e),mul:(t,n)=>K(t.mul(n),e),pow:(e,t)=>function(e,t,n){if(n.isNegative())throw Error("Expected power > 0");if(n.isZero())return e.ONE;if(n.isOne())return t;let r=e.ONE,f=t;for(;n.gt(T);)n.isEven()||(r=e.mul(r,f)),f=e.sqr(f),n=n.rightShift(U);return r}(s,e,t),div:(t,n)=>K(t.mul(W(n,e)),e),sqrN:e=>e.mul(e),addN:(e,t)=>e.add(t),subN:(e,t)=>e.sub(t),mulN:(e,t)=>e.mul(t),inv:t=>W(t,e),sqrt:r.sqrt||(e=>o(s,e)),invertBatch:e=>function(e,t){const n=Array(t.length),r=t.reduce(((t,r,f)=>e.is0(r)?t:(n[f]=t,e.mul(t,r))),e.ONE),f=e.inv(r);return t.reduceRight(((t,r,f)=>e.is0(r)?t:(n[f]=e.mul(t,n[f]),e.mul(t,r))),f),n}(s,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?z(e,i):A(e,i),fromBytes:e=>{if(e.length!==i)throw Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?O(e):v(e)}});return Object.freeze(s)}function ee(e){if(!(e instanceof h))throw Error("field order must be bigint");return e.byteLength()}function te(e){const t=ee(e);return t+Math.ceil(t/2)}
1
+ /*! OpenPGP.js v6.0.0-beta.1 - 2024-05-17 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
2
+ "undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;import{H as t,h as e,t as n,e as r,b as f,c as i,r as o,s,a,d as c,w as u,u as d,f as l}from"./sha3.min.mjs";class h extends t{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,e(t);const f=n(r);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(f.length>i?t.create().update(f).digest():f);for(let t=0;t<o.length;t++)o[t]^=54;this.iHash.update(o),this.oHash=t.create();for(let t=0;t<o.length;t++)o[t]^=106;this.oHash.update(o),o.fill(0)}update(t){return r(this),this.iHash.update(t),this}digestInto(t){r(this),f(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:f,blockLen:i,outputLen:o}=this;return t.finished=r,t.destroyed=f,t.blockLen=i,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const g=(t,e,n)=>new h(t,e).update(n).digest();g.create=(t,e)=>new h(t,e)
3
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */;const b=BigInt(0),y=BigInt(1),p=BigInt(2);function B(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function m(t){if(!B(t))throw Error("Uint8Array expected")}const w=/* @__PURE__ */Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function E(t){m(t);let e="";for(let n=0;n<t.length;n++)e+=w[t[n]];return e}function x(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function I(t){if("string"!=typeof t)throw Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":"0x"+t)}const v={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function S(t){return t>=v._0&&t<=v._9?t-v._0:t>=v._A&&t<=v._F?t-(v._A-10):t>=v._a&&t<=v._f?t-(v._a-10):void 0}function A(t){if("string"!=typeof t)throw Error("hex string expected, got "+typeof t);const e=t.length,n=e/2;if(e%2)throw Error("padded hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,f=0;e<n;e++,f+=2){const n=S(t.charCodeAt(f)),i=S(t.charCodeAt(f+1));if(void 0===n||void 0===i){const e=t[f]+t[f+1];throw Error('hex string expected, got non-hex character "'+e+'" at index '+f)}r[e]=16*n+i}return r}function O(t){return I(E(t))}function R(t){return m(t),I(E(Uint8Array.from(t).reverse()))}function q(t,e){return A(t.toString(16).padStart(2*e,"0"))}function P(t,e){return q(t,e).reverse()}function z(t,e,n){let r;if("string"==typeof e)try{r=A(e)}catch(n){throw Error(`${t} must be valid hex string, got "${e}". Cause: ${n}`)}else{if(!B(e))throw Error(t+" must be hex string or Uint8Array");r=Uint8Array.from(e)}const f=r.length;if("number"==typeof n&&f!==n)throw Error(`${t} expected ${n} bytes, got ${f}`);return r}function N(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];m(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const f=t[e];n.set(f,r),r+=f.length}return n}const H=t=>(p<<BigInt(t-1))-y,L=t=>new Uint8Array(t),T=t=>Uint8Array.from(t);function F(t,e,n){if("number"!=typeof t||t<2)throw Error("hashLen must be a number");if("number"!=typeof e||e<2)throw Error("qByteLen must be a number");if("function"!=typeof n)throw Error("hmacFn must be a function");let r=L(t),f=L(t),i=0;const o=()=>{r.fill(1),f.fill(0),i=0},s=(...t)=>n(f,r,...t),a=(t=L())=>{f=s(T([0]),t),r=s(),0!==t.length&&(f=s(T([1]),t),r=s())},c=()=>{if(i++>=1e3)throw Error("drbg: tried 1000 values");let t=0;const n=[];for(;t<e;){r=s();const e=r.slice();n.push(e),t+=r.length}return N(...n)};return(t,e)=>{let n;for(o(),a(t);!(n=e(c()));)a();return o(),n}}const _={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||B(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function U(t,e,n={}){const r=(e,n,r)=>{const f=_[n];if("function"!=typeof f)throw Error(`Invalid validator "${n}", expected function`);const i=t[e];if(!(r&&void 0===i||f(i,t)))throw Error(`Invalid param ${e+""}=${i} (${typeof i}), expected ${n}`)};for(const[t,n]of Object.entries(e))r(t,n,!1);for(const[t,e]of Object.entries(n))r(t,e,!0);return t}var Z=/*#__PURE__*/Object.freeze({__proto__:null,abytes:m,bitGet:function(t,e){return t>>BigInt(e)&y},bitLen:function(t){let e;for(e=0;t>b;t>>=y,e+=1);return e},bitMask:H,bitSet:function(t,e,n){return t|(n?y:b)<<BigInt(e)},bytesToHex:E,bytesToNumberBE:O,bytesToNumberLE:R,concatBytes:N,createHmacDrbg:F,ensureBytes:z,equalBytes:function(t,e){if(t.length!==e.length)return!1;let n=0;for(let r=0;r<t.length;r++)n|=t[r]^e[r];return 0===n},hexToBytes:A,hexToNumber:I,isBytes:B,numberToBytesBE:q,numberToBytesLE:P,numberToHexUnpadded:x,numberToVarBytesBE:function(t){return A(x(t))},utf8ToBytes:function(t){if("string"!=typeof t)throw Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))},validateObject:U});
4
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const G=BigInt(0),$=BigInt(1),k=BigInt(2),C=BigInt(3),j=BigInt(4),V=BigInt(5),K=BigInt(8);function D(t,e){const n=t%e;return n>=G?n:e+n}function Y(t,e,n){if(n<=G||e<G)throw Error("Expected power/modulo > 0");if(n===$)return G;let r=$;for(;e>G;)e&$&&(r=r*t%n),t=t*t%n,e>>=$;return r}function W(t,e,n){let r=t;for(;e-- >G;)r*=r,r%=n;return r}function M(t,e){if(t===G||e<=G)throw Error(`invert: expected positive integers, got n=${t} mod=${e}`);let n=D(t,e),r=e,f=G,i=$;for(;n!==G;){const t=r%n,e=f-i*(r/n);r=n,n=t,f=i,i=e}if(r!==$)throw Error("invert: does not exist");return D(f,e)}function J(t){if(t%j===C){const e=(t+$)/j;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw Error("Cannot find square root");return r}}if(t%K===V){const e=(t-V)/K;return function(t,n){const r=t.mul(n,k),f=t.pow(r,e),i=t.mul(n,f),o=t.mul(t.mul(i,k),f),s=t.mul(i,t.sub(o,t.ONE));if(!t.eql(t.sqr(s),n))throw Error("Cannot find square root");return s}}return function(t){const e=(t-$)/k;let n,r,f;for(n=t-$,r=0;n%k===G;n/=k,r++);for(f=k;f<t&&Y(f,e,t)!==t-$;f++);if(1===r){const e=(t+$)/j;return function(t,n){const r=t.pow(n,e);if(!t.eql(t.sqr(r),n))throw Error("Cannot find square root");return r}}const i=(n+$)/k;return function(t,o){if(t.pow(o,e)===t.neg(t.ONE))throw Error("Cannot find square root");let s=r,a=t.pow(t.mul(t.ONE,f),n),c=t.pow(o,i),u=t.pow(o,n);for(;!t.eql(u,t.ONE);){if(t.eql(u,t.ZERO))return t.ZERO;let e=1;for(let n=t.sqr(u);e<s&&!t.eql(n,t.ONE);e++)n=t.sqr(n);const n=t.pow(a,$<<BigInt(s-e-1));a=t.sqr(n),c=t.mul(c,n),u=t.mul(u,a),s=e}return c}}(t)}BigInt(9),BigInt(16);const Q=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function X(t,e){const n=void 0!==e?e:t.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function tt(t,e,n=!1,r={}){if(t<=G)throw Error("Expected Field ORDER > 0, got "+t);const{nBitLength:f,nByteLength:i}=X(t,e);if(i>2048)throw Error("Field lengths over 2048 bytes are not supported");const o=J(t),s=Object.freeze({ORDER:t,BITS:f,BYTES:i,MASK:H(f),ZERO:G,ONE:$,create:e=>D(e,t),isValid:e=>{if("bigint"!=typeof e)throw Error("Invalid field element: expected bigint, got "+typeof e);return G<=e&&e<t},is0:t=>t===G,isOdd:t=>(t&$)===$,neg:e=>D(-e,t),eql:(t,e)=>t===e,sqr:e=>D(e*e,t),add:(e,n)=>D(e+n,t),sub:(e,n)=>D(e-n,t),mul:(e,n)=>D(e*n,t),pow:(t,e)=>function(t,e,n){if(n<G)throw Error("Expected power > 0");if(n===G)return t.ONE;if(n===$)return e;let r=t.ONE,f=e;for(;n>G;)n&$&&(r=t.mul(r,f)),f=t.sqr(f),n>>=$;return r}(s,t,e),div:(e,n)=>D(e*M(n,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>M(e,t),sqrt:r.sqrt||(t=>o(s,t)),invertBatch:t=>function(t,e){const n=Array(e.length),r=e.reduce(((e,r,f)=>t.is0(r)?e:(n[f]=e,t.mul(e,r))),t.ONE),f=t.inv(r);return e.reduceRight(((e,r,f)=>t.is0(r)?e:(n[f]=t.mul(e,n[f]),t.mul(e,r))),f),n}(s,t),cmov:(t,e,n)=>n?e:t,toBytes:t=>n?P(t,i):q(t,i),fromBytes:t=>{if(t.length!==i)throw Error(`Fp.fromBytes: expected ${i}, got ${t.length}`);return n?R(t):O(t)}});return Object.freeze(s)}function et(t){if("bigint"!=typeof t)throw Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function nt(t){const e=et(t);return e+Math.ceil(e/2)}
5
5
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6
- const ne=Object.freeze(h.new(0)),re=Object.freeze(h.new(1));function fe(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){const r=n.clone();let f=e.ZERO,i=t;for(;r.gt(ne);)r.isEven()||(f=f.add(i)),i=i.double(),r.irightShift(re);return f},precomputeWindow(e,t){const{windows:n,windowSize:f}=r(t),i=[];let o=e,s=o;for(let e=0;e<n;e++){s=o,i.push(s);for(let e=1;e<f;e++)s=s.add(o),i.push(s);o=s.double()}return i},wNAF(t,f,i){const o=i.clone(),{windows:s,windowSize:a}=r(t);let c=e.ZERO,u=e.BASE;const d=h.new(2**t-1),l=2**t,b=h.new(t);for(let e=0;e<s;e++){const t=e*a;let r=o.bitwiseAnd(d).toNumber();o.irightShift(b),r>a&&(r-=l,o.iinc());const i=t,s=t+Math.abs(r)-1,h=e%2!=0,m=r<0;0===r?u=u.add(n(h,f[i])):c=c.add(n(m,f[s]))}return{p:c,f:u}},wNAFCached(e,t,n,r){const f=e._WINDOW_SIZE||1;let i=t.get(e);return i||(i=this.precomputeWindow(e,f),1!==f&&t.set(e,r(i))),this.wNAF(f,i,n)}}}function ie(e){return Z(e.Fp,J.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"BigInteger",MASK:"BigInteger",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),Z(e,{n:"BigInteger",h:"BigInteger",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Q(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}
7
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:oe,hexToBytes:se}=H,ae={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:t}=ae;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const n=e[1],r=e.subarray(2,n+2);if(!n||r.length!==n)throw new t("Invalid signature integer: wrong length");if(128&r[0])throw new t("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:oe(r),l:e.subarray(n+2)}},toSig(e){const{Err:t}=ae,n="string"==typeof e?se(e):e;if(!y(n))throw Error("ui8a expected");let r=n.length;if(r<2||48!=n[0])throw new t("Invalid signature tag");if(n[1]!==r-2)throw new t("Invalid signature: incorrect length");const{d:f,l:i}=ae._parseInt(n.subarray(2)),{d:o,l:s}=ae._parseInt(i);if(s.length)throw new t("Invalid signature: left bytes after parsing");return{r:f,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,n=e=>{const t=e instanceof h?g(e.toUint8Array()):e.toString(16);return 1&t.length?"0"+t:t},r=t(n(e.s)),f=t(n(e.r)),i=r.length/2,o=f.length/2,s=n(i),a=n(o);return`30${n(o+i+4)}02${a}${f}02${s}${r}`}},ce=Object.freeze(h.new(0)),ue=Object.freeze(h.new(1));Object.freeze(h.new(2));const de=Object.freeze(h.new(3));function le(e){const t=function(e){const t=ie(e);Z(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:f}=t;if(n){if(!r.eql(f,r.ZERO))throw Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||!(n.beta instanceof h)||"function"!=typeof n.splitScalar)throw Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,r=t.toBytes||((e,t,r)=>{const f=t.toAffine();return R(Uint8Array.from([4]),n.toBytes(f.x),n.toBytes(f.y))}),f=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function i(e){const{a:r,b:f}=t,i=n.sqr(e),o=n.mul(i,e);return n.add(n.add(o,n.mul(e,r)),f)}if(!n.eql(n.sqr(t.Gy),i(t.Gx)))throw Error("bad generator point: equation left != right");function o(e){return e instanceof h&&ce.lt(e)&&e.lt(t.n)}function s(e){if(!o(e))throw Error("Expected valid bigint: 0 < bigint < curve.n")}function a(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:f,n:i}=t;if(n&&!(e instanceof h)){if(y(e)&&(e=g(e)),"string"!=typeof e||!n.includes(e.length))throw Error("Invalid key");e=e.padStart(2*r,"0")}let o;try{o=e instanceof h?e:v(q("private key",e,r))}catch(t){throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return f&&(o=K(o,i)),s(o),o}const c=new Map;function u(e){if(!(e instanceof d))throw Error("ProjectivePoint expected")}class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw Error("x required");if(null==t||!n.isValid(t))throw Error("y required");if(null==r||!n.isValid(r))throw Error("z required")}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw Error("invalid affine point");if(e instanceof d)throw Error("projective point not allowed");const f=e=>n.eql(e,n.ZERO);return f(t)&&f(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(f(q("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(a(e))}_setWindowSize(e){this._WINDOW_SIZE=e,c.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!n.is0(this.py))return;throw Error("bad point: ZERO")}const{x:e,y:r}=this.toAffine();if(!n.isValid(e)||!n.isValid(r))throw Error("bad point: x or y not FE");const f=n.sqr(r),o=i(e);if(!n.eql(f,o))throw Error("bad point: equation left != right");if(!this.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw Error("Field doesn't support isOdd")}equals(e){u(e);const{px:t,py:r,pz:f}=this,{px:i,py:o,pz:s}=e,a=n.eql(n.mul(t,s),n.mul(i,f)),c=n.eql(n.mul(r,s),n.mul(o,f));return a&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,f=n.mul(r,de),{px:i,py:o,pz:s}=this;let a=n.ZERO,c=n.ZERO,u=n.ZERO,l=n.mul(i,i),h=n.mul(o,o),b=n.mul(s,s),m=n.mul(i,o);return m=n.add(m,m),u=n.mul(i,s),u=n.add(u,u),a=n.mul(e,u),c=n.mul(f,b),c=n.add(a,c),a=n.sub(h,c),c=n.add(h,c),c=n.mul(a,c),a=n.mul(m,a),u=n.mul(f,u),b=n.mul(e,b),m=n.sub(l,b),m=n.mul(e,m),m=n.add(m,u),u=n.add(l,l),l=n.add(u,l),l=n.add(l,b),l=n.mul(l,m),c=n.add(c,l),b=n.mul(o,s),b=n.add(b,b),l=n.mul(b,m),a=n.sub(a,l),u=n.mul(b,h),u=n.add(u,u),u=n.add(u,u),new d(a,c,u)}add(e){u(e);const{px:r,py:f,pz:i}=this,{px:o,py:s,pz:a}=e;let c=n.ZERO,l=n.ZERO,h=n.ZERO;const b=t.a,m=n.mul(t.b,de);let w=n.mul(r,o),y=n.mul(f,s),p=n.mul(i,a),g=n.add(r,f),E=n.add(o,s);g=n.mul(g,E),E=n.add(w,y),g=n.sub(g,E),E=n.add(r,i);let x=n.add(o,a);return E=n.mul(E,x),x=n.add(w,p),E=n.sub(E,x),x=n.add(f,i),c=n.add(s,a),x=n.mul(x,c),c=n.add(y,p),x=n.sub(x,c),h=n.mul(b,E),c=n.mul(m,p),h=n.add(c,h),c=n.sub(y,h),h=n.add(y,h),l=n.mul(c,h),y=n.add(w,w),y=n.add(y,w),p=n.mul(b,p),E=n.mul(m,E),y=n.add(y,p),p=n.sub(w,p),p=n.mul(b,p),E=n.add(E,p),w=n.mul(y,E),l=n.add(l,w),w=n.mul(x,E),c=n.mul(g,c),c=n.sub(c,w),w=n.mul(g,y),h=n.mul(x,h),h=n.add(h,w),new d(c,l,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return b.wNAFCached(this,c,e,(e=>{const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(d.fromAffine)}))}multiplyUnsafe(e){const r=d.ZERO;if(e.isZero())return r;if(s(e),e.isOne())return this;const{endo:f}=t;if(!f)return b.unsafeLadder(this,e);let{k1neg:i,k1:o,k2neg:a,k2:c}=f.splitScalar(e),u=r,l=r,h=this;for(;o.gt(ce)||c.gt(ce);)o.isEven()||(u=u.add(h)),c.isEven()||(l=l.add(h)),h=h.double(),o=o.rightShift(ue),c=c.rightShift(ue);return i&&(u=u.negate()),a&&(l=l.negate()),l=new d(n.mul(l.px,f.beta),l.py,l.pz),u.add(l)}multiply(e){s(e);let r,f,i=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:s,k2:a}=o.splitScalar(i);let{p:c,f:u}=this.wNAF(t),{p:l,f:h}=this.wNAF(a);c=b.constTimeNegate(e,c),l=b.constTimeNegate(s,l),l=new d(n.mul(l.px,o.beta),l.py,l.pz),r=c.add(l),f=u.add(h)}else{const{p:e,f:t}=this.wNAF(i);r=e,f=t}return d.normalizeZ([r,f])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,f=(e,t)=>t.isZero()||t.isOne()||!e.equals(r)?e.multiplyUnsafe(t):e.multiply(t),i=f(this,t).add(f(e,n));return i.is0()?void 0:i}toAffine(e){const{px:t,py:r,pz:f}=this,i=this.is0();null==e&&(e=i?n.ONE:n.inv(f));const o=n.mul(t,e),s=n.mul(r,e),a=n.mul(f,e);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(a,n.ONE))throw Error("invZ was invalid");return{x:o,y:s}}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e.isOne())return!0;if(n)return n(d,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e.isOne()?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return this.assertValidity(),r(d,this,e)}toHex(e=!0){return g(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const l=t.nBitLength,b=fe(d,t.endo?Math.ceil(l/2):l);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:o}}function he(e){const t=function(e){const t=ie(e);return Z(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r}=t,f=n.BYTES+1,i=2*n.BYTES+1;function o(e){return K(e,r)}function s(e){return W(e,r)}const{ProjectivePoint:a,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=le({...t,toBytes(e,t,r){const f=t.toAffine(),i=n.toBytes(f.x),o=R;return r?o(Uint8Array.from([t.hasEvenY()?2:3]),i):o(Uint8Array.from([4]),i,n.toBytes(f.y))},fromBytes(e){const t=e.length,r=e[0],o=e.subarray(1);if(t!==f||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw Error(`Point of length ${t} was invalid. Expected ${f} compressed bytes or ${i} uncompressed bytes`)}{const e=v(o);if(s=e,!ce.lt(s)||!s.lt(n.ORDER))throw Error("Point is not on curve");const t=u(e);let f=n.sqrt(t);return!(1&~r)!==!f.isEven()&&(f=n.neg(f)),{x:e,y:f}}var s}}),l=e=>g(A(e,t.nByteLength));function b(e){const t=r.rightShift(ue);return e.gt(t)}const m=(e,t,n)=>v(e.slice(t,n));class w{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=q("compactSignature",e,2*n),new w(m(e,0,n),m(e,n,2*n))}static fromDER(e){const{r:t,s:n}=ae.toSig(q("DER",e));return new w(t,n)}assertValidity(){if(!d(this.r))throw Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new w(this.r,this.s,e)}recoverPublicKey(e){const{r,s:f,recovery:i}=this,c=B(q("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw Error("recovery id invalid");const u=2===i||3===i?r.add(t.n):r;if(u.gte(n.ORDER))throw Error("recovery id 2 or 3 invalid");const d=1&i?"03":"02",h=a.fromHex(d+l(u)),b=s(u),m=o(c.negate().imul(b)),w=o(f.mul(b)),y=a.BASE.multiplyAndAddUnsafe(h,m,w);if(!y)throw Error("point at infinify");return y.assertValidity(),y}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new w(this.r,o(this.s.negate()),this.recovery):this}toDERRawBytes(){return S(this.toDERHex())}toDERHex(){return ae.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return S(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}const p={isValidPrivateKey(e){try{return c(e),!0}catch(e){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=te(t.n);return function(e,t,n=!1){const r=e.length,f=ee(t),i=te(t);if(r<16||r<i||r>1024)throw Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=K(n?v(e):O(e),t.dec()).inc();return n?z(o,f):A(o,f)}(t.randomBytes(e),t.n)},precompute:(e=8,t=a.BASE)=>(t._setWindowSize(e),t.multiply(h.new(3)),t)};function E(e){const t=y(e),n="string"==typeof e,r=(t||n)&&e.length;return t?r===f||r===i:n?r===2*f||r===2*i:e instanceof a}const x=t.bits2int||function(e){const n=v(e),r=8*e.length-t.nBitLength;return r>0?n.rightShift(h.new(r)):n},B=t.bits2int_modN||function(e){return o(x(e))},N=j(t.nBitLength);function P(e){if(!(e instanceof h))throw Error("bigint expected");if(!ce.lte(e)||!e.lt(N))throw Error("bigint expected < 2^"+t.nBitLength);return A(e,t.nByteLength)}function L(e,r,f=H){if(["recovered","canonical"].some((e=>e in f)))throw Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=t;let{lowS:l,prehash:h,extraEntropy:m}=f;null==l&&(l=!0),e=q("msgHash",e),h&&(e=q("prehashed msgHash",i(e)));const y=B(e),p=c(r),g=[P(p),P(y)];if(null!=m){const e=!0===m?u(n.BYTES):m;g.push(q("extraEntropy",e))}const E=R(...g),S=y;return{seed:E,k2sig:function(e){const t=x(e);if(!d(t))return;const n=s(t),r=a.BASE.multiply(t).toAffine(),f=o(r.x);if(f.isZero())return;const i=o(n.mul(o(S.add(f.mul(p)))));if(i.isZero())return;let c=(r.x.equal(f)?0:2)|r.y.getBit(0),u=i;return l&&b(i)&&(u=function(e){return b(e)?o(e.negate()):e}(i),c^=1),new w(f,u,c)}}}const H={lowS:t.lowS,prehash:!1},T={lowS:t.lowS,prehash:!1};return a.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return a.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(E(e))throw Error("first arg must be private key");if(!E(t))throw Error("second arg must be public key");return a.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n,r=H){const{seed:f,k2sig:i}=L(e,n,r),o=t;return I(o.hash.outputLen,o.nByteLength,o.hmac)(f,i)},verify:function(e,n,r,f=T){const i=e;if(n=q("msgHash",n),r=q("publicKey",r),"strict"in f)throw Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=f;let d,l;try{if("string"==typeof i||y(i))try{d=w.fromDER(i)}catch(e){if(!(e instanceof ae.Err))throw e;d=w.fromCompact(i)}else{if(!("object"==typeof i&&i.r instanceof h&&i.s instanceof h))throw Error("PARSE");{const{r:e,s:t}=i;d=new w(e,t)}}l=a.fromHex(r)}catch(e){if("PARSE"===e.message)throw Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:b,s:m}=d,p=B(n),g=s(m),E=o(p.mul(g)),x=o(b.mul(g)),S=a.BASE.multiplyAndAddUnsafe(l,E,x)?.toAffine();return!!S&&o(S.x).equal(b)},ProjectivePoint:a,Signature:w,utils:p}}
8
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function be(e){return{hash:e,hmac:(t,...n)=>m(e,t,i(...n)),randomBytes:o}}function me(e,t){const n=t=>he({...e,...be(t)});return Object.freeze({...n(t),create:n})}
9
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */Object.freeze(h.new(4));const we=X(h.new("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),ye=me({a:we.create(h.new("-3")),b:h.new("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:we,n:h.new("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:h.new("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:h.new("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:h.new(1),lowS:!1},s),pe=X(h.new("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),ge=me({a:pe.create(h.new("-3")),b:h.new("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Fp:pe,n:h.new("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:h.new("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:h.new("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:h.new(1),lowS:!1},a),Ee=X(h.new("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),xe={a:Ee.create(h.new("-3")),b:h.new("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Fp:Ee,n:h.new("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:h.new("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:h.new("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:h.new(1)},Be=me({a:xe.a,b:xe.b,Fp:Ee,n:xe.n,Gx:xe.Gx,Gy:xe.Gy,h:xe.h,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},c),Se=X(h.new("0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377")),ve=me({a:Se.create(h.new("0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9")),b:h.new("0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6"),Fp:Se,n:h.new("0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7"),Gx:h.new("0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262"),Gy:h.new("0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997"),h:h.new(1),lowS:!1},s),Oe=X(h.new("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53")),Ae=me({a:Oe.create(h.new("0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826")),b:h.new("0x04a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11"),Fp:Oe,n:h.new("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565"),Gx:h.new("0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e"),Gy:h.new("0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315"),h:h.new(1),lowS:!1},a),ze=X(h.new("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3")),qe=me({a:ze.create(h.new("0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca")),b:h.new("0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723"),Fp:ze,n:h.new("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069"),Gx:h.new("0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822"),Gy:h.new("0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892"),h:h.new(1),lowS:!1},c),Re=Object.freeze(h.new(0)),je=Object.freeze(h.new(1)),Ne=Object.freeze(h.new(2)),Pe=Object.freeze(h.new(3)),Ie=Object.freeze(h.new(8)),Le={zip215:!0};function Ze(e){const t=function(e){const t=ie(e);return Z(e,{hash:"function",a:"BigInteger",d:"BigInteger",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:n,n:r,prehash:f,hash:i,randomBytes:o,nByteLength:s,h:a}=t,c=Ne.leftShift(h.new(8*s).idec()),u=n.create,d=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:n.sqrt(e.mul(n.inv(t)))}}catch(e){return{isValid:!1,value:Re}}}),l=t.adjustScalarBytes||(e=>e),b=t.domain||((e,t,n)=>{if(t.length||n)throw Error("Contexts/pre-hash are not supported");return e}),m=e=>e instanceof h&&e.gt(Re),w=(e,t)=>m(e)&&m(t)&&e.lt(t),y=e=>e.isZero()||w(e,c);function p(e,t){if(w(e,t))return e;throw Error(`Expected valid scalar < ${t}, got ${typeof e} ${e}`)}function E(e){return e.isZero()?e:p(e,r)}const x=new Map;function B(e){if(!(e instanceof S))throw Error("ExtendedPoint expected")}class S{constructor(e,t,n,r){if(this.ex=e,this.ey=t,this.ez=n,this.et=r,!y(e))throw Error("x required");if(!y(t))throw Error("y required");if(!y(n))throw Error("z required");if(!y(r))throw Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof S)throw Error("extended point not allowed");const{x:t,y:n}=e||{};if(!y(t)||!y(n))throw Error("invalid affine point");return new S(t,n,je,u(t.mul(n)))}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.ez)));return e.map(((e,n)=>e.toAffine(t[n]))).map(S.fromAffine)}_setWindowSize(e){this._WINDOW_SIZE=e,x.delete(this)}assertValidity(){const{a:e,d:n}=t;if(this.is0())throw Error("bad point: ZERO");const{ex:r,ey:f,ez:i,et:o}=this,s=u(r.mul(r)),a=u(f.mul(f)),c=u(i.mul(i)),d=u(c.mul(c)),l=u(s.mul(e)),h=u(c.mul(u(l.add(a)))),b=u(d.add(u(n.mul(u(s.mul(a))))));if(!h.equal(b))throw Error("bad point: equation left != right (1)");const m=u(r.mul(f)),w=u(i.mul(o));if(!m.equal(w))throw Error("bad point: equation left != right (2)")}equals(e){B(e);const{ex:t,ey:n,ez:r}=this,{ex:f,ey:i,ez:o}=e,s=u(t.mul(o)),a=u(f.mul(r)),c=u(n.mul(o)),d=u(i.mul(r));return s.equal(a)&&c.equal(d)}is0(){return this.equals(S.ZERO)}negate(){return new S(u(this.ex.negate()),this.ey,this.ez,u(this.et.negate()))}double(){const{a:e}=t,{ex:n,ey:r,ez:f}=this,i=u(n.mul(n)),o=u(r.mul(r)),s=u(Ne.mul(u(f.mul(f)))),a=u(e.mul(i)),c=n.add(r),d=u(u(c.mul(c)).sub(i).isub(o)),l=a.add(o),h=l.sub(s),b=a.sub(o),m=u(d.mul(h)),w=u(l.mul(b)),y=u(d.mul(b)),p=u(h.mul(l));return new S(m,w,p,y)}add(e){B(e);const{a:n,d:r}=t,{ex:f,ey:i,ez:o,et:s}=this,{ex:a,ey:c,ez:d,et:l}=e;if(n.equal(h.new(-1))){const e=u(i.sub(f).imul(c.add(a))),t=u(i.add(f).imul(c.sub(a))),n=u(t.sub(e));if(n.isZero())return this.double();const r=u(o.mul(Ne).imul(l)),h=u(s.mul(Ne).imul(d)),b=h.add(r),m=t.add(e),w=h.sub(r),y=u(b.mul(n)),p=u(m.mul(w)),g=u(b.mul(w)),E=u(n.mul(m));return new S(y,p,E,g)}const b=u(f.mul(a)),m=u(i.mul(c)),w=u(s.mul(r).imul(l)),y=u(o.mul(d)),p=u(f.add(i).imul(a.add(c)).isub(b).isub(m)),g=y.sub(w),E=y.add(w),x=u(m.sub(n.mul(b))),v=u(p.mul(g)),O=u(E.mul(x)),A=u(p.mul(x)),z=u(g.mul(E));return new S(v,O,z,A)}subtract(e){return this.add(e.negate())}wNAF(e){return z.wNAFCached(this,x,e,S.normalizeZ)}multiply(e){const{p:t,f:n}=this.wNAF(p(e,r));return S.normalizeZ([t,n])[0]}multiplyUnsafe(e){let t=E(e);return t.isZero()?A:this.equals(A)||t.isOne()?this:this.equals(v)?this.wNAF(t).p:z.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return z.unsafeLadder(this,r).is0()}toAffine(e){const{ex:t,ey:r,ez:f}=this,i=this.is0();null==e&&(e=i?Ie:n.inv(f));const o=u(t.mul(e)),s=u(r.mul(e)),a=u(f.mul(e));if(i)return{x:Re.clone(),y:je.clone()};if(!a.isOne())throw Error("invZ was invalid");return{x:o,y:s}}clearCofactor(){const{h:e}=t;return e.isOne()?this:this.multiplyUnsafe(e)}static fromHex(e,r=!1){const{d:f,a:i}=t,o=n.BYTES,s=(e=q("pointHex",e,o)).slice(),a=e[o-1];s[o-1]=-129&a;const l=O(s);l.isZero()||p(l,r?c:n.ORDER);const h=u(l.mul(l)),b=u(h.dec()),m=u(f.mul(h).isub(i));let{isValid:w,value:y}=d(b,m);if(!w)throw Error("Point.fromHex: invalid y coordinate");const g=!y.isEven(),E=!!(128&a);if(!r&&y.isZero()&&E)throw Error("Point.fromHex: x=0 and x_0=1");return E!==g&&(y=u(y.negate())),S.fromAffine({x:y,y:l})}static fromPrivateKey(e){return P(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),r=t.toUint8Array("le",n.BYTES);return r[r.length-1]|=e.isEven()?0:128,r}toHex(){return g(this.toRawBytes())}}S.BASE=new S(t.Gx,t.Gy,je,u(t.Gx.mul(t.Gy))),S.ZERO=new S(Re,je,je,Re);const{BASE:v,ZERO:A}=S,z=fe(S,8*s);function j(e){return K(e,r)}function N(e){return j(O(e))}function P(e){const t=s;e=q("private key",e,t);const n=q("hashed private key",i(e),2*t),r=l(n.slice(0,t)),f=n.slice(t,2*t),o=N(r),a=v.multiply(o),c=a.toRawBytes();return{head:r,prefix:f,scalar:o,point:a,pointBytes:c}}function I(e=new Uint8Array,...t){const n=R(...t);return N(i(b(n,q("context",e),!!f)))}const L=Le;v._setWindowSize(8);return{CURVE:t,getPublicKey:function(e){return P(e).pointBytes},sign:function(e,t,r={}){e=q("message",e),f&&(e=f(e));const{prefix:i,scalar:o,pointBytes:a}=P(t),c=I(r.context,i,e),u=v.multiply(c).toRawBytes(),d=I(r.context,u,a,e),l=j(c.add(d.mul(o)));return E(l),q("result",R(u,l.toUint8Array("le",n.BYTES)),2*s)},verify:function(e,t,r,i=L){const{context:o,zip215:s}=i,a=n.BYTES;e=q("signature",e,2*a),t=q("message",t),f&&(t=f(t));const c=O(e.slice(a,2*a));let u,d,l;try{u=S.fromHex(r,s),d=S.fromHex(e.slice(0,a),s),l=v.multiplyUnsafe(c)}catch(e){return!1}if(!s&&u.isSmallOrder())return!1;const h=I(o,d.toRawBytes(),u.toRawBytes(),t);return d.add(u.multiplyUnsafe(h)).subtract(l).clearCofactor().equals(S.ZERO)},ExtendedPoint:S,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>o(n.BYTES),precompute:(e=8,t=S.BASE)=>(t._setWindowSize(e),t.multiply(Pe),t)}}}
10
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const He=Object.freeze(h.new(0)),Te=Object.freeze(h.new(1)),Ue=Object.freeze(h.new(2));function Fe(e){const t=(Z(n=e,{a:"BigInteger"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"BigInteger"}),Object.freeze({...n}));var n;const{P:r}=t,f=e=>K(e,r),i=t.montgomeryBits,o=Math.ceil(i/8),s=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>D(e,r.sub(Ue),r));function u(e,t,n){const r=f(e.mul(t.sub(n)));return[t=f(t.sub(r)),n=f(n.add(r))]}function d(e){if(e instanceof h&&!e.isNegative()&&e.lt(r))return e;throw Error("Expected valid scalar 0 < scalar < CURVE.P")}const l=t.a.sub(Ue).irightShift(Ue);function b(e){return z(f(e),o)}function m(e,t){const n=function(e){const t=q("u coordinate",e,o);return 32===s&&(t[31]&=127),O(t)}(t),r=function(e){const t=q("scalar",e),n=t.length;if(n!==o&&n!==s)throw Error(`Expected ${o} or ${s} bytes, got ${n}`);return O(a(t))}(e),m=function(e,t){const n=d(e),r=d(t),o=n;let s,a=Te,b=He,m=n,w=Te,y=He.clone();for(let e=h.new(i-1);!e.isNegative();e.idec()){const t=h.new(r.rightShift(e).getBit(0));y.ixor(t),s=u(y,a,m),a=s[0],m=s[1],s=u(y,b,w),b=s[0],w=s[1],y=t;const n=a.add(b),i=f(n.mul(n)),c=a.sub(b),d=f(c.mul(c)),p=i.sub(d),g=m.add(w),E=m.sub(w),x=f(E.mul(n)),B=f(g.mul(c)),S=x.add(B),v=x.sub(B);m=f(S.mul(S)),w=f(o.mul(f(v.mul(v)))),a=f(i.mul(d)),b=f(p.mul(i.add(f(l.mul(p)))))}s=u(y,a,m),a=s[0],m=s[1],s=u(y,b,w),b=s[0],w=s[1];const p=c(b);return f(a.mul(p))}(n,r);if(m.isZero())throw Error("Invalid private or public key received");return b(m)}const w=b(t.Gu);function y(e){return m(e,w)}return{scalarMult:m,scalarMultBase:y,getSharedSecret:(e,t)=>m(e,t),getPublicKey:e=>y(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:w}}
11
- /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _e=u((()=>l.create({dkLen:114}))),Ge=(u((()=>l.create({dkLen:64}))),h.new("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018365439")),ke=h.new(1),Ce=h.new(2),$e=h.new(3),Ve=h.new(11),Ke=h.new(22),De=h.new(44),Ye=h.new(88),We=h.new(223);function Me(e){const t=Ge,n=e.modExp($e,t),r=n.mul(n).imul(e).imod(t),f=Y(r,$e,t).imul(r).imod(t),i=Y(f,$e,t).imul(r).imod(t),o=Y(i,Ce,t).imul(n).imod(t),s=Y(o,Ve,t).imul(o).imod(t),a=Y(s,Ke,t).imul(s).imod(t),c=Y(a,De,t).imul(a).imod(t),u=Y(c,Ye,t).imul(c).imod(t),d=Y(u,De,t).imul(a).imod(t),l=Y(d,Ce,t).imul(n).imod(t),h=Y(l,ke,t).imul(e).imod(t);return Y(h,We,t).imul(l).imod(t)}function Je(e){return e[0]&=252,e[55]|=128,e[56]=0,e}const Qe=X(Ge,456,!0),Xe={a:h.new(1),d:h.new("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358"),Fp:Qe,n:h.new("181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779"),nBitLength:456,h:h.new(4),Gx:h.new("224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710"),Gy:h.new("298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660"),hash:_e,randomBytes:o,adjustScalarBytes:Je,domain:(e,t,n)=>{if(t.length>255)throw Error("Context is too big: "+t.length);return i(d("SigEd448"),new Uint8Array([n?1:0,t.length]),t,e)},uvRatio:function(e,t){const n=Ge,r=K(e.mul(e).imul(t),n),f=K(r.mul(e),n),i=Me(K(f.mul(r).imul(t),n)),o=K(f.mul(i),n),s=K(o.mul(o),n);return{isValid:K(s.mul(t),n).equal(e),value:o}}},et=/* @__PURE__ */Ze(Xe),tt=/* @__PURE__ */(()=>Fe({a:h.new(156326),montgomeryBits:448,nByteLength:56,P:Ge,Gu:h.new(5),powPminus2:e=>{const t=Ge;return K(Y(Me(e),h.new(2),t).mul(e),t)},adjustScalarBytes:Je,randomBytes:o}))();Object.freeze(h.new(4)),Qe.ORDER.sub($e).irightShift(Ce),h.new(156326),h.new("39082"),h.new("78163"),h.new("98944233647732219769177004876929019128417576295529901074099889598043702116001257856802131563896515373927712232092845883226922417596214"),h.new("315019913931389607337177038330951043522456072897266928557328499619017160722351061360252776265186336876723201881398623946864393857820716"),h.new("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
6
+ const rt=BigInt(0),ft=BigInt(1);function it(t,e){const n=(t,e)=>{const n=e.negate();return t?n:e},r=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:n,unsafeLadder(e,n){let r=t.ZERO,f=e;for(;n>rt;)n&ft&&(r=r.add(f)),f=f.double(),n>>=ft;return r},precomputeWindow(t,e){const{windows:n,windowSize:f}=r(e),i=[];let o=t,s=o;for(let t=0;t<n;t++){s=o,i.push(s);for(let t=1;t<f;t++)s=s.add(o),i.push(s);o=s.double()}return i},wNAF(e,f,i){const{windows:o,windowSize:s}=r(e);let a=t.ZERO,c=t.BASE;const u=BigInt(2**e-1),d=2**e,l=BigInt(e);for(let t=0;t<o;t++){const e=t*s;let r=Number(i&u);i>>=l,r>s&&(r-=d,i+=ft);const o=e,h=e+Math.abs(r)-1,g=t%2!=0,b=r<0;0===r?c=c.add(n(g,f[o])):a=a.add(n(b,f[h]))}return{p:a,f:c}},wNAFCached(t,e,n,r){const f=t._WINDOW_SIZE||1;let i=e.get(t);return i||(i=this.precomputeWindow(t,f),1!==f&&e.set(t,r(i))),this.wNAF(f,i,n)}}}function ot(t){return U(t.Fp,Q.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),U(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...X(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}
7
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const{bytesToNumberBE:st,hexToBytes:at}=Z,ct={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=ct;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const n=t[1],r=t.subarray(2,n+2);if(!n||r.length!==n)throw new e("Invalid signature integer: wrong length");if(128&r[0])throw new e("Invalid signature integer: negative");if(0===r[0]&&!(128&r[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:st(r),l:t.subarray(n+2)}},toSig(t){const{Err:e}=ct,n="string"==typeof t?at(t):t;m(n);let r=n.length;if(r<2||48!=n[0])throw new e("Invalid signature tag");if(n[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:f,l:i}=ct._parseInt(n.subarray(2)),{d:o,l:s}=ct._parseInt(i);if(s.length)throw new e("Invalid signature: left bytes after parsing");return{r:f,s:o}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,n=t=>{const e=t.toString(16);return 1&e.length?"0"+e:e},r=e(n(t.s)),f=e(n(t.r)),i=r.length/2,o=f.length/2,s=n(i),a=n(o);return`30${n(o+i+4)}02${a}${f}02${s}${r}`}},ut=BigInt(0),dt=BigInt(1);BigInt(2);const lt=BigInt(3);function ht(t){const e=function(t){const e=ot(t);U(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:f}=e;if(n){if(!r.eql(f,r.ZERO))throw Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof n||"bigint"!=typeof n.beta||"function"!=typeof n.splitScalar)throw Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:n}=e,r=e.toBytes||((t,e,r)=>{const f=e.toAffine();return N(Uint8Array.from([4]),n.toBytes(f.x),n.toBytes(f.y))}),f=e.fromBytes||(t=>{const e=t.subarray(1);return{x:n.fromBytes(e.subarray(0,n.BYTES)),y:n.fromBytes(e.subarray(n.BYTES,2*n.BYTES))}});function i(t){const{a:r,b:f}=e,i=n.sqr(t),o=n.mul(i,t);return n.add(n.add(o,n.mul(t,r)),f)}if(!n.eql(n.sqr(e.Gy),i(e.Gx)))throw Error("bad generator point: equation left != right");function o(t){return"bigint"==typeof t&&ut<t&&t<e.n}function s(t){if(!o(t))throw Error("Expected valid bigint: 0 < bigint < curve.n")}function a(t){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:f,n:i}=e;if(n&&"bigint"!=typeof t){if(B(t)&&(t=E(t)),"string"!=typeof t||!n.includes(t.length))throw Error("Invalid key");t=t.padStart(2*r,"0")}let o;try{o="bigint"==typeof t?t:O(z("private key",t,r))}catch(e){throw Error(`private key must be ${r} bytes, hex or bigint, not ${typeof t}`)}return f&&(o=D(o,i)),s(o),o}const c=new Map;function u(t){if(!(t instanceof d))throw Error("ProjectivePoint expected")}class d{constructor(t,e,r){if(this.px=t,this.py=e,this.pz=r,null==t||!n.isValid(t))throw Error("x required");if(null==e||!n.isValid(e))throw Error("y required");if(null==r||!n.isValid(r))throw Error("z required")}static fromAffine(t){const{x:e,y:r}=t||{};if(!t||!n.isValid(e)||!n.isValid(r))throw Error("invalid affine point");if(t instanceof d)throw Error("projective point not allowed");const f=t=>n.eql(t,n.ZERO);return f(e)&&f(r)?d.ZERO:new d(e,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(d.fromAffine)}static fromHex(t){const e=d.fromAffine(f(z("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return d.BASE.multiply(a(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!n.is0(this.py))return;throw Error("bad point: ZERO")}const{x:t,y:r}=this.toAffine();if(!n.isValid(t)||!n.isValid(r))throw Error("bad point: x or y not FE");const f=n.sqr(r),o=i(t);if(!n.eql(f,o))throw Error("bad point: equation left != right");if(!this.isTorsionFree())throw Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(n.isOdd)return!n.isOdd(t);throw Error("Field doesn't support isOdd")}equals(t){u(t);const{px:e,py:r,pz:f}=this,{px:i,py:o,pz:s}=t,a=n.eql(n.mul(e,s),n.mul(i,f)),c=n.eql(n.mul(r,s),n.mul(o,f));return a&&c}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:t,b:r}=e,f=n.mul(r,lt),{px:i,py:o,pz:s}=this;let a=n.ZERO,c=n.ZERO,u=n.ZERO,l=n.mul(i,i),h=n.mul(o,o),g=n.mul(s,s),b=n.mul(i,o);return b=n.add(b,b),u=n.mul(i,s),u=n.add(u,u),a=n.mul(t,u),c=n.mul(f,g),c=n.add(a,c),a=n.sub(h,c),c=n.add(h,c),c=n.mul(a,c),a=n.mul(b,a),u=n.mul(f,u),g=n.mul(t,g),b=n.sub(l,g),b=n.mul(t,b),b=n.add(b,u),u=n.add(l,l),l=n.add(u,l),l=n.add(l,g),l=n.mul(l,b),c=n.add(c,l),g=n.mul(o,s),g=n.add(g,g),l=n.mul(g,b),a=n.sub(a,l),u=n.mul(g,h),u=n.add(u,u),u=n.add(u,u),new d(a,c,u)}add(t){u(t);const{px:r,py:f,pz:i}=this,{px:o,py:s,pz:a}=t;let c=n.ZERO,l=n.ZERO,h=n.ZERO;const g=e.a,b=n.mul(e.b,lt);let y=n.mul(r,o),p=n.mul(f,s),B=n.mul(i,a),m=n.add(r,f),w=n.add(o,s);m=n.mul(m,w),w=n.add(y,p),m=n.sub(m,w),w=n.add(r,i);let E=n.add(o,a);return w=n.mul(w,E),E=n.add(y,B),w=n.sub(w,E),E=n.add(f,i),c=n.add(s,a),E=n.mul(E,c),c=n.add(p,B),E=n.sub(E,c),h=n.mul(g,w),c=n.mul(b,B),h=n.add(c,h),c=n.sub(p,h),h=n.add(p,h),l=n.mul(c,h),p=n.add(y,y),p=n.add(p,y),B=n.mul(g,B),w=n.mul(b,w),p=n.add(p,B),B=n.sub(y,B),B=n.mul(g,B),w=n.add(w,B),y=n.mul(p,w),l=n.add(l,y),y=n.mul(E,w),c=n.mul(m,c),c=n.sub(c,y),y=n.mul(m,p),h=n.mul(E,h),h=n.add(h,y),new d(c,l,h)}subtract(t){return this.add(t.negate())}is0(){return this.equals(d.ZERO)}wNAF(t){return h.wNAFCached(this,c,t,(t=>{const e=n.invertBatch(t.map((t=>t.pz)));return t.map(((t,n)=>t.toAffine(e[n]))).map(d.fromAffine)}))}multiplyUnsafe(t){const r=d.ZERO;if(t===ut)return r;if(s(t),t===dt)return this;const{endo:f}=e;if(!f)return h.unsafeLadder(this,t);let{k1neg:i,k1:o,k2neg:a,k2:c}=f.splitScalar(t),u=r,l=r,g=this;for(;o>ut||c>ut;)o&dt&&(u=u.add(g)),c&dt&&(l=l.add(g)),g=g.double(),o>>=dt,c>>=dt;return i&&(u=u.negate()),a&&(l=l.negate()),l=new d(n.mul(l.px,f.beta),l.py,l.pz),u.add(l)}multiply(t){s(t);let r,f,i=t;const{endo:o}=e;if(o){const{k1neg:t,k1:e,k2neg:s,k2:a}=o.splitScalar(i);let{p:c,f:u}=this.wNAF(e),{p:l,f:g}=this.wNAF(a);c=h.constTimeNegate(t,c),l=h.constTimeNegate(s,l),l=new d(n.mul(l.px,o.beta),l.py,l.pz),r=c.add(l),f=u.add(g)}else{const{p:t,f:e}=this.wNAF(i);r=t,f=e}return d.normalizeZ([r,f])[0]}multiplyAndAddUnsafe(t,e,n){const r=d.BASE,f=(t,e)=>e!==ut&&e!==dt&&t.equals(r)?t.multiply(e):t.multiplyUnsafe(e),i=f(this,e).add(f(t,n));return i.is0()?void 0:i}toAffine(t){const{px:e,py:r,pz:f}=this,i=this.is0();null==t&&(t=i?n.ONE:n.inv(f));const o=n.mul(e,t),s=n.mul(r,t),a=n.mul(f,t);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(a,n.ONE))throw Error("invZ was invalid");return{x:o,y:s}}isTorsionFree(){const{h:t,isTorsionFree:n}=e;if(t===dt)return!0;if(n)return n(d,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:n}=e;return t===dt?this:n?n(d,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),r(d,this,t)}toHex(t=!0){return E(this.toRawBytes(t))}}d.BASE=new d(e.Gx,e.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const l=e.nBitLength,h=it(d,e.endo?Math.ceil(l/2):l);return{CURVE:e,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:o}}function gt(t){const e=function(t){const e=ot(t);return U(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:n,n:r}=e,f=n.BYTES+1,i=2*n.BYTES+1;function o(t){return D(t,r)}function s(t){return M(t,r)}const{ProjectivePoint:a,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=ht({...e,toBytes(t,e,r){const f=e.toAffine(),i=n.toBytes(f.x),o=N;return r?o(Uint8Array.from([e.hasEvenY()?2:3]),i):o(Uint8Array.from([4]),i,n.toBytes(f.y))},fromBytes(t){const e=t.length,r=t[0],o=t.subarray(1);if(e!==f||2!==r&&3!==r){if(e===i&&4===r){return{x:n.fromBytes(o.subarray(0,n.BYTES)),y:n.fromBytes(o.subarray(n.BYTES,2*n.BYTES))}}throw Error(`Point of length ${e} was invalid. Expected ${f} compressed bytes or ${i} uncompressed bytes`)}{const t=O(o);if(!(ut<(s=t)&&s<n.ORDER))throw Error("Point is not on curve");const e=u(t);let f;try{f=n.sqrt(e)}catch(t){const e=t instanceof Error?": "+t.message:"";throw Error("Point is not on curve"+e)}return!(1&~r)!==((f&dt)===dt)&&(f=n.neg(f)),{x:t,y:f}}var s}}),l=t=>E(q(t,e.nByteLength));function h(t){return t>r>>dt}const g=(t,e,n)=>O(t.slice(e,n));class b{constructor(t,e,n){this.r=t,this.s=e,this.recovery=n,this.assertValidity()}static fromCompact(t){const n=e.nByteLength;return t=z("compactSignature",t,2*n),new b(g(t,0,n),g(t,n,2*n))}static fromDER(t){const{r:e,s:n}=ct.toSig(z("DER",t));return new b(e,n)}assertValidity(){if(!d(this.r))throw Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new b(this.r,this.s,t)}recoverPublicKey(t){const{r,s:f,recovery:i}=this,c=w(z("msgHash",t));if(null==i||![0,1,2,3].includes(i))throw Error("recovery id invalid");const u=2===i||3===i?r+e.n:r;if(u>=n.ORDER)throw Error("recovery id 2 or 3 invalid");const d=1&i?"03":"02",h=a.fromHex(d+l(u)),g=s(u),b=o(-c*g),y=o(f*g),p=a.BASE.multiplyAndAddUnsafe(h,b,y);if(!p)throw Error("point at infinify");return p.assertValidity(),p}hasHighS(){return h(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return A(this.toDERHex())}toDERHex(){return ct.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return A(this.toCompactHex())}toCompactHex(){return l(this.r)+l(this.s)}}const y={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=nt(e.n);return function(t,e,n=!1){const r=t.length,f=et(e),i=nt(e);if(r<16||r<i||r>1024)throw Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=D(n?O(t):R(t),e-$)+$;return n?P(o,f):q(o,f)}(e.randomBytes(t),e.n)},precompute:(t=8,e=a.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function p(t){const e=B(t),n="string"==typeof t,r=(e||n)&&t.length;return e?r===f||r===i:n?r===2*f||r===2*i:t instanceof a}const m=e.bits2int||function(t){const n=O(t),r=8*t.length-e.nBitLength;return r>0?n>>BigInt(r):n},w=e.bits2int_modN||function(t){return o(m(t))},x=H(e.nBitLength);function I(t){if("bigint"!=typeof t)throw Error("bigint expected");if(!(ut<=t&&t<x))throw Error("bigint expected < 2^"+e.nBitLength);return q(t,e.nByteLength)}function v(t,r,f=S){if(["recovered","canonical"].some((t=>t in f)))throw Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=e;let{lowS:l,prehash:g,extraEntropy:y}=f;null==l&&(l=!0),t=z("msgHash",t),g&&(t=z("prehashed msgHash",i(t)));const p=w(t),B=c(r),E=[I(B),I(p)];if(null!=y&&!1!==y){const t=!0===y?u(n.BYTES):y;E.push(z("extraEntropy",t))}const x=N(...E),v=p;return{seed:x,k2sig:function(t){const e=m(t);if(!d(e))return;const n=s(e),r=a.BASE.multiply(e).toAffine(),f=o(r.x);if(f===ut)return;const i=o(n*o(v+f*B));if(i===ut)return;let c=(r.x===f?0:2)|Number(r.y&dt),u=i;return l&&h(i)&&(u=function(t){return h(t)?o(-t):t}(i),c^=1),new b(f,u,c)}}}const S={lowS:e.lowS,prehash:!1},L={lowS:e.lowS,prehash:!1};return a.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return a.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,n=!0){if(p(t))throw Error("first arg must be private key");if(!p(e))throw Error("second arg must be public key");return a.fromHex(e).multiply(c(t)).toRawBytes(n)},sign:function(t,n,r=S){const{seed:f,k2sig:i}=v(t,n,r),o=e;return F(o.hash.outputLen,o.nByteLength,o.hmac)(f,i)},verify:function(t,n,r,f=L){const i=t;if(n=z("msgHash",n),r=z("publicKey",r),"strict"in f)throw Error("options.strict was renamed to lowS");const{lowS:c,prehash:u}=f;let d,l;try{if("string"==typeof i||B(i))try{d=b.fromDER(i)}catch(t){if(!(t instanceof ct.Err))throw t;d=b.fromCompact(i)}else{if("object"!=typeof i||"bigint"!=typeof i.r||"bigint"!=typeof i.s)throw Error("PARSE");{const{r:t,s:e}=i;d=new b(t,e)}}l=a.fromHex(r)}catch(t){if("PARSE"===t.message)throw Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=e.hash(n));const{r:h,s:g}=d,y=w(n),p=s(g),m=o(y*p),E=o(h*p),x=a.BASE.multiplyAndAddUnsafe(l,m,E)?.toAffine();return!!x&&o(x.x)===h},ProjectivePoint:a,Signature:b,utils:y}}
8
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function bt(t){return{hash:t,hmac:(e,...n)=>g(t,e,i(...n)),randomBytes:o}}function yt(t,e){const n=e=>gt({...t,...bt(e)});return Object.freeze({...n(e),create:n})}
9
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */BigInt(4);const pt=tt(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Bt=yt({a:pt.create(BigInt("-3")),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:pt,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},s),mt=tt(BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff")),wt=yt({a:mt.create(BigInt("-3")),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Fp:mt,n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f"),h:BigInt(1),lowS:!1},a),Et=tt(BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")),xt={a:Et.create(BigInt("-3")),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Fp:Et,n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650"),h:BigInt(1)},It=yt({a:xt.a,b:xt.b,Fp:Et,n:xt.n,Gx:xt.Gx,Gy:xt.Gy,h:xt.h,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},c),vt=BigInt(0),St=BigInt(1),At=BigInt(2),Ot=BigInt(8),Rt={zip215:!0};function qt(t){const e=function(t){const e=ot(t);return U(t,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}(t),{Fp:n,n:r,prehash:f,hash:i,randomBytes:o,nByteLength:s,h:a}=e,c=At<<BigInt(8*s)-St,u=n.create,d=e.uvRatio||((t,e)=>{try{return{isValid:!0,value:n.sqrt(t*n.inv(e))}}catch(t){return{isValid:!1,value:vt}}}),l=e.adjustScalarBytes||(t=>t),h=e.domain||((t,e,n)=>{if(e.length||n)throw Error("Contexts/pre-hash are not supported");return t}),g=t=>"bigint"==typeof t&&vt<t,b=(t,e)=>g(t)&&g(e)&&t<e,y=t=>t===vt||b(t,c);function p(t,e){if(b(t,e))return t;throw Error(`Expected valid scalar < ${e}, got ${typeof t} ${t}`)}function B(t){return t===vt?t:p(t,r)}const m=new Map;function w(t){if(!(t instanceof x))throw Error("ExtendedPoint expected")}class x{constructor(t,e,n,r){if(this.ex=t,this.ey=e,this.ez=n,this.et=r,!y(t))throw Error("x required");if(!y(e))throw Error("y required");if(!y(n))throw Error("z required");if(!y(r))throw Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(t){if(t instanceof x)throw Error("extended point not allowed");const{x:e,y:n}=t||{};if(!y(e)||!y(n))throw Error("invalid affine point");return new x(e,n,St,u(e*n))}static normalizeZ(t){const e=n.invertBatch(t.map((t=>t.ez)));return t.map(((t,n)=>t.toAffine(e[n]))).map(x.fromAffine)}_setWindowSize(t){this._WINDOW_SIZE=t,m.delete(this)}assertValidity(){const{a:t,d:n}=e;if(this.is0())throw Error("bad point: ZERO");const{ex:r,ey:f,ez:i,et:o}=this,s=u(r*r),a=u(f*f),c=u(i*i),d=u(c*c),l=u(s*t);if(u(c*u(l+a))!==u(d+u(n*u(s*a))))throw Error("bad point: equation left != right (1)");if(u(r*f)!==u(i*o))throw Error("bad point: equation left != right (2)")}equals(t){w(t);const{ex:e,ey:n,ez:r}=this,{ex:f,ey:i,ez:o}=t,s=u(e*o),a=u(f*r),c=u(n*o),d=u(i*r);return s===a&&c===d}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:t}=e,{ex:n,ey:r,ez:f}=this,i=u(n*n),o=u(r*r),s=u(At*u(f*f)),a=u(t*i),c=n+r,d=u(u(c*c)-i-o),l=a+o,h=l-s,g=a-o,b=u(d*h),y=u(l*g),p=u(d*g),B=u(h*l);return new x(b,y,B,p)}add(t){w(t);const{a:n,d:r}=e,{ex:f,ey:i,ez:o,et:s}=this,{ex:a,ey:c,ez:d,et:l}=t;if(n===BigInt(-1)){const t=u((i-f)*(c+a)),e=u((i+f)*(c-a)),n=u(e-t);if(n===vt)return this.double();const r=u(o*At*l),h=u(s*At*d),g=h+r,b=e+t,y=h-r,p=u(g*n),B=u(b*y),m=u(g*y),w=u(n*b);return new x(p,B,w,m)}const h=u(f*a),g=u(i*c),b=u(s*r*l),y=u(o*d),p=u((f+i)*(a+c)-h-g),B=y-b,m=y+b,E=u(g-n*h),I=u(p*B),v=u(m*E),S=u(p*E),A=u(B*m);return new x(I,v,A,S)}subtract(t){return this.add(t.negate())}wNAF(t){return S.wNAFCached(this,m,t,x.normalizeZ)}multiply(t){const{p:e,f:n}=this.wNAF(p(t,r));return x.normalizeZ([e,n])[0]}multiplyUnsafe(t){let e=B(t);return e===vt?v:this.equals(v)||e===St?this:this.equals(I)?this.wNAF(e).p:S.unsafeLadder(this,e)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return S.unsafeLadder(this,r).is0()}toAffine(t){const{ex:e,ey:r,ez:f}=this,i=this.is0();null==t&&(t=i?Ot:n.inv(f));const o=u(e*t),s=u(r*t),a=u(f*t);if(i)return{x:vt,y:St};if(a!==St)throw Error("invZ was invalid");return{x:o,y:s}}clearCofactor(){const{h:t}=e;return t===St?this:this.multiplyUnsafe(t)}static fromHex(t,r=!1){const{d:f,a:i}=e,o=n.BYTES,s=(t=z("pointHex",t,o)).slice(),a=t[o-1];s[o-1]=-129&a;const l=R(s);l===vt||p(l,r?c:n.ORDER);const h=u(l*l),g=u(h-St),b=u(f*h-i);let{isValid:y,value:B}=d(g,b);if(!y)throw Error("Point.fromHex: invalid y coordinate");const m=(B&St)===St,w=!!(128&a);if(!r&&B===vt&&w)throw Error("Point.fromHex: x=0 and x_0=1");return w!==m&&(B=u(-B)),x.fromAffine({x:B,y:l})}static fromPrivateKey(t){return q(t).point}toRawBytes(){const{x:t,y:e}=this.toAffine(),r=P(e,n.BYTES);return r[r.length-1]|=t&St?128:0,r}toHex(){return E(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,St,u(e.Gx*e.Gy)),x.ZERO=new x(vt,St,St,vt);const{BASE:I,ZERO:v}=x,S=it(x,8*s);function A(t){return D(t,r)}function O(t){return A(R(t))}function q(t){const e=s;t=z("private key",t,e);const n=z("hashed private key",i(t),2*e),r=l(n.slice(0,e)),f=n.slice(e,2*e),o=O(r),a=I.multiply(o),c=a.toRawBytes();return{head:r,prefix:f,scalar:o,point:a,pointBytes:c}}function H(t=new Uint8Array,...e){const n=N(...e);return O(i(h(n,z("context",t),!!f)))}const L=Rt;I._setWindowSize(8);return{CURVE:e,getPublicKey:function(t){return q(t).pointBytes},sign:function(t,e,r={}){t=z("message",t),f&&(t=f(t));const{prefix:i,scalar:o,pointBytes:a}=q(e),c=H(r.context,i,t),u=I.multiply(c).toRawBytes(),d=A(c+H(r.context,u,a,t)*o);return B(d),z("result",N(u,P(d,n.BYTES)),2*s)},verify:function(t,e,r,i=L){const{context:o,zip215:s}=i,a=n.BYTES;t=z("signature",t,2*a),e=z("message",e),f&&(e=f(e));const c=R(t.slice(a,2*a));let u,d,l;try{u=x.fromHex(r,s),d=x.fromHex(t.slice(0,a),s),l=I.multiplyUnsafe(c)}catch(t){return!1}if(!s&&u.isSmallOrder())return!1;const h=H(o,d.toRawBytes(),u.toRawBytes(),e);return d.add(u.multiplyUnsafe(h)).subtract(l).clearCofactor().equals(x.ZERO)},ExtendedPoint:x,utils:{getExtendedPublicKey:q,randomPrivateKey:()=>o(n.BYTES),precompute:(t=8,e=x.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)}}}
10
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Pt=BigInt(0),zt=BigInt(1);function Nt(t){const e=(U(n=t,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...n}));var n;const{P:r}=e,f=t=>D(t,r),i=e.montgomeryBits,o=Math.ceil(i/8),s=e.nByteLength,a=e.adjustScalarBytes||(t=>t),c=e.powPminus2||(t=>Y(t,r-BigInt(2),r));function u(t,e,n){const r=f(t*(e-n));return[e=f(e-r),n=f(n+r)]}function d(t){if("bigint"==typeof t&&Pt<=t&&t<r)return t;throw Error("Expected valid scalar 0 < scalar < CURVE.P")}const l=(e.a-BigInt(2))/BigInt(4);function h(t){return P(f(t),o)}function g(t,e){const n=function(t){const e=z("u coordinate",t,o);return 32===s&&(e[31]&=127),R(e)}(e),r=function(t){const e=z("scalar",t),n=e.length;if(n!==o&&n!==s)throw Error(`Expected ${o} or ${s} bytes, got ${n}`);return R(a(e))}(t),g=function(t,e){const n=d(t),r=d(e),o=n;let s,a=zt,h=Pt,g=n,b=zt,y=Pt;for(let t=BigInt(i-1);t>=Pt;t--){const e=r>>t&zt;y^=e,s=u(y,a,g),a=s[0],g=s[1],s=u(y,h,b),h=s[0],b=s[1],y=e;const n=a+h,i=f(n*n),c=a-h,d=f(c*c),p=i-d,B=g+b,m=f((g-b)*n),w=f(B*c),E=m+w,x=m-w;g=f(E*E),b=f(o*f(x*x)),a=f(i*d),h=f(p*(i+f(l*p)))}s=u(y,a,g),a=s[0],g=s[1],s=u(y,h,b),h=s[0],b=s[1];const p=c(h);return f(a*p)}(n,r);if(g===Pt)throw Error("Invalid private or public key received");return h(g)}const b=h(e.Gu);function y(t){return g(t,b)}return{scalarMult:g,scalarMultBase:y,getSharedSecret:(t,e)=>g(t,e),getPublicKey:t=>y(t),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:b}}
11
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ht=u((()=>l.create({dkLen:114}))),Lt=(u((()=>l.create({dkLen:64}))),BigInt("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018365439")),Tt=BigInt(1),Ft=BigInt(2),_t=BigInt(3);BigInt(4);const Ut=BigInt(11),Zt=BigInt(22),Gt=BigInt(44),$t=BigInt(88),kt=BigInt(223);function Ct(t){const e=Lt,n=t*t*t%e,r=n*n*t%e,f=W(r,_t,e)*r%e,i=W(f,_t,e)*r%e,o=W(i,Ft,e)*n%e,s=W(o,Ut,e)*o%e,a=W(s,Zt,e)*s%e,c=W(a,Gt,e)*a%e,u=W(c,$t,e)*c%e,d=W(u,Gt,e)*a%e,l=W(d,Ft,e)*n%e,h=W(l,Tt,e)*t%e;return W(h,kt,e)*l%e}function jt(t){return t[0]&=252,t[55]|=128,t[56]=0,t}const Vt=tt(Lt,456,!0),Kt={a:BigInt(1),d:BigInt("726838724295606890549323807888004534353641360687318060281490199180612328166730772686396383698676545930088884461843637361053498018326358"),Fp:Vt,n:BigInt("181709681073901722637330951972001133588410340171829515070372549795146003961539585716195755291692375963310293709091662304773755859649779"),nBitLength:456,h:BigInt(4),Gx:BigInt("224580040295924300187604334099896036246789641632564134246125461686950415467406032909029192869357953282578032075146446173674602635247710"),Gy:BigInt("298819210078481492676017930443930673437544040154080242095928241372331506189835876003536878655418784733982303233503462500531545062832660"),hash:Ht,randomBytes:o,adjustScalarBytes:jt,domain:(t,e,n)=>{if(e.length>255)throw Error("Context is too big: "+e.length);return i(d("SigEd448"),new Uint8Array([n?1:0,e.length]),e,t)},uvRatio:function(t,e){const n=Lt,r=D(t*t*e,n),f=D(r*t,n),i=D(f*r*e,n),o=D(f*Ct(i),n),s=D(o*o,n);return{isValid:D(s*e,n)===t,value:o}}},Dt=/* @__PURE__ */qt(Kt),Yt=/* @__PURE__ */(()=>Nt({a:BigInt(156326),montgomeryBits:448,nByteLength:56,P:Lt,Gu:BigInt(5),powPminus2:t=>{const e=Lt;return D(W(Ct(t),BigInt(2),e)*t,e)},adjustScalarBytes:jt,randomBytes:o}))();Vt.ORDER,BigInt(3),BigInt(4),BigInt(156326),BigInt("39082"),BigInt("78163"),BigInt("98944233647732219769177004876929019128417576295529901074099889598043702116001257856802131563896515373927712232092845883226922417596214"),BigInt("315019913931389607337177038330951043522456072897266928557328499619017160722351061360252776265186336876723201881398623946864393857820716"),BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
12
12
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
13
- const nt=Object.freeze(h.new("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f")),rt=Object.freeze(h.new("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"));Object.freeze(h.new(0));const ft=Object.freeze(h.new(1)),it=Object.freeze(h.new(2)),ot=(e,t)=>e.add(t.rightShift(ft)).idiv(t);const st=X(nt,void 0,void 0,{sqrt:function(e){const t=nt,n=h.new(3),r=h.new(6),f=h.new(11),i=h.new(22),o=h.new(23),s=h.new(44),a=h.new(88),c=e.mul(e).imul(e).imod(t),u=c.mul(c).imul(e).imod(t),d=Y(u,n,t).imul(u).imod(t),l=Y(d,n,t).imul(u).imod(t),b=Y(l,it,t).imul(c).imod(t),m=Y(b,f,t).imul(b).imod(t),w=Y(m,i,t).imul(m).imod(t),y=Y(w,s,t).imul(w).imod(t),p=Y(y,a,t).imul(y).imod(t),g=Y(p,s,t).imul(w).imod(t),E=Y(g,n,t).imul(u).imod(t),x=Y(E,o,t).imul(m).imod(t),B=Y(x,r,t).imul(c).imod(t),S=Y(B,it,t);if(!st.eql(st.sqr(S),e))throw Error("Cannot find square root");return S}}),at=me({a:h.new(0),b:h.new(7),Fp:st,n:rt,Gx:h.new("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:h.new("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:h.new(1),lowS:!0,endo:{beta:h.new("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=rt,n=h.new("0x3086d221a7d46bcde86c90e49284eb15"),r=ft.negate().imul(h.new("0xe4437ed6010e88286f547fa90abfe4c3")),f=h.new("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=h.new("0x100000000000000000000000000000000"),s=ot(i.mul(e),t),a=ot(r.negate().imul(e),t);let c=K(e.sub(s.mul(n)).sub(a.mul(f)),t),u=K(s.negate().mul(r).isub(a.mul(i)),t);const d=c.gt(o),l=u.gt(o);if(d&&(c=t.sub(c)),l&&(u=t.sub(u)),c.gt(o)||u.gt(o))throw Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:l,k2:u}}}},s);at.ProjectivePoint;const ct=new Map(Object.entries({nistP256:ye,nistP384:ge,nistP521:Be,brainpoolP256r1:ve,brainpoolP384r1:Ae,brainpoolP512r1:qe,secp256k1:at,x448:tt,ed448:et}));export{ct as nobleCurves};
13
+ const Wt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Mt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Jt=BigInt(1),Qt=BigInt(2),Xt=(t,e)=>(t+e/Qt)/e;const te=tt(Wt,void 0,void 0,{sqrt:function(t){const e=Wt,n=BigInt(3),r=BigInt(6),f=BigInt(11),i=BigInt(22),o=BigInt(23),s=BigInt(44),a=BigInt(88),c=t*t*t%e,u=c*c*t%e,d=W(u,n,e)*u%e,l=W(d,n,e)*u%e,h=W(l,Qt,e)*c%e,g=W(h,f,e)*h%e,b=W(g,i,e)*g%e,y=W(b,s,e)*b%e,p=W(y,a,e)*y%e,B=W(p,s,e)*b%e,m=W(B,n,e)*u%e,w=W(m,o,e)*g%e,E=W(w,r,e)*c%e,x=W(E,Qt,e);if(!te.eql(te.sqr(x),t))throw Error("Cannot find square root");return x}}),ee=yt({a:BigInt(0),b:BigInt(7),Fp:te,n:Mt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=Mt,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Jt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),f=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,o=BigInt("0x100000000000000000000000000000000"),s=Xt(i*t,e),a=Xt(-r*t,e);let c=D(t-s*n-a*f,e),u=D(-s*r-a*i,e);const d=c>o,l=u>o;if(d&&(c=e-c),l&&(u=e-u),c>o||u>o)throw Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:d,k1:c,k2neg:l,k2:u}}}},s);BigInt(0),ee.ProjectivePoint;const ne=tt(BigInt("0xa9fb57dba1eea9bc3e660a909d838d726e3bf623d52620282013481d1f6e5377")),re=yt({a:ne.create(BigInt("0x7d5a0975fc2c3057eef67530417affe7fb8055c126dc5c6ce94a4b44f330b5d9")),b:BigInt("0x26dc5c6ce94a4b44f330b5d9bbd77cbf958416295cf7e1ce6bccdc18ff8c07b6"),Fp:ne,n:BigInt("0xa9fb57dba1eea9bc3e660a909d838d718c397aa3b561a6f7901e0e82974856a7"),Gx:BigInt("0x8bd2aeb9cb7e57cb2c4b482ffc81b7afb9de27e1e3bd23c23a4453bd9ace3262"),Gy:BigInt("0x547ef835c3dac4fd97f8461a14611dc9c27745132ded8e545c1d54c72f046997"),h:BigInt(1),lowS:!1},s),fe=tt(BigInt("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b412b1da197fb71123acd3a729901d1a71874700133107ec53")),ie=yt({a:fe.create(BigInt("0x7bc382c63d8c150c3c72080ace05afa0c2bea28e4fb22787139165efba91f90f8aa5814a503ad4eb04a8c7dd22ce2826")),b:BigInt("0x04a8c7dd22ce28268b39b55416f0447c2fb77de107dcd2a62e880ea53eeb62d57cb4390295dbc9943ab78696fa504c11"),Fp:fe,n:BigInt("0x8cb91e82a3386d280f5d6f7e50e641df152f7109ed5456b31f166e6cac0425a7cf3ab6af6b7fc3103b883202e9046565"),Gx:BigInt("0x1d1c64f068cf45ffa2a63a81b7c13f6b8847a3e77ef14fe3db7fcafe0cbd10e8e826e03436d646aaef87b2e247d4af1e"),Gy:BigInt("0x8abe1d7520f9c2a45cb1eb8e95cfd55262b70b29feec5864e19c054ff99129280e4646217791811142820341263c5315"),h:BigInt(1),lowS:!1},a),oe=tt(BigInt("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca703308717d4d9b009bc66842aecda12ae6a380e62881ff2f2d82c68528aa6056583a48f3")),se=yt({a:oe.create(BigInt("0x7830a3318b603b89e2327145ac234cc594cbdd8d3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94ca")),b:BigInt("0x3df91610a83441caea9863bc2ded5d5aa8253aa10a2ef1c98b9ac8b57f1117a72bf2c7b9e7c1ac4d77fc94cadc083e67984050b75ebae5dd2809bd638016f723"),Fp:oe,n:BigInt("0xaadd9db8dbe9c48b3fd4e6ae33c9fc07cb308db3b3c9d20ed6639cca70330870553e5c414ca92619418661197fac10471db1d381085ddaddb58796829ca90069"),Gx:BigInt("0x81aee4bdd82ed9645a21322e9c4c6a9385ed9f70b5d916c1b43b62eef4d0098eff3b1f78e2d0d48d50d1687b93b97d5f7c6d5047406a5e688b352209bcb9f822"),Gy:BigInt("0x7dde385d566332ecc0eabfa9cf7822fdf209f70024a57b1aa000c55b881f8111b2dcde494a5f485e5bca4bd88a2763aed1ca2b2fa8f0540678cd1e0f3ad80892"),h:BigInt(1),lowS:!1},c),ae=new Map(Object.entries({nistP256:Bt,nistP384:wt,nistP521:It,brainpoolP256r1:re,brainpoolP384r1:ie,brainpoolP512r1:se,secp256k1:ee,x448:Yt,ed448:Dt}));export{ae as nobleCurves};
14
14
  //# sourceMappingURL=noble_curves.min.mjs.map