UNPKG

@dappykit/sdk

Version:

Web3 SDK for DApps

2 lines 1.11 MB
/*! For license information please see index.browser.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("./emptyModule.js")):"function"==typeof define&&define.amd?define(["./emptyModule.js"],t):"object"==typeof exports?exports.DappyKit=t(require("./emptyModule.js")):e.DappyKit=t(e["./emptyModule.js"])}(this,(e=>(()=>{"use strict";var t={92269:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getHash=i,t.createCurve=function(e,t){const n=t=>(0,o.weierstrass)({...e,...i(t)});return Object.freeze({...n(t),create:n})};const r=n(72815),a=n(93815),o=n(58116);function i(e){return{hash:e,hmac:(t,...n)=>(0,r.hmac)(e,t,(0,a.concatBytes)(...n)),randomBytes:a.randomBytes}}},831:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wNAF=function(e,t){return{constTimeNegate:s,hasPrecomputes:e=>1!==m(e),unsafeLadder(t,n,r=e.ZERO){let a=t;for(;n>o;)n&i&&(r=r.add(a)),a=a.double(),n>>=i;return r},precomputeWindow(e,n){const{windows:r,windowSize:a}=u(n,t),o=[];let i=e,s=i;for(let t=0;t<r;t++){s=i,o.push(s);for(let e=1;e<a;e++)s=s.add(i),o.push(s);i=s.double()}return o},wNAF(n,r,a){const{windows:o,windowSize:c}=u(n,t);let l=e.ZERO,d=e.BASE;const p=BigInt(2**n-1),f=2**n,m=BigInt(n);for(let e=0;e<o;e++){const t=e*c;let n=Number(a&p);a>>=m,n>c&&(n-=f,a+=i);const o=t,u=t+Math.abs(n)-1,y=e%2!=0,b=n<0;0===n?d=d.add(s(y,r[o])):l=l.add(s(b,r[u]))}return{p:l,f:d}},wNAFUnsafe(n,r,a,s=e.ZERO){const{windows:c,windowSize:l}=u(n,t),d=BigInt(2**n-1),p=2**n,f=BigInt(n);for(let e=0;e<c;e++){const t=e*l;if(a===o)break;let n=Number(a&d);if(a>>=f,n>l&&(n-=p,a+=i),0===n)continue;let c=r[t+Math.abs(n)-1];n<0&&(c=c.negate()),s=s.add(c)}return s},getPrecomputes(e,t,n){let r=p.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&p.set(t,n(r))),r},wNAFCached(e,t,n){const r=m(e);return this.wNAF(r,this.getPrecomputes(r,e,n),t)},wNAFCachedUnsafe(e,t,n,r){const a=m(e);return 1===a?this.unsafeLadder(e,t,r):this.wNAFUnsafe(a,this.getPrecomputes(a,e,n),t,r)},setWindowSize(e,n){c(n,t),f.set(e,n),p.delete(e)}}},t.pippenger=function(e,t,n,r){if(l(n,e),d(r,t),n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");const o=e.ZERO,i=(0,a.bitLen)(BigInt(n.length)),s=i>12?i-3:i>4?i-2:i?2:1,c=(1<<s)-1,u=new Array(c+1).fill(o),p=Math.floor((t.BITS-1)/s)*s;let f=o;for(let a=p;a>=0;a-=s){u.fill(o);for(let t=0;t<r.length;t++){const e=r[t],o=Number(e>>BigInt(a)&BigInt(c));u[o]=u[o].add(n[t])}let e=o;for(let t=u.length-1,n=o;t>0;t--)n=n.add(u[t]),e=e.add(n);if(f=f.add(e),0!==a)for(let t=0;t<s;t++)f=f.double()}return f},t.precomputeMSMUnsafe=function(e,t,n,r){c(r,t.BITS),l(n,e);const a=e.ZERO,o=2**r-1,i=Math.ceil(t.BITS/r),s=BigInt((1<<r)-1),u=n.map((e=>{const t=[];for(let n=0,r=e;n<o;n++)t.push(r),r=r.add(e);return t}));return e=>{if(d(e,t),e.length>n.length)throw new Error("array of scalars must be smaller than array of points");let o=a;for(let t=0;t<i;t++){if(o!==a)for(let e=0;e<r;e++)o=o.double();const n=BigInt(i*r-(t+1)*r);for(let t=0;t<e.length;t++){const r=e[t],a=Number(r>>n&s);a&&(o=o.add(u[t][a-1]))}}return o}},t.validateBasic=function(e){return(0,r.validateField)(e.Fp),(0,a.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,r.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};const r=n(6630),a=n(65565),o=BigInt(0),i=BigInt(1);function s(e,t){const n=t.negate();return e?n:t}function c(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function u(e,t){c(e,t);return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}}function l(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)}))}function d(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)}))}const p=new WeakMap,f=new WeakMap;function m(e){return f.get(e)||1}},39924:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.expand_message_xmd=u,t.expand_message_xof=l,t.hash_to_field=d,t.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[a,o,i,s]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r)))));return t=e.div(a,o),r=e.mul(r,e.div(i,s)),{x:t,y:r}}},t.createHasher=function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(r,a){const o=d(r,2,{...n,DST:n.DST,...a}),i=e.fromAffine(t(o[0])),s=e.fromAffine(t(o[1])),c=i.add(s).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,a){const o=d(r,1,{...n,DST:n.encodeDST,...a}),i=e.fromAffine(t(o[0])).clearCofactor();return i.assertValidity(),i},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(const e of n)if("bigint"!=typeof e)throw new Error("mapToCurve: expected array of bigints");const r=e.fromAffine(t(n)).clearCofactor();return r.assertValidity(),r}}};const r=n(6630),a=n(65565),o=a.bytesToNumberBE;function i(e,t){if(c(e),c(t),e<0||e>=1<<8*t)throw new Error("invalid I2OSP input: "+e);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function s(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function c(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function u(e,t,n,r){(0,a.abytes)(e),(0,a.abytes)(t),c(n),t.length>255&&(t=r((0,a.concatBytes)((0,a.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:o,blockLen:u}=r,l=Math.ceil(n/o);if(n>65535||l>255)throw new Error("expand_message_xmd: invalid lenInBytes");const d=(0,a.concatBytes)(t,i(t.length,1)),p=i(0,u),f=i(n,2),m=new Array(l),y=r((0,a.concatBytes)(p,e,f,i(0,1),d));m[0]=r((0,a.concatBytes)(y,i(1,1),d));for(let c=1;c<=l;c++){const e=[s(y,m[c-1]),i(c+1,1),d];m[c]=r((0,a.concatBytes)(...e))}return(0,a.concatBytes)(...m).slice(0,n)}function l(e,t,n,r,o){if((0,a.abytes)(e),(0,a.abytes)(t),c(n),t.length>255){const e=Math.ceil(2*r/8);t=o.create({dkLen:e}).update((0,a.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return o.create({dkLen:n}).update(e).update(i(n,2)).update(t).update(i(t.length,1)).digest()}function d(e,t,n){(0,a.validateObject)(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:i,k:s,m:d,hash:p,expand:f,DST:m}=n;(0,a.abytes)(e),c(t);const y="string"==typeof m?(0,a.utf8ToBytes)(m):m,b=i.toString(2).length,h=Math.ceil((b+s)/8),g=t*d*h;let v;if("xmd"===f)v=u(e,y,g,p);else if("xof"===f)v=l(e,y,g,s,p);else{if("_internal_pass"!==f)throw new Error('expand must be "xmd" or "xof"');v=e}const E=new Array(t);for(let a=0;a<t;a++){const e=new Array(d);for(let t=0;t<d;t++){const n=h*(t+a*d),s=v.subarray(n,n+h);e[t]=(0,r.mod)(o(s),i)}E[a]=e}return E}},6630:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isNegativeLE=void 0,t.mod=d,t.pow=p,t.pow2=function(e,t,n){let r=e;for(;t-- >a;)r*=r,r%=n;return r},t.invert=f,t.tonelliShanks=m,t.FpSqrt=y,t.validateField=function(e){const t=b.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,r.validateObject)(e,t)},t.FpPow=h,t.FpInvertBatch=g,t.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?f(n,e.ORDER):e.inv(n))},t.FpLegendre=v,t.FpIsSquare=function(e){const t=v(e.ORDER);return n=>{const r=t(e,n);return e.eql(r,e.ZERO)||e.eql(r,e.ONE)}},t.nLength=E,t.Field=function(e,t,n=!1,i={}){if(e<=a)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:s,nByteLength:c}=E(e,t);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const l=Object.freeze({ORDER:e,BITS:s,BYTES:c,MASK:(0,r.bitMask)(s),ZERO:a,ONE:o,create:t=>d(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return a<=t&&t<e},is0:e=>e===a,isOdd:e=>(e&o)===o,neg:t=>d(-t,e),eql:(e,t)=>e===t,sqr:t=>d(t*t,e),add:(t,n)=>d(t+n,e),sub:(t,n)=>d(t-n,e),mul:(t,n)=>d(t*n,e),pow:(e,t)=>h(l,e,t),div:(t,n)=>d(t*f(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>f(t,e),sqrt:i.sqrt||(t=>(u||(u=y(e)),u(l,t))),invertBatch:e=>g(l,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?(0,r.numberToBytesLE)(e,c):(0,r.numberToBytesBE)(e,c),fromBytes:e=>{if(e.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+e.length);return n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e)}});return Object.freeze(l)},t.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)},t.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n},t.hashToPrivateScalar=function(e,t,n=!1){const a=(e=(0,r.ensureBytes)("privateHash",e)).length,i=E(t).nByteLength+8;if(i<24||a<i||a>1024)throw new Error("hashToPrivateScalar: expected "+i+"-1024 bytes of input, got "+a);return d(n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e),t-o)+o},t.getFieldBytesLength=x,t.getMinHashLength=w,t.mapHashToField=function(e,t,n=!1){const a=e.length,i=x(t),s=w(t);if(a<16||a<s||a>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+a);const c=d(n?(0,r.bytesToNumberBE)(e):(0,r.bytesToNumberLE)(e),t-o)+o;return n?(0,r.numberToBytesLE)(c,i):(0,r.numberToBytesBE)(c,i)};const r=n(65565),a=BigInt(0),o=BigInt(1),i=BigInt(2),s=BigInt(3),c=BigInt(4),u=BigInt(5),l=BigInt(8);function d(e,t){const n=e%t;return n>=a?n:t+n}function p(e,t,n){if(t<a)throw new Error("invalid exponent, negatives unsupported");if(n<=a)throw new Error("invalid modulus");if(n===o)return a;let r=o;for(;t>a;)t&o&&(r=r*e%n),e=e*e%n,t>>=o;return r}function f(e,t){if(e===a)throw new Error("invert: expected non-zero number");if(t<=a)throw new Error("invert: expected positive modulus, got "+t);let n=d(e,t),r=t,i=a,s=o,c=o,u=a;for(;n!==a;){const e=r/n,t=r%n,a=i-c*e,o=s-u*e;r=n,n=t,i=c,s=u,c=a,u=o}if(r!==o)throw new Error("invert: does not exist");return d(i,t)}function m(e){const t=(e-o)/i;let n,r,s;for(n=e-o,r=0;n%i===a;n/=i,r++);for(s=i;s<e&&p(s,t,e)!==e-o;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(1===r){const t=(e+o)/c;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const u=(n+o)/i;return function(e,a){if(e.pow(a,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let i=r,c=e.pow(e.mul(e.ONE,s),n),l=e.pow(a,u),d=e.pow(a,n);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let r=e.sqr(d);t<i&&!e.eql(r,e.ONE);t++)r=e.sqr(r);const n=e.pow(c,o<<BigInt(i-t-1));c=e.sqr(n),l=e.mul(l,n),d=e.mul(d,c),i=t}return l}}function y(e){if(e%c===s){const t=(e+o)/c;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%l===u){const t=(e-u)/l;return function(e,n){const r=e.mul(n,i),a=e.pow(r,t),o=e.mul(n,a),s=e.mul(e.mul(o,i),a),c=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(c),n))throw new Error("Cannot find square root");return c}}return m(e)}t.isNegativeLE=(e,t)=>(d(e,t)&o)===o;const b=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function h(e,t,n){if(n<a)throw new Error("invalid exponent, negatives unsupported");if(n===a)return e.ONE;if(n===o)return t;let r=e.ONE,i=t;for(;n>a;)n&o&&(r=e.mul(r,i)),i=e.sqr(i),n>>=o;return r}function g(e,t){const n=new Array(t.length),r=t.reduce(((t,r,a)=>e.is0(r)?t:(n[a]=t,e.mul(t,r))),e.ONE),a=e.inv(r);return t.reduceRight(((t,r,a)=>e.is0(r)?t:(n[a]=e.mul(t,n[a]),e.mul(t,r))),a),n}function v(e){const t=(e-o)/i;return(e,n)=>e.pow(n,t)}function E(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function x(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function w(e){const t=x(e);return t+Math.ceil(t/2)}},65565:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.notImplemented=t.bitMask=void 0,t.isBytes=o,t.abytes=i,t.abool=function(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)},t.bytesToHex=c,t.numberToHexUnpadded=u,t.hexToNumber=l,t.hexToBytes=f,t.bytesToNumberBE=function(e){return l(c(e))},t.bytesToNumberLE=function(e){return i(e),l(c(Uint8Array.from(e).reverse()))},t.numberToBytesBE=m,t.numberToBytesLE=function(e,t){return m(e,t).reverse()},t.numberToVarBytesBE=function(e){return f(u(e))},t.ensureBytes=function(e,t,n){let r;if("string"==typeof t)try{r=f(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else{if(!o(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const a=r.length;if("number"==typeof n&&a!==n)throw new Error(e+" of length "+n+" expected, got "+a);return r},t.concatBytes=y,t.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},t.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))},t.inRange=h,t.aInRange=function(e,t,n,r){if(!h(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)},t.bitLen=function(e){let t;for(t=0;e>n;e>>=r,t+=1);return t},t.bitGet=function(e,t){return e>>BigInt(t)&r},t.bitSet=function(e,t,a){return e|(a?r:n)<<BigInt(t)},t.createHmacDrbg=function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");let r=g(e),a=g(e),o=0;const i=()=>{r.fill(1),a.fill(0),o=0},s=(...e)=>n(a,r,...e),c=(e=g())=>{a=s(v([0]),e),r=s(),0!==e.length&&(a=s(v([1]),e),r=s())},u=()=>{if(o++>=1e3)throw new 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 y(...n)};return(e,t)=>{let n;for(i(),c(e);!(n=t(u()));)c();return i(),n}},t.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const a=E[n];if("function"!=typeof a)throw new Error("invalid validator function");const o=e[t];if(!(r&&void 0===o||a(o,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+o)};for(const[a,o]of Object.entries(t))r(a,o,!1);for(const[a,o]of Object.entries(n))r(a,o,!0);return e},t.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const a=t.get(n);if(void 0!==a)return a;const o=e(n,...r);return t.set(n,o),o}};const n=BigInt(0),r=BigInt(1),a=BigInt(2);function o(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function i(e){if(!o(e))throw new Error("Uint8Array expected")}const s=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function c(e){i(e);let t="";for(let n=0;n<e.length;n++)t+=s[e[n]];return t}function u(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function l(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?n:BigInt("0x"+e)}const d={_0:48,_9:57,A:65,F:70,a:97,f:102};function p(e){return e>=d._0&&e<=d._9?e-d._0:e>=d.A&&e<=d.F?e-(d.A-10):e>=d.a&&e<=d.f?e-(d.a-10):void 0}function f(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let a=0,o=0;a<n;a++,o+=2){const t=p(e.charCodeAt(o)),n=p(e.charCodeAt(o+1));if(void 0===t||void 0===n){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[a]=16*t+n}return r}function m(e,t){return f(e.toString(16).padStart(2*t,"0"))}function y(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];i(n),t+=n.length}const n=new Uint8Array(t);for(let r=0,a=0;r<e.length;r++){const t=e[r];n.set(t,a),a+=t.length}return n}const b=e=>"bigint"==typeof e&&n<=e;function h(e,t,n){return b(e)&&b(t)&&b(n)&&t<=e&&e<n}t.bitMask=e=>(a<<BigInt(e-1))-r;const g=e=>new Uint8Array(e),v=e=>Uint8Array.from(e);const E={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||o(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)};t.notImplemented=()=>{throw new Error("not implemented")}},58116:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DER=void 0,t.weierstrassPoints=y,t.weierstrass=function(e){const n=function(e){const t=(0,r.validateBasic)(e);return o.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:c,n:u}=n,p=c.BYTES+1,f=2*c.BYTES+1;function m(e){return a.mod(e,u)}function b(e){return a.invert(e,u)}const{ProjectivePoint:h,normPrivateKeyToScalar:g,weierstrassEquation:v,isWithinCurveOrder:E}=y({...n,toBytes(e,t,n){const r=t.toAffine(),a=c.toBytes(r.x),s=o.concatBytes;return(0,i.abool)("isCompressed",n),n?s(Uint8Array.from([t.hasEvenY()?2:3]),a):s(Uint8Array.from([4]),a,c.toBytes(r.y))},fromBytes(e){const t=e.length,n=e[0],r=e.subarray(1);if(t!==p||2!==n&&3!==n){if(t===f&&4===n){return{x:c.fromBytes(r.subarray(0,c.BYTES)),y:c.fromBytes(r.subarray(c.BYTES,2*c.BYTES))}}throw new Error("invalid Point, expected length of "+p+", or uncompressed "+f+", got "+t)}{const e=o.bytesToNumberBE(r);if(!o.inRange(e,d,c.ORDER))throw new Error("Point is not on curve");const t=v(e);let i;try{i=c.sqrt(t)}catch(a){const e=a instanceof Error?": "+a.message:"";throw new Error("Point is not on curve"+e)}return!(1&~n)!==((i&d)===d)&&(i=c.neg(i)),{x:e,y:i}}}}),x=e=>o.bytesToHex(o.numberToBytesBE(e,n.nByteLength));function w(e){return e>u>>d}const P=(e,t,n)=>o.bytesToNumberBE(e.slice(t,n));class T{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const t=n.nByteLength;return e=(0,i.ensureBytes)("compactSignature",e,2*t),new T(P(e,0,t),P(e,t,2*t))}static fromDER(e){const{r:n,s:r}=t.DER.toSig((0,i.ensureBytes)("DER",e));return new T(n,r)}assertValidity(){o.aInRange("r",this.r,d,u),o.aInRange("s",this.s,d,u)}addRecoveryBit(e){return new T(this.r,this.s,e)}recoverPublicKey(e){const{r:t,s:r,recovery:a}=this,o=k((0,i.ensureBytes)("msgHash",e));if(null==a||![0,1,2,3].includes(a))throw new Error("recovery id invalid");const s=2===a||3===a?t+n.n:t;if(s>=c.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=1&a?"03":"02",l=h.fromHex(u+x(s)),d=b(s),p=m(-o*d),f=m(r*d),y=h.BASE.multiplyAndAddUnsafe(l,p,f);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new T(this.r,m(-this.s),this.recovery):this}toDERRawBytes(){return o.hexToBytes(this.toDERHex())}toDERHex(){return t.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return o.hexToBytes(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}const O={isValidPrivateKey(e){try{return g(e),!0}catch(t){return!1}},normPrivateKeyToScalar:g,randomPrivateKey:()=>{const e=a.getMinHashLength(n.n);return a.mapHashToField(n.randomBytes(e),n.n)},precompute:(e=8,t=h.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function A(e){const t=o.isBytes(e),n="string"==typeof e,r=(t||n)&&e.length;return t?r===p||r===f:n?r===2*p||r===2*f:e instanceof h}const C=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=o.bytesToNumberBE(e),r=8*e.length-n.nBitLength;return r>0?t>>BigInt(r):t},k=n.bits2int_modN||function(e){return m(C(e))},S=o.bitMask(n.nBitLength);function B(e){return o.aInRange("num < 2^"+n.nBitLength,e,l,S),o.numberToBytesBE(e,n.nByteLength)}function j(e,t,r=_){if(["recovered","canonical"].some((e=>e in r)))throw new Error("sign() legacy options not supported");const{hash:a,randomBytes:u}=n;let{lowS:p,prehash:f,extraEntropy:y}=r;null==p&&(p=!0),e=(0,i.ensureBytes)("msgHash",e),s(r),f&&(e=(0,i.ensureBytes)("prehashed msgHash",a(e)));const v=k(e),x=g(t),P=[B(x),B(v)];if(null!=y&&!1!==y){const e=!0===y?u(c.BYTES):y;P.push((0,i.ensureBytes)("extraEntropy",e))}const O=o.concatBytes(...P),A=v;return{seed:O,k2sig:function(e){const t=C(e);if(!E(t))return;const n=b(t),r=h.BASE.multiply(t).toAffine(),a=m(r.x);if(a===l)return;const o=m(n*m(A+a*x));if(o===l)return;let i=(r.x===a?0:2)|Number(r.y&d),s=o;return p&&w(o)&&(s=function(e){return w(e)?m(-e):e}(o),i^=1),new T(a,s,i)}}}const _={lowS:n.lowS,prehash:!1},I={lowS:n.lowS,prehash:!1};return h.BASE._setWindowSize(8),{CURVE:n,getPublicKey:function(e,t=!0){return h.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(A(e))throw new Error("first arg must be private key");if(!A(t))throw new Error("second arg must be public key");return h.fromHex(t).multiply(g(e)).toRawBytes(n)},sign:function(e,t,r=_){const{seed:a,k2sig:i}=j(e,t,r),s=n;return o.createHmacDrbg(s.hash.outputLen,s.nByteLength,s.hmac)(a,i)},verify:function(e,r,a,c=I){const u=e;r=(0,i.ensureBytes)("msgHash",r),a=(0,i.ensureBytes)("publicKey",a);const{lowS:l,prehash:d,format:p}=c;if(s(c),"strict"in c)throw new Error("options.strict was renamed to lowS");if(void 0!==p&&"compact"!==p&&"der"!==p)throw new Error("format must be compact or der");const f="string"==typeof u||o.isBytes(u),y=!f&&!p&&"object"==typeof u&&null!==u&&"bigint"==typeof u.r&&"bigint"==typeof u.s;if(!f&&!y)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let g,v;try{if(y&&(g=new T(u.r,u.s)),f){try{"compact"!==p&&(g=T.fromDER(u))}catch(S){if(!(S instanceof t.DER.Err))throw S}g||"der"===p||(g=T.fromCompact(u))}v=h.fromHex(a)}catch(B){return!1}if(!g)return!1;if(l&&g.hasHighS())return!1;d&&(r=n.hash(r));const{r:E,s:x}=g,w=k(r),P=b(x),O=m(w*P),A=m(E*P),C=h.BASE.multiplyAndAddUnsafe(v,O,A)?.toAffine();if(!C)return!1;return m(C.x)===E},ProjectivePoint:h,Signature:T,utils:O}},t.SWUFpSqrtRatio=b,t.mapToCurveSimpleSWU=function(e,t){if(a.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const n=b(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return r=>{let a,o,i,s,c,u,l,d;a=e.sqr(r),a=e.mul(a,t.Z),o=e.sqr(a),o=e.add(o,a),i=e.add(o,e.ONE),i=e.mul(i,t.B),s=e.cmov(t.Z,e.neg(o),!e.eql(o,e.ZERO)),s=e.mul(s,t.A),o=e.sqr(i),u=e.sqr(s),c=e.mul(u,t.A),o=e.add(o,c),o=e.mul(o,i),u=e.mul(u,s),c=e.mul(u,t.B),o=e.add(o,c),l=e.mul(a,i);const{isValid:p,value:f}=n(o,u);d=e.mul(a,r),d=e.mul(d,f),l=e.cmov(l,i,p),d=e.cmov(d,f,p);const m=e.isOdd(r)===e.isOdd(d);return d=e.cmov(e.neg(d),d,m),l=e.div(l,s),{x:l,y:d}}};const r=n(831),a=n(6630),o=n(65565),i=n(65565);function s(e){void 0!==e.lowS&&(0,i.abool)("lowS",e.lowS),void 0!==e.prehash&&(0,i.abool)("prehash",e.prehash)}const{bytesToNumberBE:c,hexToBytes:u}=o;t.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(e,n)=>{const{Err:r}=t.DER;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&n.length)throw new r("tlv.encode: unpadded data");const a=n.length/2,i=o.numberToHexUnpadded(a);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const s=a>127?o.numberToHexUnpadded(i.length/2|128):"";return o.numberToHexUnpadded(e)+s+i+n},decode(e,n){const{Err:r}=t.DER;let a=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(n.length<2||n[a++]!==e)throw new r("tlv.decode: wrong tlv");const o=n[a++];let i=0;if(!!(128&o)){const e=127&o;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const t=n.subarray(a,a+e);if(t.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===t[0])throw new r("tlv.decode(long): zero leftmost byte");for(const n of t)i=i<<8|n;if(a+=e,i<128)throw new r("tlv.decode(long): not minimal encoding")}else i=o;const s=n.subarray(a,a+i);if(s.length!==i)throw new r("tlv.decode: wrong value length");return{v:s,l:n.subarray(a+i)}}},_int:{encode(e){const{Err:n}=t.DER;if(e<l)throw new n("integer: negative integers are not allowed");let r=o.numberToHexUnpadded(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new n("unexpected DER parsing assertion: unpadded hex");return r},decode(e){const{Err:n}=t.DER;if(128&e[0])throw new n("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new n("invalid signature integer: unnecessary leading zero");return c(e)}},toSig(e){const{Err:n,_int:r,_tlv:a}=t.DER,i="string"==typeof e?u(e):e;o.abytes(i);const{v:s,l:c}=a.decode(48,i);if(c.length)throw new n("invalid signature: left bytes after parsing");const{v:l,l:d}=a.decode(2,s),{v:p,l:f}=a.decode(2,d);if(f.length)throw new n("invalid signature: left bytes after parsing");return{r:r.decode(l),s:r.decode(p)}},hexFromSig(e){const{_tlv:n,_int:r}=t.DER,a=n.encode(2,r.encode(e.r))+n.encode(2,r.encode(e.s));return n.encode(48,a)}};const l=BigInt(0),d=BigInt(1),p=BigInt(2),f=BigInt(3),m=BigInt(4);function y(e){const t=function(e){const t=(0,r.validateBasic)(e);o.validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:a,a:i}=t;if(n){if(!a.eql(i,a.ZERO))throw new Error("invalid 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 new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,s=a.Field(t.n,t.nBitLength),c=t.toBytes||((e,t,r)=>{const a=t.toAffine();return o.concatBytes(Uint8Array.from([4]),n.toBytes(a.x),n.toBytes(a.y))}),u=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 p(e){const{a:r,b:a}=t,o=n.sqr(e),i=n.mul(o,e);return n.add(n.add(i,n.mul(e,r)),a)}if(!n.eql(n.sqr(t.Gy),p(t.Gx)))throw new Error("bad generator point: equation left != right");function m(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:s,n:c}=t;if(n&&"bigint"!=typeof e){if(o.isBytes(e)&&(e=o.bytesToHex(e)),"string"!=typeof e||!n.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*r,"0")}let u;try{u="bigint"==typeof e?e:o.bytesToNumberBE((0,i.ensureBytes)("private key",e,r))}catch(l){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return s&&(u=a.mod(u,c)),o.aInRange("private key",u,d,c),u}function y(e){if(!(e instanceof g))throw new Error("ProjectivePoint expected")}const b=(0,i.memoized)(((e,t)=>{const{px:r,py:a,pz:o}=e;if(n.eql(o,n.ONE))return{x:r,y:a};const i=e.is0();null==t&&(t=i?n.ONE:n.inv(o));const s=n.mul(r,t),c=n.mul(a,t),u=n.mul(o,t);if(i)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:s,y:c}})),h=(0,i.memoized)((e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:r,y:a}=e.toAffine();if(!n.isValid(r)||!n.isValid(a))throw new Error("bad point: x or y not FE");const o=n.sqr(a),i=p(r);if(!n.eql(o,i))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class g{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required");Object.freeze(this)}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof g)throw new Error("projective point not allowed");const a=e=>n.eql(e,n.ZERO);return a(t)&&a(r)?g.ZERO:new g(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(g.fromAffine)}static fromHex(e){const t=g.fromAffine(u((0,i.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return g.BASE.multiply(m(e))}static msm(e,t){return(0,r.pippenger)(g,s,e,t)}_setWindowSize(e){E.setWindowSize(this,e)}assertValidity(){h(this)}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){y(e);const{px:t,py:r,pz:a}=this,{px:o,py:i,pz:s}=e,c=n.eql(n.mul(t,s),n.mul(o,a)),u=n.eql(n.mul(r,s),n.mul(i,a));return c&&u}negate(){return new g(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,a=n.mul(r,f),{px:o,py:i,pz:s}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,d=n.mul(o,o),p=n.mul(i,i),m=n.mul(s,s),y=n.mul(o,i);return y=n.add(y,y),l=n.mul(o,s),l=n.add(l,l),c=n.mul(e,l),u=n.mul(a,m),u=n.add(c,u),c=n.sub(p,u),u=n.add(p,u),u=n.mul(c,u),c=n.mul(y,c),l=n.mul(a,l),m=n.mul(e,m),y=n.sub(d,m),y=n.mul(e,y),y=n.add(y,l),l=n.add(d,d),d=n.add(l,d),d=n.add(d,m),d=n.mul(d,y),u=n.add(u,d),m=n.mul(i,s),m=n.add(m,m),d=n.mul(m,y),c=n.sub(c,d),l=n.mul(m,p),l=n.add(l,l),l=n.add(l,l),new g(c,u,l)}add(e){y(e);const{px:r,py:a,pz:o}=this,{px:i,py:s,pz:c}=e;let u=n.ZERO,l=n.ZERO,d=n.ZERO;const p=t.a,m=n.mul(t.b,f);let b=n.mul(r,i),h=n.mul(a,s),v=n.mul(o,c),E=n.add(r,a),x=n.add(i,s);E=n.mul(E,x),x=n.add(b,h),E=n.sub(E,x),x=n.add(r,o);let w=n.add(i,c);return x=n.mul(x,w),w=n.add(b,v),x=n.sub(x,w),w=n.add(a,o),u=n.add(s,c),w=n.mul(w,u),u=n.add(h,v),w=n.sub(w,u),d=n.mul(p,x),u=n.mul(m,v),d=n.add(u,d),u=n.sub(h,d),d=n.add(h,d),l=n.mul(u,d),h=n.add(b,b),h=n.add(h,b),v=n.mul(p,v),x=n.mul(m,x),h=n.add(h,v),v=n.sub(b,v),v=n.mul(p,v),x=n.add(x,v),b=n.mul(h,x),l=n.add(l,b),b=n.mul(w,x),u=n.mul(E,u),u=n.sub(u,b),b=n.mul(E,h),d=n.mul(w,d),d=n.add(d,b),new g(u,l,d)}subtract(e){return this.add(e.negate())}is0(){return this.equals(g.ZERO)}wNAF(e){return E.wNAFCached(this,e,g.normalizeZ)}multiplyUnsafe(e){const{endo:r,n:a}=t;o.aInRange("scalar",e,l,a);const i=g.ZERO;if(e===l)return i;if(this.is0()||e===d)return this;if(!r||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,e,g.normalizeZ);let{k1neg:s,k1:c,k2neg:u,k2:p}=r.splitScalar(e),f=i,m=i,y=this;for(;c>l||p>l;)c&d&&(f=f.add(y)),p&d&&(m=m.add(y)),y=y.double(),c>>=d,p>>=d;return s&&(f=f.negate()),u&&(m=m.negate()),m=new g(n.mul(m.px,r.beta),m.py,m.pz),f.add(m)}multiply(e){const{endo:r,n:a}=t;let i,s;if(o.aInRange("scalar",e,d,a),r){const{k1neg:t,k1:a,k2neg:o,k2:c}=r.splitScalar(e);let{p:u,f:l}=this.wNAF(a),{p:d,f:p}=this.wNAF(c);u=E.constTimeNegate(t,u),d=E.constTimeNegate(o,d),d=new g(n.mul(d.px,r.beta),d.py,d.pz),i=u.add(d),s=l.add(p)}else{const{p:t,f:n}=this.wNAF(e);i=t,s=n}return g.normalizeZ([i,s])[0]}multiplyAndAddUnsafe(e,t,n){const r=g.BASE,a=(e,t)=>t!==l&&t!==d&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=a(this,t).add(a(e,n));return o.is0()?void 0:o}toAffine(e){return b(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===d)return!0;if(n)return n(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===d?this:n?n(g,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return(0,i.abool)("isCompressed",e),this.assertValidity(),c(g,this,e)}toHex(e=!0){return(0,i.abool)("isCompressed",e),o.bytesToHex(this.toRawBytes(e))}}g.BASE=new g(t.Gx,t.Gy,n.ONE),g.ZERO=new g(n.ZERO,n.ONE,n.ZERO);const v=t.nBitLength,E=(0,r.wNAF)(g,t.endo?Math.ceil(v/2):v);return{CURVE:t,ProjectivePoint:g,normPrivateKeyToScalar:m,weierstrassEquation:p,isWithinCurveOrder:function(e){return o.inRange(e,d,t.n)}}}function b(e,t){const n=e.ORDER;let r=l;for(let f=n-d;f%p===l;f/=p)r+=d;const a=r,o=p<<a-d-d,i=o*p,s=(n-d)/i,c=(s-d)/p,u=i-d,y=o,b=e.pow(t,s),h=e.pow(t,(s+d)/p);let g=(t,n)=>{let r=b,o=e.pow(n,u),i=e.sqr(o);i=e.mul(i,n);let s=e.mul(t,i);s=e.pow(s,c),s=e.mul(s,o),o=e.mul(s,n),i=e.mul(s,t);let l=e.mul(i,o);s=e.pow(l,y);let f=e.eql(s,e.ONE);o=e.mul(i,h),s=e.mul(l,r),i=e.cmov(o,i,f),l=e.cmov(s,l,f);for(let c=a;c>d;c--){let t=c-p;t=p<<t-d;let n=e.pow(l,t);const a=e.eql(n,e.ONE);o=e.mul(i,r),r=e.mul(r,r),n=e.mul(l,r),i=e.cmov(o,i,a),l=e.cmov(n,l,a)}return{isValid:f,value:i}};if(e.ORDER%m===f){const n=(e.ORDER-f)/m,r=e.sqrt(e.neg(t));g=(t,a)=>{let o=e.sqr(a);const i=e.mul(t,a);o=e.mul(o,i);let s=e.pow(o,n);s=e.mul(s,i);const c=e.mul(s,r),u=e.mul(e.sqr(s),a),l=e.eql(u,t);return{isValid:l,value:e.cmov(c,s,l)}}}return g}},38165:(e,t)=>{function n(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function r(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");n(e.outputLen),n(e.blockLen)}function o(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function i(e,t){r(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}Object.defineProperty(t,"__esModule",{value:!0}),t.anumber=n,t.number=n,t.abytes=r,t.bytes=r,t.ahash=a,t.aexists=o,t.aoutput=i;const s={number:n,bytes:r,hash:a,exists:o,output:i};t.default=s},44802:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HashMD=t.Maj=t.Chi=void 0;const r=n(38165),a=n(93815);t.Chi=(e,t,n)=>e&t^~e&n;t.Maj=(e,t,n)=>e&t^e&n^t&n;class o extends a.Hash{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=(0,a.createView)(this.buffer)}update(e){(0,r.aexists)(this);const{view:t,buffer:n,blockLen:o}=this,i=(e=(0,a.toBytes)(e)).length;for(let r=0;r<i;){const s=Math.min(o-this.pos,i-r);if(s!==o)n.set(e.subarray(r,r+s),this.pos),this.pos+=s,r+=s,this.pos===o&&(this.process(t,0),this.pos=0);else{const t=(0,a.createView)(e);for(;o<=i-r;r+=o)this.process(t,r)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,r.aexists)(this),(0,r.aoutput)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:o,isLE:i}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let r=s;r<o;r++)t[r]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const a=BigInt(32),o=BigInt(4294967295),i=Number(n>>a&o),s=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+u,s,r)}(n,o-8,BigInt(8*this.length),i),this.process(n,0);const c=(0,a.createView)(e),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=u/4,d=this.get();if(l>d.length)throw new Error("_sha2: outputLen bigger than state");for(let r=0;r<l;r++)c.setUint32(4*r,d[r],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:a,destroyed:o,pos:i}=this;return e.length=r,e.pos=i,e.finished=a,e.destroyed=o,r%t&&e.buffer.set(n),e}}t.HashMD=o},1673:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},72815:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.hmac=t.HMAC=void 0;const r=n(38165),a=n(93815);class o extends a.Hash{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,(0,r.ahash)(e);const n=(0,a.toBytes)(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let r=0;r<i.length;r++)i[r]^=54;this.iHash.update(i),this.oHash=e.create();for(let r=0;r<i.length;r++)i[r]^=106;this.oHash.update(i),i.fill(0)}update(e){return(0,r.aexists)(this),this.iHash.update(e),this}digestInto(e){(0,r.aexists)(this),(0,r.abytes)(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:a,blockLen:o,outputLen:i}=this;return e.finished=r,e.destroyed=a,e.blockLen=o,e.outputLen=i,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}t.HMAC=o;t.hmac=(e,t,n)=>new o(e,t).update(n).digest(),t.hmac.create=(e,t)=>new o(e,t)},1359:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sha224=t.sha256=t.SHA256=void 0;const r=n(44802),a=n(93815),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint32Array(64);class c extends r.HashMD{constructor(){super(64,32,8,!1),this.A=0|i[0],this.B=0|i[1],this.C=0|i[2],this.D=0|i[3],this.E=0|i[4],this.F=0|i[5],this.G=0|i[6],this.H=0|i[7]}get(){const{A:e,B:t,C:n,D:r,E:a,F:o,G:i,H:s}=this;return[e,t,n,r,a,o,i,s]}set(e,t,n,r,a,o,i,s){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|a,this.F=0|o,this.G=0|i,this.H=0|s}process(e,t){for(let r=0;r<16;r++,t+=4)s[r]=e.getUint32(t,!1);for(let r=16;r<64;r++){const e=s[r-15],t=s[r-2],n=(0,a.rotr)(e,7)^(0,a.rotr)(e,18)^e>>>3,o=(0,a.rotr)(t,17)^(0,a.rotr)(t,19)^t>>>10;s[r]=o+s[r-7]+n+s[r-16]|0}let{A:n,B:i,C:c,D:u,E:l,F:d,G:p,H:f}=this;for(let m=0;m<64;m++){const e=f+((0,a.rotr)(l,6)^(0,a.rotr)(l,11)^(0,a.rotr)(l,25))+(0,r.Chi)(l,d,p)+o[m]+s[m]|0,t=((0,a.rotr)(n,2)^(0,a.rotr)(n,13)^(0,a.rotr)(n,22))+(0,r.Maj)(n,i,c)|0;f=p,p=d,d=l,l=u+e|0,u=c,c=i,i=n,n=e+t|0}n=n+this.A|0,i=i+this.B|0,c=c+this.C|0,u=u+this.D|0,l=l+this.E|0,d=d+this.F|0,p=p+this.G|0,f=f+this.H|0,this.set(n,i,c,u,l,d,p,f)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}t.SHA256=c;class u extends c{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}t.sha256=(0,a.wrapConstructor)((()=>new c)),t.sha224=(0,a.wrapConstructor)((()=>new u))},93815:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Hash=t.nextTick=t.byteSwapIfBE=t.byteSwap=t.isLE=t.rotl=t.rotr=t.createView=t.u32=t.u8=void 0,t.isBytes=function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name},t.byteSwap32=function(e){for(let n=0;n<e.length;n++)e[n]=(0,t.byteSwap)(e[n])},t.bytesToHex=function(e){(0,a.abytes)(e);let t="";for(let n=0;n<e.length;n++)t+=o[e[n]];return t},t.hexToBytes=function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let a=0,o=0;a<n;a++,o+=2){const t=s(e.charCodeAt(o)),n=s(e.charCodeAt(o+1));if(void 0===t||void 0===n){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[a]=16*t+n}return r},t.asyncLoop=async function(e,n,r){let a=Date.now();for(let o=0;o<e;o++){r(o);const e=Date.now()-a;e>=0&&e<n||(await(0,t.nextTick)(),a+=e)}},t.utf8ToBytes=c,t.toBytes=u,t.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const n=e[r];(0,a.abytes)(n),t+=n.length}const n=new Uint8Array(t);for(let r=0,a=0;r<e.length;r++){const t=e[r];n.set(t,a),a+=t.length}return n},t.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!=={}.toString.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)},t.wrapConstructor=function(e){const t=t=>e().update(u(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t},t.wrapConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(u(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},t.wrapXOFConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(u(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},t.randomBytes=function(e=32){if(r.crypto&&"function"==typeof r.crypto.getRandomValues)return r.crypto.getRandomValues(new Uint8Array(e));if(r.crypto&&"function"==typeof r.crypto.randomBytes)return r.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")};const r=n(1673),a=n(38165);t.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength);t.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));t.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);t.rotr=(e,t)=>e<<32-t|e>>>t;t.rotl=(e,t)=>e<<t|e>>>32-t>>>0,t.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];t.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,t.byteSwapIfBE=t.isLE?e=>e:e=>(0,t.byteSwap)(e);const o=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));const i={_0:48,_9:57,A:65,F:70,a:97,f:102};function s(e){return e>=i._0&&e<=i._9?e-i._0:e>=i.A&&e<=i.F?e-(i.A-10):e>=i.a&&e<=i.f?e-(i.a-10):void 0}function c(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function u(e){return"string"==typeof e&&(e=c(e)),(0,a.abytes)(e),e}t.nextTick=async()=>{};t.Hash=class{clone(){return this._cloneInto()}}},36968:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.encodeToCurve=t.hashToCurve=t.secp256r1=t.p256=void 0;const r=n(1359),a=n(92269),o=n(39924),i=n(6630),s=n(58116),c=(0,i.Field)(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),u=c.create(BigInt("-3")),l=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b");t.p256=(0,a.createCurve)({a:u,b:l,Fp:c,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},r.sha256),t.secp256r1=t.p256;const d=(()=>(0,s.mapToCurveSimpleSWU)(c,{A:u,B:l,Z:c.create(BigInt("-10"))}))(),p=(()=>(0,o.createHasher)(t.secp256r1.ProjectivePoint,(e=>d(e[0])),{DST:"P256_XMD:SHA-256_SSWU_RO_",encodeDST:"P256_XMD:SHA-256_SSWU_NU_",p:c.ORDER,m:1,k:128,expand:"xmd",hash:r.sha256}))();t.hashToCurve=p.hashToCurve,t.encodeToCurve=p.encodeToCurve},19998:(e,t)=>{function n(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function r(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function a(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");n(e.outputLen),n(e.blockLen)}function o(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function i(e,t){r(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}Object.defineProperty(t,"__esModule",{value:!0}),t.anumber=n,t.number=n,t.abytes=r,t.bytes=r,t.ahash=a,t.aexists=o,t.aoutput=i;const s={number:n,bytes:r,hash:a,exists:o,output:i};t.default=s},57807:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.add5L=t.add5H=t.add4H=t.add4L=t.add3H=t.add3L=t.rotlBL=t.rotlBH=t.rotlSL=t.rotlSH=t.rotr32L=t.rotr32H=t.rotrBL=t.rotrBH=t.rotrSL=t.rotrSH=t.shrSL=t.shrSH=t.toBig=void 0,t.fromBig=a,t.split=o,t.add=v;const n=BigInt(2**32-1),r=BigInt(32);function a(e,t=!1){return t?{h:Number(e&n),l:Number(e>>r&n)}:{h:0|Number(e>>r&n),l:0|Number(e&n)}}function o(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=a(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]}const i=(e,t)=>BigInt(e>>>0)<<r|BigInt(t>>>0);t.toBig=i;const s=(e,t,n)=>e>>>n;t.shrSH=s;const c=(e,t,n)=>e<<32-n|t>>>n;t.shrSL=c;const u=(e,t,n)=>e>>>n|t<<32-n;t.rotrSH=u;const l=(e,t,n)=>e<<32-n|t>>>n;t.rotrSL=l;const d=(e,t,n)=>e<<64-n|t>>>n-32;t.rotrBH=d;const p=(e,t,n)=>e>>>n-32|t<<64-n;t.rotrBL=p;const f=(e,t)=>t;t.rotr32H=f;const m=(e,t)=>e;t.rotr32L=m;const y=(e,t,n)=>e<<n|t>>>32-n;t.rotlSH=y;const b=(e,t,n)=>t<<n|e>>>32-n;t.rotlSL=b;const h=(e,t,n)=>t<<n-32|e>>>64-n;t.rotlBH=h;const g=(e,t,n)=>e<<n-32|t>>>64-n;function v(e,t,n,r){const a=(t>>>0)+(r>>>0);return{h:e+n+(a/2**32|0)|0,l:0|a}}t.rotlBL=g;const E=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);t.add3L=E;const x=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;t.add3H=x;const w=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);t.add4L=w;const P=(e,t,n,r,a)=>t+n+r+a+(e/2**32|0)|0;t.add4H=P;const T=(e,t,n,r,a)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(a>>>0);t.add5L=T;const O=(e,t,n,r,a,o)=>t+n+r+a+o+(e/2**32|0)|0;t.add5H=O;const A={fromBig:a,split:o,toBig:i,shrSH:s,shrSL:c,rotrSH:u,rotrSL:l,rotrBH:d,rotrBL:p,rotr32H:f,rotr32L:m,rotlSH:y,rotlSL:b,rotlBH:h,rotlBL:g,add:v,add3L:E,add3H:x,add4L:w,add4H:P,add5H:O,add5L:T};t.default=A},7288:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0,t.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},66526:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shake256=t.shake128=t.keccak_512=t.keccak_384=t.keccak_256=t.keccak_224=t.sha3_512=t.sha3_384=t.sha3_256=t.sha3_224=t.Keccak=void 0,t.keccakP=v;const r=n(19998),a=n(57807),o=n(74904),i=[],s=[],c=[],u=BigInt(0),l=BigInt(1),d=BigInt(2),p=BigInt(7),f=BigInt(256),m=BigInt(113);for(let P=0,T=l,O=1,A=0;P<24;P++){[O,A]=[A,(2*O+3*A)%5],i.push(2*(5*A+O)),s.push((P+1)*(P+2)/2%64);let e=u;for(let t=0;t<7;t++)T=(T<<l^(T>>p)*m)%f,T&d&&(e^=l<<(l<<BigInt(t))-l);c.push(e)}const[y,b]=(0,a.split)(c,!0),h=(e,t,n)=>n>32?(0,a.rotlBH)(e,t,n):(0,a.rotlSH)(e,t,n),g=(e,t,n)=>n>32?(0,a.rotlBL)(e,t,n):(0,a.rotlSL)(e,t,n);function v(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let r=0;r<10;r++)n[r]=e[r]^e[r+10]^e[r+20]^e[r+30]^e[r+40];for(let r=0;r<10;r+=2){const t=(r+8)%10,a=(r+2)%10,o=n[a],i=n[a+1],s=h(o,i,1)^n[t],c=g(o,i,1)^n[t+1];for(let n=0;n<50;n+=10)e[r+n]^=s,e[r+n+1]^=c}let t=e[2],a=e[3];for(let n=0;n<24;n++){const r=s[n],o=h(t,a,r),c=g(t,a,r),u=i[n];t=e[u],a=e[u+1],e[u]=o,e[u+1]=c}for(let r=0;r<50;r+=10){for(let t=0;t<10;t++)n[t]=e[r+t];for(let t=0;t<10;t++)e[r+t]^=~n[(t+2)%10]&n[(t+4)%10]}e[0]^=y[r],e[1]^=b[r]}n.fill(0)}class E extends o.Hash{constructor(e,t,n,a=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=a,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,r.anumber)(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,o.u32)(this.state)}keccak(){o.isLE||(0,o.byteSwap32)(this.state32),v(this.state32,this.rounds),o.isLE||(0,o.byteSwap32)(this.state32),this.posOut=0,this.pos=0}update(e){(0,r.aexists)(this);const{blockLen:t,state:n}=this,a=(e=(0,o.toBytes)(e)).length;for(let r=0;r<a;){const o=Math.min(t-this.pos,a-r);for(let t=0;t<o;t++)n[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){(0,r.aexists)(this,!1),(0,r.abytes)(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,a=e.length;r<a;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,a-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,r.anumber)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,r.aoutput)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:a,enableXOF:o}=this;return e||(e=new E(t,n,r,o,a)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=a,e.suffix=n,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}}t.Keccak=E;const x=(e,t,n)=>(0,o.wrapConstructor)((()=>new E(t,e,n)));t.sha3_224=x(6,144,28),t.sha3_256=x(6,136,32),t.sha3_384=x(6,104,48),t.sha3_512=x(6,72,64),t.keccak_224=x(1,144,28),t.keccak_256=x(1,136,32),t.keccak_384=x(1,104,48),t.keccak_512=x(1,72,64);const w=(e,t,n)=