diff --git a/dist/custom-module-bundle.js b/dist/custom-module-bundle.js index af64f6a..f81bab2 100644 --- a/dist/custom-module-bundle.js +++ b/dist/custom-module-bundle.js @@ -1,2 +1,2 @@ /*! For license information please see custom-module-bundle.js.LICENSE.txt */ -var customModule;(()=>{var t={904:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createCurve=e.getHash=void 0;const n=r(569),o=r(89),i=r(551);function s(t){return{hash:t,hmac:(e,...r)=>(0,n.hmac)(t,e,(0,o.concatBytes)(...r)),randomBytes:o.randomBytes}}e.getHash=s,e.createCurve=function(t,e){const r=e=>(0,i.weierstrass)({...t,...s(e)});return Object.freeze({...r(e),create:r})}},525:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateBasic=e.wNAF=void 0;const n=r(632),o=r(219),i=BigInt(0),s=BigInt(1);e.wNAF=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,o=e;for(;r>i;)r&s&&(n=n.add(o)),o=o.double(),r>>=s;return n},precomputeWindow(t,e){const{windows:r,windowSize:o}=n(e),i=[];let s=t,a=s;for(let t=0;t>=d,n>f&&(n-=l,i+=s);const a=e,y=e+Math.abs(n)-1,p=t%2!=0,w=n<0;0===n?c=c.add(r(p,o[a])):u=u.add(r(w,o[y]))}return{p:u,f:c}},wNAFCached(t,e,r,n){const o=t._WINDOW_SIZE||1;let i=e.get(t);return i||(i=this.precomputeWindow(t,o),1!==o&&e.set(t,n(i))),this.wNAF(o,i,r)}}},e.validateBasic=function(t){return(0,n.validateField)(t.Fp),(0,o.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}},134:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createHasher=e.isogenyMap=e.hash_to_field=e.expand_message_xof=e.expand_message_xmd=void 0;const n=r(632),o=r(219),i=o.bytesToNumberBE;function s(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function a(t,e){const r=new Uint8Array(t.length);for(let n=0;n255&&(e=n((0,o.concatBytes)((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));const{outputLen:i,blockLen:c}=n,h=Math.ceil(r/i);if(h>255)throw new Error("Invalid xmd length");const l=(0,o.concatBytes)(e,s(e.length,1)),d=s(0,c),y=s(r,2),p=new Array(h),w=n((0,o.concatBytes)(d,t,y,s(0,1),l));p[0]=n((0,o.concatBytes)(w,s(1,1),l));for(let t=1;t<=h;t++){const e=[a(w,p[t-1]),s(t+1,1),l];p[t]=n((0,o.concatBytes)(...e))}return(0,o.concatBytes)(...p).slice(0,r)}function h(t,e,r,n,i){if(f(t),f(e),u(r),e.length>255){const t=Math.ceil(2*n/8);e=i.create({dkLen:t}).update((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(s(r,2)).update(e).update(s(e.length,1)).digest()}function l(t,e,r){(0,o.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:a,m:l,hash:d,expand:y,DST:p}=r;f(t),u(e);const w=function(t){if(t instanceof Uint8Array)return t;if("string"==typeof t)return(0,o.utf8ToBytes)(t);throw new Error("DST must be Uint8Array or string")}(p),g=s.toString(2).length,b=Math.ceil((g+a)/8),m=e*l*b;let E;if("xmd"===y)E=c(t,w,m,d);else if("xof"===y)E=h(t,w,m,a,d);else{if("_internal_pass"!==y)throw new Error('expand must be "xmd" or "xof"');E=t}const v=new Array(e);for(let t=0;tArray.from(t).reverse()));return(e,n)=>{const[o,i,s,a]=r.map((r=>r.reduce(((r,n)=>t.add(t.mul(r,e),n)))));return e=t.div(o,i),n=t.mul(n,t.div(s,a)),{x:e,y:n}}},e.createHasher=function(t,e,r){if("function"!=typeof e)throw new Error("mapToCurve() must be defined");return{hashToCurve(n,o){const i=l(n,2,{...r,DST:r.DST,...o}),s=t.fromAffine(e(i[0])),a=t.fromAffine(e(i[1])),f=s.add(a).clearCofactor();return f.assertValidity(),f},encodeToCurve(n,o){const i=l(n,1,{...r,DST:r.encodeDST,...o}),s=t.fromAffine(e(i[0])).clearCofactor();return s.assertValidity(),s}}}},632:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.mapHashToField=e.getMinHashLength=e.getFieldBytesLength=e.hashToPrivateScalar=e.FpSqrtEven=e.FpSqrtOdd=e.Field=e.nLength=e.FpIsSquare=e.FpDiv=e.FpInvertBatch=e.FpPow=e.validateField=e.isNegativeLE=e.FpSqrt=e.tonelliShanks=e.invert=e.pow2=e.pow=e.mod=void 0;const n=r(219),o=BigInt(0),i=BigInt(1),s=BigInt(2),a=BigInt(3),f=BigInt(4),u=BigInt(5),c=BigInt(8);function h(t,e){const r=t%e;return r>=o?r:e+r}function l(t,e,r){if(r<=o||e 0");if(r===i)return o;let n=i;for(;e>o;)e&i&&(n=n*t%r),t=t*t%r,e>>=i;return n}function d(t,e){if(t===o||e<=o)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=h(t,e),n=e,s=o,a=i,f=i,u=o;for(;r!==o;){const t=n/r,e=n%r,o=s-f*t,i=a-u*t;n=r,r=e,s=f,a=u,f=o,u=i}if(n!==i)throw new Error("invert: does not exist");return h(s,e)}function y(t){const e=(t-i)/s;let r,n,a;for(r=t-i,n=0;r%s===o;r/=s,n++);for(a=s;ao;)n*=n,n%=r;return n},e.invert=d,e.tonelliShanks=y,e.FpSqrt=p,e.isNegativeLE=(t,e)=>(h(t,e)&i)===i;const w=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function g(t,e,r){if(r 0");if(r===o)return t.ONE;if(r===i)return e;let n=t.ONE,s=e;for(;r>o;)r&i&&(n=t.mul(n,s)),s=t.sqr(s),r>>=i;return n}function b(t,e){const r=new Array(e.length),n=e.reduce(((e,n,o)=>t.is0(n)?e:(r[o]=e,t.mul(e,n))),t.ONE),o=t.inv(n);return e.reduceRight(((e,n,o)=>t.is0(n)?e:(r[o]=t.mul(e,r[o]),t.mul(e,n))),o),r}function m(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function E(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function v(t){const e=E(t);return e+Math.ceil(e/2)}e.validateField=function(t){const e=w.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,n.validateObject)(t,e)},e.FpPow=g,e.FpInvertBatch=b,e.FpDiv=function(t,e,r){return t.mul(e,"bigint"==typeof r?d(r,t.ORDER):t.inv(r))},e.FpIsSquare=function(t){const e=(t.ORDER-i)/s;return r=>{const n=t.pow(r,e);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}},e.nLength=m,e.Field=function(t,e,r=!1,s={}){if(t<=o)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:a,nByteLength:f}=m(t,e);if(f>2048)throw new Error("Field lengths over 2048 bytes are not supported");const u=p(t),c=Object.freeze({ORDER:t,BITS:a,BYTES:f,MASK:(0,n.bitMask)(a),ZERO:o,ONE:i,create:e=>h(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return o<=e&&et===o,isOdd:t=>(t&i)===i,neg:e=>h(-e,t),eql:(t,e)=>t===e,sqr:e=>h(e*e,t),add:(e,r)=>h(e+r,t),sub:(e,r)=>h(e-r,t),mul:(e,r)=>h(e*r,t),pow:(t,e)=>g(c,t,e),div:(e,r)=>h(e*d(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>d(e,t),sqrt:s.sqrt||(t=>u(c,t)),invertBatch:t=>b(c,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?(0,n.numberToBytesLE)(t,f):(0,n.numberToBytesBE)(t,f),fromBytes:t=>{if(t.length!==f)throw new Error(`Fp.fromBytes: expected ${f}, got ${t.length}`);return r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t)}});return Object.freeze(c)},e.FpSqrtOdd=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)},e.FpSqrtEven=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r},e.hashToPrivateScalar=function(t,e,r=!1){const o=(t=(0,n.ensureBytes)("privateHash",t)).length,s=m(e).nByteLength+8;if(s<24||o1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${o}`);return h(r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t),e-i)+i},e.getFieldBytesLength=E,e.getMinHashLength=v,e.mapHashToField=function(t,e,r=!1){const o=t.length,s=E(e),a=v(e);if(o<16||o1024)throw new Error(`expected ${a}-1024 bytes of input, got ${o}`);const f=h(r?(0,n.bytesToNumberBE)(t):(0,n.bytesToNumberLE)(t),e-i)+i;return r?(0,n.numberToBytesLE)(f,s):(0,n.numberToBytesBE)(f,s)}},219:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateObject=e.createHmacDrbg=e.bitMask=e.bitSet=e.bitGet=e.bitLen=e.utf8ToBytes=e.equalBytes=e.concatBytes=e.ensureBytes=e.numberToVarBytesBE=e.numberToBytesLE=e.numberToBytesBE=e.bytesToNumberLE=e.bytesToNumberBE=e.hexToBytes=e.hexToNumber=e.numberToHexUnpadded=e.bytesToHex=void 0;const r=BigInt(0),n=BigInt(1),o=BigInt(2),i=t=>t instanceof Uint8Array,s=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function a(t){if(!i(t))throw new Error("Uint8Array expected");let e="";for(let r=0;rt+e.length),0));let r=0;return t.forEach((t=>{if(!i(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}e.bytesToHex=a,e.numberToHexUnpadded=f,e.hexToNumber=u,e.hexToBytes=c,e.bytesToNumberBE=function(t){return u(a(t))},e.bytesToNumberLE=function(t){if(!i(t))throw new Error("Uint8Array expected");return u(a(Uint8Array.from(t).reverse()))},e.numberToBytesBE=h,e.numberToBytesLE=function(t,e){return h(t,e).reverse()},e.numberToVarBytesBE=function(t){return c(f(t))},e.ensureBytes=function(t,e,r){let n;if("string"==typeof e)try{n=c(e)}catch(r){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else{if(!i(e))throw new Error(`${t} must be hex string or Uint8Array`);n=Uint8Array.from(e)}const o=n.length;if("number"==typeof r&&o!==r)throw new Error(`${t} expected ${r} bytes, got ${o}`);return n},e.concatBytes=l,e.equalBytes=function(t,e){if(t.length!==e.length)return!1;for(let r=0;rr;t>>=n,e+=1);return e},e.bitGet=function(t,e){return t>>BigInt(e)&n},e.bitSet=(t,e,o)=>t|(o?n:r)<(o<new Uint8Array(t),y=t=>Uint8Array.from(t);e.createHmacDrbg=function(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=d(t),o=d(t),i=0;const s=()=>{n.fill(1),o.fill(0),i=0},a=(...t)=>r(o,n,...t),f=(t=d())=>{o=a(y([0]),t),n=a(),0!==t.length&&(o=a(y([1]),t),n=a())},u=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t{let r;for(s(),f(t);!(r=e(u()));)f();return s(),r}};const p={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};e.validateObject=function(t,e,r={}){const n=(e,r,n)=>{const o=p[r];if("function"!=typeof o)throw new Error(`Invalid validator "${r}", expected function`);const i=t[e];if(!(n&&void 0===i||o(i,t)))throw new Error(`Invalid param ${String(e)}=${i} (${typeof i}), expected ${r}`)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t}},551:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.mapToCurveSimpleSWU=e.SWUFpSqrtRatio=e.weierstrass=e.weierstrassPoints=e.DER=void 0;const n=r(632),o=r(219),i=r(219),s=r(525),{bytesToNumberBE:a,hexToBytes:f}=o;e.DER={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:r}=e.DER;if(t.length<2||2!==t[0])throw new r("Invalid signature integer tag");const n=t[1],o=t.subarray(2,n+2);if(!n||o.length!==n)throw new r("Invalid signature integer: wrong length");if(128&o[0])throw new r("Invalid signature integer: negative");if(0===o[0]&&!(128&o[1]))throw new r("Invalid signature integer: unnecessary leading zero");return{d:a(o),l:t.subarray(n+2)}},toSig(t){const{Err:r}=e.DER,n="string"==typeof t?f(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let o=n.length;if(o<2||48!=n[0])throw new r("Invalid signature tag");if(n[1]!==o-2)throw new r("Invalid signature: incorrect length");const{d:i,l:s}=e.DER._parseInt(n.subarray(2)),{d:a,l:u}=e.DER._parseInt(s);if(u.length)throw new r("Invalid signature: left bytes after parsing");return{r:i,s:a}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),o=e(r(t.r)),i=n.length/2,s=o.length/2,a=r(i),f=r(s);return`30${r(s+i+4)}02${f}${o}02${a}${n}`}};const u=BigInt(0),c=BigInt(1),h=BigInt(2),l=BigInt(3),d=BigInt(4);function y(t){const e=function(t){const e=(0,s.validateBasic)(t);o.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,a=e.toBytes||((t,e,n)=>{const i=e.toAffine();return o.concatBytes(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),f=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function h(t){const{a:n,b:o}=e,i=r.sqr(t),s=r.mul(i,t);return r.add(r.add(s,r.mul(t,n)),o)}if(!r.eql(r.sqr(e.Gy),h(e.Gx)))throw new Error("bad generator point: equation left != right");function d(t){return"bigint"==typeof t&&ur.eql(t,r.ZERO);return o(e)&&o(n)?b.ZERO:new b(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(b.fromAffine)}static fromHex(t){const e=b.fromAffine(f((0,i.ensureBytes)("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return b.BASE.multiply(p(t))}_setWindowSize(t){this._WINDOW_SIZE=t,w.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const o=r.sqr(n),i=h(t);if(!r.eql(o,i))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){g(t);const{px:e,py:n,pz:o}=this,{px:i,py:s,pz:a}=t,f=r.eql(r.mul(e,a),r.mul(i,o)),u=r.eql(r.mul(n,a),r.mul(s,o));return f&&u}negate(){return new b(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,o=r.mul(n,l),{px:i,py:s,pz:a}=this;let f=r.ZERO,u=r.ZERO,c=r.ZERO,h=r.mul(i,i),d=r.mul(s,s),y=r.mul(a,a),p=r.mul(i,s);return p=r.add(p,p),c=r.mul(i,a),c=r.add(c,c),f=r.mul(t,c),u=r.mul(o,y),u=r.add(f,u),f=r.sub(d,u),u=r.add(d,u),u=r.mul(f,u),f=r.mul(p,f),c=r.mul(o,c),y=r.mul(t,y),p=r.sub(h,y),p=r.mul(t,p),p=r.add(p,c),c=r.add(h,h),h=r.add(c,h),h=r.add(h,y),h=r.mul(h,p),u=r.add(u,h),y=r.mul(s,a),y=r.add(y,y),h=r.mul(y,p),f=r.sub(f,h),c=r.mul(y,d),c=r.add(c,c),c=r.add(c,c),new b(f,u,c)}add(t){g(t);const{px:n,py:o,pz:i}=this,{px:s,py:a,pz:f}=t;let u=r.ZERO,c=r.ZERO,h=r.ZERO;const d=e.a,y=r.mul(e.b,l);let p=r.mul(n,s),w=r.mul(o,a),m=r.mul(i,f),E=r.add(n,o),v=r.add(s,a);E=r.mul(E,v),v=r.add(p,w),E=r.sub(E,v),v=r.add(n,i);let B=r.add(s,f);return v=r.mul(v,B),B=r.add(p,m),v=r.sub(v,B),B=r.add(o,i),u=r.add(a,f),B=r.mul(B,u),u=r.add(w,m),B=r.sub(B,u),h=r.mul(d,v),u=r.mul(y,m),h=r.add(u,h),u=r.sub(w,h),h=r.add(w,h),c=r.mul(u,h),w=r.add(p,p),w=r.add(w,p),m=r.mul(d,m),v=r.mul(y,v),w=r.add(w,m),m=r.sub(p,m),m=r.mul(d,m),v=r.add(v,m),p=r.mul(w,v),c=r.add(c,p),p=r.mul(B,v),u=r.mul(E,u),u=r.sub(u,p),p=r.mul(E,w),h=r.mul(B,h),h=r.add(h,p),new b(u,c,h)}subtract(t){return this.add(t.negate())}is0(){return this.equals(b.ZERO)}wNAF(t){return E.wNAFCached(this,w,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(b.fromAffine)}))}multiplyUnsafe(t){const n=b.ZERO;if(t===u)return n;if(y(t),t===c)return this;const{endo:o}=e;if(!o)return E.unsafeLadder(this,t);let{k1neg:i,k1:s,k2neg:a,k2:f}=o.splitScalar(t),h=n,l=n,d=this;for(;s>u||f>u;)s&c&&(h=h.add(d)),f&c&&(l=l.add(d)),d=d.double(),s>>=c,f>>=c;return i&&(h=h.negate()),a&&(l=l.negate()),l=new b(r.mul(l.px,o.beta),l.py,l.pz),h.add(l)}multiply(t){y(t);let n,o,i=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:f}=s.splitScalar(i);let{p:u,f:c}=this.wNAF(e),{p:h,f:l}=this.wNAF(f);u=E.constTimeNegate(t,u),h=E.constTimeNegate(a,h),h=new b(r.mul(h.px,s.beta),h.py,h.pz),n=u.add(h),o=c.add(l)}else{const{p:t,f:e}=this.wNAF(i);n=t,o=e}return b.normalizeZ([n,o])[0]}multiplyAndAddUnsafe(t,e,r){const n=b.BASE,o=(t,e)=>e!==u&&e!==c&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),i=o(this,e).add(o(t,r));return i.is0()?void 0:i}toAffine(t){const{px:e,py:n,pz:o}=this,i=this.is0();null==t&&(t=i?r.ONE:r.inv(o));const s=r.mul(e,t),a=r.mul(n,t),f=r.mul(o,t);if(i)return{x:r.ZERO,y:r.ZERO};if(!r.eql(f,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===c)return!0;if(r)return r(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===c?this:r?r(b,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),a(b,this,t)}toHex(t=!0){return o.bytesToHex(this.toRawBytes(t))}}b.BASE=new b(e.Gx,e.Gy,r.ONE),b.ZERO=new b(r.ZERO,r.ONE,r.ZERO);const m=e.nBitLength,E=(0,s.wNAF)(b,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:p,weierstrassEquation:h,isWithinCurveOrder:d}}function p(t,e){const r=t.ORDER;let n=u;for(let t=r-c;t%h===u;t/=h)n+=c;const o=n,i=h<{let n=w,i=t.pow(r,y),s=t.sqr(i);s=t.mul(s,r);let a=t.mul(e,s);a=t.pow(a,f),a=t.mul(a,i),i=t.mul(a,r),s=t.mul(a,e);let u=t.mul(s,i);a=t.pow(u,p);let l=t.eql(a,t.ONE);i=t.mul(s,g),a=t.mul(u,n),s=t.cmov(i,s,l),u=t.cmov(a,u,l);for(let e=o;e>c;e--){let r=e-h;r=h<{let i=t.sqr(o);const s=t.mul(e,o);i=t.mul(i,s);let a=t.pow(i,r);a=t.mul(a,s);const f=t.mul(a,n),u=t.mul(t.sqr(a),o),c=t.eql(u,e);return{isValid:c,value:t.cmov(f,a,c)}}}return b}e.weierstrassPoints=y,e.weierstrass=function(t){const r=function(t){const e=(0,s.validateBasic)(t);return o.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:a,n:f}=r,h=a.BYTES+1,l=2*a.BYTES+1;function d(t){return n.mod(t,f)}function p(t){return n.invert(t,f)}const{ProjectivePoint:w,normPrivateKeyToScalar:g,weierstrassEquation:b,isWithinCurveOrder:m}=y({...r,toBytes(t,e,r){const n=e.toAffine(),i=a.toBytes(n.x),s=o.concatBytes;return r?s(Uint8Array.from([e.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,a.toBytes(n.y))},fromBytes(t){const e=t.length,r=t[0],n=t.subarray(1);if(e!==h||2!==r&&3!==r){if(e===l&&4===r)return{x:a.fromBytes(n.subarray(0,a.BYTES)),y:a.fromBytes(n.subarray(a.BYTES,2*a.BYTES))};throw new Error(`Point of length ${e} was invalid. Expected ${h} compressed bytes or ${l} uncompressed bytes`)}{const t=o.bytesToNumberBE(n);if(!(u<(i=t)&&io.bytesToHex(o.numberToBytesBE(t,r.nByteLength));function v(t){return t>f>>c}const B=(t,e,r)=>o.bytesToNumberBE(t.slice(e,r));class x{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const e=r.nByteLength;return t=(0,i.ensureBytes)("compactSignature",t,2*e),new x(B(t,0,e),B(t,e,2*e))}static fromDER(t){const{r,s:n}=e.DER.toSig((0,i.ensureBytes)("DER",t));return new x(r,n)}assertValidity(){if(!m(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!m(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new x(this.r,this.s,t)}recoverPublicKey(t){const{r:e,s:n,recovery:o}=this,s=U((0,i.ensureBytes)("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const f=2===o||3===o?e+r.n:e;if(f>=a.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=0==(1&o)?"02":"03",c=w.fromHex(u+E(f)),h=p(f),l=d(-s*h),y=d(n*h),g=w.BASE.multiplyAndAddUnsafe(c,l,y);if(!g)throw new Error("point at infinify");return g.assertValidity(),g}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return o.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return o.hexToBytes(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}const A={isValidPrivateKey(t){try{return g(t),!0}catch(t){return!1}},normPrivateKeyToScalar:g,randomPrivateKey:()=>{const t=n.getMinHashLength(r.n);return n.mapHashToField(r.randomBytes(t),r.n)},precompute:(t=8,e=w.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function S(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===h||n===l:r?n===2*h||n===2*l:t instanceof w}const T=r.bits2int||function(t){const e=o.bytesToNumberBE(t),n=8*t.length-r.nBitLength;return n>0?e>>BigInt(n):e},U=r.bits2int_modN||function(t){return d(T(t))},_=o.bitMask(r.nBitLength);function O(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(u<=t&&t<_))throw new Error(`bigint expected < 2^${r.nBitLength}`);return o.numberToBytesBE(t,r.nByteLength)}const I={lowS:r.lowS,prehash:!1},L={lowS:r.lowS,prehash:!1};return w.BASE._setWindowSize(8),{CURVE:r,getPublicKey:function(t,e=!0){return w.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(S(t))throw new Error("first arg must be private key");if(!S(e))throw new Error("second arg must be public key");return w.fromHex(e).multiply(g(t)).toRawBytes(r)},sign:function(t,e,n=I){const{seed:s,k2sig:f}=function(t,e,n=I){if(["recovered","canonical"].some((t=>t in n)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:f}=r;let{lowS:h,prehash:l,extraEntropy:y}=n;null==h&&(h=!0),t=(0,i.ensureBytes)("msgHash",t),l&&(t=(0,i.ensureBytes)("prehashed msgHash",s(t)));const b=U(t),E=g(e),B=[O(E),O(b)];if(null!=y){const t=!0===y?f(a.BYTES):y;B.push((0,i.ensureBytes)("extraEntropy",t))}const A=o.concatBytes(...B),S=b;return{seed:A,k2sig:function(t){const e=T(t);if(!m(e))return;const r=p(e),n=w.BASE.multiply(e).toAffine(),o=d(n.x);if(o===u)return;const i=d(r*d(S+o*E));if(i===u)return;let s=(n.x===o?0:2)|Number(n.y&c),a=i;return h&&v(i)&&(a=function(t){return v(t)?d(-t):t}(i),s^=1),new x(o,a,s)}}}(t,e,n),h=r;return o.createHmacDrbg(h.hash.outputLen,h.nByteLength,h.hmac)(s,f)},verify:function(t,n,o,s=L){const a=t;if(n=(0,i.ensureBytes)("msgHash",n),o=(0,i.ensureBytes)("publicKey",o),"strict"in s)throw new Error("options.strict was renamed to lowS");const{lowS:f,prehash:u}=s;let c,h;try{if("string"==typeof a||a instanceof Uint8Array)try{c=x.fromDER(a)}catch(t){if(!(t instanceof e.DER.Err))throw t;c=x.fromCompact(a)}else{if("object"!=typeof a||"bigint"!=typeof a.r||"bigint"!=typeof a.s)throw new Error("PARSE");{const{r:t,s:e}=a;c=new x(t,e)}}h=w.fromHex(o)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(f&&c.hasHighS())return!1;u&&(n=r.hash(n));const{r:l,s:y}=c,g=U(n),b=p(y),m=d(g*b),E=d(l*b),v=w.BASE.multiplyAndAddUnsafe(h,m,E)?.toAffine();return!!v&&d(v.x)===l},ProjectivePoint:w,Signature:x,utils:A}},e.SWUFpSqrtRatio=p,e.mapToCurveSimpleSWU=function(t,e){if(n.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=p(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let o,i,s,a,f,u,c,h;o=t.sqr(n),o=t.mul(o,e.Z),i=t.sqr(o),i=t.add(i,o),s=t.add(i,t.ONE),s=t.mul(s,e.B),a=t.cmov(e.Z,t.neg(i),!t.eql(i,t.ZERO)),a=t.mul(a,e.A),i=t.sqr(s),u=t.sqr(a),f=t.mul(u,e.A),i=t.add(i,f),i=t.mul(i,s),u=t.mul(u,a),f=t.mul(u,e.B),i=t.add(i,f),c=t.mul(o,s);const{isValid:l,value:d}=r(i,u);h=t.mul(o,n),h=t.mul(h,d),c=t.cmov(c,s,l),h=t.cmov(h,d,l);const y=t.isOdd(n)===t.isOdd(h);return h=t.cmov(t.neg(h),h,y),c=t.div(c,a),{x:c,y:h}}}},497:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0;const n=r(61),o=r(89),i=r(632),s=r(551),a=r(219),f=r(134),u=r(904),c=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),h=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),l=BigInt(1),d=BigInt(2),y=(t,e)=>(t+e/d)/e;function p(t){const e=c,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),a=BigInt(23),f=BigInt(44),u=BigInt(88),h=t*t*t%e,l=h*h*t%e,y=(0,i.pow2)(l,r,e)*l%e,p=(0,i.pow2)(y,r,e)*l%e,g=(0,i.pow2)(p,d,e)*h%e,b=(0,i.pow2)(g,o,e)*g%e,m=(0,i.pow2)(b,s,e)*b%e,E=(0,i.pow2)(m,f,e)*m%e,v=(0,i.pow2)(E,u,e)*E%e,B=(0,i.pow2)(v,f,e)*m%e,x=(0,i.pow2)(B,r,e)*l%e,A=(0,i.pow2)(x,a,e)*b%e,S=(0,i.pow2)(A,n,e)*h%e,T=(0,i.pow2)(S,d,e);if(!w.eql(w.sqr(T),t))throw new Error("Cannot find square root");return T}const w=(0,i.Field)(c,void 0,void 0,{sqrt:p});e.secp256k1=(0,u.createCurve)({a:BigInt(0),b:BigInt(7),Fp:w,n:h,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=h,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-l*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),f=y(s*t,e),u=y(-n*t,e);let c=(0,i.mod)(t-f*r-u*o,e),d=(0,i.mod)(-f*n-u*s,e);const p=c>a,w=d>a;if(p&&(c=e-c),w&&(d=e-d),c>a||d>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:p,k1:c,k2neg:w,k2:d}}}},n.sha256);const g=BigInt(0),b=t=>"bigint"==typeof t&&g"bigint"==typeof t&&gt.charCodeAt(0))));r=(0,a.concatBytes)(e,e),E[t]=r}return(0,n.sha256)((0,a.concatBytes)(r,...e))}const B=t=>t.toRawBytes(!0).slice(1),x=t=>(0,a.numberToBytesBE)(t,32),A=t=>(0,i.mod)(t,c),S=t=>(0,i.mod)(t,h),T=e.secp256k1.ProjectivePoint,U=(t,e,r)=>T.BASE.multiplyAndAddUnsafe(t,e,r);function _(t){let r=e.secp256k1.utils.normPrivateKeyToScalar(t),n=T.fromPrivateKey(r);return{scalar:n.hasEvenY()?r:S(-r),bytes:B(n)}}function O(t){if(!b(t))throw new Error("bad x: need 0 < x < p");const e=A(t*t);let r=p(A(e*t+BigInt(7)));r%d!==g&&(r=A(-r));const n=new T(t,r,l);return n.assertValidity(),n}function I(...t){return S((0,a.bytesToNumberBE)(v("BIP0340/challenge",...t)))}function L(t,e,r){const n=(0,a.ensureBytes)("signature",t,64),o=(0,a.ensureBytes)("message",e),i=(0,a.ensureBytes)("publicKey",r,32);try{const t=O((0,a.bytesToNumberBE)(i)),e=(0,a.bytesToNumberBE)(n.subarray(0,32));if(!b(e))return!1;const r=(0,a.bytesToNumberBE)(n.subarray(32,64));if(!m(r))return!1;const s=I(x(e),B(t),o),f=U(t,r,S(-s));return!(!f||!f.hasEvenY()||f.toAffine().x!==e)}catch(t){return!1}}e.schnorr={getPublicKey:function(t){return _(t).bytes},sign:function(t,e,r=(0,o.randomBytes)(32)){const n=(0,a.ensureBytes)("message",t),{bytes:i,scalar:s}=_(e),f=(0,a.ensureBytes)("auxRand",r,32),u=x(s^(0,a.bytesToNumberBE)(v("BIP0340/aux",f))),c=v("BIP0340/nonce",u,i,n),h=S((0,a.bytesToNumberBE)(c));if(h===g)throw new Error("sign failed: k is zero");const{bytes:l,scalar:d}=_(h),y=I(l,i,n),p=new Uint8Array(64);if(p.set(l,0),p.set(x(S(d+y*s)),32),!L(p,n,i))throw new Error("sign: Invalid signature produced");return p},verify:L,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:O,pointToBytes:B,numberToBytesBE:a.numberToBytesBE,bytesToNumberBE:a.bytesToNumberBE,taggedHash:v,mod:i.mod}};const R=(()=>(0,f.isogenyMap)(w,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((t=>t.map((t=>BigInt(t)))))))(),N=(()=>(0,s.mapToCurveSimpleSWU)(w,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:w.create(BigInt("-11"))}))(),k=(()=>(0,f.createHasher)(e.secp256k1.ProjectivePoint,(t=>{const{x:e,y:r}=N(w.create(t[0]));return R(e,r)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:w.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256}))();e.hashToCurve=k.hashToCurve,e.encodeToCurve=k.encodeToCurve},320:(t,e)=>{"use strict";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function n(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function o(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function i(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function a(t,e){o(t);const r=e.outputLen;if(t.length{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SHA2=void 0;const n=r(320),o=r(89);class i extends o.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,o.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:i}=this,s=(t=(0,o.toBytes)(t)).length;for(let n=0;ni-a&&(this.process(r,0),a=0);for(let t=a;t>o&i),a=Number(r&i),f=n?4:0,u=n?0:4;t.setUint32(e+f,s,n),t.setUint32(e+u,a,n)}(r,i-8,BigInt(8*this.length),s),this.process(r,0);const f=(0,o.createView)(t),u=this.outputLen;if(u%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=u/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},569:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(320),o=r(89);class i extends o.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,o.toBytes)(e);if(this.iHash=t.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 i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let t=0;tnew i(t,e).update(r).digest(),e.hmac.create=(t,e)=>new i(t,e)},61:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const n=r(505),o=r(89),i=(t,e,r)=>t&e^t&r^e&r,s=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]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),f=new Uint32Array(64);class u extends n.SHA2{constructor(){super(64,32,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:r,D:n,E:o,F:i,G:s,H:a}=this;return[t,e,r,n,o,i,s,a]}set(t,e,r,n,o,i,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)f[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=f[t-15],r=f[t-2],n=(0,o.rotr)(e,7)^(0,o.rotr)(e,18)^e>>>3,i=(0,o.rotr)(r,17)^(0,o.rotr)(r,19)^r>>>10;f[t]=i+f[t-7]+n+f[t-16]|0}let{A:r,B:n,C:a,D:u,E:c,F:h,G:l,H:d}=this;for(let t=0;t<64;t++){const e=d+((0,o.rotr)(c,6)^(0,o.rotr)(c,11)^(0,o.rotr)(c,25))+((y=c)&h^~y&l)+s[t]+f[t]|0,p=((0,o.rotr)(r,2)^(0,o.rotr)(r,13)^(0,o.rotr)(r,22))+i(r,n,a)|0;d=l,l=h,h=c,c=u+e|0,u=a,a=n,n=r,r=e+p|0}var y;r=r+this.A|0,n=n+this.B|0,a=a+this.C|0,u=u+this.D|0,c=c+this.E|0,h=h+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,n,a,u,c,h,l,d)}roundClean(){f.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class c extends u{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}}e.sha256=(0,o.wrapConstructor)((()=>new u)),e.sha224=(0,o.wrapConstructor)((()=>new c))},89:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const n=r(945),o=t=>t instanceof Uint8Array;if(e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const i=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function s(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function a(t){if("string"==typeof t&&(t=s(t)),!o(t))throw new Error("expected Uint8Array, got "+typeof t);return t}e.bytesToHex=function(t){if(!o(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r{},e.asyncLoop=async function(t,r,n){let o=Date.now();for(let i=0;i=0&&tt+e.length),0));let r=0;return t.forEach((t=>{if(!o(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e},e.Hash=class{clone(){return this._cloneInto()}};const f={}.toString;e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==f.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(a(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(a(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(a(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}},885:function(t){!function(e,r){"use strict";t.exports?t.exports=r():(e.nacl||(e.nacl={}),e.nacl.util=r())}(this,(function(){"use strict";var t={};function e(t){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(t))throw new TypeError("invalid encoding")}return t.decodeUTF8=function(t){if("string"!=typeof t)throw new TypeError("expected string");var e,r=unescape(encodeURIComponent(t)),n=new Uint8Array(r.length);for(e=0;e{!function(t){"use strict";var e=function(t){var e,r=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r,t[e+4]=n>>24&255,t[e+5]=n>>16&255,t[e+6]=n>>8&255,t[e+7]=255&n}function p(t,e,r,n,o){var i,s=0;for(i=0;i>>8)-1}function w(t,e,r,n){return p(t,e,r,n,16)}function g(t,e,r,n){return p(t,e,r,n,32)}function b(t,e,r,n){!function(t,e,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,f=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,c=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,y=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,w=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,m=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,v=i,B=s,x=a,A=f,S=u,T=c,U=h,_=l,O=d,I=y,L=p,R=w,N=g,k=b,H=m,M=E,q=0;q<20;q+=2)v^=(o=(N^=(o=(O^=(o=(S^=(o=v+N|0)<<7|o>>>25)+v|0)<<9|o>>>23)+S|0)<<13|o>>>19)+O|0)<<18|o>>>14,T^=(o=(B^=(o=(k^=(o=(I^=(o=T+B|0)<<7|o>>>25)+T|0)<<9|o>>>23)+I|0)<<13|o>>>19)+k|0)<<18|o>>>14,L^=(o=(U^=(o=(x^=(o=(H^=(o=L+U|0)<<7|o>>>25)+L|0)<<9|o>>>23)+H|0)<<13|o>>>19)+x|0)<<18|o>>>14,M^=(o=(R^=(o=(_^=(o=(A^=(o=M+R|0)<<7|o>>>25)+M|0)<<9|o>>>23)+A|0)<<13|o>>>19)+_|0)<<18|o>>>14,v^=(o=(A^=(o=(x^=(o=(B^=(o=v+A|0)<<7|o>>>25)+v|0)<<9|o>>>23)+B|0)<<13|o>>>19)+x|0)<<18|o>>>14,T^=(o=(S^=(o=(_^=(o=(U^=(o=T+S|0)<<7|o>>>25)+T|0)<<9|o>>>23)+U|0)<<13|o>>>19)+_|0)<<18|o>>>14,L^=(o=(I^=(o=(O^=(o=(R^=(o=L+I|0)<<7|o>>>25)+L|0)<<9|o>>>23)+R|0)<<13|o>>>19)+O|0)<<18|o>>>14,M^=(o=(H^=(o=(k^=(o=(N^=(o=M+H|0)<<7|o>>>25)+M|0)<<9|o>>>23)+N|0)<<13|o>>>19)+k|0)<<18|o>>>14;v=v+i|0,B=B+s|0,x=x+a|0,A=A+f|0,S=S+u|0,T=T+c|0,U=U+h|0,_=_+l|0,O=O+d|0,I=I+y|0,L=L+p|0,R=R+w|0,N=N+g|0,k=k+b|0,H=H+m|0,M=M+E|0,t[0]=v>>>0&255,t[1]=v>>>8&255,t[2]=v>>>16&255,t[3]=v>>>24&255,t[4]=B>>>0&255,t[5]=B>>>8&255,t[6]=B>>>16&255,t[7]=B>>>24&255,t[8]=x>>>0&255,t[9]=x>>>8&255,t[10]=x>>>16&255,t[11]=x>>>24&255,t[12]=A>>>0&255,t[13]=A>>>8&255,t[14]=A>>>16&255,t[15]=A>>>24&255,t[16]=S>>>0&255,t[17]=S>>>8&255,t[18]=S>>>16&255,t[19]=S>>>24&255,t[20]=T>>>0&255,t[21]=T>>>8&255,t[22]=T>>>16&255,t[23]=T>>>24&255,t[24]=U>>>0&255,t[25]=U>>>8&255,t[26]=U>>>16&255,t[27]=U>>>24&255,t[28]=_>>>0&255,t[29]=_>>>8&255,t[30]=_>>>16&255,t[31]=_>>>24&255,t[32]=O>>>0&255,t[33]=O>>>8&255,t[34]=O>>>16&255,t[35]=O>>>24&255,t[36]=I>>>0&255,t[37]=I>>>8&255,t[38]=I>>>16&255,t[39]=I>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=R>>>0&255,t[45]=R>>>8&255,t[46]=R>>>16&255,t[47]=R>>>24&255,t[48]=N>>>0&255,t[49]=N>>>8&255,t[50]=N>>>16&255,t[51]=N>>>24&255,t[52]=k>>>0&255,t[53]=k>>>8&255,t[54]=k>>>16&255,t[55]=k>>>24&255,t[56]=H>>>0&255,t[57]=H>>>8&255,t[58]=H>>>16&255,t[59]=H>>>24&255,t[60]=M>>>0&255,t[61]=M>>>8&255,t[62]=M>>>16&255,t[63]=M>>>24&255}(t,e,r,n)}function m(t,e,r,n){!function(t,e,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,f=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,u=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,c=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,y=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,w=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,g=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,m=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,v=0;v<20;v+=2)i^=(o=(g^=(o=(d^=(o=(u^=(o=i+g|0)<<7|o>>>25)+i|0)<<9|o>>>23)+u|0)<<13|o>>>19)+d|0)<<18|o>>>14,c^=(o=(s^=(o=(b^=(o=(y^=(o=c+s|0)<<7|o>>>25)+c|0)<<9|o>>>23)+y|0)<<13|o>>>19)+b|0)<<18|o>>>14,p^=(o=(h^=(o=(a^=(o=(m^=(o=p+h|0)<<7|o>>>25)+p|0)<<9|o>>>23)+m|0)<<13|o>>>19)+a|0)<<18|o>>>14,E^=(o=(w^=(o=(l^=(o=(f^=(o=E+w|0)<<7|o>>>25)+E|0)<<9|o>>>23)+f|0)<<13|o>>>19)+l|0)<<18|o>>>14,i^=(o=(f^=(o=(a^=(o=(s^=(o=i+f|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+a|0)<<18|o>>>14,c^=(o=(u^=(o=(l^=(o=(h^=(o=c+u|0)<<7|o>>>25)+c|0)<<9|o>>>23)+h|0)<<13|o>>>19)+l|0)<<18|o>>>14,p^=(o=(y^=(o=(d^=(o=(w^=(o=p+y|0)<<7|o>>>25)+p|0)<<9|o>>>23)+w|0)<<13|o>>>19)+d|0)<<18|o>>>14,E^=(o=(m^=(o=(b^=(o=(g^=(o=E+m|0)<<7|o>>>25)+E|0)<<9|o>>>23)+g|0)<<13|o>>>19)+b|0)<<18|o>>>14;t[0]=i>>>0&255,t[1]=i>>>8&255,t[2]=i>>>16&255,t[3]=i>>>24&255,t[4]=c>>>0&255,t[5]=c>>>8&255,t[6]=c>>>16&255,t[7]=c>>>24&255,t[8]=p>>>0&255,t[9]=p>>>8&255,t[10]=p>>>16&255,t[11]=p>>>24&255,t[12]=E>>>0&255,t[13]=E>>>8&255,t[14]=E>>>16&255,t[15]=E>>>24&255,t[16]=h>>>0&255,t[17]=h>>>8&255,t[18]=h>>>16&255,t[19]=h>>>24&255,t[20]=l>>>0&255,t[21]=l>>>8&255,t[22]=l>>>16&255,t[23]=l>>>24&255,t[24]=d>>>0&255,t[25]=d>>>8&255,t[26]=d>>>16&255,t[27]=d>>>24&255,t[28]=y>>>0&255,t[29]=y>>>8&255,t[30]=y>>>16&255,t[31]=y>>>24&255}(t,e,r,n)}var E=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function v(t,e,r,n,o,i,s){var a,f,u=new Uint8Array(16),c=new Uint8Array(64);for(f=0;f<16;f++)u[f]=0;for(f=0;f<8;f++)u[f]=i[f];for(;o>=64;){for(b(c,u,s,E),f=0;f<64;f++)t[e+f]=r[n+f]^c[f];for(a=1,f=8;f<16;f++)a=a+(255&u[f])|0,u[f]=255&a,a>>>=8;o-=64,e+=64,n+=64}if(o>0)for(b(c,u,s,E),f=0;f=64;){for(b(f,a,o,E),s=0;s<64;s++)t[e+s]=f[s];for(i=1,s=8;s<16;s++)i=i+(255&a[s])|0,a[s]=255&i,i>>>=8;r-=64,e+=64}if(r>0)for(b(f,a,o,E),s=0;s>>13|r<<3),n=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(r>>>10|n<<6),o=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(n>>>7|o<<9),i=255&t[8]|(255&t[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(i>>>14|s<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(s>>>11|a<<5),f=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|f<<8),this.r[9]=f>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function T(t,e,r,n,o,i){var s=new S(i);return s.update(r,n,o),s.finish(t,e),0}function U(t,e,r,n,o,i){var s=new Uint8Array(16);return T(s,0,r,n,o,i),w(t,e,s,0)}function _(t,e,r,n,o){var i;if(r<32)return-1;for(A(t,0,e,0,r,n,o),T(t,16,t,32,r-32,t),i=0;i<16;i++)t[i]=0;return 0}function O(t,e,r,n,o){var i,s=new Uint8Array(32);if(r<32)return-1;if(x(s,0,32,n,o),0!==U(e,16,e,32,r-32,s))return-1;for(A(t,0,e,0,r,n,o),i=0;i<32;i++)t[i]=0;return 0}function I(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]}function L(t){var e,r,n=1;for(e=0;e<16;e++)r=t[e]+n+65535,n=Math.floor(r/65536),t[e]=r-65536*n;t[0]+=n-1+37*(n-1)}function R(t,e,r){for(var n,o=~(r-1),i=0;i<16;i++)n=o&(t[i]^e[i]),t[i]^=n,e[i]^=n}function N(t,r){var n,o,i,s=e(),a=e();for(n=0;n<16;n++)a[n]=r[n];for(L(a),L(a),L(a),o=0;o<2;o++){for(s[0]=a[0]-65517,n=1;n<15;n++)s[n]=a[n]-65535-(s[n-1]>>16&1),s[n-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,R(a,s,1-i)}for(n=0;n<16;n++)t[2*n]=255&a[n],t[2*n+1]=a[n]>>8}function k(t,e){var r=new Uint8Array(32),n=new Uint8Array(32);return N(r,t),N(n,e),g(r,0,n,0)}function H(t){var e=new Uint8Array(32);return N(e,t),1&e[0]}function M(t,e){var r;for(r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}function q(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]+r[n]}function C(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]-r[n]}function F(t,e,r){var n,o,i=0,s=0,a=0,f=0,u=0,c=0,h=0,l=0,d=0,y=0,p=0,w=0,g=0,b=0,m=0,E=0,v=0,B=0,x=0,A=0,S=0,T=0,U=0,_=0,O=0,I=0,L=0,R=0,N=0,k=0,H=0,M=r[0],q=r[1],C=r[2],F=r[3],P=r[4],D=r[5],z=r[6],j=r[7],K=r[8],V=r[9],Z=r[10],$=r[11],Y=r[12],W=r[13],G=r[14],X=r[15];i+=(n=e[0])*M,s+=n*q,a+=n*C,f+=n*F,u+=n*P,c+=n*D,h+=n*z,l+=n*j,d+=n*K,y+=n*V,p+=n*Z,w+=n*$,g+=n*Y,b+=n*W,m+=n*G,E+=n*X,s+=(n=e[1])*M,a+=n*q,f+=n*C,u+=n*F,c+=n*P,h+=n*D,l+=n*z,d+=n*j,y+=n*K,p+=n*V,w+=n*Z,g+=n*$,b+=n*Y,m+=n*W,E+=n*G,v+=n*X,a+=(n=e[2])*M,f+=n*q,u+=n*C,c+=n*F,h+=n*P,l+=n*D,d+=n*z,y+=n*j,p+=n*K,w+=n*V,g+=n*Z,b+=n*$,m+=n*Y,E+=n*W,v+=n*G,B+=n*X,f+=(n=e[3])*M,u+=n*q,c+=n*C,h+=n*F,l+=n*P,d+=n*D,y+=n*z,p+=n*j,w+=n*K,g+=n*V,b+=n*Z,m+=n*$,E+=n*Y,v+=n*W,B+=n*G,x+=n*X,u+=(n=e[4])*M,c+=n*q,h+=n*C,l+=n*F,d+=n*P,y+=n*D,p+=n*z,w+=n*j,g+=n*K,b+=n*V,m+=n*Z,E+=n*$,v+=n*Y,B+=n*W,x+=n*G,A+=n*X,c+=(n=e[5])*M,h+=n*q,l+=n*C,d+=n*F,y+=n*P,p+=n*D,w+=n*z,g+=n*j,b+=n*K,m+=n*V,E+=n*Z,v+=n*$,B+=n*Y,x+=n*W,A+=n*G,S+=n*X,h+=(n=e[6])*M,l+=n*q,d+=n*C,y+=n*F,p+=n*P,w+=n*D,g+=n*z,b+=n*j,m+=n*K,E+=n*V,v+=n*Z,B+=n*$,x+=n*Y,A+=n*W,S+=n*G,T+=n*X,l+=(n=e[7])*M,d+=n*q,y+=n*C,p+=n*F,w+=n*P,g+=n*D,b+=n*z,m+=n*j,E+=n*K,v+=n*V,B+=n*Z,x+=n*$,A+=n*Y,S+=n*W,T+=n*G,U+=n*X,d+=(n=e[8])*M,y+=n*q,p+=n*C,w+=n*F,g+=n*P,b+=n*D,m+=n*z,E+=n*j,v+=n*K,B+=n*V,x+=n*Z,A+=n*$,S+=n*Y,T+=n*W,U+=n*G,_+=n*X,y+=(n=e[9])*M,p+=n*q,w+=n*C,g+=n*F,b+=n*P,m+=n*D,E+=n*z,v+=n*j,B+=n*K,x+=n*V,A+=n*Z,S+=n*$,T+=n*Y,U+=n*W,_+=n*G,O+=n*X,p+=(n=e[10])*M,w+=n*q,g+=n*C,b+=n*F,m+=n*P,E+=n*D,v+=n*z,B+=n*j,x+=n*K,A+=n*V,S+=n*Z,T+=n*$,U+=n*Y,_+=n*W,O+=n*G,I+=n*X,w+=(n=e[11])*M,g+=n*q,b+=n*C,m+=n*F,E+=n*P,v+=n*D,B+=n*z,x+=n*j,A+=n*K,S+=n*V,T+=n*Z,U+=n*$,_+=n*Y,O+=n*W,I+=n*G,L+=n*X,g+=(n=e[12])*M,b+=n*q,m+=n*C,E+=n*F,v+=n*P,B+=n*D,x+=n*z,A+=n*j,S+=n*K,T+=n*V,U+=n*Z,_+=n*$,O+=n*Y,I+=n*W,L+=n*G,R+=n*X,b+=(n=e[13])*M,m+=n*q,E+=n*C,v+=n*F,B+=n*P,x+=n*D,A+=n*z,S+=n*j,T+=n*K,U+=n*V,_+=n*Z,O+=n*$,I+=n*Y,L+=n*W,R+=n*G,N+=n*X,m+=(n=e[14])*M,E+=n*q,v+=n*C,B+=n*F,x+=n*P,A+=n*D,S+=n*z,T+=n*j,U+=n*K,_+=n*V,O+=n*Z,I+=n*$,L+=n*Y,R+=n*W,N+=n*G,k+=n*X,E+=(n=e[15])*M,s+=38*(B+=n*C),a+=38*(x+=n*F),f+=38*(A+=n*P),u+=38*(S+=n*D),c+=38*(T+=n*z),h+=38*(U+=n*j),l+=38*(_+=n*K),d+=38*(O+=n*V),y+=38*(I+=n*Z),p+=38*(L+=n*$),w+=38*(R+=n*Y),g+=38*(N+=n*W),b+=38*(k+=n*G),m+=38*(H+=n*X),i=(n=(i+=38*(v+=n*q))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),m=(n=m+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),m=(n=m+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),i+=o-1+37*(o-1),t[0]=i,t[1]=s,t[2]=a,t[3]=f,t[4]=u,t[5]=c,t[6]=h,t[7]=l,t[8]=d,t[9]=y,t[10]=p,t[11]=w,t[12]=g,t[13]=b,t[14]=m,t[15]=E}function P(t,e){F(t,e,e)}function D(t,r){var n,o=e();for(n=0;n<16;n++)o[n]=r[n];for(n=253;n>=0;n--)P(o,o),2!==n&&4!==n&&F(o,o,r);for(n=0;n<16;n++)t[n]=o[n]}function z(t,r){var n,o=e();for(n=0;n<16;n++)o[n]=r[n];for(n=250;n>=0;n--)P(o,o),1!==n&&F(o,o,r);for(n=0;n<16;n++)t[n]=o[n]}function j(t,r,n){var o,i,s=new Uint8Array(32),a=new Float64Array(80),u=e(),c=e(),h=e(),l=e(),d=e(),y=e();for(i=0;i<31;i++)s[i]=r[i];for(s[31]=127&r[31]|64,s[0]&=248,M(a,n),i=0;i<16;i++)c[i]=a[i],l[i]=u[i]=h[i]=0;for(u[0]=l[0]=1,i=254;i>=0;--i)R(u,c,o=s[i>>>3]>>>(7&i)&1),R(h,l,o),q(d,u,h),C(u,u,h),q(h,c,l),C(c,c,l),P(l,d),P(y,u),F(u,h,u),F(h,c,d),q(d,u,h),C(u,u,h),P(c,u),C(h,l,y),F(u,h,f),q(u,u,l),F(h,h,u),F(u,l,y),F(l,c,a),P(c,d),R(u,c,o),R(h,l,o);for(i=0;i<16;i++)a[i+16]=u[i],a[i+32]=h[i],a[i+48]=c[i],a[i+64]=l[i];var p=a.subarray(32),w=a.subarray(16);return D(p,p),F(w,w,p),N(t,w),0}function K(t,e){return j(t,e,i)}function V(t,e){return n(e,32),K(t,e)}function Z(t,e,r){var n=new Uint8Array(32);return j(n,r,e),m(t,o,n,E)}S.prototype.blocks=function(t,e,r){for(var n,o,i,s,a,f,u,c,h,l,d,y,p,w,g,b,m,E,v,B=this.fin?0:2048,x=this.h[0],A=this.h[1],S=this.h[2],T=this.h[3],U=this.h[4],_=this.h[5],O=this.h[6],I=this.h[7],L=this.h[8],R=this.h[9],N=this.r[0],k=this.r[1],H=this.r[2],M=this.r[3],q=this.r[4],C=this.r[5],F=this.r[6],P=this.r[7],D=this.r[8],z=this.r[9];r>=16;)l=h=0,l+=(x+=8191&(n=255&t[e+0]|(255&t[e+1])<<8))*N,l+=(A+=8191&(n>>>13|(o=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*z),l+=(S+=8191&(o>>>10|(i=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*D),l+=(T+=8191&(i>>>7|(s=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*P),h=(l+=(U+=8191&(s>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*F))>>>13,l&=8191,l+=(_+=a>>>1&8191)*(5*C),l+=(O+=8191&(a>>>14|(f=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*q),l+=(I+=8191&(f>>>11|(u=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*M),l+=(L+=8191&(u>>>8|(c=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*H),d=h+=(l+=(R+=c>>>5|B)*(5*k))>>>13,d+=x*k,d+=A*N,d+=S*(5*z),d+=T*(5*D),h=(d+=U*(5*P))>>>13,d&=8191,d+=_*(5*F),d+=O*(5*C),d+=I*(5*q),d+=L*(5*M),h+=(d+=R*(5*H))>>>13,d&=8191,y=h,y+=x*H,y+=A*k,y+=S*N,y+=T*(5*z),h=(y+=U*(5*D))>>>13,y&=8191,y+=_*(5*P),y+=O*(5*F),y+=I*(5*C),y+=L*(5*q),p=h+=(y+=R*(5*M))>>>13,p+=x*M,p+=A*H,p+=S*k,p+=T*N,h=(p+=U*(5*z))>>>13,p&=8191,p+=_*(5*D),p+=O*(5*P),p+=I*(5*F),p+=L*(5*C),w=h+=(p+=R*(5*q))>>>13,w+=x*q,w+=A*M,w+=S*H,w+=T*k,h=(w+=U*N)>>>13,w&=8191,w+=_*(5*z),w+=O*(5*D),w+=I*(5*P),w+=L*(5*F),g=h+=(w+=R*(5*C))>>>13,g+=x*C,g+=A*q,g+=S*M,g+=T*H,h=(g+=U*k)>>>13,g&=8191,g+=_*N,g+=O*(5*z),g+=I*(5*D),g+=L*(5*P),b=h+=(g+=R*(5*F))>>>13,b+=x*F,b+=A*C,b+=S*q,b+=T*M,h=(b+=U*H)>>>13,b&=8191,b+=_*k,b+=O*N,b+=I*(5*z),b+=L*(5*D),m=h+=(b+=R*(5*P))>>>13,m+=x*P,m+=A*F,m+=S*C,m+=T*q,h=(m+=U*M)>>>13,m&=8191,m+=_*H,m+=O*k,m+=I*N,m+=L*(5*z),E=h+=(m+=R*(5*D))>>>13,E+=x*D,E+=A*P,E+=S*F,E+=T*C,h=(E+=U*q)>>>13,E&=8191,E+=_*M,E+=O*H,E+=I*k,E+=L*N,v=h+=(E+=R*(5*z))>>>13,v+=x*z,v+=A*D,v+=S*P,v+=T*F,h=(v+=U*C)>>>13,v&=8191,v+=_*q,v+=O*M,v+=I*H,v+=L*k,x=l=8191&(h=(h=((h+=(v+=R*N)>>>13)<<2)+h|0)+(l&=8191)|0),A=d+=h>>>=13,S=y&=8191,T=p&=8191,U=w&=8191,_=g&=8191,O=b&=8191,I=m&=8191,L=E&=8191,R=v&=8191,e+=16,r-=16;this.h[0]=x,this.h[1]=A,this.h[2]=S,this.h[3]=T,this.h[4]=U,this.h[5]=_,this.h[6]=O,this.h[7]=I,this.h[8]=L,this.h[9]=R},S.prototype.finish=function(t,e){var r,n,o,i,s=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=r,r=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,s[0]=this.h[0]+5,r=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+r,r=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,n=(1^r)-1,i=0;i<10;i++)s[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|s[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},S.prototype.update=function(t,e,r){var n,o;if(this.leftover){for((o=16-this.leftover)>r&&(o=r),n=0;n=16&&(o=r-r%16,this.blocks(t,e,o),e+=o,r-=o),r){for(n=0;n=128;){for(B=0;B<16;B++)x=8*B+Y,I[B]=r[x+0]<<24|r[x+1]<<16|r[x+2]<<8|r[x+3],L[B]=r[x+4]<<24|r[x+5]<<16|r[x+6]<<8|r[x+7];for(B=0;B<80;B++)if(o=R,i=N,s=k,a=H,f=M,u=q,c=C,l=P,d=D,y=z,p=j,w=K,g=V,b=Z,T=65535&(S=$),U=S>>>16,_=65535&(A=F),O=A>>>16,T+=65535&(S=(K>>>14|M<<18)^(K>>>18|M<<14)^(M>>>9|K<<23)),U+=S>>>16,_+=65535&(A=(M>>>14|K<<18)^(M>>>18|K<<14)^(K>>>9|M<<23)),O+=A>>>16,T+=65535&(S=K&V^~K&Z),U+=S>>>16,_+=65535&(A=M&q^~M&C),O+=A>>>16,A=W[2*B],T+=65535&(S=W[2*B+1]),U+=S>>>16,_+=65535&A,O+=A>>>16,A=I[B%16],U+=(S=L[B%16])>>>16,_+=65535&A,O+=A>>>16,_+=(U+=(T+=65535&S)>>>16)>>>16,T=65535&(S=v=65535&T|U<<16),U=S>>>16,_=65535&(A=E=65535&_|(O+=_>>>16)<<16),O=A>>>16,T+=65535&(S=(P>>>28|R<<4)^(R>>>2|P<<30)^(R>>>7|P<<25)),U+=S>>>16,_+=65535&(A=(R>>>28|P<<4)^(P>>>2|R<<30)^(P>>>7|R<<25)),O+=A>>>16,U+=(S=P&D^P&z^D&z)>>>16,_+=65535&(A=R&N^R&k^N&k),O+=A>>>16,h=65535&(_+=(U+=(T+=65535&S)>>>16)>>>16)|(O+=_>>>16)<<16,m=65535&T|U<<16,T=65535&(S=p),U=S>>>16,_=65535&(A=a),O=A>>>16,U+=(S=v)>>>16,_+=65535&(A=E),O+=A>>>16,N=o,k=i,H=s,M=a=65535&(_+=(U+=(T+=65535&S)>>>16)>>>16)|(O+=_>>>16)<<16,q=f,C=u,F=c,R=h,D=l,z=d,j=y,K=p=65535&T|U<<16,V=w,Z=g,$=b,P=m,B%16==15)for(x=0;x<16;x++)A=I[x],T=65535&(S=L[x]),U=S>>>16,_=65535&A,O=A>>>16,A=I[(x+9)%16],T+=65535&(S=L[(x+9)%16]),U+=S>>>16,_+=65535&A,O+=A>>>16,E=I[(x+1)%16],T+=65535&(S=((v=L[(x+1)%16])>>>1|E<<31)^(v>>>8|E<<24)^(v>>>7|E<<25)),U+=S>>>16,_+=65535&(A=(E>>>1|v<<31)^(E>>>8|v<<24)^E>>>7),O+=A>>>16,E=I[(x+14)%16],U+=(S=((v=L[(x+14)%16])>>>19|E<<13)^(E>>>29|v<<3)^(v>>>6|E<<26))>>>16,_+=65535&(A=(E>>>19|v<<13)^(v>>>29|E<<3)^E>>>6),O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,I[x]=65535&_|O<<16,L[x]=65535&T|U<<16;T=65535&(S=P),U=S>>>16,_=65535&(A=R),O=A>>>16,A=t[0],U+=(S=e[0])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[0]=R=65535&_|O<<16,e[0]=P=65535&T|U<<16,T=65535&(S=D),U=S>>>16,_=65535&(A=N),O=A>>>16,A=t[1],U+=(S=e[1])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[1]=N=65535&_|O<<16,e[1]=D=65535&T|U<<16,T=65535&(S=z),U=S>>>16,_=65535&(A=k),O=A>>>16,A=t[2],U+=(S=e[2])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[2]=k=65535&_|O<<16,e[2]=z=65535&T|U<<16,T=65535&(S=j),U=S>>>16,_=65535&(A=H),O=A>>>16,A=t[3],U+=(S=e[3])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[3]=H=65535&_|O<<16,e[3]=j=65535&T|U<<16,T=65535&(S=K),U=S>>>16,_=65535&(A=M),O=A>>>16,A=t[4],U+=(S=e[4])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[4]=M=65535&_|O<<16,e[4]=K=65535&T|U<<16,T=65535&(S=V),U=S>>>16,_=65535&(A=q),O=A>>>16,A=t[5],U+=(S=e[5])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[5]=q=65535&_|O<<16,e[5]=V=65535&T|U<<16,T=65535&(S=Z),U=S>>>16,_=65535&(A=C),O=A>>>16,A=t[6],U+=(S=e[6])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[6]=C=65535&_|O<<16,e[6]=Z=65535&T|U<<16,T=65535&(S=$),U=S>>>16,_=65535&(A=F),O=A>>>16,A=t[7],U+=(S=e[7])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[7]=F=65535&_|O<<16,e[7]=$=65535&T|U<<16,Y+=128,n-=128}return n}function X(t,e,r){var n,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=r;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,G(o,i,e,r),r%=128,n=0;n=0;--o)Q(t,e,n=r[o/8|0]>>(7&o)&1),J(e,t),J(t,t),Q(t,e,n)}function rt(t,r){var n=[e(),e(),e(),e()];I(n[0],h),I(n[1],l),I(n[2],a),F(n[3],h,l),et(t,n,r)}function nt(t,r,o){var i,s=new Uint8Array(64),a=[e(),e(),e(),e()];for(o||n(r,32),X(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,rt(a,s),tt(t,a),i=0;i<32;i++)r[i+32]=t[i];return 0}var ot=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function it(t,e){var r,n,o,i;for(n=63;n>=32;--n){for(r=0,o=n-32,i=n-12;o>4)*ot[o],r=e[o]>>8,e[o]&=255;for(o=0;o<32;o++)e[o]-=r*ot[o];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,t[n]=255&e[n]}function st(t){var e,r=new Float64Array(64);for(e=0;e<64;e++)r[e]=t[e];for(e=0;e<64;e++)t[e]=0;it(t,r)}function at(t,r,n,o){var i,s,a=new Uint8Array(64),f=new Uint8Array(64),u=new Uint8Array(64),c=new Float64Array(64),h=[e(),e(),e(),e()];X(a,o,32),a[0]&=248,a[31]&=127,a[31]|=64;var l=n+64;for(i=0;i>7&&C(t[0],s,t[0]),F(t[3],t[0],t[1]),0)}(l,o))return-1;for(i=0;i=0},t.sign.keyPair=function(){var t=new Uint8Array(ht),e=new Uint8Array(lt);return nt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(yt(t),t.length!==lt)throw new Error("bad secret key size");for(var e=new Uint8Array(ht),r=0;r{const n=r(780),o=r(885),i=r(497),s=r(61);t.exports={nacl:n,util:o,secp256k1:i,sha256:s}},24:()=>{}},e={},r=function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(82);customModule=r})(); \ No newline at end of file +var customModule;(()=>{var t={904:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createCurve=e.getHash=void 0;const n=r(569),o=r(89),i=r(551);function s(t){return{hash:t,hmac:(e,...r)=>(0,n.hmac)(t,e,(0,o.concatBytes)(...r)),randomBytes:o.randomBytes}}e.getHash=s,e.createCurve=function(t,e){const r=e=>(0,i.weierstrass)({...t,...s(e)});return Object.freeze({...r(e),create:r})}},525:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateBasic=e.wNAF=void 0;const n=r(632),o=r(219),i=BigInt(0),s=BigInt(1);e.wNAF=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,o=e;for(;r>i;)r&s&&(n=n.add(o)),o=o.double(),r>>=s;return n},precomputeWindow(t,e){const{windows:r,windowSize:o}=n(e),i=[];let s=t,a=s;for(let t=0;t>=d,n>f&&(n-=l,i+=s);const a=e,y=e+Math.abs(n)-1,p=t%2!=0,g=n<0;0===n?u=u.add(r(p,o[a])):c=c.add(r(g,o[y]))}return{p:c,f:u}},wNAFCached(t,e,r,n){const o=t._WINDOW_SIZE||1;let i=e.get(t);return i||(i=this.precomputeWindow(t,o),1!==o&&e.set(t,n(i))),this.wNAF(o,i,r)}}},e.validateBasic=function(t){return(0,n.validateField)(t.Fp),(0,o.validateObject)(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,n.nLength)(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}},134:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.createHasher=e.isogenyMap=e.hash_to_field=e.expand_message_xof=e.expand_message_xmd=void 0;const n=r(632),o=r(219),i=o.bytesToNumberBE;function s(t,e){if(t<0||t>=1<<8*e)throw new Error(`bad I2OSP call: value=${t} length=${e}`);const r=Array.from({length:e}).fill(0);for(let n=e-1;n>=0;n--)r[n]=255&t,t>>>=8;return new Uint8Array(r)}function a(t,e){const r=new Uint8Array(t.length);for(let n=0;n255&&(e=n((0,o.concatBytes)((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-"),e)));const{outputLen:i,blockLen:u}=n,h=Math.ceil(r/i);if(h>255)throw new Error("Invalid xmd length");const l=(0,o.concatBytes)(e,s(e.length,1)),d=s(0,u),y=s(r,2),p=new Array(h),g=n((0,o.concatBytes)(d,t,y,s(0,1),l));p[0]=n((0,o.concatBytes)(g,s(1,1),l));for(let t=1;t<=h;t++){const e=[a(g,p[t-1]),s(t+1,1),l];p[t]=n((0,o.concatBytes)(...e))}return(0,o.concatBytes)(...p).slice(0,r)}function h(t,e,r,n,i){if(f(t),f(e),c(r),e.length>255){const t=Math.ceil(2*n/8);e=i.create({dkLen:t}).update((0,o.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(e).digest()}if(r>65535||e.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:r}).update(t).update(s(r,2)).update(e).update(s(e.length,1)).digest()}function l(t,e,r){(0,o.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:s,k:a,m:l,hash:d,expand:y,DST:p}=r;f(t),c(e);const g=function(t){if(t instanceof Uint8Array)return t;if("string"==typeof t)return(0,o.utf8ToBytes)(t);throw new Error("DST must be Uint8Array or string")}(p),w=s.toString(2).length,b=Math.ceil((w+a)/8),m=e*l*b;let E;if("xmd"===y)E=u(t,g,m,d);else if("xof"===y)E=h(t,g,m,a,d);else{if("_internal_pass"!==y)throw new Error('expand must be "xmd" or "xof"');E=t}const v=new Array(e);for(let t=0;tArray.from(t).reverse()));return(e,n)=>{const[o,i,s,a]=r.map((r=>r.reduce(((r,n)=>t.add(t.mul(r,e),n)))));return e=t.div(o,i),n=t.mul(n,t.div(s,a)),{x:e,y:n}}},e.createHasher=function(t,e,r){if("function"!=typeof e)throw new Error("mapToCurve() must be defined");return{hashToCurve(n,o){const i=l(n,2,{...r,DST:r.DST,...o}),s=t.fromAffine(e(i[0])),a=t.fromAffine(e(i[1])),f=s.add(a).clearCofactor();return f.assertValidity(),f},encodeToCurve(n,o){const i=l(n,1,{...r,DST:r.encodeDST,...o}),s=t.fromAffine(e(i[0])).clearCofactor();return s.assertValidity(),s}}}},632:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.mapHashToField=e.getMinHashLength=e.getFieldBytesLength=e.hashToPrivateScalar=e.FpSqrtEven=e.FpSqrtOdd=e.Field=e.nLength=e.FpIsSquare=e.FpDiv=e.FpInvertBatch=e.FpPow=e.validateField=e.isNegativeLE=e.FpSqrt=e.tonelliShanks=e.invert=e.pow2=e.pow=e.mod=void 0;const n=r(219),o=BigInt(0),i=BigInt(1),s=BigInt(2),a=BigInt(3),f=BigInt(4),c=BigInt(5),u=BigInt(8);function h(t,e){const r=t%e;return r>=o?r:e+r}function l(t,e,r){if(r<=o||e 0");if(r===i)return o;let n=i;for(;e>o;)e&i&&(n=n*t%r),t=t*t%r,e>>=i;return n}function d(t,e){if(t===o||e<=o)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=h(t,e),n=e,s=o,a=i,f=i,c=o;for(;r!==o;){const t=n/r,e=n%r,o=s-f*t,i=a-c*t;n=r,r=e,s=f,a=c,f=o,c=i}if(n!==i)throw new Error("invert: does not exist");return h(s,e)}function y(t){const e=(t-i)/s;let r,n,a;for(r=t-i,n=0;r%s===o;r/=s,n++);for(a=s;ao;)n*=n,n%=r;return n},e.invert=d,e.tonelliShanks=y,e.FpSqrt=p,e.isNegativeLE=(t,e)=>(h(t,e)&i)===i;const g=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function w(t,e,r){if(r 0");if(r===o)return t.ONE;if(r===i)return e;let n=t.ONE,s=e;for(;r>o;)r&i&&(n=t.mul(n,s)),s=t.sqr(s),r>>=i;return n}function b(t,e){const r=new Array(e.length),n=e.reduce(((e,n,o)=>t.is0(n)?e:(r[o]=e,t.mul(e,n))),t.ONE),o=t.inv(n);return e.reduceRight(((e,n,o)=>t.is0(n)?e:(r[o]=t.mul(e,r[o]),t.mul(e,n))),o),r}function m(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function E(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function v(t){const e=E(t);return e+Math.ceil(e/2)}e.validateField=function(t){const e=g.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,n.validateObject)(t,e)},e.FpPow=w,e.FpInvertBatch=b,e.FpDiv=function(t,e,r){return t.mul(e,"bigint"==typeof r?d(r,t.ORDER):t.inv(r))},e.FpIsSquare=function(t){const e=(t.ORDER-i)/s;return r=>{const n=t.pow(r,e);return t.eql(n,t.ZERO)||t.eql(n,t.ONE)}},e.nLength=m,e.Field=function(t,e,r=!1,s={}){if(t<=o)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:a,nByteLength:f}=m(t,e);if(f>2048)throw new Error("Field lengths over 2048 bytes are not supported");const c=p(t),u=Object.freeze({ORDER:t,BITS:a,BYTES:f,MASK:(0,n.bitMask)(a),ZERO:o,ONE:i,create:e=>h(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return o<=e&&et===o,isOdd:t=>(t&i)===i,neg:e=>h(-e,t),eql:(t,e)=>t===e,sqr:e=>h(e*e,t),add:(e,r)=>h(e+r,t),sub:(e,r)=>h(e-r,t),mul:(e,r)=>h(e*r,t),pow:(t,e)=>w(u,t,e),div:(e,r)=>h(e*d(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>d(e,t),sqrt:s.sqrt||(t=>c(u,t)),invertBatch:t=>b(u,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?(0,n.numberToBytesLE)(t,f):(0,n.numberToBytesBE)(t,f),fromBytes:t=>{if(t.length!==f)throw new Error(`Fp.fromBytes: expected ${f}, got ${t.length}`);return r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t)}});return Object.freeze(u)},e.FpSqrtOdd=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?r:t.neg(r)},e.FpSqrtEven=function(t,e){if(!t.isOdd)throw new Error("Field doesn't have isOdd");const r=t.sqrt(e);return t.isOdd(r)?t.neg(r):r},e.hashToPrivateScalar=function(t,e,r=!1){const o=(t=(0,n.ensureBytes)("privateHash",t)).length,s=m(e).nByteLength+8;if(s<24||o1024)throw new Error(`hashToPrivateScalar: expected ${s}-1024 bytes of input, got ${o}`);return h(r?(0,n.bytesToNumberLE)(t):(0,n.bytesToNumberBE)(t),e-i)+i},e.getFieldBytesLength=E,e.getMinHashLength=v,e.mapHashToField=function(t,e,r=!1){const o=t.length,s=E(e),a=v(e);if(o<16||o1024)throw new Error(`expected ${a}-1024 bytes of input, got ${o}`);const f=h(r?(0,n.bytesToNumberBE)(t):(0,n.bytesToNumberLE)(t),e-i)+i;return r?(0,n.numberToBytesLE)(f,s):(0,n.numberToBytesBE)(f,s)}},219:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.validateObject=e.createHmacDrbg=e.bitMask=e.bitSet=e.bitGet=e.bitLen=e.utf8ToBytes=e.equalBytes=e.concatBytes=e.ensureBytes=e.numberToVarBytesBE=e.numberToBytesLE=e.numberToBytesBE=e.bytesToNumberLE=e.bytesToNumberBE=e.hexToBytes=e.hexToNumber=e.numberToHexUnpadded=e.bytesToHex=void 0;const r=BigInt(0),n=BigInt(1),o=BigInt(2),i=t=>t instanceof Uint8Array,s=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function a(t){if(!i(t))throw new Error("Uint8Array expected");let e="";for(let r=0;rt+e.length),0));let r=0;return t.forEach((t=>{if(!i(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}e.bytesToHex=a,e.numberToHexUnpadded=f,e.hexToNumber=c,e.hexToBytes=u,e.bytesToNumberBE=function(t){return c(a(t))},e.bytesToNumberLE=function(t){if(!i(t))throw new Error("Uint8Array expected");return c(a(Uint8Array.from(t).reverse()))},e.numberToBytesBE=h,e.numberToBytesLE=function(t,e){return h(t,e).reverse()},e.numberToVarBytesBE=function(t){return u(f(t))},e.ensureBytes=function(t,e,r){let n;if("string"==typeof e)try{n=u(e)}catch(r){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else{if(!i(e))throw new Error(`${t} must be hex string or Uint8Array`);n=Uint8Array.from(e)}const o=n.length;if("number"==typeof r&&o!==r)throw new Error(`${t} expected ${r} bytes, got ${o}`);return n},e.concatBytes=l,e.equalBytes=function(t,e){if(t.length!==e.length)return!1;for(let r=0;rr;t>>=n,e+=1);return e},e.bitGet=function(t,e){return t>>BigInt(e)&n},e.bitSet=(t,e,o)=>t|(o?n:r)<(o<new Uint8Array(t),y=t=>Uint8Array.from(t);e.createHmacDrbg=function(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=d(t),o=d(t),i=0;const s=()=>{n.fill(1),o.fill(0),i=0},a=(...t)=>r(o,n,...t),f=(t=d())=>{o=a(y([0]),t),n=a(),0!==t.length&&(o=a(y([1]),t),n=a())},c=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t{let r;for(s(),f(t);!(r=e(c()));)f();return s(),r}};const p={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};e.validateObject=function(t,e,r={}){const n=(e,r,n)=>{const o=p[r];if("function"!=typeof o)throw new Error(`Invalid validator "${r}", expected function`);const i=t[e];if(!(n&&void 0===i||o(i,t)))throw new Error(`Invalid param ${String(e)}=${i} (${typeof i}), expected ${r}`)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t}},551:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.mapToCurveSimpleSWU=e.SWUFpSqrtRatio=e.weierstrass=e.weierstrassPoints=e.DER=void 0;const n=r(632),o=r(219),i=r(219),s=r(525),{bytesToNumberBE:a,hexToBytes:f}=o;e.DER={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:r}=e.DER;if(t.length<2||2!==t[0])throw new r("Invalid signature integer tag");const n=t[1],o=t.subarray(2,n+2);if(!n||o.length!==n)throw new r("Invalid signature integer: wrong length");if(128&o[0])throw new r("Invalid signature integer: negative");if(0===o[0]&&!(128&o[1]))throw new r("Invalid signature integer: unnecessary leading zero");return{d:a(o),l:t.subarray(n+2)}},toSig(t){const{Err:r}=e.DER,n="string"==typeof t?f(t):t;if(!(n instanceof Uint8Array))throw new Error("ui8a expected");let o=n.length;if(o<2||48!=n[0])throw new r("Invalid signature tag");if(n[1]!==o-2)throw new r("Invalid signature: incorrect length");const{d:i,l:s}=e.DER._parseInt(n.subarray(2)),{d:a,l:c}=e.DER._parseInt(s);if(c.length)throw new r("Invalid signature: left bytes after parsing");return{r:i,s:a}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),o=e(r(t.r)),i=n.length/2,s=o.length/2,a=r(i),f=r(s);return`30${r(s+i+4)}02${f}${o}02${a}${n}`}};const c=BigInt(0),u=BigInt(1),h=BigInt(2),l=BigInt(3),d=BigInt(4);function y(t){const e=function(t){const e=(0,s.validateBasic)(t);o.validateObject(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,a=e.toBytes||((t,e,n)=>{const i=e.toAffine();return o.concatBytes(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),f=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function h(t){const{a:n,b:o}=e,i=r.sqr(t),s=r.mul(i,t);return r.add(r.add(s,r.mul(t,n)),o)}if(!r.eql(r.sqr(e.Gy),h(e.Gx)))throw new Error("bad generator point: equation left != right");function d(t){return"bigint"==typeof t&&cr.eql(t,r.ZERO);return o(e)&&o(n)?b.ZERO:new b(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(b.fromAffine)}static fromHex(t){const e=b.fromAffine(f((0,i.ensureBytes)("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return b.BASE.multiply(p(t))}_setWindowSize(t){this._WINDOW_SIZE=t,g.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const o=r.sqr(n),i=h(t);if(!r.eql(o,i))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){w(t);const{px:e,py:n,pz:o}=this,{px:i,py:s,pz:a}=t,f=r.eql(r.mul(e,a),r.mul(i,o)),c=r.eql(r.mul(n,a),r.mul(s,o));return f&&c}negate(){return new b(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,o=r.mul(n,l),{px:i,py:s,pz:a}=this;let f=r.ZERO,c=r.ZERO,u=r.ZERO,h=r.mul(i,i),d=r.mul(s,s),y=r.mul(a,a),p=r.mul(i,s);return p=r.add(p,p),u=r.mul(i,a),u=r.add(u,u),f=r.mul(t,u),c=r.mul(o,y),c=r.add(f,c),f=r.sub(d,c),c=r.add(d,c),c=r.mul(f,c),f=r.mul(p,f),u=r.mul(o,u),y=r.mul(t,y),p=r.sub(h,y),p=r.mul(t,p),p=r.add(p,u),u=r.add(h,h),h=r.add(u,h),h=r.add(h,y),h=r.mul(h,p),c=r.add(c,h),y=r.mul(s,a),y=r.add(y,y),h=r.mul(y,p),f=r.sub(f,h),u=r.mul(y,d),u=r.add(u,u),u=r.add(u,u),new b(f,c,u)}add(t){w(t);const{px:n,py:o,pz:i}=this,{px:s,py:a,pz:f}=t;let c=r.ZERO,u=r.ZERO,h=r.ZERO;const d=e.a,y=r.mul(e.b,l);let p=r.mul(n,s),g=r.mul(o,a),m=r.mul(i,f),E=r.add(n,o),v=r.add(s,a);E=r.mul(E,v),v=r.add(p,g),E=r.sub(E,v),v=r.add(n,i);let B=r.add(s,f);return v=r.mul(v,B),B=r.add(p,m),v=r.sub(v,B),B=r.add(o,i),c=r.add(a,f),B=r.mul(B,c),c=r.add(g,m),B=r.sub(B,c),h=r.mul(d,v),c=r.mul(y,m),h=r.add(c,h),c=r.sub(g,h),h=r.add(g,h),u=r.mul(c,h),g=r.add(p,p),g=r.add(g,p),m=r.mul(d,m),v=r.mul(y,v),g=r.add(g,m),m=r.sub(p,m),m=r.mul(d,m),v=r.add(v,m),p=r.mul(g,v),u=r.add(u,p),p=r.mul(B,v),c=r.mul(E,c),c=r.sub(c,p),p=r.mul(E,g),h=r.mul(B,h),h=r.add(h,p),new b(c,u,h)}subtract(t){return this.add(t.negate())}is0(){return this.equals(b.ZERO)}wNAF(t){return E.wNAFCached(this,g,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(b.fromAffine)}))}multiplyUnsafe(t){const n=b.ZERO;if(t===c)return n;if(y(t),t===u)return this;const{endo:o}=e;if(!o)return E.unsafeLadder(this,t);let{k1neg:i,k1:s,k2neg:a,k2:f}=o.splitScalar(t),h=n,l=n,d=this;for(;s>c||f>c;)s&u&&(h=h.add(d)),f&u&&(l=l.add(d)),d=d.double(),s>>=u,f>>=u;return i&&(h=h.negate()),a&&(l=l.negate()),l=new b(r.mul(l.px,o.beta),l.py,l.pz),h.add(l)}multiply(t){y(t);let n,o,i=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:f}=s.splitScalar(i);let{p:c,f:u}=this.wNAF(e),{p:h,f:l}=this.wNAF(f);c=E.constTimeNegate(t,c),h=E.constTimeNegate(a,h),h=new b(r.mul(h.px,s.beta),h.py,h.pz),n=c.add(h),o=u.add(l)}else{const{p:t,f:e}=this.wNAF(i);n=t,o=e}return b.normalizeZ([n,o])[0]}multiplyAndAddUnsafe(t,e,r){const n=b.BASE,o=(t,e)=>e!==c&&e!==u&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),i=o(this,e).add(o(t,r));return i.is0()?void 0:i}toAffine(t){const{px:e,py:n,pz:o}=this,i=this.is0();null==t&&(t=i?r.ONE:r.inv(o));const s=r.mul(e,t),a=r.mul(n,t),f=r.mul(o,t);if(i)return{x:r.ZERO,y:r.ZERO};if(!r.eql(f,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===u)return!0;if(r)return r(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===u?this:r?r(b,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),a(b,this,t)}toHex(t=!0){return o.bytesToHex(this.toRawBytes(t))}}b.BASE=new b(e.Gx,e.Gy,r.ONE),b.ZERO=new b(r.ZERO,r.ONE,r.ZERO);const m=e.nBitLength,E=(0,s.wNAF)(b,e.endo?Math.ceil(m/2):m);return{CURVE:e,ProjectivePoint:b,normPrivateKeyToScalar:p,weierstrassEquation:h,isWithinCurveOrder:d}}function p(t,e){const r=t.ORDER;let n=c;for(let t=r-u;t%h===c;t/=h)n+=u;const o=n,i=h<{let n=g,i=t.pow(r,y),s=t.sqr(i);s=t.mul(s,r);let a=t.mul(e,s);a=t.pow(a,f),a=t.mul(a,i),i=t.mul(a,r),s=t.mul(a,e);let c=t.mul(s,i);a=t.pow(c,p);let l=t.eql(a,t.ONE);i=t.mul(s,w),a=t.mul(c,n),s=t.cmov(i,s,l),c=t.cmov(a,c,l);for(let e=o;e>u;e--){let r=e-h;r=h<{let i=t.sqr(o);const s=t.mul(e,o);i=t.mul(i,s);let a=t.pow(i,r);a=t.mul(a,s);const f=t.mul(a,n),c=t.mul(t.sqr(a),o),u=t.eql(c,e);return{isValid:u,value:t.cmov(f,a,u)}}}return b}e.weierstrassPoints=y,e.weierstrass=function(t){const r=function(t){const e=(0,s.validateBasic)(t);return o.validateObject(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:a,n:f}=r,h=a.BYTES+1,l=2*a.BYTES+1;function d(t){return n.mod(t,f)}function p(t){return n.invert(t,f)}const{ProjectivePoint:g,normPrivateKeyToScalar:w,weierstrassEquation:b,isWithinCurveOrder:m}=y({...r,toBytes(t,e,r){const n=e.toAffine(),i=a.toBytes(n.x),s=o.concatBytes;return r?s(Uint8Array.from([e.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,a.toBytes(n.y))},fromBytes(t){const e=t.length,r=t[0],n=t.subarray(1);if(e!==h||2!==r&&3!==r){if(e===l&&4===r)return{x:a.fromBytes(n.subarray(0,a.BYTES)),y:a.fromBytes(n.subarray(a.BYTES,2*a.BYTES))};throw new Error(`Point of length ${e} was invalid. Expected ${h} compressed bytes or ${l} uncompressed bytes`)}{const t=o.bytesToNumberBE(n);if(!(c<(i=t)&&io.bytesToHex(o.numberToBytesBE(t,r.nByteLength));function v(t){return t>f>>u}const B=(t,e,r)=>o.bytesToNumberBE(t.slice(e,r));class x{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const e=r.nByteLength;return t=(0,i.ensureBytes)("compactSignature",t,2*e),new x(B(t,0,e),B(t,e,2*e))}static fromDER(t){const{r,s:n}=e.DER.toSig((0,i.ensureBytes)("DER",t));return new x(r,n)}assertValidity(){if(!m(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!m(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new x(this.r,this.s,t)}recoverPublicKey(t){const{r:e,s:n,recovery:o}=this,s=U((0,i.ensureBytes)("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const f=2===o||3===o?e+r.n:e;if(f>=a.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=0==(1&o)?"02":"03",u=g.fromHex(c+E(f)),h=p(f),l=d(-s*h),y=d(n*h),w=g.BASE.multiplyAndAddUnsafe(u,l,y);if(!w)throw new Error("point at infinify");return w.assertValidity(),w}hasHighS(){return v(this.s)}normalizeS(){return this.hasHighS()?new x(this.r,d(-this.s),this.recovery):this}toDERRawBytes(){return o.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return o.hexToBytes(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}const A={isValidPrivateKey(t){try{return w(t),!0}catch(t){return!1}},normPrivateKeyToScalar:w,randomPrivateKey:()=>{const t=n.getMinHashLength(r.n);return n.mapHashToField(r.randomBytes(t),r.n)},precompute:(t=8,e=g.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function S(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===h||n===l:r?n===2*h||n===2*l:t instanceof g}const T=r.bits2int||function(t){const e=o.bytesToNumberBE(t),n=8*t.length-r.nBitLength;return n>0?e>>BigInt(n):e},U=r.bits2int_modN||function(t){return d(T(t))},_=o.bitMask(r.nBitLength);function O(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(c<=t&&t<_))throw new Error(`bigint expected < 2^${r.nBitLength}`);return o.numberToBytesBE(t,r.nByteLength)}const I={lowS:r.lowS,prehash:!1},L={lowS:r.lowS,prehash:!1};return g.BASE._setWindowSize(8),{CURVE:r,getPublicKey:function(t,e=!0){return g.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(S(t))throw new Error("first arg must be private key");if(!S(e))throw new Error("second arg must be public key");return g.fromHex(e).multiply(w(t)).toRawBytes(r)},sign:function(t,e,n=I){const{seed:s,k2sig:f}=function(t,e,n=I){if(["recovered","canonical"].some((t=>t in n)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:f}=r;let{lowS:h,prehash:l,extraEntropy:y}=n;null==h&&(h=!0),t=(0,i.ensureBytes)("msgHash",t),l&&(t=(0,i.ensureBytes)("prehashed msgHash",s(t)));const b=U(t),E=w(e),B=[O(E),O(b)];if(null!=y){const t=!0===y?f(a.BYTES):y;B.push((0,i.ensureBytes)("extraEntropy",t))}const A=o.concatBytes(...B),S=b;return{seed:A,k2sig:function(t){const e=T(t);if(!m(e))return;const r=p(e),n=g.BASE.multiply(e).toAffine(),o=d(n.x);if(o===c)return;const i=d(r*d(S+o*E));if(i===c)return;let s=(n.x===o?0:2)|Number(n.y&u),a=i;return h&&v(i)&&(a=function(t){return v(t)?d(-t):t}(i),s^=1),new x(o,a,s)}}}(t,e,n),h=r;return o.createHmacDrbg(h.hash.outputLen,h.nByteLength,h.hmac)(s,f)},verify:function(t,n,o,s=L){const a=t;if(n=(0,i.ensureBytes)("msgHash",n),o=(0,i.ensureBytes)("publicKey",o),"strict"in s)throw new Error("options.strict was renamed to lowS");const{lowS:f,prehash:c}=s;let u,h;try{if("string"==typeof a||a instanceof Uint8Array)try{u=x.fromDER(a)}catch(t){if(!(t instanceof e.DER.Err))throw t;u=x.fromCompact(a)}else{if("object"!=typeof a||"bigint"!=typeof a.r||"bigint"!=typeof a.s)throw new Error("PARSE");{const{r:t,s:e}=a;u=new x(t,e)}}h=g.fromHex(o)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(f&&u.hasHighS())return!1;c&&(n=r.hash(n));const{r:l,s:y}=u,w=U(n),b=p(y),m=d(w*b),E=d(l*b),v=g.BASE.multiplyAndAddUnsafe(h,m,E)?.toAffine();return!!v&&d(v.x)===l},ProjectivePoint:g,Signature:x,utils:A}},e.SWUFpSqrtRatio=p,e.mapToCurveSimpleSWU=function(t,e){if(n.validateField(t),!t.isValid(e.A)||!t.isValid(e.B)||!t.isValid(e.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=p(t,e.Z);if(!t.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let o,i,s,a,f,c,u,h;o=t.sqr(n),o=t.mul(o,e.Z),i=t.sqr(o),i=t.add(i,o),s=t.add(i,t.ONE),s=t.mul(s,e.B),a=t.cmov(e.Z,t.neg(i),!t.eql(i,t.ZERO)),a=t.mul(a,e.A),i=t.sqr(s),c=t.sqr(a),f=t.mul(c,e.A),i=t.add(i,f),i=t.mul(i,s),c=t.mul(c,a),f=t.mul(c,e.B),i=t.add(i,f),u=t.mul(o,s);const{isValid:l,value:d}=r(i,c);h=t.mul(o,n),h=t.mul(h,d),u=t.cmov(u,s,l),h=t.cmov(h,d,l);const y=t.isOdd(n)===t.isOdd(h);return h=t.cmov(t.neg(h),h,y),u=t.div(u,a),{x:u,y:h}}}},497:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0;const n=r(61),o=r(89),i=r(632),s=r(551),a=r(219),f=r(134),c=r(904),u=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),h=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),l=BigInt(1),d=BigInt(2),y=(t,e)=>(t+e/d)/e;function p(t){const e=u,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),a=BigInt(23),f=BigInt(44),c=BigInt(88),h=t*t*t%e,l=h*h*t%e,y=(0,i.pow2)(l,r,e)*l%e,p=(0,i.pow2)(y,r,e)*l%e,w=(0,i.pow2)(p,d,e)*h%e,b=(0,i.pow2)(w,o,e)*w%e,m=(0,i.pow2)(b,s,e)*b%e,E=(0,i.pow2)(m,f,e)*m%e,v=(0,i.pow2)(E,c,e)*E%e,B=(0,i.pow2)(v,f,e)*m%e,x=(0,i.pow2)(B,r,e)*l%e,A=(0,i.pow2)(x,a,e)*b%e,S=(0,i.pow2)(A,n,e)*h%e,T=(0,i.pow2)(S,d,e);if(!g.eql(g.sqr(T),t))throw new Error("Cannot find square root");return T}const g=(0,i.Field)(u,void 0,void 0,{sqrt:p});e.secp256k1=(0,c.createCurve)({a:BigInt(0),b:BigInt(7),Fp:g,n:h,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=h,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-l*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),f=y(s*t,e),c=y(-n*t,e);let u=(0,i.mod)(t-f*r-c*o,e),d=(0,i.mod)(-f*n-c*s,e);const p=u>a,g=d>a;if(p&&(u=e-u),g&&(d=e-d),u>a||d>a)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:p,k1:u,k2neg:g,k2:d}}}},n.sha256);const w=BigInt(0),b=t=>"bigint"==typeof t&&w"bigint"==typeof t&&wt.charCodeAt(0))));r=(0,a.concatBytes)(e,e),E[t]=r}return(0,n.sha256)((0,a.concatBytes)(r,...e))}const B=t=>t.toRawBytes(!0).slice(1),x=t=>(0,a.numberToBytesBE)(t,32),A=t=>(0,i.mod)(t,u),S=t=>(0,i.mod)(t,h),T=e.secp256k1.ProjectivePoint,U=(t,e,r)=>T.BASE.multiplyAndAddUnsafe(t,e,r);function _(t){let r=e.secp256k1.utils.normPrivateKeyToScalar(t),n=T.fromPrivateKey(r);return{scalar:n.hasEvenY()?r:S(-r),bytes:B(n)}}function O(t){if(!b(t))throw new Error("bad x: need 0 < x < p");const e=A(t*t);let r=p(A(e*t+BigInt(7)));r%d!==w&&(r=A(-r));const n=new T(t,r,l);return n.assertValidity(),n}function I(...t){return S((0,a.bytesToNumberBE)(v("BIP0340/challenge",...t)))}function L(t,e,r){const n=(0,a.ensureBytes)("signature",t,64),o=(0,a.ensureBytes)("message",e),i=(0,a.ensureBytes)("publicKey",r,32);try{const t=O((0,a.bytesToNumberBE)(i)),e=(0,a.bytesToNumberBE)(n.subarray(0,32));if(!b(e))return!1;const r=(0,a.bytesToNumberBE)(n.subarray(32,64));if(!m(r))return!1;const s=I(x(e),B(t),o),f=U(t,r,S(-s));return!(!f||!f.hasEvenY()||f.toAffine().x!==e)}catch(t){return!1}}e.schnorr={getPublicKey:function(t){return _(t).bytes},sign:function(t,e,r=(0,o.randomBytes)(32)){const n=(0,a.ensureBytes)("message",t),{bytes:i,scalar:s}=_(e),f=(0,a.ensureBytes)("auxRand",r,32),c=x(s^(0,a.bytesToNumberBE)(v("BIP0340/aux",f))),u=v("BIP0340/nonce",c,i,n),h=S((0,a.bytesToNumberBE)(u));if(h===w)throw new Error("sign failed: k is zero");const{bytes:l,scalar:d}=_(h),y=I(l,i,n),p=new Uint8Array(64);if(p.set(l,0),p.set(x(S(d+y*s)),32),!L(p,n,i))throw new Error("sign: Invalid signature produced");return p},verify:L,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:O,pointToBytes:B,numberToBytesBE:a.numberToBytesBE,bytesToNumberBE:a.bytesToNumberBE,taggedHash:v,mod:i.mod}};const N=(()=>(0,f.isogenyMap)(g,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((t=>t.map((t=>BigInt(t)))))))(),R=(()=>(0,s.mapToCurveSimpleSWU)(g,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:g.create(BigInt("-11"))}))(),k=(()=>(0,f.createHasher)(e.secp256k1.ProjectivePoint,(t=>{const{x:e,y:r}=R(g.create(t[0]));return N(e,r)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:g.ORDER,m:1,k:128,expand:"xmd",hash:n.sha256}))();e.hashToCurve=k.hashToCurve,e.encodeToCurve=k.encodeToCurve},320:(t,e)=>{"use strict";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function n(t){if("boolean"!=typeof t)throw new Error(`Expected boolean, not ${t}`)}function o(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function i(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function s(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function a(t,e){o(t);const r=e.outputLen;if(t.length{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SHA2=void 0;const n=r(320),o=r(89);class i extends o.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,o.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:i}=this,s=(t=(0,o.toBytes)(t)).length;for(let n=0;ni-a&&(this.process(r,0),a=0);for(let t=a;t>o&i),a=Number(r&i),f=n?4:0,c=n?0:4;t.setUint32(e+f,s,n),t.setUint32(e+c,a,n)}(r,i-8,BigInt(8*this.length),s),this.process(r,0);const f=(0,o.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,h=this.get();if(u>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},569:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(320),o=r(89);class i extends o.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,o.toBytes)(e);if(this.iHash=t.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 i=this.blockLen,s=new Uint8Array(i);s.set(r.length>i?t.create().update(r).digest():r);for(let t=0;tnew i(t,e).update(r).digest(),e.hmac.create=(t,e)=>new i(t,e)},61:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const n=r(505),o=r(89),i=(t,e,r)=>t&e^t&r^e&r,s=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]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),f=new Uint32Array(64);class c extends n.SHA2{constructor(){super(64,32,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:r,D:n,E:o,F:i,G:s,H:a}=this;return[t,e,r,n,o,i,s,a]}set(t,e,r,n,o,i,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)f[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=f[t-15],r=f[t-2],n=(0,o.rotr)(e,7)^(0,o.rotr)(e,18)^e>>>3,i=(0,o.rotr)(r,17)^(0,o.rotr)(r,19)^r>>>10;f[t]=i+f[t-7]+n+f[t-16]|0}let{A:r,B:n,C:a,D:c,E:u,F:h,G:l,H:d}=this;for(let t=0;t<64;t++){const e=d+((0,o.rotr)(u,6)^(0,o.rotr)(u,11)^(0,o.rotr)(u,25))+((y=u)&h^~y&l)+s[t]+f[t]|0,p=((0,o.rotr)(r,2)^(0,o.rotr)(r,13)^(0,o.rotr)(r,22))+i(r,n,a)|0;d=l,l=h,h=u,u=c+e|0,c=a,a=n,n=r,r=e+p|0}var y;r=r+this.A|0,n=n+this.B|0,a=a+this.C|0,c=c+this.D|0,u=u+this.E|0,h=h+this.F|0,l=l+this.G|0,d=d+this.H|0,this.set(r,n,a,c,u,h,l,d)}roundClean(){f.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}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}}e.sha256=(0,o.wrapConstructor)((()=>new c)),e.sha224=(0,o.wrapConstructor)((()=>new u))},89:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.isLE=e.rotr=e.createView=e.u32=e.u8=void 0;const n=r(945),o=t=>t instanceof Uint8Array;if(e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const i=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function s(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function a(t){if("string"==typeof t&&(t=s(t)),!o(t))throw new Error("expected Uint8Array, got "+typeof t);return t}e.bytesToHex=function(t){if(!o(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r{},e.asyncLoop=async function(t,r,n){let o=Date.now();for(let i=0;i=0&&tt+e.length),0));let r=0;return t.forEach((t=>{if(!o(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e},e.Hash=class{clone(){return this._cloneInto()}};const f={}.toString;e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==f.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(a(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(a(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(a(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}},885:function(t){!function(e,r){"use strict";t.exports?t.exports=r():(e.nacl||(e.nacl={}),e.nacl.util=r())}(this,(function(){"use strict";var t={};function e(t){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(t))throw new TypeError("invalid encoding")}return t.decodeUTF8=function(t){if("string"!=typeof t)throw new TypeError("expected string");var e,r=unescape(encodeURIComponent(t)),n=new Uint8Array(r.length);for(e=0;e{!function(t){"use strict";var e=function(t){var e,r=new Float64Array(16);if(t)for(e=0;e>24&255,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r,t[e+4]=n>>24&255,t[e+5]=n>>16&255,t[e+6]=n>>8&255,t[e+7]=255&n}function p(t,e,r,n,o){var i,s=0;for(i=0;i>>8)-1}function g(t,e,r,n){return p(t,e,r,n,16)}function w(t,e,r,n){return p(t,e,r,n,32)}function b(t,e,r,n){!function(t,e,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,f=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,y=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,w=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,m=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,v=i,B=s,x=a,A=f,S=c,T=u,U=h,_=l,O=d,I=y,L=p,N=g,R=w,k=b,H=m,M=E,q=0;q<20;q+=2)v^=(o=(R^=(o=(O^=(o=(S^=(o=v+R|0)<<7|o>>>25)+v|0)<<9|o>>>23)+S|0)<<13|o>>>19)+O|0)<<18|o>>>14,T^=(o=(B^=(o=(k^=(o=(I^=(o=T+B|0)<<7|o>>>25)+T|0)<<9|o>>>23)+I|0)<<13|o>>>19)+k|0)<<18|o>>>14,L^=(o=(U^=(o=(x^=(o=(H^=(o=L+U|0)<<7|o>>>25)+L|0)<<9|o>>>23)+H|0)<<13|o>>>19)+x|0)<<18|o>>>14,M^=(o=(N^=(o=(_^=(o=(A^=(o=M+N|0)<<7|o>>>25)+M|0)<<9|o>>>23)+A|0)<<13|o>>>19)+_|0)<<18|o>>>14,v^=(o=(A^=(o=(x^=(o=(B^=(o=v+A|0)<<7|o>>>25)+v|0)<<9|o>>>23)+B|0)<<13|o>>>19)+x|0)<<18|o>>>14,T^=(o=(S^=(o=(_^=(o=(U^=(o=T+S|0)<<7|o>>>25)+T|0)<<9|o>>>23)+U|0)<<13|o>>>19)+_|0)<<18|o>>>14,L^=(o=(I^=(o=(O^=(o=(N^=(o=L+I|0)<<7|o>>>25)+L|0)<<9|o>>>23)+N|0)<<13|o>>>19)+O|0)<<18|o>>>14,M^=(o=(H^=(o=(k^=(o=(R^=(o=M+H|0)<<7|o>>>25)+M|0)<<9|o>>>23)+R|0)<<13|o>>>19)+k|0)<<18|o>>>14;v=v+i|0,B=B+s|0,x=x+a|0,A=A+f|0,S=S+c|0,T=T+u|0,U=U+h|0,_=_+l|0,O=O+d|0,I=I+y|0,L=L+p|0,N=N+g|0,R=R+w|0,k=k+b|0,H=H+m|0,M=M+E|0,t[0]=v>>>0&255,t[1]=v>>>8&255,t[2]=v>>>16&255,t[3]=v>>>24&255,t[4]=B>>>0&255,t[5]=B>>>8&255,t[6]=B>>>16&255,t[7]=B>>>24&255,t[8]=x>>>0&255,t[9]=x>>>8&255,t[10]=x>>>16&255,t[11]=x>>>24&255,t[12]=A>>>0&255,t[13]=A>>>8&255,t[14]=A>>>16&255,t[15]=A>>>24&255,t[16]=S>>>0&255,t[17]=S>>>8&255,t[18]=S>>>16&255,t[19]=S>>>24&255,t[20]=T>>>0&255,t[21]=T>>>8&255,t[22]=T>>>16&255,t[23]=T>>>24&255,t[24]=U>>>0&255,t[25]=U>>>8&255,t[26]=U>>>16&255,t[27]=U>>>24&255,t[28]=_>>>0&255,t[29]=_>>>8&255,t[30]=_>>>16&255,t[31]=_>>>24&255,t[32]=O>>>0&255,t[33]=O>>>8&255,t[34]=O>>>16&255,t[35]=O>>>24&255,t[36]=I>>>0&255,t[37]=I>>>8&255,t[38]=I>>>16&255,t[39]=I>>>24&255,t[40]=L>>>0&255,t[41]=L>>>8&255,t[42]=L>>>16&255,t[43]=L>>>24&255,t[44]=N>>>0&255,t[45]=N>>>8&255,t[46]=N>>>16&255,t[47]=N>>>24&255,t[48]=R>>>0&255,t[49]=R>>>8&255,t[50]=R>>>16&255,t[51]=R>>>24&255,t[52]=k>>>0&255,t[53]=k>>>8&255,t[54]=k>>>16&255,t[55]=k>>>24&255,t[56]=H>>>0&255,t[57]=H>>>8&255,t[58]=H>>>16&255,t[59]=H>>>24&255,t[60]=M>>>0&255,t[61]=M>>>8&255,t[62]=M>>>16&255,t[63]=M>>>24&255}(t,e,r,n)}function m(t,e,r,n){!function(t,e,r,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,f=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,c=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,d=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,y=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,g=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,w=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,m=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,v=0;v<20;v+=2)i^=(o=(w^=(o=(d^=(o=(c^=(o=i+w|0)<<7|o>>>25)+i|0)<<9|o>>>23)+c|0)<<13|o>>>19)+d|0)<<18|o>>>14,u^=(o=(s^=(o=(b^=(o=(y^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+y|0)<<13|o>>>19)+b|0)<<18|o>>>14,p^=(o=(h^=(o=(a^=(o=(m^=(o=p+h|0)<<7|o>>>25)+p|0)<<9|o>>>23)+m|0)<<13|o>>>19)+a|0)<<18|o>>>14,E^=(o=(g^=(o=(l^=(o=(f^=(o=E+g|0)<<7|o>>>25)+E|0)<<9|o>>>23)+f|0)<<13|o>>>19)+l|0)<<18|o>>>14,i^=(o=(f^=(o=(a^=(o=(s^=(o=i+f|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+a|0)<<18|o>>>14,u^=(o=(c^=(o=(l^=(o=(h^=(o=u+c|0)<<7|o>>>25)+u|0)<<9|o>>>23)+h|0)<<13|o>>>19)+l|0)<<18|o>>>14,p^=(o=(y^=(o=(d^=(o=(g^=(o=p+y|0)<<7|o>>>25)+p|0)<<9|o>>>23)+g|0)<<13|o>>>19)+d|0)<<18|o>>>14,E^=(o=(m^=(o=(b^=(o=(w^=(o=E+m|0)<<7|o>>>25)+E|0)<<9|o>>>23)+w|0)<<13|o>>>19)+b|0)<<18|o>>>14;t[0]=i>>>0&255,t[1]=i>>>8&255,t[2]=i>>>16&255,t[3]=i>>>24&255,t[4]=u>>>0&255,t[5]=u>>>8&255,t[6]=u>>>16&255,t[7]=u>>>24&255,t[8]=p>>>0&255,t[9]=p>>>8&255,t[10]=p>>>16&255,t[11]=p>>>24&255,t[12]=E>>>0&255,t[13]=E>>>8&255,t[14]=E>>>16&255,t[15]=E>>>24&255,t[16]=h>>>0&255,t[17]=h>>>8&255,t[18]=h>>>16&255,t[19]=h>>>24&255,t[20]=l>>>0&255,t[21]=l>>>8&255,t[22]=l>>>16&255,t[23]=l>>>24&255,t[24]=d>>>0&255,t[25]=d>>>8&255,t[26]=d>>>16&255,t[27]=d>>>24&255,t[28]=y>>>0&255,t[29]=y>>>8&255,t[30]=y>>>16&255,t[31]=y>>>24&255}(t,e,r,n)}var E=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function v(t,e,r,n,o,i,s){var a,f,c=new Uint8Array(16),u=new Uint8Array(64);for(f=0;f<16;f++)c[f]=0;for(f=0;f<8;f++)c[f]=i[f];for(;o>=64;){for(b(u,c,s,E),f=0;f<64;f++)t[e+f]=r[n+f]^u[f];for(a=1,f=8;f<16;f++)a=a+(255&c[f])|0,c[f]=255&a,a>>>=8;o-=64,e+=64,n+=64}if(o>0)for(b(u,c,s,E),f=0;f=64;){for(b(f,a,o,E),s=0;s<64;s++)t[e+s]=f[s];for(i=1,s=8;s<16;s++)i=i+(255&a[s])|0,a[s]=255&i,i>>>=8;r-=64,e+=64}if(r>0)for(b(f,a,o,E),s=0;s>>13|r<<3),n=255&t[4]|(255&t[5])<<8,this.r[2]=7939&(r>>>10|n<<6),o=255&t[6]|(255&t[7])<<8,this.r[3]=8191&(n>>>7|o<<9),i=255&t[8]|(255&t[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,s=255&t[10]|(255&t[11])<<8,this.r[6]=8191&(i>>>14|s<<2),a=255&t[12]|(255&t[13])<<8,this.r[7]=8065&(s>>>11|a<<5),f=255&t[14]|(255&t[15])<<8,this.r[8]=8191&(a>>>8|f<<8),this.r[9]=f>>>5&127,this.pad[0]=255&t[16]|(255&t[17])<<8,this.pad[1]=255&t[18]|(255&t[19])<<8,this.pad[2]=255&t[20]|(255&t[21])<<8,this.pad[3]=255&t[22]|(255&t[23])<<8,this.pad[4]=255&t[24]|(255&t[25])<<8,this.pad[5]=255&t[26]|(255&t[27])<<8,this.pad[6]=255&t[28]|(255&t[29])<<8,this.pad[7]=255&t[30]|(255&t[31])<<8};function T(t,e,r,n,o,i){var s=new S(i);return s.update(r,n,o),s.finish(t,e),0}function U(t,e,r,n,o,i){var s=new Uint8Array(16);return T(s,0,r,n,o,i),g(t,e,s,0)}function _(t,e,r,n,o){var i;if(r<32)return-1;for(A(t,0,e,0,r,n,o),T(t,16,t,32,r-32,t),i=0;i<16;i++)t[i]=0;return 0}function O(t,e,r,n,o){var i,s=new Uint8Array(32);if(r<32)return-1;if(x(s,0,32,n,o),0!==U(e,16,e,32,r-32,s))return-1;for(A(t,0,e,0,r,n,o),i=0;i<32;i++)t[i]=0;return 0}function I(t,e){var r;for(r=0;r<16;r++)t[r]=0|e[r]}function L(t){var e,r,n=1;for(e=0;e<16;e++)r=t[e]+n+65535,n=Math.floor(r/65536),t[e]=r-65536*n;t[0]+=n-1+37*(n-1)}function N(t,e,r){for(var n,o=~(r-1),i=0;i<16;i++)n=o&(t[i]^e[i]),t[i]^=n,e[i]^=n}function R(t,r){var n,o,i,s=e(),a=e();for(n=0;n<16;n++)a[n]=r[n];for(L(a),L(a),L(a),o=0;o<2;o++){for(s[0]=a[0]-65517,n=1;n<15;n++)s[n]=a[n]-65535-(s[n-1]>>16&1),s[n-1]&=65535;s[15]=a[15]-32767-(s[14]>>16&1),i=s[15]>>16&1,s[14]&=65535,N(a,s,1-i)}for(n=0;n<16;n++)t[2*n]=255&a[n],t[2*n+1]=a[n]>>8}function k(t,e){var r=new Uint8Array(32),n=new Uint8Array(32);return R(r,t),R(n,e),w(r,0,n,0)}function H(t){var e=new Uint8Array(32);return R(e,t),1&e[0]}function M(t,e){var r;for(r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}function q(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]+r[n]}function C(t,e,r){for(var n=0;n<16;n++)t[n]=e[n]-r[n]}function F(t,e,r){var n,o,i=0,s=0,a=0,f=0,c=0,u=0,h=0,l=0,d=0,y=0,p=0,g=0,w=0,b=0,m=0,E=0,v=0,B=0,x=0,A=0,S=0,T=0,U=0,_=0,O=0,I=0,L=0,N=0,R=0,k=0,H=0,M=r[0],q=r[1],C=r[2],F=r[3],P=r[4],D=r[5],j=r[6],z=r[7],$=r[8],K=r[9],V=r[10],Z=r[11],Y=r[12],W=r[13],G=r[14],J=r[15];i+=(n=e[0])*M,s+=n*q,a+=n*C,f+=n*F,c+=n*P,u+=n*D,h+=n*j,l+=n*z,d+=n*$,y+=n*K,p+=n*V,g+=n*Z,w+=n*Y,b+=n*W,m+=n*G,E+=n*J,s+=(n=e[1])*M,a+=n*q,f+=n*C,c+=n*F,u+=n*P,h+=n*D,l+=n*j,d+=n*z,y+=n*$,p+=n*K,g+=n*V,w+=n*Z,b+=n*Y,m+=n*W,E+=n*G,v+=n*J,a+=(n=e[2])*M,f+=n*q,c+=n*C,u+=n*F,h+=n*P,l+=n*D,d+=n*j,y+=n*z,p+=n*$,g+=n*K,w+=n*V,b+=n*Z,m+=n*Y,E+=n*W,v+=n*G,B+=n*J,f+=(n=e[3])*M,c+=n*q,u+=n*C,h+=n*F,l+=n*P,d+=n*D,y+=n*j,p+=n*z,g+=n*$,w+=n*K,b+=n*V,m+=n*Z,E+=n*Y,v+=n*W,B+=n*G,x+=n*J,c+=(n=e[4])*M,u+=n*q,h+=n*C,l+=n*F,d+=n*P,y+=n*D,p+=n*j,g+=n*z,w+=n*$,b+=n*K,m+=n*V,E+=n*Z,v+=n*Y,B+=n*W,x+=n*G,A+=n*J,u+=(n=e[5])*M,h+=n*q,l+=n*C,d+=n*F,y+=n*P,p+=n*D,g+=n*j,w+=n*z,b+=n*$,m+=n*K,E+=n*V,v+=n*Z,B+=n*Y,x+=n*W,A+=n*G,S+=n*J,h+=(n=e[6])*M,l+=n*q,d+=n*C,y+=n*F,p+=n*P,g+=n*D,w+=n*j,b+=n*z,m+=n*$,E+=n*K,v+=n*V,B+=n*Z,x+=n*Y,A+=n*W,S+=n*G,T+=n*J,l+=(n=e[7])*M,d+=n*q,y+=n*C,p+=n*F,g+=n*P,w+=n*D,b+=n*j,m+=n*z,E+=n*$,v+=n*K,B+=n*V,x+=n*Z,A+=n*Y,S+=n*W,T+=n*G,U+=n*J,d+=(n=e[8])*M,y+=n*q,p+=n*C,g+=n*F,w+=n*P,b+=n*D,m+=n*j,E+=n*z,v+=n*$,B+=n*K,x+=n*V,A+=n*Z,S+=n*Y,T+=n*W,U+=n*G,_+=n*J,y+=(n=e[9])*M,p+=n*q,g+=n*C,w+=n*F,b+=n*P,m+=n*D,E+=n*j,v+=n*z,B+=n*$,x+=n*K,A+=n*V,S+=n*Z,T+=n*Y,U+=n*W,_+=n*G,O+=n*J,p+=(n=e[10])*M,g+=n*q,w+=n*C,b+=n*F,m+=n*P,E+=n*D,v+=n*j,B+=n*z,x+=n*$,A+=n*K,S+=n*V,T+=n*Z,U+=n*Y,_+=n*W,O+=n*G,I+=n*J,g+=(n=e[11])*M,w+=n*q,b+=n*C,m+=n*F,E+=n*P,v+=n*D,B+=n*j,x+=n*z,A+=n*$,S+=n*K,T+=n*V,U+=n*Z,_+=n*Y,O+=n*W,I+=n*G,L+=n*J,w+=(n=e[12])*M,b+=n*q,m+=n*C,E+=n*F,v+=n*P,B+=n*D,x+=n*j,A+=n*z,S+=n*$,T+=n*K,U+=n*V,_+=n*Z,O+=n*Y,I+=n*W,L+=n*G,N+=n*J,b+=(n=e[13])*M,m+=n*q,E+=n*C,v+=n*F,B+=n*P,x+=n*D,A+=n*j,S+=n*z,T+=n*$,U+=n*K,_+=n*V,O+=n*Z,I+=n*Y,L+=n*W,N+=n*G,R+=n*J,m+=(n=e[14])*M,E+=n*q,v+=n*C,B+=n*F,x+=n*P,A+=n*D,S+=n*j,T+=n*z,U+=n*$,_+=n*K,O+=n*V,I+=n*Z,L+=n*Y,N+=n*W,R+=n*G,k+=n*J,E+=(n=e[15])*M,s+=38*(B+=n*C),a+=38*(x+=n*F),f+=38*(A+=n*P),c+=38*(S+=n*D),u+=38*(T+=n*j),h+=38*(U+=n*z),l+=38*(_+=n*$),d+=38*(O+=n*K),y+=38*(I+=n*V),p+=38*(L+=n*Z),g+=38*(N+=n*Y),w+=38*(R+=n*W),b+=38*(k+=n*G),m+=38*(H+=n*J),i=(n=(i+=38*(v+=n*q))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),m=(n=m+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),m=(n=m+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),i+=o-1+37*(o-1),t[0]=i,t[1]=s,t[2]=a,t[3]=f,t[4]=c,t[5]=u,t[6]=h,t[7]=l,t[8]=d,t[9]=y,t[10]=p,t[11]=g,t[12]=w,t[13]=b,t[14]=m,t[15]=E}function P(t,e){F(t,e,e)}function D(t,r){var n,o=e();for(n=0;n<16;n++)o[n]=r[n];for(n=253;n>=0;n--)P(o,o),2!==n&&4!==n&&F(o,o,r);for(n=0;n<16;n++)t[n]=o[n]}function j(t,r){var n,o=e();for(n=0;n<16;n++)o[n]=r[n];for(n=250;n>=0;n--)P(o,o),1!==n&&F(o,o,r);for(n=0;n<16;n++)t[n]=o[n]}function z(t,r,n){var o,i,s=new Uint8Array(32),a=new Float64Array(80),c=e(),u=e(),h=e(),l=e(),d=e(),y=e();for(i=0;i<31;i++)s[i]=r[i];for(s[31]=127&r[31]|64,s[0]&=248,M(a,n),i=0;i<16;i++)u[i]=a[i],l[i]=c[i]=h[i]=0;for(c[0]=l[0]=1,i=254;i>=0;--i)N(c,u,o=s[i>>>3]>>>(7&i)&1),N(h,l,o),q(d,c,h),C(c,c,h),q(h,u,l),C(u,u,l),P(l,d),P(y,c),F(c,h,c),F(h,u,d),q(d,c,h),C(c,c,h),P(u,c),C(h,l,y),F(c,h,f),q(c,c,l),F(h,h,c),F(c,l,y),F(l,u,a),P(u,d),N(c,u,o),N(h,l,o);for(i=0;i<16;i++)a[i+16]=c[i],a[i+32]=h[i],a[i+48]=u[i],a[i+64]=l[i];var p=a.subarray(32),g=a.subarray(16);return D(p,p),F(g,g,p),R(t,g),0}function $(t,e){return z(t,e,i)}function K(t,e){return n(e,32),$(t,e)}function V(t,e,r){var n=new Uint8Array(32);return z(n,r,e),m(t,o,n,E)}S.prototype.blocks=function(t,e,r){for(var n,o,i,s,a,f,c,u,h,l,d,y,p,g,w,b,m,E,v,B=this.fin?0:2048,x=this.h[0],A=this.h[1],S=this.h[2],T=this.h[3],U=this.h[4],_=this.h[5],O=this.h[6],I=this.h[7],L=this.h[8],N=this.h[9],R=this.r[0],k=this.r[1],H=this.r[2],M=this.r[3],q=this.r[4],C=this.r[5],F=this.r[6],P=this.r[7],D=this.r[8],j=this.r[9];r>=16;)l=h=0,l+=(x+=8191&(n=255&t[e+0]|(255&t[e+1])<<8))*R,l+=(A+=8191&(n>>>13|(o=255&t[e+2]|(255&t[e+3])<<8)<<3))*(5*j),l+=(S+=8191&(o>>>10|(i=255&t[e+4]|(255&t[e+5])<<8)<<6))*(5*D),l+=(T+=8191&(i>>>7|(s=255&t[e+6]|(255&t[e+7])<<8)<<9))*(5*P),h=(l+=(U+=8191&(s>>>4|(a=255&t[e+8]|(255&t[e+9])<<8)<<12))*(5*F))>>>13,l&=8191,l+=(_+=a>>>1&8191)*(5*C),l+=(O+=8191&(a>>>14|(f=255&t[e+10]|(255&t[e+11])<<8)<<2))*(5*q),l+=(I+=8191&(f>>>11|(c=255&t[e+12]|(255&t[e+13])<<8)<<5))*(5*M),l+=(L+=8191&(c>>>8|(u=255&t[e+14]|(255&t[e+15])<<8)<<8))*(5*H),d=h+=(l+=(N+=u>>>5|B)*(5*k))>>>13,d+=x*k,d+=A*R,d+=S*(5*j),d+=T*(5*D),h=(d+=U*(5*P))>>>13,d&=8191,d+=_*(5*F),d+=O*(5*C),d+=I*(5*q),d+=L*(5*M),h+=(d+=N*(5*H))>>>13,d&=8191,y=h,y+=x*H,y+=A*k,y+=S*R,y+=T*(5*j),h=(y+=U*(5*D))>>>13,y&=8191,y+=_*(5*P),y+=O*(5*F),y+=I*(5*C),y+=L*(5*q),p=h+=(y+=N*(5*M))>>>13,p+=x*M,p+=A*H,p+=S*k,p+=T*R,h=(p+=U*(5*j))>>>13,p&=8191,p+=_*(5*D),p+=O*(5*P),p+=I*(5*F),p+=L*(5*C),g=h+=(p+=N*(5*q))>>>13,g+=x*q,g+=A*M,g+=S*H,g+=T*k,h=(g+=U*R)>>>13,g&=8191,g+=_*(5*j),g+=O*(5*D),g+=I*(5*P),g+=L*(5*F),w=h+=(g+=N*(5*C))>>>13,w+=x*C,w+=A*q,w+=S*M,w+=T*H,h=(w+=U*k)>>>13,w&=8191,w+=_*R,w+=O*(5*j),w+=I*(5*D),w+=L*(5*P),b=h+=(w+=N*(5*F))>>>13,b+=x*F,b+=A*C,b+=S*q,b+=T*M,h=(b+=U*H)>>>13,b&=8191,b+=_*k,b+=O*R,b+=I*(5*j),b+=L*(5*D),m=h+=(b+=N*(5*P))>>>13,m+=x*P,m+=A*F,m+=S*C,m+=T*q,h=(m+=U*M)>>>13,m&=8191,m+=_*H,m+=O*k,m+=I*R,m+=L*(5*j),E=h+=(m+=N*(5*D))>>>13,E+=x*D,E+=A*P,E+=S*F,E+=T*C,h=(E+=U*q)>>>13,E&=8191,E+=_*M,E+=O*H,E+=I*k,E+=L*R,v=h+=(E+=N*(5*j))>>>13,v+=x*j,v+=A*D,v+=S*P,v+=T*F,h=(v+=U*C)>>>13,v&=8191,v+=_*q,v+=O*M,v+=I*H,v+=L*k,x=l=8191&(h=(h=((h+=(v+=N*R)>>>13)<<2)+h|0)+(l&=8191)|0),A=d+=h>>>=13,S=y&=8191,T=p&=8191,U=g&=8191,_=w&=8191,O=b&=8191,I=m&=8191,L=E&=8191,N=v&=8191,e+=16,r-=16;this.h[0]=x,this.h[1]=A,this.h[2]=S,this.h[3]=T,this.h[4]=U,this.h[5]=_,this.h[6]=O,this.h[7]=I,this.h[8]=L,this.h[9]=N},S.prototype.finish=function(t,e){var r,n,o,i,s=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=r,r=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,s[0]=this.h[0]+5,r=s[0]>>>13,s[0]&=8191,i=1;i<10;i++)s[i]=this.h[i]+r,r=s[i]>>>13,s[i]&=8191;for(s[9]-=8192,n=(1^r)-1,i=0;i<10;i++)s[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|s[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;t[e+0]=this.h[0]>>>0&255,t[e+1]=this.h[0]>>>8&255,t[e+2]=this.h[1]>>>0&255,t[e+3]=this.h[1]>>>8&255,t[e+4]=this.h[2]>>>0&255,t[e+5]=this.h[2]>>>8&255,t[e+6]=this.h[3]>>>0&255,t[e+7]=this.h[3]>>>8&255,t[e+8]=this.h[4]>>>0&255,t[e+9]=this.h[4]>>>8&255,t[e+10]=this.h[5]>>>0&255,t[e+11]=this.h[5]>>>8&255,t[e+12]=this.h[6]>>>0&255,t[e+13]=this.h[6]>>>8&255,t[e+14]=this.h[7]>>>0&255,t[e+15]=this.h[7]>>>8&255},S.prototype.update=function(t,e,r){var n,o;if(this.leftover){for((o=16-this.leftover)>r&&(o=r),n=0;n=16&&(o=r-r%16,this.blocks(t,e,o),e+=o,r-=o),r){for(n=0;n=128;){for(B=0;B<16;B++)x=8*B+Y,I[B]=r[x+0]<<24|r[x+1]<<16|r[x+2]<<8|r[x+3],L[B]=r[x+4]<<24|r[x+5]<<16|r[x+6]<<8|r[x+7];for(B=0;B<80;B++)if(o=N,i=R,s=k,a=H,f=M,c=q,u=C,l=P,d=D,y=j,p=z,g=$,w=K,b=V,T=65535&(S=Z),U=S>>>16,_=65535&(A=F),O=A>>>16,T+=65535&(S=($>>>14|M<<18)^($>>>18|M<<14)^(M>>>9|$<<23)),U+=S>>>16,_+=65535&(A=(M>>>14|$<<18)^(M>>>18|$<<14)^($>>>9|M<<23)),O+=A>>>16,T+=65535&(S=$&K^~$&V),U+=S>>>16,_+=65535&(A=M&q^~M&C),O+=A>>>16,A=W[2*B],T+=65535&(S=W[2*B+1]),U+=S>>>16,_+=65535&A,O+=A>>>16,A=I[B%16],U+=(S=L[B%16])>>>16,_+=65535&A,O+=A>>>16,_+=(U+=(T+=65535&S)>>>16)>>>16,T=65535&(S=v=65535&T|U<<16),U=S>>>16,_=65535&(A=E=65535&_|(O+=_>>>16)<<16),O=A>>>16,T+=65535&(S=(P>>>28|N<<4)^(N>>>2|P<<30)^(N>>>7|P<<25)),U+=S>>>16,_+=65535&(A=(N>>>28|P<<4)^(P>>>2|N<<30)^(P>>>7|N<<25)),O+=A>>>16,U+=(S=P&D^P&j^D&j)>>>16,_+=65535&(A=N&R^N&k^R&k),O+=A>>>16,h=65535&(_+=(U+=(T+=65535&S)>>>16)>>>16)|(O+=_>>>16)<<16,m=65535&T|U<<16,T=65535&(S=p),U=S>>>16,_=65535&(A=a),O=A>>>16,U+=(S=v)>>>16,_+=65535&(A=E),O+=A>>>16,R=o,k=i,H=s,M=a=65535&(_+=(U+=(T+=65535&S)>>>16)>>>16)|(O+=_>>>16)<<16,q=f,C=c,F=u,N=h,D=l,j=d,z=y,$=p=65535&T|U<<16,K=g,V=w,Z=b,P=m,B%16==15)for(x=0;x<16;x++)A=I[x],T=65535&(S=L[x]),U=S>>>16,_=65535&A,O=A>>>16,A=I[(x+9)%16],T+=65535&(S=L[(x+9)%16]),U+=S>>>16,_+=65535&A,O+=A>>>16,E=I[(x+1)%16],T+=65535&(S=((v=L[(x+1)%16])>>>1|E<<31)^(v>>>8|E<<24)^(v>>>7|E<<25)),U+=S>>>16,_+=65535&(A=(E>>>1|v<<31)^(E>>>8|v<<24)^E>>>7),O+=A>>>16,E=I[(x+14)%16],U+=(S=((v=L[(x+14)%16])>>>19|E<<13)^(E>>>29|v<<3)^(v>>>6|E<<26))>>>16,_+=65535&(A=(E>>>19|v<<13)^(v>>>29|E<<3)^E>>>6),O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,I[x]=65535&_|O<<16,L[x]=65535&T|U<<16;T=65535&(S=P),U=S>>>16,_=65535&(A=N),O=A>>>16,A=t[0],U+=(S=e[0])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[0]=N=65535&_|O<<16,e[0]=P=65535&T|U<<16,T=65535&(S=D),U=S>>>16,_=65535&(A=R),O=A>>>16,A=t[1],U+=(S=e[1])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[1]=R=65535&_|O<<16,e[1]=D=65535&T|U<<16,T=65535&(S=j),U=S>>>16,_=65535&(A=k),O=A>>>16,A=t[2],U+=(S=e[2])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[2]=k=65535&_|O<<16,e[2]=j=65535&T|U<<16,T=65535&(S=z),U=S>>>16,_=65535&(A=H),O=A>>>16,A=t[3],U+=(S=e[3])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[3]=H=65535&_|O<<16,e[3]=z=65535&T|U<<16,T=65535&(S=$),U=S>>>16,_=65535&(A=M),O=A>>>16,A=t[4],U+=(S=e[4])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[4]=M=65535&_|O<<16,e[4]=$=65535&T|U<<16,T=65535&(S=K),U=S>>>16,_=65535&(A=q),O=A>>>16,A=t[5],U+=(S=e[5])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[5]=q=65535&_|O<<16,e[5]=K=65535&T|U<<16,T=65535&(S=V),U=S>>>16,_=65535&(A=C),O=A>>>16,A=t[6],U+=(S=e[6])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[6]=C=65535&_|O<<16,e[6]=V=65535&T|U<<16,T=65535&(S=Z),U=S>>>16,_=65535&(A=F),O=A>>>16,A=t[7],U+=(S=e[7])>>>16,_+=65535&A,O+=A>>>16,O+=(_+=(U+=(T+=65535&S)>>>16)>>>16)>>>16,t[7]=F=65535&_|O<<16,e[7]=Z=65535&T|U<<16,Y+=128,n-=128}return n}function J(t,e,r){var n,o=new Int32Array(8),i=new Int32Array(8),s=new Uint8Array(256),a=r;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,G(o,i,e,r),r%=128,n=0;n=0;--o)Q(t,e,n=r[o/8|0]>>(7&o)&1),X(e,t),X(t,t),Q(t,e,n)}function rt(t,r){var n=[e(),e(),e(),e()];I(n[0],h),I(n[1],l),I(n[2],a),F(n[3],h,l),et(t,n,r)}function nt(t,r,o){var i,s=new Uint8Array(64),a=[e(),e(),e(),e()];for(o||n(r,32),J(s,r,32),s[0]&=248,s[31]&=127,s[31]|=64,rt(a,s),tt(t,a),i=0;i<32;i++)r[i+32]=t[i];return 0}var ot=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function it(t,e){var r,n,o,i;for(n=63;n>=32;--n){for(r=0,o=n-32,i=n-12;o>4)*ot[o],r=e[o]>>8,e[o]&=255;for(o=0;o<32;o++)e[o]-=r*ot[o];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,t[n]=255&e[n]}function st(t){var e,r=new Float64Array(64);for(e=0;e<64;e++)r[e]=t[e];for(e=0;e<64;e++)t[e]=0;it(t,r)}function at(t,r,n,o){var i,s,a=new Uint8Array(64),f=new Uint8Array(64),c=new Uint8Array(64),u=new Float64Array(64),h=[e(),e(),e(),e()];J(a,o,32),a[0]&=248,a[31]&=127,a[31]|=64;var l=n+64;for(i=0;i>7&&C(t[0],s,t[0]),F(t[3],t[0],t[1]),0)}(l,o))return-1;for(i=0;i=0},t.sign.keyPair=function(){var t=new Uint8Array(ht),e=new Uint8Array(lt);return nt(t,e),{publicKey:t,secretKey:e}},t.sign.keyPair.fromSecretKey=function(t){if(yt(t),t.length!==lt)throw new Error("bad secret key size");for(var e=new Uint8Array(ht),r=0;r{const n=r(780),o=r(885),i=r(497),s=r(61),a={toString:function(t,e="utf8"){switch(e){case"utf8":return function(t){return(new TextDecoder).decode(t)}(t);case"base16":return function(t){return Array.from(t).map((t=>t.toString(16).padStart(2,"0"))).join("")}(t);case"base64url":return function(t){return Buffer.from(t).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}(t);default:throw new Error(`Unsupported encoding "${e}"`)}},fromString:function(t,e="utf8"){if("utf8"===e)return(new TextEncoder).encode(t);if("base16"===e){if(t.length%2!=0)throw new Error("Invalid hex string length.");let e=new Uint8Array(t.length/2);for(let r=0;rp(await e(t))}(r),o=Math.floor(Date.now()/1e3),f={exp:o+60,iat:o,iss:e},d=await async function(t,e,r={}){const{issuer:n,signer:o,alg:i,expiresIn:s,canonicalize:a}=e;if(!o)throw new Error("missing_signer: No Signer functionality has been configured");if(!n)throw new Error("missing_issuer: No issuing DID has been configured");r.typ||(r.typ="JWT"),r.alg||(r.alg=i);const f={iat:Math.floor(Date.now()/1e3),exp:void 0};if(s){if("number"!=typeof s)throw new Error("invalid_argument: JWT expiresIn is not a number");f.exp=(t.nbf||f.iat)+Math.floor(s)}return async function(t,e,r={},n={}){r.alg||(r.alg=c);const o="string"==typeof t?t:u(t,n.canonicalize),i=[u(r,n.canonicalize),o].join("."),s=(!1,async function(t,e){const r=await e(t);return"object"==typeof(n=r)&&"r"in n&&"s"in n?l(r,false):r;var n});return[i,await s(i,e)].join(".")}({...f,...t,iss:n},o,r,{canonicalize:a})}(f,{alg:void 0,issuer:e,signer:n});return d}const c="ES256K";function u(t,e=!1){return r=e?function(t){if("number"==typeof t&&isNaN(t))throw new Error("NaN is not allowed");if("number"==typeof t&&!isFinite(t))throw new Error("Infinity is not allowed");return null===t||"object"!=typeof t?JSON.stringify(t):t.toJSON instanceof Function?serialize(t.toJSON()):Array.isArray(t)?`[${t.reduce(((t,e,r)=>`${t}${0===r?"":","}${serialize(void 0===e||"symbol"==typeof e?null:e)}`),"")}]`:`{${Object.keys(t).sort().reduce(((e,r)=>void 0===t[r]||"symbol"==typeof t[r]?e:`${e}${0===e.length?"":","}${serialize(r)}:${serialize(t[r])}`),"")}}`}(t):JSON.stringify(t),d(a.fromString(r));var r}function h(t,e=64){return t.length===e?t:"0".repeat(e-t.length)+t}function l(t,e){const{r,s:n,recoveryParam:o}=t,i=new Uint8Array(e?65:64);if(i.set(a.fromString(r,"base16"),0),i.set(a.fromString(n,"base16"),32),e){if(void 0===o)throw new Error("Signer did not return a recoveryParam");i[64]=o}return d(i)}function d(t){return a.toString(t,"base64url")}function y(t){return a.toString(t,"base16")}function p(t){const e=function(t){const e=t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");return a.fromString(e,"base64url")}(t);if(e.length<64||e.length>65)throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${e.length}`);return{r:y(e.slice(0,32)),s:y(e.slice(32,64)),recoveryParam:65===e.length?e[64]:void 0}}t.exports={makeNotifications:async function(){const t=localStorage.getItem("secret"),e=o.decodeBase64(t),r=(await async function(t){return new Promise(((t,e)=>{let r=indexedDB.open("TimeSafari");r.onupgradeneeded=t=>{let e=t.target.result;e.objectStoreNames.contains("settings")||e.createObjectStore("settings",{keyPath:"id"})},r.onsuccess=r=>{let n=r.target.result.transaction("settings","readonly").objectStore("settings").get(1);n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)},r.onerror=()=>e(r.error)}))}(),await async function(){try{const t=await new Promise(((t,e)=>{let r=indexedDB.open("TimeSafariAccounts");r.onupgradeneeded=t=>{let e=t.target.result;e.objectStoreNames.contains("accounts")||e.createObjectStore("accounts",{keyPath:"id"})},r.onsuccess=r=>{let n=r.target.result.transaction("accounts","readonly").objectStore("accounts").getAll();n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)},r.onerror=()=>e(r.error)}));return console.log("Accounts:",t),t}catch(t){console.error("Could not get accounts:",t)}}());let i=[];for(var s=0;s{}},e={},r=function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}(82);customModule=r})(); \ No newline at end of file diff --git a/src/custom-module-entry.js b/src/custom-module-entry.js index 974414b..0ee90fa 100644 --- a/src/custom-module-entry.js +++ b/src/custom-module-entry.js @@ -4,9 +4,417 @@ const util = require("tweetnacl-util"); const secp256k1 = require('@noble/curves/secp256k1'); const sha256$1 = require('@noble/hashes/sha256'); +function fromString(str, encoding = 'utf8') { + if (encoding === 'utf8') { + return new TextEncoder().encode(str); + } else if (encoding === 'base16') { + if (str.length % 2 !== 0) { + throw new Error('Invalid hex string length.'); + } + let bytes = new Uint8Array(str.length / 2); + for (let i = 0; i < str.length; i += 2) { + bytes[i/2] = parseInt(str.substring(i, i + 2), 16); + } + return bytes; + + } else if (encoding === 'base64url') { + str = str.replace(/-/g, '+').replace(/_/g, '/'); + while (str.length % 4) { + str += '='; + } + return new Uint8Array(Buffer.from(str, 'base64')); + } else { + throw new Error(`Unsupported encoding "${encoding}"`); + } +} + + +/** + * Convert a Uint8Array to a string with the given encoding. + * + * @param {Uint8Array} byteArray - The Uint8Array to convert. + * @param {string} [encoding='utf8'] - The desired encoding ('utf8', 'base16', 'base64url'). + * @returns {string} - The encoded string. + * @throws {Error} - Throws an error if the encoding is unsupported. + */ +function toString(byteArray, encoding = 'utf8') { + switch (encoding) { + case 'utf8': + return decodeUTF8(byteArray); + case 'base16': + return toBase16(byteArray); + case 'base64url': + return toBase64Url(byteArray); + default: + throw new Error(`Unsupported encoding "${encoding}"`); + } +} + +/** + * Decode a Uint8Array as a UTF-8 string. + * + * @param {Uint8Array} byteArray + * @returns {string} + */ +function decodeUTF8(byteArray) { + return new TextDecoder().decode(byteArray); +} + +/** + * Convert a Uint8Array to a base16 (hex) encoded string. + * + * @param {Uint8Array} byteArray + * @returns {string} + */ +function toBase16(byteArray) { + return Array.from(byteArray).map(byte => byte.toString(16).padStart(2, '0')).join(''); +} + +/** + * Convert a Uint8Array to a base64url encoded string. + * + * @param {Uint8Array} byteArray + * @returns {string} + */ +function toBase64Url(byteArray) { + const base64 = Buffer.from(byteArray).toString('base64'); + return base64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, ''); +} + +const u8a = { toString, fromString }; + +function sha256(payload) { + const data = typeof payload === 'string' ? u8a.fromString(payload) : payload; + return sha256$1.sha256(data); +} + + +async function accessToken(identifier) { + const did = identifier['did']; + const privateKeyHex = identifier['keys'][0]['privateKeyHex']; + + const signer = await SimpleSigner(privateKeyHex); + + const nowEpoch = Math.floor(Date.now() / 1000); + const endEpoch = nowEpoch + 60; // add one minute + + const tokenPayload = { exp: endEpoch, iat: nowEpoch, iss: did }; + const alg = undefined; // defaults to 'ES256K', more standardized but harder to verify vs ES256K-R + const jwt = await createJWT(tokenPayload, { + alg, + issuer: did, + signer, + }); + return jwt; +} + + +async function createJWT(payload, options, header = {}) { + const { issuer, signer, alg, expiresIn, canonicalize } = options; + + if (!signer) throw new Error('missing_signer: No Signer functionality has been configured'); + if (!issuer) throw new Error('missing_issuer: No issuing DID has been configured'); + if (!header.typ) header.typ = 'JWT'; + if (!header.alg) header.alg = alg; + + const timestamps = { + iat: Math.floor(Date.now() / 1000), + exp: undefined, + }; + + if (expiresIn) { + if (typeof expiresIn === 'number') { + timestamps.exp = (payload.nbf || timestamps.iat) + Math.floor(expiresIn); + } else { + throw new Error('invalid_argument: JWT expiresIn is not a number'); + } + } + + const fullPayload = { ...timestamps, ...payload, iss: issuer }; + return createJWS(fullPayload, signer, header, { canonicalize }); +} + + +const defaultAlg = 'ES256K' + + +async function createJWS(payload, signer, header = {}, options = {}) { + if (!header.alg) header.alg = defaultAlg; + const encodedPayload = typeof payload === 'string' ? payload : encodeSection(payload, options.canonicalize); + const signingInput = [encodeSection(header, options.canonicalize), encodedPayload].join('.'); + + const jwtSigner = ES256KSignerAlg(false); + const signature = await jwtSigner(signingInput, signer); + + // JWS Compact Serialization + // https://www.rfc-editor.org/rfc/rfc7515#section-7.1 + return [signingInput, signature].join('.'); +} + +function canonicalizeData (object) { + if (typeof object === 'number' && isNaN(object)) { + throw new Error('NaN is not allowed'); + } + + if (typeof object === 'number' && !isFinite(object)) { + throw new Error('Infinity is not allowed'); + } + + if (object === null || typeof object !== 'object') { + return JSON.stringify(object); + } + + if (object.toJSON instanceof Function) { + return serialize(object.toJSON()); + } + + if (Array.isArray(object)) { + const values = object.reduce((t, cv, ci) => { + const comma = ci === 0 ? '' : ','; + const value = cv === undefined || typeof cv === 'symbol' ? null : cv; + return `${t}${comma}${serialize(value)}`; + }, ''); + return `[${values}]`; + } + + const values = Object.keys(object).sort().reduce((t, cv) => { + if (object[cv] === undefined || + typeof object[cv] === 'symbol') { + return t; + } + const comma = t.length === 0 ? '' : ','; + return `${t}${comma}${serialize(cv)}:${serialize(object[cv])}`; + }, ''); + return `{${values}}`; +}; + +function encodeSection(data, shouldCanonicalize = false) { + if (shouldCanonicalize) { + return encodeBase64url(canonicalizeData(data)); + } else { + return encodeBase64url(JSON.stringify(data)); + } +} + + +function encodeBase64url(s) { + return bytesToBase64url(u8a.fromString(s)) +} + +function instanceOfEcdsaSignature(object) { + return typeof object === 'object' && 'r' in object && 's' in object; +} + +function ES256KSignerAlg(recoverable) { + return async function sign(payload, signer) { + const signature = await signer(payload); + if (instanceOfEcdsaSignature(signature)) { + return toJose(signature, recoverable); + } else { + if (recoverable && typeof fromJose(signature).recoveryParam === 'undefined') { + throw new Error(`not_supported: ES256K-R not supported when signer doesn't provide a recovery param`); + } + return signature; + } + }; +} + +function leftpad(data, size = 64) { + if (data.length === size) return data; + return '0'.repeat(size - data.length) + data; +} + + +async function SimpleSigner(hexPrivateKey) { + const signer = await ES256KSigner(hexToBytes(hexPrivateKey), true); + return async (data) => { + const signature = (await signer(data)); + return fromJose(signature); + }; +} + + +function hexToBytes(s, minLength) { + let input = s.startsWith('0x') ? s.substring(2) : s; + + if (input.length % 2 !== 0) { + input = `0${input}`; + } + + if (minLength) { + const paddedLength = Math.max(input.length, minLength * 2); + input = input.padStart(paddedLength, '00'); + } + + return u8a.fromString(input.toLowerCase(), 'base16'); +} + + +function ES256KSigner(privateKey, recoverable = false) { + const privateKeyBytes = privateKey; + if (privateKeyBytes.length !== 32) { + throw new Error(`bad_key: Invalid private key format. Expecting 32 bytes, but got ${privateKeyBytes.length}`); + } + + return async function(data) { + const signature = secp256k1.secp256k1.sign(sha256(data), privateKeyBytes); + console.log(signature) + return toJose({ + r: leftpad(signature.r.toString(16)), + s: leftpad(signature.s.toString(16)), + recoveryParam: signature.recovery, + }, recoverable); + } +} + + +function toJose(signature, recoverable) { + const { r, s, recoveryParam } = signature; + const jose = new Uint8Array(recoverable ? 65 : 64); + jose.set(u8a.fromString(r, 'base16'), 0); + jose.set(u8a.fromString(s, 'base16'), 32); + + if (recoverable) { + if (typeof recoveryParam === 'undefined') { + throw new Error('Signer did not return a recoveryParam'); + } + jose[64] = recoveryParam; + } + return bytesToBase64url(jose); +} + + +function bytesToBase64url(b) { + return u8a.toString(b, 'base64url'); +} + + +function base64ToBytes(s) { + const inputBase64Url = s.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '') + return u8a.fromString(inputBase64Url, 'base64url') +} + + +function bytesToHex(b) { + return u8a.toString(b, 'base16') +} + + +function fromJose(signature) { + const signatureBytes = base64ToBytes(signature); + if (signatureBytes.length < 64 || signatureBytes.length > 65) { + throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${signatureBytes.length}`,); + } + const r = bytesToHex(signatureBytes.slice(0, 32)); + const s = bytesToHex(signatureBytes.slice(32, 64)); + const recoveryParam = signatureBytes.length === 65 ? signatureBytes[64] : undefined; + + return { r, s, recoveryParam }; +} + + +async function getSettingById(id) { + return new Promise((resolve, reject) => { + let openRequest = indexedDB.open('TimeSafari'); + + openRequest.onupgradeneeded = (event) => { + // Handle database setup if necessary + let db = event.target.result; + if (!db.objectStoreNames.contains('settings')) { + db.createObjectStore('settings', { keyPath: 'id' }); + } + }; + + openRequest.onsuccess = (event) => { + let db = event.target.result; + let transaction = db.transaction('settings', 'readonly'); + let objectStore = transaction.objectStore('settings'); + let getRequest = objectStore.get(id); + + getRequest.onsuccess = () => resolve(getRequest.result); + getRequest.onerror = () => reject(getRequest.error); + }; + + openRequest.onerror = () => reject(openRequest.error); + }); +} + + +function getAllAccounts() { + return new Promise((resolve, reject) => { + let openRequest = indexedDB.open('TimeSafariAccounts'); + + openRequest.onupgradeneeded = (event) => { + // Handle database setup if necessary + let db = event.target.result; + if (!db.objectStoreNames.contains('accounts')) { + db.createObjectStore('accounts', { keyPath: 'id' }); + } + }; + + openRequest.onsuccess = (event) => { + let db = event.target.result; + let transaction = db.transaction('accounts', 'readonly'); + let objectStore = transaction.objectStore('accounts'); + let getAllRequest = objectStore.getAll(); + + getAllRequest.onsuccess = () => resolve(getAllRequest.result); + getAllRequest.onerror = () => reject(getAllRequest.error); + }; + + openRequest.onerror = () => reject(openRequest.error); + }); +} + +// Usage with async/await: +async function fetchAllAccounts() { + try { + const accounts = await getAllAccounts(); + console.log('Accounts:', accounts); + return accounts; + // Further processing with 'accounts' if necessary + } catch (error) { + console.error('Could not get accounts:', error); + } +} + + +async function makeNotifications() { + const secret = localStorage.getItem('secret'); + const secretUint8Array = util.decodeBase64(secret); + + const setting = await getSettingById(1); + const accounts = await fetchAllAccounts(); + + let results = []; + for (var i = 0; i < accounts.length; i++) { + let account = accounts[i]; + let did = account['did']; + let publicKeyHex = account['publicKeyHex']; + let identity = account['identity']; + + const messageWithNonceAsUint8Array = util.decodeBase64(identity); + const nonce = messageWithNonceAsUint8Array.slice(0, 24); + const message = messageWithNonceAsUint8Array.slice(24, identity.length); + const decrypted = nacl.secretbox.open(message, nonce, secretUint8Array); + + const decoder = new TextDecoder('utf-8'); + const msg = decoder.decode(decrypted); + const identifier = JSON.parse(JSON.parse(msg)); + + const headers = { + "Content-Type": "application/json", + }; + + headers["Authorization"] = "Bearer " + await accessToken(identifier); + + results.push({ "headers": headers }) + + } + + return { "headers": headers } +} + module.exports = { - nacl, - util, - secp256k1, - sha256: sha256$1 + makeNotifications };