@dappykit/sdk
Version:
Web3 SDK for DApps
2 lines • 1.18 MB
JavaScript
/*! For license information please see index.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=>(()=>{var t={92269:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getHash=s,t.createCurve=function(e,t){const n=t=>(0,o.weierstrass)({...e,...s(t)});return Object.freeze({...n(t),create:n})};const r=n(72815),a=n(93815),o=n(58116);function s(e){return{hash:e,hmac:(t,...n)=>(0,r.hmac)(e,t,(0,a.concatBytes)(...n)),randomBytes:a.randomBytes}}},831:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wNAF=function(e,t){return{constTimeNegate:i,hasPrecomputes:e=>1!==m(e),unsafeLadder(t,n,r=e.ZERO){let a=t;for(;n>o;)n&s&&(r=r.add(a)),a=a.double(),n>>=s;return r},precomputeWindow(e,n){const{windows:r,windowSize:a}=u(n,t),o=[];let s=e,i=s;for(let t=0;t<r;t++){i=s,o.push(i);for(let e=1;e<a;e++)i=i.add(s),o.push(i);s=i.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+=s);const o=t,u=t+Math.abs(n)-1,y=e%2!=0,b=n<0;0===n?d=d.add(i(y,r[o])):l=l.add(i(b,r[u]))}return{p:l,f:d}},wNAFUnsafe(n,r,a,i=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+=s),0===n)continue;let c=r[t+Math.abs(n)-1];n<0&&(c=c.negate()),i=i.add(c)}return i},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,s=(0,a.bitLen)(BigInt(n.length)),i=s>12?s-3:s>4?s-2:s?2:1,c=(1<<i)-1,u=new Array(c+1).fill(o),p=Math.floor((t.BITS-1)/i)*i;let f=o;for(let a=p;a>=0;a-=i){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<i;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,s=Math.ceil(t.BITS/r),i=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<s;t++){if(o!==a)for(let e=0;e<r;e++)o=o.double();const n=BigInt(s*r-(t+1)*r);for(let t=0;t<e.length;t++){const r=e[t],a=Number(r>>n&i);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),s=BigInt(1);function i(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)=>{"use strict";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,s,i]=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(s,i)),{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}),s=e.fromAffine(t(o[0])),i=e.fromAffine(t(o[1])),c=s.add(i).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,a){const o=d(r,1,{...n,DST:n.encodeDST,...a}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s},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 s(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 i(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,s(t.length,1)),p=s(0,u),f=s(n,2),m=new Array(l),y=r((0,a.concatBytes)(p,e,f,s(0,1),d));m[0]=r((0,a.concatBytes)(y,s(1,1),d));for(let c=1;c<=l;c++){const e=[i(y,m[c-1]),s(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(s(n,2)).update(t).update(s(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:s,k:i,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=s.toString(2).length,h=Math.ceil((b+i)/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,i,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),i=v.subarray(n,n+h);e[t]=(0,r.mod)(o(i),s)}E[a]=e}return E}},6630:(e,t,n)=>{"use strict";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,s={}){if(e<=a)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:i,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:i,BYTES:c,MASK:(0,r.bitMask)(i),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:s.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,s=E(t).nByteLength+8;if(s<24||a<s||a>1024)throw new Error("hashToPrivateScalar: expected "+s+"-1024 bytes of input, got "+a);return d(n?(0,r.bytesToNumberLE)(e):(0,r.bytesToNumberBE)(e),t-o)+o},t.getFieldBytesLength=w,t.getMinHashLength=x,t.mapHashToField=function(e,t,n=!1){const a=e.length,s=w(t),i=x(t);if(a<16||a<i||a>1024)throw new Error("expected "+i+"-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,s):(0,r.numberToBytesBE)(c,s)};const r=n(65565),a=BigInt(0),o=BigInt(1),s=BigInt(2),i=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,s=a,i=o,c=o,u=a;for(;n!==a;){const e=r/n,t=r%n,a=s-c*e,o=i-u*e;r=n,n=t,s=c,i=u,c=a,u=o}if(r!==o)throw new Error("invert: does not exist");return d(s,t)}function m(e){const t=(e-o)/s;let n,r,i;for(n=e-o,r=0;n%s===a;n/=s,r++);for(i=s;i<e&&p(i,t,e)!==e-o;i++)if(i>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)/s;return function(e,a){if(e.pow(a,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let s=r,c=e.pow(e.mul(e.ONE,i),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<s&&!e.eql(r,e.ONE);t++)r=e.sqr(r);const n=e.pow(c,o<<BigInt(s-t-1));c=e.sqr(n),l=e.mul(l,n),d=e.mul(d,c),s=t}return l}}function y(e){if(e%c===i){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,s),a=e.pow(r,t),o=e.mul(n,a),i=e.mul(e.mul(o,s),a),c=e.mul(o,e.sub(i,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,s=t;for(;n>a;)n&o&&(r=e.mul(r,s)),s=e.sqr(s),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)/s;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 w(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 x(e){const t=w(e);return t+Math.ceil(t/2)}},65565:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.notImplemented=t.bitMask=void 0,t.isBytes=o,t.abytes=s,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 s(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(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}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 s=()=>{r.fill(1),a.fill(0),o=0},i=(...e)=>n(a,r,...e),c=(e=g())=>{a=i(v([0]),e),r=i(),0!==e.length&&(a=i(v([1]),e),r=i())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=i();const t=r.slice();n.push(t),e+=r.length}return y(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(u()));)c();return s(),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 s(e){if(!o(e))throw new Error("Uint8Array expected")}const i=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function c(e){s(e);let t="";for(let n=0;n<e.length;n++)t+=i[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];s(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)=>{"use strict";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),i=o.concatBytes;return(0,s.abool)("isCompressed",n),n?i(Uint8Array.from([t.hasEvenY()?2:3]),a):i(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 s;try{s=c.sqrt(t)}catch(a){const e=a instanceof Error?": "+a.message:"";throw new Error("Point is not on curve"+e)}return!(1&~n)!==((s&d)===d)&&(s=c.neg(s)),{x:e,y:s}}}}),w=e=>o.bytesToHex(o.numberToBytesBE(e,n.nByteLength));function x(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,s.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,s.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=C((0,s.ensureBytes)("msgHash",e));if(null==a||![0,1,2,3].includes(a))throw new Error("recovery id invalid");const i=2===a||3===a?t+n.n:t;if(i>=c.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=1&a?"03":"02",l=h.fromHex(u+w(i)),d=b(i),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 x(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 w(this.r)+w(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 k=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},C=n.bits2int_modN||function(e){return m(k(e))},_=o.bitMask(n.nBitLength);function S(e){return o.aInRange("num < 2^"+n.nBitLength,e,l,_),o.numberToBytesBE(e,n.nByteLength)}function B(e,t,r=j){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,s.ensureBytes)("msgHash",e),i(r),f&&(e=(0,s.ensureBytes)("prehashed msgHash",a(e)));const v=C(e),w=g(t),P=[S(w),S(v)];if(null!=y&&!1!==y){const e=!0===y?u(c.BYTES):y;P.push((0,s.ensureBytes)("extraEntropy",e))}const O=o.concatBytes(...P),A=v;return{seed:O,k2sig:function(e){const t=k(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*w));if(o===l)return;let s=(r.x===a?0:2)|Number(r.y&d),i=o;return p&&x(o)&&(i=function(e){return x(e)?m(-e):e}(o),s^=1),new T(a,i,s)}}}const j={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=j){const{seed:a,k2sig:s}=B(e,t,r),i=n;return o.createHmacDrbg(i.hash.outputLen,i.nByteLength,i.hmac)(a,s)},verify:function(e,r,a,c=I){const u=e;r=(0,s.ensureBytes)("msgHash",r),a=(0,s.ensureBytes)("publicKey",a);const{lowS:l,prehash:d,format:p}=c;if(i(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(_){if(!(_ instanceof t.DER.Err))throw _}g||"der"===p||(g=T.fromCompact(u))}v=h.fromHex(a)}catch(S){return!1}if(!g)return!1;if(l&&g.hasHighS())return!1;d&&(r=n.hash(r));const{r:E,s:w}=g,x=C(r),P=b(w),O=m(x*P),A=m(E*P),k=h.BASE.multiplyAndAddUnsafe(v,O,A)?.toAffine();if(!k)return!1;return m(k.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,s,i,c,u,l,d;a=e.sqr(r),a=e.mul(a,t.Z),o=e.sqr(a),o=e.add(o,a),s=e.add(o,e.ONE),s=e.mul(s,t.B),i=e.cmov(t.Z,e.neg(o),!e.eql(o,e.ZERO)),i=e.mul(i,t.A),o=e.sqr(s),u=e.sqr(i),c=e.mul(u,t.A),o=e.add(o,c),o=e.mul(o,s),u=e.mul(u,i),c=e.mul(u,t.B),o=e.add(o,c),l=e.mul(a,s);const{isValid:p,value:f}=n(o,u);d=e.mul(a,r),d=e.mul(d,f),l=e.cmov(l,s,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,i),{x:l,y:d}}};const r=n(831),a=n(6630),o=n(65565),s=n(65565);function i(e){void 0!==e.lowS&&(0,s.abool)("lowS",e.lowS),void 0!==e.prehash&&(0,s.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,s=o.numberToHexUnpadded(a);if(s.length/2&128)throw new r("tlv.encode: long form length too big");const i=a>127?o.numberToHexUnpadded(s.length/2|128):"";return o.numberToHexUnpadded(e)+i+s+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 s=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)s=s<<8|n;if(a+=e,s<128)throw new r("tlv.decode(long): not minimal encoding")}else s=o;const i=n.subarray(a,a+s);if(i.length!==s)throw new r("tlv.decode: wrong value length");return{v:i,l:n.subarray(a+s)}}},_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,s="string"==typeof e?u(e):e;o.abytes(s);const{v:i,l:c}=a.decode(48,s);if(c.length)throw new n("invalid signature: left bytes after parsing");const{v:l,l:d}=a.decode(2,i),{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:s}=t;if(n){if(!a.eql(s,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,i=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),s=n.mul(o,e);return n.add(n.add(s,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:i,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,s.ensureBytes)("private key",e,r))}catch(l){throw new Error("invalid private key, expected hex or "+r+" bytes, got "+typeof e)}return i&&(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,s.memoized)(((e,t)=>{const{px:r,py:a,pz:o}=e;if(n.eql(o,n.ONE))return{x:r,y:a};const s=e.is0();null==t&&(t=s?n.ONE:n.inv(o));const i=n.mul(r,t),c=n.mul(a,t),u=n.mul(o,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(u,n.ONE))throw new Error("invZ was invalid");return{x:i,y:c}})),h=(0,s.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),s=p(r);if(!n.eql(o,s))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,s.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,i,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:s,pz:i}=e,c=n.eql(n.mul(t,i),n.mul(o,a)),u=n.eql(n.mul(r,i),n.mul(s,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:s,pz:i}=this;let c=n.ZERO,u=n.ZERO,l=n.ZERO,d=n.mul(o,o),p=n.mul(s,s),m=n.mul(i,i),y=n.mul(o,s);return y=n.add(y,y),l=n.mul(o,i),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(s,i),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:s,py:i,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,s),h=n.mul(a,i),v=n.mul(o,c),E=n.add(r,a),w=n.add(s,i);E=n.mul(E,w),w=n.add(b,h),E=n.sub(E,w),w=n.add(r,o);let x=n.add(s,c);return w=n.mul(w,x),x=n.add(b,v),w=n.sub(w,x),x=n.add(a,o),u=n.add(i,c),x=n.mul(x,u),u=n.add(h,v),x=n.sub(x,u),d=n.mul(p,w),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),w=n.mul(m,w),h=n.add(h,v),v=n.sub(b,v),v=n.mul(p,v),w=n.add(w,v),b=n.mul(h,w),l=n.add(l,b),b=n.mul(x,w),u=n.mul(E,u),u=n.sub(u,b),b=n.mul(E,h),d=n.mul(x,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 s=g.ZERO;if(e===l)return s;if(this.is0()||e===d)return this;if(!r||E.hasPrecomputes(this))return E.wNAFCachedUnsafe(this,e,g.normalizeZ);let{k1neg:i,k1:c,k2neg:u,k2:p}=r.splitScalar(e),f=s,m=s,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 i&&(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 s,i;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),s=u.add(d),i=l.add(p)}else{const{p:t,f:n}=this.wNAF(e);s=t,i=n}return g.normalizeZ([s,i])[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,s.abool)("isCompressed",e),this.assertValidity(),c(g,this,e)}toHex(e=!0){return(0,s.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,s=o*p,i=(n-d)/s,c=(i-d)/p,u=s-d,y=o,b=e.pow(t,i),h=e.pow(t,(i+d)/p);let g=(t,n)=>{let r=b,o=e.pow(n,u),s=e.sqr(o);s=e.mul(s,n);let i=e.mul(t,s);i=e.pow(i,c),i=e.mul(i,o),o=e.mul(i,n),s=e.mul(i,t);let l=e.mul(s,o);i=e.pow(l,y);let f=e.eql(i,e.ONE);o=e.mul(s,h),i=e.mul(l,r),s=e.cmov(o,s,f),l=e.cmov(i,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(s,r),r=e.mul(r,r),n=e.mul(l,r),s=e.cmov(o,s,a),l=e.cmov(n,l,a)}return{isValid:f,value:s}};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 s=e.mul(t,a);o=e.mul(o,s);let i=e.pow(o,n);i=e.mul(i,s);const c=e.mul(i,r),u=e.mul(e.sqr(i),a),l=e.eql(u,t);return{isValid:l,value:e.cmov(c,i,l)}}}return g}},38165:(e,t)=>{"use strict";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 s(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=s;const i={number:n,bytes:r,hash:a,exists:o,output:s};t.default=i},44802:(e,t,n)=>{"use strict";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,s=(e=(0,a.toBytes)(e)).length;for(let r=0;r<s;){const i=Math.min(o-this.pos,s-r);if(i!==o)n.set(e.subarray(r,r+i),this.pos),this.pos+=i,r+=i,this.pos===o&&(this.process(t,0),this.pos=0);else{const t=(0,a.createView)(e);for(;o<=s-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:s}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let r=i;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),s=Number(n>>a&o),i=Number(n&o),c=r?4:0,u=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+u,i,r)}(n,o-8,BigInt(8*this.length),s),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],s)}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:s}=this;return e.length=r,e.pos=s,e.finished=a,e.destroyed=o,r%t&&e.buffer.set(n),e}}t.HashMD=o},93997:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0;const r=n(77598);t.crypto=r&&"object"==typeof r&&"webcrypto"in r?r.webcrypto:r&&"object"==typeof r&&"randomBytes"in r?r:void 0},72815:(e,t,n)=>{"use strict";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,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let r=0;r<s.length;r++)s[r]^=54;this.iHash.update(s),this.oHash=e.create();for(let r=0;r<s.length;r++)s[r]^=106;this.oHash.update(s),s.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:s}=this;return e.finished=r,e.destroyed=a,e.blockLen=o,e.outputLen=s,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)=>{"use strict";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]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),i=new Uint32Array(64);class c extends r.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:e,B:t,C:n,D:r,E:a,F:o,G:s,H:i}=this;return[e,t,n,r,a,o,s,i]}set(e,t,n,r,a,o,s,i){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|s,this.H=0|i}process(e,t){for(let r=0;r<16;r++,t+=4)i[r]=e.getUint32(t,!1);for(let r=16;r<64;r++){const e=i[r-15],t=i[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;i[r]=o+i[r-7]+n+i[r-16]|0}let{A:n,B:s,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]+i[m]|0,t=((0,a.rotr)(n,2)^(0,a.rotr)(n,13)^(0,a.rotr)(n,22))+(0,r.Maj)(n,s,c)|0;f=p,p=d,d=l,l=u+e|0,u=c,c=s,s=n,n=e+t|0}n=n+this.A|0,s=s+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,s,c,u,l,d,p,f)}roundClean(){i.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)=>{"use strict";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=i(e.charCodeAt(o)),n=i(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(93997),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 s={_0:48,_9:57,A:65,F:70,a:97,f:102};function i(e){return e>=s._0&&e<=s._9?e-s._0:e>=s.A&&e<=s.F?e-(s.A-10):e>=s.a&&e<=s.f?e-(s.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)=>{"use strict";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),s=n(6630),i=n(58116),c=(0,s.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,i.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)=>{"use strict";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 s(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=s;const i={number:n,bytes:r,hash:a,exists:o,output:s};t.default=i},57807:(e,t)=>{"use strict";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:s,l:i}=a(e[o],t);[n[o],r[o]]=[s,i]}return[n,r]}const s=(e,t)=>BigInt(e>>>0)<<r|BigInt(t>>>0);t.toBig=s;const i=(e,t,n)=>e>>>n;t.shrSH=i;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 w=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;t.add3H=w;const x=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);t.add4L=x;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:s,shrSH:i,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:w,add4L:x,add4H:P,add5H:O,add5L:T};t.default=A},29592:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.crypto=void 0;const r=n(77598);t.crypto=r&&"object"==typeof r&&"webcrypto"in r?r.webcrypto:r&&"object"==typeof r&&"randomBytes"in r?r:void 0},66526:(e,t,n)=>{"use strict";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),s=[],i=[],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],s.push(2*(5*A+O)),i.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],s=n[a+1],i=h(o,s,1)^n[t],c=g(o,s,1)^n[t+1];for(let n=0;n<50;n+=10)e[r+n]^=i,e[r+n+1]^=c}let t=e[2],a=e[3];for(let n=0;n<24;n++){const r=i[n],o=h(t,a,r),c=g(t,a,r),u=s[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,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=a,this.rounds=s,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=thi