@dtu-olp-2024/kafka-nocobase
Version:
A NocoBase plugin for Apache Kafka integration, supporting message publishing, topic management, and event-driven workflows. Built for the DTU GreenHope project.
7 lines • 644 kB
JavaScript
(function(){var __webpack_modules__={1654:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.createCurve=t.getHash=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const o=r(9810);const i=r(2164);const a=r(5388);function getHash(e){return{hash:e,hmac:(t,...r)=>(0,o.hmac)(e,t,(0,i.concatBytes)(...r)),randomBytes:i.randomBytes}}t.getHash=getHash;function createCurve(e,t){const create=t=>(0,a.weierstrass)({...e,...getHash(t)});return Object.freeze({...create(t),create:create})}t.createCurve=createCurve},7724:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.validateBasic=t.wNAF=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const o=r(7020);const i=r(2294);const a=BigInt(0);const c=BigInt(1);function wNAF(e,t){const constTimeNegate=(e,t)=>{const r=t.negate();return e?r:t};const opts=e=>{const r=Math.ceil(t/e)+1;const o=2**(e-1);return{windows:r,windowSize:o}};return{constTimeNegate:constTimeNegate,unsafeLadder(t,r){let o=e.ZERO;let i=t;while(r>a){if(r&c)o=o.add(i);i=i.double();r>>=c}return o},precomputeWindow(e,t){const{windows:r,windowSize:o}=opts(t);const i=[];let a=e;let c=a;for(let e=0;e<r;e++){c=a;i.push(c);for(let e=1;e<o;e++){c=c.add(a);i.push(c)}a=c.double()}return i},wNAF(t,r,o){const{windows:i,windowSize:a}=opts(t);let u=e.ZERO;let l=e.BASE;const d=BigInt(2**t-1);const g=2**t;const p=BigInt(t);for(let e=0;e<i;e++){const t=e*a;let i=Number(o&d);o>>=p;if(i>a){i-=g;o+=c}const m=t;const y=t+Math.abs(i)-1;const A=e%2!==0;const v=i<0;if(i===0){l=l.add(constTimeNegate(A,r[m]))}else{u=u.add(constTimeNegate(v,r[y]))}}return{p:u,f:l}},wNAFCached(e,t,r,o){const i=e._WINDOW_SIZE||1;let a=t.get(e);if(!a){a=this.precomputeWindow(e,i);if(i!==1){t.set(e,o(a))}}return this.wNAF(i,a,r)}}}t.wNAF=wNAF;function validateBasic(e){(0,o.validateField)(e.Fp);(0,i.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"});return Object.freeze({...(0,o.nLength)(e.n,e.nBitLength),...e,...{p:e.Fp.ORDER}})}t.validateBasic=validateBasic},8273:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.createHasher=t.isogenyMap=t.hash_to_field=t.expand_message_xof=t.expand_message_xmd=void 0;const o=r(7020);const i=r(2294);function validateDST(e){if(e instanceof Uint8Array)return e;if(typeof e==="string")return(0,i.utf8ToBytes)(e);throw new Error("DST must be Uint8Array or string")}const a=i.bytesToNumberBE;function i2osp(e,t){if(e<0||e>=1<<8*t){throw new Error(`bad I2OSP call: value=${e} length=${t}`)}const r=Array.from({length:t}).fill(0);for(let o=t-1;o>=0;o--){r[o]=e&255;e>>>=8}return new Uint8Array(r)}function strxor(e,t){const r=new Uint8Array(e.length);for(let o=0;o<e.length;o++){r[o]=e[o]^t[o]}return r}function isBytes(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected")}function isNum(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function expand_message_xmd(e,t,r,o){isBytes(e);isBytes(t);isNum(r);if(t.length>255)t=o((0,i.concatBytes)((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-"),t));const{outputLen:a,blockLen:c}=o;const u=Math.ceil(r/a);if(u>255)throw new Error("Invalid xmd length");const l=(0,i.concatBytes)(t,i2osp(t.length,1));const d=i2osp(0,c);const g=i2osp(r,2);const p=new Array(u);const m=o((0,i.concatBytes)(d,e,g,i2osp(0,1),l));p[0]=o((0,i.concatBytes)(m,i2osp(1,1),l));for(let e=1;e<=u;e++){const t=[strxor(m,p[e-1]),i2osp(e+1,1),l];p[e]=o((0,i.concatBytes)(...t))}const y=(0,i.concatBytes)(...p);return y.slice(0,r)}t.expand_message_xmd=expand_message_xmd;function expand_message_xof(e,t,r,o,a){isBytes(e);isBytes(t);isNum(r);if(t.length>255){const e=Math.ceil(2*o/8);t=a.create({dkLen:e}).update((0,i.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(r>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return a.create({dkLen:r}).update(e).update(i2osp(r,2)).update(t).update(i2osp(t.length,1)).digest()}t.expand_message_xof=expand_message_xof;function hash_to_field(e,t,r){(0,i.validateObject)(r,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:c,k:u,m:l,hash:d,expand:g,DST:p}=r;isBytes(e);isNum(t);const m=validateDST(p);const y=c.toString(2).length;const A=Math.ceil((y+u)/8);const v=t*l*A;let w;if(g==="xmd"){w=expand_message_xmd(e,m,v,d)}else if(g==="xof"){w=expand_message_xof(e,m,v,u,d)}else if(g==="_internal_pass"){w=e}else{throw new Error('expand must be "xmd" or "xof"')}const E=new Array(t);for(let e=0;e<t;e++){const t=new Array(l);for(let r=0;r<l;r++){const i=A*(r+e*l);const u=w.subarray(i,i+A);t[r]=(0,o.mod)(a(u),c)}E[e]=t}return E}t.hash_to_field=hash_to_field;function isogenyMap(e,t){const r=t.map((e=>Array.from(e).reverse()));return(t,o)=>{const[i,a,c,u]=r.map((r=>r.reduce(((r,o)=>e.add(e.mul(r,t),o)))));t=e.div(i,a);o=e.mul(o,e.div(c,u));return{x:t,y:o}}}t.isogenyMap=isogenyMap;function createHasher(e,t,r){if(typeof t!=="function")throw new Error("mapToCurve() must be defined");return{hashToCurve(o,i){const a=hash_to_field(o,2,{...r,DST:r.DST,...i});const c=e.fromAffine(t(a[0]));const u=e.fromAffine(t(a[1]));const l=c.add(u).clearCofactor();l.assertValidity();return l},encodeToCurve(o,i){const a=hash_to_field(o,1,{...r,DST:r.encodeDST,...i});const c=e.fromAffine(t(a[0])).clearCofactor();c.assertValidity();return c}}}t.createHasher=createHasher},7020:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.mapHashToField=t.getMinHashLength=t.getFieldBytesLength=t.hashToPrivateScalar=t.FpSqrtEven=t.FpSqrtOdd=t.Field=t.nLength=t.FpIsSquare=t.FpDiv=t.FpInvertBatch=t.FpPow=t.validateField=t.isNegativeLE=t.FpSqrt=t.tonelliShanks=t.invert=t.pow2=t.pow=t.mod=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const o=r(2294);const i=BigInt(0),a=BigInt(1),c=BigInt(2),u=BigInt(3);const l=BigInt(4),d=BigInt(5),g=BigInt(8);const p=BigInt(9),m=BigInt(16);function mod(e,t){const r=e%t;return r>=i?r:t+r}t.mod=mod;function pow(e,t,r){if(r<=i||t<i)throw new Error("Expected power/modulo > 0");if(r===a)return i;let o=a;while(t>i){if(t&a)o=o*e%r;e=e*e%r;t>>=a}return o}t.pow=pow;function pow2(e,t,r){let o=e;while(t-- >i){o*=o;o%=r}return o}t.pow2=pow2;function invert(e,t){if(e===i||t<=i){throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`)}let r=mod(e,t);let o=t;let c=i,u=a,l=a,d=i;while(r!==i){const e=o/r;const t=o%r;const i=c-l*e;const a=u-d*e;o=r,r=t,c=l,u=d,l=i,d=a}const g=o;if(g!==a)throw new Error("invert: does not exist");return mod(c,t)}t.invert=invert;function tonelliShanks(e){const t=(e-a)/c;let r,o,u;for(r=e-a,o=0;r%c===i;r/=c,o++);for(u=c;u<e&&pow(u,t,e)!==e-a;u++);if(o===1){const t=(e+a)/l;return function tonelliFast(e,r){const o=e.pow(r,t);if(!e.eql(e.sqr(o),r))throw new Error("Cannot find square root");return o}}const d=(r+a)/c;return function tonelliSlow(e,i){if(e.pow(i,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let c=o;let l=e.pow(e.mul(e.ONE,u),r);let g=e.pow(i,d);let p=e.pow(i,r);while(!e.eql(p,e.ONE)){if(e.eql(p,e.ZERO))return e.ZERO;let t=1;for(let r=e.sqr(p);t<c;t++){if(e.eql(r,e.ONE))break;r=e.sqr(r)}const r=e.pow(l,a<<BigInt(c-t-1));l=e.sqr(r);g=e.mul(g,r);p=e.mul(p,l);c=t}return g}}t.tonelliShanks=tonelliShanks;function FpSqrt(e){if(e%l===u){const t=(e+a)/l;return function sqrt3mod4(e,r){const o=e.pow(r,t);if(!e.eql(e.sqr(o),r))throw new Error("Cannot find square root");return o}}if(e%g===d){const t=(e-d)/g;return function sqrt5mod8(e,r){const o=e.mul(r,c);const i=e.pow(o,t);const a=e.mul(r,i);const u=e.mul(e.mul(a,c),i);const l=e.mul(a,e.sub(u,e.ONE));if(!e.eql(e.sqr(l),r))throw new Error("Cannot find square root");return l}}if(e%m===p){}return tonelliShanks(e)}t.FpSqrt=FpSqrt;const isNegativeLE=(e,t)=>(mod(e,t)&a)===a;t.isNegativeLE=isNegativeLE;const y=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function validateField(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"};const r=y.reduce(((e,t)=>{e[t]="function";return e}),t);return(0,o.validateObject)(e,r)}t.validateField=validateField;function FpPow(e,t,r){if(r<i)throw new Error("Expected power > 0");if(r===i)return e.ONE;if(r===a)return t;let o=e.ONE;let c=t;while(r>i){if(r&a)o=e.mul(o,c);c=e.sqr(c);r>>=a}return o}t.FpPow=FpPow;function FpInvertBatch(e,t){const r=new Array(t.length);const o=t.reduce(((t,o,i)=>{if(e.is0(o))return t;r[i]=t;return e.mul(t,o)}),e.ONE);const i=e.inv(o);t.reduceRight(((t,o,i)=>{if(e.is0(o))return t;r[i]=e.mul(t,r[i]);return e.mul(t,o)}),i);return r}t.FpInvertBatch=FpInvertBatch;function FpDiv(e,t,r){return e.mul(t,typeof r==="bigint"?invert(r,e.ORDER):e.inv(r))}t.FpDiv=FpDiv;function FpIsSquare(e){const t=(e.ORDER-a)/c;return r=>{const o=e.pow(r,t);return e.eql(o,e.ZERO)||e.eql(o,e.ONE)}}t.FpIsSquare=FpIsSquare;function nLength(e,t){const r=t!==undefined?t:e.toString(2).length;const o=Math.ceil(r/8);return{nBitLength:r,nByteLength:o}}t.nLength=nLength;function Field(e,t,r=false,c={}){if(e<=i)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:u,nByteLength:l}=nLength(e,t);if(l>2048)throw new Error("Field lengths over 2048 bytes are not supported");const d=FpSqrt(e);const g=Object.freeze({ORDER:e,BITS:u,BYTES:l,MASK:(0,o.bitMask)(u),ZERO:i,ONE:a,create:t=>mod(t,e),isValid:t=>{if(typeof t!=="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof t}`);return i<=t&&t<e},is0:e=>e===i,isOdd:e=>(e&a)===a,neg:t=>mod(-t,e),eql:(e,t)=>e===t,sqr:t=>mod(t*t,e),add:(t,r)=>mod(t+r,e),sub:(t,r)=>mod(t-r,e),mul:(t,r)=>mod(t*r,e),pow:(e,t)=>FpPow(g,e,t),div:(t,r)=>mod(t*invert(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>invert(t,e),sqrt:c.sqrt||(e=>d(g,e)),invertBatch:e=>FpInvertBatch(g,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?(0,o.numberToBytesLE)(e,l):(0,o.numberToBytesBE)(e,l),fromBytes:e=>{if(e.length!==l)throw new Error(`Fp.fromBytes: expected ${l}, got ${e.length}`);return r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e)}});return Object.freeze(g)}t.Field=Field;function FpSqrtOdd(e,t){if(!e.isOdd)throw new Error(`Field doesn't have isOdd`);const r=e.sqrt(t);return e.isOdd(r)?r:e.neg(r)}t.FpSqrtOdd=FpSqrtOdd;function FpSqrtEven(e,t){if(!e.isOdd)throw new Error(`Field doesn't have isOdd`);const r=e.sqrt(t);return e.isOdd(r)?e.neg(r):r}t.FpSqrtEven=FpSqrtEven;function hashToPrivateScalar(e,t,r=false){e=(0,o.ensureBytes)("privateHash",e);const i=e.length;const c=nLength(t).nByteLength+8;if(c<24||i<c||i>1024)throw new Error(`hashToPrivateScalar: expected ${c}-1024 bytes of input, got ${i}`);const u=r?(0,o.bytesToNumberLE)(e):(0,o.bytesToNumberBE)(e);return mod(u,t-a)+a}t.hashToPrivateScalar=hashToPrivateScalar;function getFieldBytesLength(e){if(typeof e!=="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}t.getFieldBytesLength=getFieldBytesLength;function getMinHashLength(e){const t=getFieldBytesLength(e);return t+Math.ceil(t/2)}t.getMinHashLength=getMinHashLength;function mapHashToField(e,t,r=false){const i=e.length;const c=getFieldBytesLength(t);const u=getMinHashLength(t);if(i<16||i<u||i>1024)throw new Error(`expected ${u}-1024 bytes of input, got ${i}`);const l=r?(0,o.bytesToNumberBE)(e):(0,o.bytesToNumberLE)(e);const d=mod(l,t-a)+a;return r?(0,o.numberToBytesLE)(d,c):(0,o.numberToBytesBE)(d,c)}t.mapHashToField=mapHashToField},2294:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.validateObject=t.createHmacDrbg=t.bitMask=t.bitSet=t.bitGet=t.bitLen=t.utf8ToBytes=t.equalBytes=t.concatBytes=t.ensureBytes=t.numberToVarBytesBE=t.numberToBytesLE=t.numberToBytesBE=t.bytesToNumberLE=t.bytesToNumberBE=t.hexToBytes=t.hexToNumber=t.numberToHexUnpadded=t.bytesToHex=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const r=BigInt(0);const o=BigInt(1);const i=BigInt(2);const u8a=e=>e instanceof Uint8Array;const a=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function bytesToHex(e){if(!u8a(e))throw new Error("Uint8Array expected");let t="";for(let r=0;r<e.length;r++){t+=a[e[r]]}return t}t.bytesToHex=bytesToHex;function numberToHexUnpadded(e){const t=e.toString(16);return t.length&1?`0${t}`:t}t.numberToHexUnpadded=numberToHexUnpadded;function hexToNumber(e){if(typeof e!=="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}t.hexToNumber=hexToNumber;function hexToBytes(e){if(typeof e!=="string")throw new Error("hex string expected, got "+typeof e);const t=e.length;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(t/2);for(let t=0;t<r.length;t++){const o=t*2;const i=e.slice(o,o+2);const a=Number.parseInt(i,16);if(Number.isNaN(a)||a<0)throw new Error("Invalid byte sequence");r[t]=a}return r}t.hexToBytes=hexToBytes;function bytesToNumberBE(e){return hexToNumber(bytesToHex(e))}t.bytesToNumberBE=bytesToNumberBE;function bytesToNumberLE(e){if(!u8a(e))throw new Error("Uint8Array expected");return hexToNumber(bytesToHex(Uint8Array.from(e).reverse()))}t.bytesToNumberLE=bytesToNumberLE;function numberToBytesBE(e,t){return hexToBytes(e.toString(16).padStart(t*2,"0"))}t.numberToBytesBE=numberToBytesBE;function numberToBytesLE(e,t){return numberToBytesBE(e,t).reverse()}t.numberToBytesLE=numberToBytesLE;function numberToVarBytesBE(e){return hexToBytes(numberToHexUnpadded(e))}t.numberToVarBytesBE=numberToVarBytesBE;function ensureBytes(e,t,r){let o;if(typeof t==="string"){try{o=hexToBytes(t)}catch(r){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${r}`)}}else if(u8a(t)){o=Uint8Array.from(t)}else{throw new Error(`${e} must be hex string or Uint8Array`)}const i=o.length;if(typeof r==="number"&&i!==r)throw new Error(`${e} expected ${r} bytes, got ${i}`);return o}t.ensureBytes=ensureBytes;function concatBytes(...e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.length),0));let r=0;e.forEach((e=>{if(!u8a(e))throw new Error("Uint8Array expected");t.set(e,r);r+=e.length}));return t}t.concatBytes=concatBytes;function equalBytes(e,t){if(e.length!==t.length)return false;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return false;return true}t.equalBytes=equalBytes;function utf8ToBytes(e){if(typeof e!=="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array((new TextEncoder).encode(e))}t.utf8ToBytes=utf8ToBytes;function bitLen(e){let t;for(t=0;e>r;e>>=o,t+=1);return t}t.bitLen=bitLen;function bitGet(e,t){return e>>BigInt(t)&o}t.bitGet=bitGet;const bitSet=(e,t,i)=>e|(i?o:r)<<BigInt(t);t.bitSet=bitSet;const bitMask=e=>(i<<BigInt(e-1))-o;t.bitMask=bitMask;const u8n=e=>new Uint8Array(e);const u8fr=e=>Uint8Array.from(e);function createHmacDrbg(e,t,r){if(typeof e!=="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!=="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!=="function")throw new Error("hmacFn must be a function");let o=u8n(e);let i=u8n(e);let a=0;const reset=()=>{o.fill(1);i.fill(0);a=0};const h=(...e)=>r(i,o,...e);const reseed=(e=u8n())=>{i=h(u8fr([0]),e);o=h();if(e.length===0)return;i=h(u8fr([1]),e);o=h()};const gen=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];while(e<t){o=h();const t=o.slice();r.push(t);e+=o.length}return concatBytes(...r)};const genUntil=(e,t)=>{reset();reseed(e);let r=undefined;while(!(r=t(gen())))reseed();reset();return r};return genUntil}t.createHmacDrbg=createHmacDrbg;const c={bigint:e=>typeof e==="bigint",function:e=>typeof e==="function",boolean:e=>typeof e==="boolean",string:e=>typeof e==="string",stringOrUint8Array:e=>typeof e==="string"||e instanceof Uint8Array,isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e==="function"&&Number.isSafeInteger(e.outputLen)};function validateObject(e,t,r={}){const checkField=(t,r,o)=>{const i=c[r];if(typeof i!=="function")throw new Error(`Invalid validator "${r}", expected function`);const a=e[t];if(o&&a===undefined)return;if(!i(a,e)){throw new Error(`Invalid param ${String(t)}=${a} (${typeof a}), expected ${r}`)}};for(const[e,r]of Object.entries(t))checkField(e,r,false);for(const[e,t]of Object.entries(r))checkField(e,t,true);return e}t.validateObject=validateObject},5388:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.mapToCurveSimpleSWU=t.SWUFpSqrtRatio=t.weierstrass=t.weierstrassPoints=t.DER=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const o=r(7020);const i=r(2294);const a=r(2294);const c=r(7724);function validatePointOpts(e){const t=(0,c.validateBasic)(e);i.validateObject(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:o,a:a}=t;if(r){if(!o.eql(a,o.ZERO)){throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0")}if(typeof r!=="object"||typeof r.beta!=="bigint"||typeof r.splitScalar!=="function"){throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}}return Object.freeze({...t})}const{bytesToNumberBE:u,hexToBytes:l}=i;t.DER={Err:class DERErr extends Error{constructor(e=""){super(e)}},_parseInt(e){const{Err:r}=t.DER;if(e.length<2||e[0]!==2)throw new r("Invalid signature integer tag");const o=e[1];const i=e.subarray(2,o+2);if(!o||i.length!==o)throw new r("Invalid signature integer: wrong length");if(i[0]&128)throw new r("Invalid signature integer: negative");if(i[0]===0&&!(i[1]&128))throw new r("Invalid signature integer: unnecessary leading zero");return{d:u(i),l:e.subarray(o+2)}},toSig(e){const{Err:r}=t.DER;const o=typeof e==="string"?l(e):e;if(!(o instanceof Uint8Array))throw new Error("ui8a expected");let i=o.length;if(i<2||o[0]!=48)throw new r("Invalid signature tag");if(o[1]!==i-2)throw new r("Invalid signature: incorrect length");const{d:a,l:c}=t.DER._parseInt(o.subarray(2));const{d:u,l:d}=t.DER._parseInt(c);if(d.length)throw new r("Invalid signature: left bytes after parsing");return{r:a,s:u}},hexFromSig(e){const slice=e=>Number.parseInt(e[0],16)&8?"00"+e:e;const h=e=>{const t=e.toString(16);return t.length&1?`0${t}`:t};const t=slice(h(e.s));const r=slice(h(e.r));const o=t.length/2;const i=r.length/2;const a=h(o);const c=h(i);return`30${h(i+o+4)}02${c}${r}02${a}${t}`}};const d=BigInt(0),g=BigInt(1),p=BigInt(2),m=BigInt(3),y=BigInt(4);function weierstrassPoints(e){const t=validatePointOpts(e);const{Fp:r}=t;const u=t.toBytes||((e,t,o)=>{const a=t.toAffine();return i.concatBytes(Uint8Array.from([4]),r.toBytes(a.x),r.toBytes(a.y))});const l=t.fromBytes||(e=>{const t=e.subarray(1);const o=r.fromBytes(t.subarray(0,r.BYTES));const i=r.fromBytes(t.subarray(r.BYTES,2*r.BYTES));return{x:o,y:i}});function weierstrassEquation(e){const{a:o,b:i}=t;const a=r.sqr(e);const c=r.mul(a,e);return r.add(r.add(c,r.mul(e,o)),i)}if(!r.eql(r.sqr(t.Gy),weierstrassEquation(t.Gx)))throw new Error("bad generator point: equation left != right");function isWithinCurveOrder(e){return typeof e==="bigint"&&d<e&&e<t.n}function assertGE(e){if(!isWithinCurveOrder(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function normPrivateKeyToScalar(e){const{allowedPrivateKeyLengths:r,nByteLength:c,wrapPrivateKey:u,n:l}=t;if(r&&typeof e!=="bigint"){if(e instanceof Uint8Array)e=i.bytesToHex(e);if(typeof e!=="string"||!r.includes(e.length))throw new Error("Invalid key");e=e.padStart(c*2,"0")}let d;try{d=typeof e==="bigint"?e:i.bytesToNumberBE((0,a.ensureBytes)("private key",e,c))}catch(t){throw new Error(`private key must be ${c} bytes, hex or bigint, not ${typeof e}`)}if(u)d=o.mod(d,l);assertGE(d);return d}const p=new Map;function assertPrjPoint(e){if(!(e instanceof Point))throw new Error("ProjectivePoint expected")}class Point{constructor(e,t,o){this.px=e;this.py=t;this.pz=o;if(e==null||!r.isValid(e))throw new Error("x required");if(t==null||!r.isValid(t))throw new Error("y required");if(o==null||!r.isValid(o))throw new Error("z required")}static fromAffine(e){const{x:t,y:o}=e||{};if(!e||!r.isValid(t)||!r.isValid(o))throw new Error("invalid affine point");if(e instanceof Point)throw new Error("projective point not allowed");const is0=e=>r.eql(e,r.ZERO);if(is0(t)&&is0(o))return Point.ZERO;return new Point(t,o,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(Point.fromAffine)}static fromHex(e){const t=Point.fromAffine(l((0,a.ensureBytes)("pointHex",e)));t.assertValidity();return t}static fromPrivateKey(e){return Point.BASE.multiply(normPrivateKeyToScalar(e))}_setWindowSize(e){this._WINDOW_SIZE=e;p.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:o}=this.toAffine();if(!r.isValid(e)||!r.isValid(o))throw new Error("bad point: x or y not FE");const i=r.sqr(o);const a=weierstrassEquation(e);if(!r.eql(i,a))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){assertPrjPoint(e);const{px:t,py:o,pz:i}=this;const{px:a,py:c,pz:u}=e;const l=r.eql(r.mul(t,u),r.mul(a,i));const d=r.eql(r.mul(o,u),r.mul(c,i));return l&&d}negate(){return new Point(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:o}=t;const i=r.mul(o,m);const{px:a,py:c,pz:u}=this;let l=r.ZERO,d=r.ZERO,g=r.ZERO;let p=r.mul(a,a);let y=r.mul(c,c);let A=r.mul(u,u);let v=r.mul(a,c);v=r.add(v,v);g=r.mul(a,u);g=r.add(g,g);l=r.mul(e,g);d=r.mul(i,A);d=r.add(l,d);l=r.sub(y,d);d=r.add(y,d);d=r.mul(l,d);l=r.mul(v,l);g=r.mul(i,g);A=r.mul(e,A);v=r.sub(p,A);v=r.mul(e,v);v=r.add(v,g);g=r.add(p,p);p=r.add(g,p);p=r.add(p,A);p=r.mul(p,v);d=r.add(d,p);A=r.mul(c,u);A=r.add(A,A);p=r.mul(A,v);l=r.sub(l,p);g=r.mul(A,y);g=r.add(g,g);g=r.add(g,g);return new Point(l,d,g)}add(e){assertPrjPoint(e);const{px:o,py:i,pz:a}=this;const{px:c,py:u,pz:l}=e;let d=r.ZERO,g=r.ZERO,p=r.ZERO;const y=t.a;const A=r.mul(t.b,m);let v=r.mul(o,c);let w=r.mul(i,u);let E=r.mul(a,l);let T=r.add(o,i);let P=r.add(c,u);T=r.mul(T,P);P=r.add(v,w);T=r.sub(T,P);P=r.add(o,a);let S=r.add(c,l);P=r.mul(P,S);S=r.add(v,E);P=r.sub(P,S);S=r.add(i,a);d=r.add(u,l);S=r.mul(S,d);d=r.add(w,E);S=r.sub(S,d);p=r.mul(y,P);d=r.mul(A,E);p=r.add(d,p);d=r.sub(w,p);p=r.add(w,p);g=r.mul(d,p);w=r.add(v,v);w=r.add(w,v);E=r.mul(y,E);P=r.mul(A,P);w=r.add(w,E);E=r.sub(v,E);E=r.mul(y,E);P=r.add(P,E);v=r.mul(w,P);g=r.add(g,v);v=r.mul(S,P);d=r.mul(T,d);d=r.sub(d,v);v=r.mul(T,w);p=r.mul(S,p);p=r.add(p,v);return new Point(d,g,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(Point.ZERO)}wNAF(e){return A.wNAFCached(this,p,e,(e=>{const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(Point.fromAffine)}))}multiplyUnsafe(e){const o=Point.ZERO;if(e===d)return o;assertGE(e);if(e===g)return this;const{endo:i}=t;if(!i)return A.unsafeLadder(this,e);let{k1neg:a,k1:c,k2neg:u,k2:l}=i.splitScalar(e);let p=o;let m=o;let y=this;while(c>d||l>d){if(c&g)p=p.add(y);if(l&g)m=m.add(y);y=y.double();c>>=g;l>>=g}if(a)p=p.negate();if(u)m=m.negate();m=new Point(r.mul(m.px,i.beta),m.py,m.pz);return p.add(m)}multiply(e){assertGE(e);let o=e;let i,a;const{endo:c}=t;if(c){const{k1neg:e,k1:t,k2neg:u,k2:l}=c.splitScalar(o);let{p:d,f:g}=this.wNAF(t);let{p:p,f:m}=this.wNAF(l);d=A.constTimeNegate(e,d);p=A.constTimeNegate(u,p);p=new Point(r.mul(p.px,c.beta),p.py,p.pz);i=d.add(p);a=g.add(m)}else{const{p:e,f:t}=this.wNAF(o);i=e;a=t}return Point.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,r){const o=Point.BASE;const mul=(e,t)=>t===d||t===g||!e.equals(o)?e.multiplyUnsafe(t):e.multiply(t);const i=mul(this,t).add(mul(e,r));return i.is0()?undefined:i}toAffine(e){const{px:t,py:o,pz:i}=this;const a=this.is0();if(e==null)e=a?r.ONE:r.inv(i);const c=r.mul(t,e);const u=r.mul(o,e);const l=r.mul(i,e);if(a)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:c,y:u}}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===g)return true;if(r)return r(Point,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;if(e===g)return this;if(r)return r(Point,this);return this.multiplyUnsafe(t.h)}toRawBytes(e=true){this.assertValidity();return u(Point,this,e)}toHex(e=true){return i.bytesToHex(this.toRawBytes(e))}}Point.BASE=new Point(t.Gx,t.Gy,r.ONE);Point.ZERO=new Point(r.ZERO,r.ONE,r.ZERO);const y=t.nBitLength;const A=(0,c.wNAF)(Point,t.endo?Math.ceil(y/2):y);return{CURVE:t,ProjectivePoint:Point,normPrivateKeyToScalar:normPrivateKeyToScalar,weierstrassEquation:weierstrassEquation,isWithinCurveOrder:isWithinCurveOrder}}t.weierstrassPoints=weierstrassPoints;function validateOpts(e){const t=(0,c.validateBasic)(e);i.validateObject(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"});return Object.freeze({lowS:true,...t})}function weierstrass(e){const r=validateOpts(e);const{Fp:c,n:u}=r;const l=c.BYTES+1;const p=2*c.BYTES+1;function isValidFieldElement(e){return d<e&&e<c.ORDER}function modN(e){return o.mod(e,u)}function invN(e){return o.invert(e,u)}const{ProjectivePoint:m,normPrivateKeyToScalar:y,weierstrassEquation:A,isWithinCurveOrder:v}=weierstrassPoints({...r,toBytes(e,t,r){const o=t.toAffine();const a=c.toBytes(o.x);const u=i.concatBytes;if(r){return u(Uint8Array.from([t.hasEvenY()?2:3]),a)}else{return u(Uint8Array.from([4]),a,c.toBytes(o.y))}},fromBytes(e){const t=e.length;const r=e[0];const o=e.subarray(1);if(t===l&&(r===2||r===3)){const e=i.bytesToNumberBE(o);if(!isValidFieldElement(e))throw new Error("Point is not on curve");const t=A(e);let a=c.sqrt(t);const u=(a&g)===g;const l=(r&1)===1;if(l!==u)a=c.neg(a);return{x:e,y:a}}else if(t===p&&r===4){const e=c.fromBytes(o.subarray(0,c.BYTES));const t=c.fromBytes(o.subarray(c.BYTES,2*c.BYTES));return{x:e,y:t}}else{throw new Error(`Point of length ${t} was invalid. Expected ${l} compressed bytes or ${p} uncompressed bytes`)}}});const numToNByteStr=e=>i.bytesToHex(i.numberToBytesBE(e,r.nByteLength));function isBiggerThanHalfOrder(e){const t=u>>g;return e>t}function normalizeS(e){return isBiggerThanHalfOrder(e)?modN(-e):e}const slcNum=(e,t,r)=>i.bytesToNumberBE(e.slice(t,r));class Signature{constructor(e,t,r){this.r=e;this.s=t;this.recovery=r;this.assertValidity()}static fromCompact(e){const t=r.nByteLength;e=(0,a.ensureBytes)("compactSignature",e,t*2);return new Signature(slcNum(e,0,t),slcNum(e,t,2*t))}static fromDER(e){const{r:r,s:o}=t.DER.toSig((0,a.ensureBytes)("DER",e));return new Signature(r,o)}assertValidity(){if(!v(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!v(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new Signature(this.r,this.s,e)}recoverPublicKey(e){const{r:t,s:o,recovery:i}=this;const u=T((0,a.ensureBytes)("msgHash",e));if(i==null||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const l=i===2||i===3?t+r.n:t;if(l>=c.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=(i&1)===0?"02":"03";const g=m.fromHex(d+numToNByteStr(l));const p=invN(l);const y=modN(-u*p);const A=modN(o*p);const v=m.BASE.multiplyAndAddUnsafe(g,y,A);if(!v)throw new Error("point at infinify");v.assertValidity();return v}hasHighS(){return isBiggerThanHalfOrder(this.s)}normalizeS(){return this.hasHighS()?new Signature(this.r,modN(-this.s),this.recovery):this}toDERRawBytes(){return i.hexToBytes(this.toDERHex())}toDERHex(){return t.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return i.hexToBytes(this.toCompactHex())}toCompactHex(){return numToNByteStr(this.r)+numToNByteStr(this.s)}}const w={isValidPrivateKey(e){try{y(e);return true}catch(e){return false}},normPrivateKeyToScalar:y,randomPrivateKey:()=>{const e=o.getMinHashLength(r.n);return o.mapHashToField(r.randomBytes(e),r.n)},precompute(e=8,t=m.BASE){t._setWindowSize(e);t.multiply(BigInt(3));return t}};function getPublicKey(e,t=true){return m.fromPrivateKey(e).toRawBytes(t)}function isProbPub(e){const t=e instanceof Uint8Array;const r=typeof e==="string";const o=(t||r)&&e.length;if(t)return o===l||o===p;if(r)return o===2*l||o===2*p;if(e instanceof m)return true;return false}function getSharedSecret(e,t,r=true){if(isProbPub(e))throw new Error("first arg must be private key");if(!isProbPub(t))throw new Error("second arg must be public key");const o=m.fromHex(t);return o.multiply(y(e)).toRawBytes(r)}const E=r.bits2int||function(e){const t=i.bytesToNumberBE(e);const o=e.length*8-r.nBitLength;return o>0?t>>BigInt(o):t};const T=r.bits2int_modN||function(e){return modN(E(e))};const P=i.bitMask(r.nBitLength);function int2octets(e){if(typeof e!=="bigint")throw new Error("bigint expected");if(!(d<=e&&e<P))throw new Error(`bigint expected < 2^${r.nBitLength}`);return i.numberToBytesBE(e,r.nByteLength)}function prepSig(e,t,o=S){if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");const{hash:u,randomBytes:l}=r;let{lowS:p,prehash:A,extraEntropy:w}=o;if(p==null)p=true;e=(0,a.ensureBytes)("msgHash",e);if(A)e=(0,a.ensureBytes)("prehashed msgHash",u(e));const P=T(e);const O=y(t);const k=[int2octets(O),int2octets(P)];if(w!=null){const e=w===true?l(c.BYTES):w;k.push((0,a.ensureBytes)("extraEntropy",e))}const R=i.concatBytes(...k);const B=P;function k2sig(e){const t=E(e);if(!v(t))return;const r=invN(t);const o=m.BASE.multiply(t).toAffine();const i=modN(o.x);if(i===d)return;const a=modN(r*modN(B+i*O));if(a===d)return;let c=(o.x===i?0:2)|Number(o.y&g);let u=a;if(p&&isBiggerThanHalfOrder(a)){u=normalizeS(a);c^=1}return new Signature(i,u,c)}return{seed:R,k2sig:k2sig}}const S={lowS:r.lowS,prehash:false};const O={lowS:r.lowS,prehash:false};function sign(e,t,o=S){const{seed:a,k2sig:c}=prepSig(e,t,o);const u=r;const l=i.createHmacDrbg(u.hash.outputLen,u.nByteLength,u.hmac);return l(a,c)}m.BASE._setWindowSize(8);function verify(e,o,i,c=O){const u=e;o=(0,a.ensureBytes)("msgHash",o);i=(0,a.ensureBytes)("publicKey",i);if("strict"in c)throw new Error("options.strict was renamed to lowS");const{lowS:l,prehash:d}=c;let g=undefined;let p;try{if(typeof u==="string"||u instanceof Uint8Array){try{g=Signature.fromDER(u)}catch(e){if(!(e instanceof t.DER.Err))throw e;g=Signature.fromCompact(u)}}else if(typeof u==="object"&&typeof u.r==="bigint"&&typeof u.s==="bigint"){const{r:e,s:t}=u;g=new Signature(e,t)}else{throw new Error("PARSE")}p=m.fromHex(i)}catch(e){if(e.message==="PARSE")throw new Error(`signature must be Signature instance, Uint8Array or hex string`);return false}if(l&&g.hasHighS())return false;if(d)o=r.hash(o);const{r:y,s:A}=g;const v=T(o);const w=invN(A);const E=modN(v*w);const P=modN(y*w);const S=m.BASE.multiplyAndAddUnsafe(p,E,P)?.toAffine();if(!S)return false;const k=modN(S.x);return k===y}return{CURVE:r,getPublicKey:getPublicKey,getSharedSecret:getSharedSecret,sign:sign,verify:verify,ProjectivePoint:m,Signature:Signature,utils:w}}t.weierstrass=weierstrass;function SWUFpSqrtRatio(e,t){const r=e.ORDER;let o=d;for(let e=r-g;e%p===d;e/=p)o+=g;const i=o;const a=p<<i-g-g;const c=a*p;const u=(r-g)/c;const l=(u-g)/p;const A=c-g;const v=a;const w=e.pow(t,u);const E=e.pow(t,(u+g)/p);let sqrtRatio=(t,r)=>{let o=w;let a=e.pow(r,A);let c=e.sqr(a);c=e.mul(c,r);let u=e.mul(t,c);u=e.pow(u,l);u=e.mul(u,a);a=e.mul(u,r);c=e.mul(u,t);let d=e.mul(c,a);u=e.pow(d,v);let m=e.eql(u,e.ONE);a=e.mul(c,E);u=e.mul(d,o);c=e.cmov(a,c,m);d=e.cmov(u,d,m);for(let t=i;t>g;t--){let r=t-p;r=p<<r-g;let i=e.pow(d,r);const u=e.eql(i,e.ONE);a=e.mul(c,o);o=e.mul(o,o);i=e.mul(d,o);c=e.cmov(a,c,u);d=e.cmov(i,d,u)}return{isValid:m,value:c}};if(e.ORDER%y===m){const r=(e.ORDER-m)/y;const o=e.sqrt(e.neg(t));sqrtRatio=(t,i)=>{let a=e.sqr(i);const c=e.mul(t,i);a=e.mul(a,c);let u=e.pow(a,r);u=e.mul(u,c);const l=e.mul(u,o);const d=e.mul(e.sqr(u),i);const g=e.eql(d,t);let p=e.cmov(l,u,g);return{isValid:g,value:p}}}return sqrtRatio}t.SWUFpSqrtRatio=SWUFpSqrtRatio;function mapToCurveSimpleSWU(e,t){o.validateField(e);if(!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=SWUFpSqrtRatio(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return o=>{let i,a,c,u,l,d,g,p;i=e.sqr(o);i=e.mul(i,t.Z);a=e.sqr(i);a=e.add(a,i);c=e.add(a,e.ONE);c=e.mul(c,t.B);u=e.cmov(t.Z,e.neg(a),!e.eql(a,e.ZERO));u=e.mul(u,t.A);a=e.sqr(c);d=e.sqr(u);l=e.mul(d,t.A);a=e.add(a,l);a=e.mul(a,c);d=e.mul(d,u);l=e.mul(d,t.B);a=e.add(a,l);g=e.mul(i,c);const{isValid:m,value:y}=r(a,d);p=e.mul(i,o);p=e.mul(p,y);g=e.cmov(g,c,m);p=e.cmov(p,y,m);const A=e.isOdd(o)===e.isOdd(p);p=e.cmov(e.neg(p),p,A);g=e.div(g,u);return{x:g,y:p}}}t.mapToCurveSimpleSWU=mapToCurveSimpleSWU},8691:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.encodeToCurve=t.hashToCurve=t.schnorr=t.secp256k1=void 0;
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const o=r(9347);const i=r(2164);const a=r(7020);const c=r(5388);const u=r(2294);const l=r(8273);const d=r(1654);const g=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");const p=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");const m=BigInt(1);const y=BigInt(2);const divNearest=(e,t)=>(e+t/y)/t;function sqrtMod(e){const t=g;const r=BigInt(3),o=BigInt(6),i=BigInt(11),c=BigInt(22);const u=BigInt(23),l=BigInt(44),d=BigInt(88);const p=e*e*e%t;const m=p*p*e%t;const v=(0,a.pow2)(m,r,t)*m%t;const w=(0,a.pow2)(v,r,t)*m%t;const E=(0,a.pow2)(w,y,t)*p%t;const T=(0,a.pow2)(E,i,t)*E%t;const P=(0,a.pow2)(T,c,t)*T%t;const S=(0,a.pow2)(P,l,t)*P%t;const O=(0,a.pow2)(S,d,t)*S%t;const k=(0,a.pow2)(O,l,t)*P%t;const R=(0,a.pow2)(k,r,t)*m%t;const B=(0,a.pow2)(R,u,t)*T%t;const N=(0,a.pow2)(B,o,t)*p%t;const L=(0,a.pow2)(N,y,t);if(!A.eql(A.sqr(L),e))throw new Error("Cannot find square root");return L}const A=(0,a.Field)(g,undefined,undefined,{sqrt:sqrtMod});t.secp256k1=(0,d.createCurve)({a:BigInt(0),b:BigInt(7),Fp:A,n:p,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:true,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=p;const r=BigInt("0x3086d221a7d46bcde86c90e49284eb15");const o=-m*BigInt("0xe4437ed6010e88286f547fa90abfe4c3");const i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8");const c=r;const u=BigInt("0x100000000000000000000000000000000");const l=divNearest(c*e,t);const d=divNearest(-o*e,t);let g=(0,a.mod)(e-l*r-d*i,t);let y=(0,a.mod)(-l*o-d*c,t);const A=g>u;const v=y>u;if(A)g=t-g;if(v)y=t-y;if(g>u||y>u){throw new Error("splitScalar: Endomorphism failed, k="+e)}return{k1neg:A,k1:g,k2neg:v,k2:y}}}},o.sha256);const v=BigInt(0);const fe=e=>typeof e==="bigint"&&v<e&&e<g;const ge=e=>typeof e==="bigint"&&v<e&&e<p;const w={};function taggedHash(e,...t){let r=w[e];if(r===undefined){const t=(0,o.sha256)(Uint8Array.from(e,(e=>e.charCodeAt(0))));r=(0,u.concatBytes)(t,t);w[e]=r}return(0,o.sha256)((0,u.concatBytes)(r,...t))}const pointToBytes=e=>e.toRawBytes(true).slice(1);const numTo32b=e=>(0,u.numberToBytesBE)(e,32);const modP=e=>(0,a.mod)(e,g);const modN=e=>(0,a.mod)(e,p);const E=t.secp256k1.ProjectivePoint;const GmulAdd=(e,t,r)=>E.BASE.multiplyAndAddUnsafe(e,t,r);function schnorrGetExtPubKey(e){let r=t.secp256k1.utils.normPrivateKeyToScalar(e);let o=E.fromPrivateKey(r);const i=o.hasEvenY()?r:modN(-r);return{scalar:i,bytes:pointToBytes(o)}}function lift_x(e){if(!fe(e))throw new Error("bad x: need 0 < x < p");const t=modP(e*e);const r=modP(t*e+BigInt(7));let o=sqrtMod(r);if(o%y!==v)o=modP(-o);const i=new E(e,o,m);i.assertValidity();return i}function challenge(...e){return modN((0,u.bytesToNumberBE)(taggedHash("BIP0340/challenge",...e)))}function schnorrGetPublicKey(e){return schnorrGetExtPubKey(e).bytes}function schnorrSign(e,t,r=(0,i.randomBytes)(32)){const o=(0,u.ensureBytes)("message",e);const{bytes:a,scalar:c}=schnorrGetExtPubKey(t);const l=(0,u.ensureBytes)("auxRand",r,32);const d=numTo32b(c^(0,u.bytesToNumberBE)(taggedHash("BIP0340/aux",l)));const g=taggedHash("BIP0340/nonce",d,a,o);const p=modN((0,u.bytesToNumberBE)(g));if(p===v)throw new Error("sign failed: k is zero");const{bytes:m,scalar:y}=schnorrGetExtPubKey(p);const A=challenge(m,a,o);const w=new Uint8Array(64);w.set(m,0);w.set(numTo32b(modN(y+A*c)),32);if(!schnorrVerify(w,o,a))throw new Error("sign: Invalid signature produced");return w}function schnorrVerify(e,t,r){const o=(0,u.ensureBytes)("signature",e,64);const i=(0,u.ensureBytes)("message",t);const a=(0,u.ensureBytes)("publicKey",r,32);try{const e=lift_x((0,u.bytesToNumberBE)(a));const t=(0,u.bytesToNumberBE)(o.subarray(0,32));if(!fe(t))return false;const r=(0,u.bytesToNumberBE)(o.subarray(32,64));if(!ge(r))return false;const c=challenge(numTo32b(t),pointToBytes(e),i);const l=GmulAdd(e,r,modN(-c));if(!l||!l.hasEvenY()||l.toAffine().x!==t)return false;return true}catch(e){return false}}t.schnorr=(()=>({getPublicKey:schnorrGetPublicKey,sign:schnorrSign,verify:schnorrVerify,utils:{randomPrivateKey:t.secp256k1.utils.randomPrivateKey,lift_x:lift_x,pointToBytes:pointToBytes,numberToBytesBE:u.numberToBytesBE,bytesToNumberBE:u.bytesToNumberBE,taggedHash:taggedHash,mod:a.mod}}))();const T=(()=>(0,l.isogenyMap)(A,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))))();const P=(()=>(0,c.mapToCurveSimpleSWU)(A,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:A.create(BigInt("-11"))}))();const S=(()=>(0,l.createHasher)(t.secp256k1.ProjectivePoint,(e=>{const{x:t,y:r}=P(A.create(e[0]));return T(t,r)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:A.ORDER,m:1,k:128,expand:"xmd",hash:o.sha256}))();t.hashToCurve=(()=>S.hashToCurve)();t.encodeToCurve=(()=>S.encodeToCurve)()},7620:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.output=t.exists=t.hash=t.bytes=t.bool=t.number=void 0;function number(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}t.number=number;function bool(e){if(typeof e!=="boolean")throw new Error(`Expected boolean, not ${e}`)}t.bool=bool;function bytes(e,...t){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(e.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`)}t.bytes=bytes;function hash(e){if(typeof e!=="function"||typeof e.create!=="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");number(e.outputLen);number(e.blockLen)}t.hash=hash;function exists(e,t=true){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}t.exists=exists;function output(e,t){bytes(e);const r=t.outputLen;if(e.length<r){throw new Error(`digestInto() expects output buffer of length at least ${r}`)}}t.output=output;const r={number:number,bool:bool,bytes:bytes,hash:hash,exists:exists,output:output};t["default"]=r},3413:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.SHA2=void 0;const o=r(7620);const i=r(2164);function setBigUint64(e,t,r,o){if(typeof e.setBigUint64==="function")return e.setBigUint64(t,r,o);const i=BigInt(32);const a=BigInt(4294967295);const c=Number(r>>i&a);const u=Number(r&a);const l=o?4:0;const d=o?0:4;e.setUint32(t+l,c,o);e.setUint32(t+d,u,o)}class SHA2 extends i.Hash{constructor(e,t,r,o){super();this.blockLen=e;this.outputLen=t;this.padOffset=r;this.isLE=o;this.finished=false;this.length=0;this.pos=0;this.destroyed=false;this.buffer=new Uint8Array(e);this.view=(0,i.createView)(this.buffer)}update(e){(0,o.exists)(this);const{view:t,buffer:r,blockLen:a}=this;e=(0,i.toBytes)(e);const c=e.length;for(let o=0;o<c;){const u=Math.min(a-this.pos,c-o);if(u===a){const t=(0,i.createView)(e);for(;a<=c-o;o+=a)this.process(t,o);continue}r.set(e.subarray(o,o+u),this.pos);this.pos+=u;o+=u;if(this.pos===a){this.process(t,0);this.pos=0}}this.length+=e.length;this.roundClean();return this}digestInto(e){(0,o.exists)(this);(0,o.output)(e,this);this.finished=true;const{buffer:t,view:r,blockLen:a,isLE:c}=this;let{pos:u}=this;t[u++]=128;this.buffer.subarray(u).fill(0);if(this.padOffset>a-u){this.process(r,0);u=0}for(let e=u;e<a;e++)t[e]=0;setBigUint64(r,a-8,BigInt(this.length*8),c);this.process(r,0);const l=(0,i.createView)(e);const d=this.outputLen;if(d%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const g=d/4;const p=this.get();if(g>p.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<g;e++)l.setUint32(4*e,p[e],c)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);this.destroy();return r}_cloneInto(e){e||(e=new this.constructor);e.set(...this.get());const{blockLen:t,buffer:r,length:o,finished:i,destroyed:a,pos:c}=this;e.length=o;e.pos=c;e.finished=i;e.destroyed=a;if(o%t)e.buffer.set(r);return e}}t.SHA2=SHA2},4626:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.add5L=t.add5H=t.add4H=t.add4L=t.add3H=t.add3L=t.add=t.rotlBL=t.rotlBH=t.rotlSL=t.rotlSH=t.rotr32L=t.rotr32H=t.rotrBL=t.rotrBH=t.rotrSL=t.rotrSH=t.shrSL=t.shrSH=t.toBig=t.split=t.fromBig=void 0;const r=BigInt(2**32-1);const o=BigInt(32);function fromBig(e,t=false){if(t)return{h:Number(e&r),l:Number(e>>o&r)};return{h:Number(e>>o&r)|0,l:Number(e&r)|0}}t.fromBig=fromBig;function split(e,t=false){let r=new Uint32Array(e.length);let o=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:a,l:c}=fromBig(e[i],t);[r[i],o[i]]=[a,c]}return[r,o]}t.split=split;const toBig=(e,t)=>BigInt(e>>>0)<<o|BigInt(t>>>0);t.toBig=toBig;const shrSH=(e,t,r)=>e>>>r;t.shrSH=shrSH;const shrSL=(e,t,r)=>e<<32-r|t>>>r;t.shrSL=shrSL;const rotrSH=(e,t,r)=>e>>>r|t<<32-r;t.rotrSH=rotrSH;const rotrSL=(e,t,r)=>e<<32-r|t>>>r;t.rotrSL=rotrSL;const rotrBH=(e,t,r)=>e<<64-r|t>>>r-32;t.rotrBH=rotrBH;const rotrBL=(e,t,r)=>e>>>r-32|t<<64-r;t.rotrBL=rotrBL;const rotr32H=(e,t)=>t;t.rotr32H=rotr32H;const rotr32L=(e,t)=>e;t.rotr32L=rotr32L;const rotlSH=(e,t,r)=>e<<r|t>>>32-r;t.rotlSH=rotlSH;const rotlSL=(e,t,r)=>t<<r|e>>>32-r;t.rotlSL=rotlSL;const rotlBH=(e,t,r)=>t<<r-32|e>>>64-r;t.rotlBH=rotlBH;const rotlBL=(e,t,r)=>e<<r-32|t>>>64-r;t.rotlBL=rotlBL;function add(e,t,r,o){const i=(t>>>0)+(o>>>0);return{h:e+r+(i/2**32|0)|0,l:i|0}}t.add=add;const add3L=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0);t.add3L=add3L;const add3H=(e,t,r,o)=>t+r+o+(e/2**32|0)|0;t.add3H=add3H;const add4L=(e,t,r,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0);t.add4L=add4L;const add4H=(e,t,r,o,i)=>t+r+o+i+(e/2**32|0)|0;t.add4H=add4H;const add5L=(e,t,r,o,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(o>>>0)+(i>>>0);t.add5L=add5L;const add5H=(e,t,r,o,i,a)=>t+r+o+i+a+(e/2**32|0)|0;t.add5H=add5H;const i={fromBig:fromBig,split:split,toBig:toBig,shrSH:shrSH,shrSL:shrSL,rotrSH:rotrSH,rotrSL:rotrSL,rotrBH:rotrBH,rotrBL:rotrBL,rotr32H:rotr32H,rotr32L:rotr32L,rotlSH:rotlSH,rotlSL:rotlSL,rotlBH:rotlBH,rotlBL:rotlBL,add:add,add3L:add3L,add3H:add3H,add4L:add4L,add4H:add4H,add5H:add5H,add5L:add5L};t["default"]=i},9945:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.crypto=void 0;const o=r(6005);t.crypto=o&&typeof o==="object"&&"webcrypto"in o?o.webcrypto:undefined},9810:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.hmac=t.HMAC=void 0;const o=r(7620);const i=r(2164);class HMAC extends i.Hash{constructor(e,t){super();this.finished=false;this.destroyed=false;(0,o.hash)(e);const r=(0,i.toBytes)(t);this.iHash=e.create();if(typeof this.iHash.update!=="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen;this.outputLen=this.iHash.outputLen;const a=this.blockLen;const c=new Uint8Array(a);c.set(r.length>a?e.create().update(r).digest():r);for(let e=0;e<c.length;e++)c[e]^=54;this.iHash.update(c);this.oHash=e.create();for(let e=0;e<c.length;e++)c[e]^=54^92;this.oHash.update(c);c.fill(0)}update(e){(0,o.exists)(this);this.iHash.update(e);return this}digestInto(e){(0,o.exists)(this);(0,o.bytes)(e,this.outputLen);this.finished=true;this.iHash.digestInto(e);this.oHash.update(e);this.oHash.digestInto(e);this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);this.digestInto(e);return e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:o,destroyed:i,blockLen:a,outputLen:c}=this;e=e;e.finished=o;e.destroyed=i;e.blockLen=a;e.outputLen=c;e.oHash=t._cloneInto(e.oHash);e.iHash=r._cloneInto(e.iHash);return e}destroy(){this.destroyed=true;this.oHash.destroy();this.iHash.destroy()}}t.HMAC=HMAC;const hmac=(e,t,r)=>new HMAC(e,t).update(r).digest();t.hmac=hmac;t.hmac.create=(e,t)=>new HMAC(e,t)},644:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.pbkdf2Async=t.pbkdf2=void 0;const o=r(7620);const i=r(9810);const a=r(2164);function pbkdf2Init(e,t,r,c){(0,o.hash)(e);const u=(0,a.checkOpts)({dkLen:32,asyncTick:10},c);const{c:l,dkLen:d,asyncTick:g}=u;(0,o.number)(l);(0,o.number)(d);(0,o.number)(g);if(l<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const p=(0,a.toBytes)(t);const m=(0,a.toBytes)(r);const y=new Uint8Array(d);const A=i.hmac.create(e,p);const v=A._cloneInto().update(m);return{c:l,dkLen:d,asyncTick:g,DK:y,PRF:A,PRFSalt:v}}function pbkdf2Output(e,t,r,o,i){e.destroy();t.destroy();if(o)o.destroy();i.fill(0);return r}function pbkdf2(e,t,r,o){const{c:i,dkLen:c,DK:u,PRF:l,PRFSalt:d}=pbkdf2Init(e,t,r,o);let g;const p=new Uint8Array(4);const m=(0,a.createView)(p);const y=new Uint8Array(l.outputLen);for(let e=1,t=0;t<c;e++,t+=l.outputLen){const r=u.subarray(t,t+l.outputLen);m.setInt32(0,e,false);(g=d._cloneInto(g)).update(p).digestInto(y);r.set(y.subarray(0,r.length));for(let e=1;e<i;e++){l._cloneInto(g).update(y).digestInto(y);for(let e=0;e<r.length;e++)r[e]^=y[e]}}return pbkdf2Output(l,d,u,g,y)}t.pbkdf2=pbkdf2;async function pbkdf2Async(e,t,r,o){const{c:i,dkLen:c,asyncTick:u,DK:l,PRF:d,PRFSalt:g}=pbkdf2Init(e,t,r,o);let p;const m=new Uint8Array(4);const y=(0,a.createView)(m);const A=new Uint8Array(d.outputLen);for(let e=1,t=0;t<c;e++,t+=d.outputLen){const r=l.subarray(t,t+d.outputLen);y.setInt32(0,e,false);(p=g._cloneInto(p)).update(m).digestInto(A);r.set(A.subarray(0,r.length));await(0,a.asyncLoop)(i-1,u,(()=>{d._cloneInto(p).update(A).digestInto(A);for(let e=0;e<r.length;e++)r[e]^=A[e]}))}return pbkdf2Output(d,g,l,p,A)}t.pbkdf2Async=pbkdf2Async},7928:function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:true});t.ripemd160=t.RIPEMD160=void 0;const o=r(3413);const i=r(2164);const a=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]);const c=Uint8Array.from({length:16},((e,t)=>t));const u=c.map((e=>(9*e+5)%16));let l=[c];let d=[u];for(let e=0;e<4;e++)for(let t of[l,d])t.push(t[e].map((e=>a[e])));const g=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((e=>new Uint8Array(e)));const p=l.map(((e,t)=>e.map((e=>g[t][e]))));const m=d.map(((e,t)=>e.map((e=>g[t][e]))));const y=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]);const A=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);const rotl=(e,t)=>e<<t|e>>>32-t;function f(e,t,r,o){if(e===0)return t^r^o;else if(e===1)return t&r|~t&o;else if(e===2)return(t|~r)^o;else if(e===3)return t&o|r&~o;else return t^(r|~o)}const v=new Uint32Array(16);class RIPEMD160 extends o.SHA2{constructor(){super(64,20,8,true);this.h0=1732584193|0;this.h1=4023233417|0;this.h2=2562383102|0;this.h3=271733878|0;this.h4=3285377520|0}get(){const{h0:e,h1:t,h2:r,h3:o,h4:i}=this;return[e,t,r,o,i]}set(e,t,r,o,i){this.h0=e|0;this.h1=t|0;this.h2=r|0;this.h3=o|0;this.h4=i|0}process(e,t){for(let r=0;r<16;r++,t+=4)v[r]=e.getUint32(t,true);let r=this.h0|0,o=r,i=this.h1|0,a=i,c=this.h2|0,u=c,g=this.h3|0,w=g,E=this.h4|0,T=E;for(let e=0;e<5;e++){const t=4-e;const P=y[e],S=A[e];const O=l[e],k=d[e];const R=p[e],B=m[e];for(let t=0;t<16;t++){const o=rotl(r+f(e,i,c,g)+v[O[t]]+P,R[t])+E|0;r=E,E=g,g=rotl(c,10)|0,c=i,i=o}for(let e=0;e<16;e++){const r=rotl(o+f(t,a,u,w)+v[k[e]]+S,B[e])+T|0;o=T,T=w,w=rotl(u,10)|0,u=a,a=r}}this.set(this.h1+c+w|0,this.h2+g+T|0,this.h3+E+o|0,this.h4+r+a|0,this.h0+i+u|0)}roundClean(){v.fill(0)}destroy(){this.destroyed=true;this.buffer