(function(C,V){typeof exports=="object"&&typeof module<"u"?V(exports):typeof define=="function"&&define.amd?define(["exports"],V):(C=typeof globalThis<"u"?globalThis:C||self,V(C.CurveP256={}))})(this,function(C){"use strict";var De=Object.defineProperty;var Ke=(C,V,rt)=>V in C?De(C,V,{enumerable:!0,configurable:!0,writable:!0,value:rt}):C[V]=rt;var _=(C,V,rt)=>(Ke(C,typeof V!="symbol"?V+"":V,rt),rt);function V(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`Wrong positive integer: ${e}`)}function rt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function $t(e,...n){if(!rt(e))throw new Error("Expected Uint8Array");if(n.length>0&&!n.includes(e.length))throw new Error(`Expected Uint8Array of length ${n}, not of length=${e.length}`)}function ee(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");V(e.outputLen),V(e.blockLen)}function bt(e,n=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(n&&e.finished)throw new Error("Hash#digest() has already been called")}function ne(e,n){$t(e);const t=n.outputLen;if(e.length65536){const t="Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length ("+e.byteLength+") exceeds the number of bytes of entropy available via this API (65536).";throw"DOMException"in globalThis?new globalThis.DOMException(t):new Error(t)}const n=Math.pow(256,e.BYTES_PER_ELEMENT);for(let t=0;t2147483647)throw new RangeError(`[ERR_OUT_OF_RANGE]: The value of "size" is out of range. It must be >= 0 && <= 2147483647. Received ${e}`);if(n&&typeof n!="function")throw new TypeError(`[ERR_INVALID_ARG_TYPE]: The "callback" argument must be of type function. Received type ${typeof n} (${n})`);if(!n){const t=new Uint8Array(e);return Et(t)}return new Promise(t=>{const r=new Uint8Array(e);let o=null;const i=n;try{i(null,Et(r))}catch{i(o,r)}t(r)})}function re(){return Bt(16).reduce((t,r,o)=>{let i=t+r.toString(16).padStart(2,"0");return(o===8||o===12||o===16||o===20)&&(i+="-"),i},"")}(function(){if("crypto"in globalThis)"randomBytes"in globalThis.crypto||(globalThis.crypto.randomBytes=Bt);else{const e={getRandomValues:Et,randomUUID:re,randomBytes:Bt};globalThis.crypto=e}})();const At=globalThis.crypto;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Rt(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}const vt=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),D=(e,n)=>e<<32-n|e>>>n;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function oe(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function xt(e){if(typeof e=="string"&&(e=oe(e)),!Rt(e))throw new Error(`expected Uint8Array, got ${typeof e}`);return e}function ie(...e){let n=0;for(let r=0;re().update(xt(r)).digest(),t=e();return n.outputLen=t.outputLen,n.blockLen=t.blockLen,n.create=()=>e(),n}function ce(e=32){if(At&&typeof At.getRandomValues=="function")return At.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}class Ct extends qt{constructor(t,r){super();_(this,"oHash");_(this,"iHash");_(this,"blockLen");_(this,"outputLen");_(this,"finished",!1);_(this,"destroyed",!1);ee(t);const o=xt(r);if(this.iHash=t.create(),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 i=this.blockLen,u=new Uint8Array(i);u.set(o.length>i?t.create().update(o).digest():o);for(let s=0;snew Ct(e,n).update(t).digest();Vt.create=(e,n)=>new Ct(e,n);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Zt=BigInt(0),mt=BigInt(1),fe=BigInt(2);function K(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}const ue=Array.from({length:256},(e,n)=>n.toString(16).padStart(2,"0"));function ot(e){if(!K(e))throw new Error("Uint8Array expected");let n="";for(let t=0;t=W._0&&e<=W._9)return e-W._0;if(e>=W._A&&e<=W._F)return e-(W._A-10);if(e>=W._a&&e<=W._f)return e-(W._a-10)}function it(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);const n=e.length,t=n/2;if(n%2)throw new Error("padded hex string expected, got unpadded hex of length "+n);const r=new Uint8Array(t);for(let o=0,i=0;oZt;e>>=mt,n+=1);return n}function ge(e,n){return e>>BigInt(n)&mt}const we=(e,n,t)=>e|(t?mt:Zt)<(fe<new Uint8Array(e),kt=e=>Uint8Array.from(e);function zt(e,n,t){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof n!="number"||n<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=Ut(e),o=Ut(e),i=0;const u=()=>{r.fill(1),o.fill(0),i=0},s=(...S)=>t(o,r,...S),c=(S=Ut())=>{o=s(kt([0]),S),r=s(),S.length!==0&&(o=s(kt([1]),S),r=s())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let S=0;const w=[];for(;S{u(),c(S);let U;for(;!(U=w(f()));)c();return u(),U}}const pe={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"||K(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,n)=>n.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function pt(e,n,t={}){const r=(o,i,u)=>{const s=pe[i];if(typeof s!="function")throw new Error(`Invalid validator "${i}", expected function`);const c=e[o];if(!(u&&c===void 0)&&!s(c,e))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${i}`)};for(const[o,i]of Object.entries(n))r(o,i,!1);for(const[o,i]of Object.entries(t))r(o,i,!0);return e}const ye=Object.freeze(Object.defineProperty({__proto__:null,bitGet:ge,bitLen:de,bitMask:Lt,bitSet:we,bytesToHex:ot,bytesToNumberBE:st,bytesToNumberLE:It,concatBytes:at,createHmacDrbg:zt,ensureBytes:M,equalBytes:ae,hexToBytes:it,hexToNumber:St,isBytes:K,numberToBytesBE:lt,numberToBytesLE:Tt,numberToHexUnpadded:jt,numberToVarBytesBE:le,utf8ToBytes:he,validateObject:pt},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const q=BigInt(0),$=BigInt(1),ct=BigInt(2),be=BigInt(3),Ot=BigInt(4),Yt=BigInt(5),Mt=BigInt(8);BigInt(9),BigInt(16);function z(e,n){const t=e%n;return t>=q?t:n+t}function me(e,n,t){if(t<=q||n 0");if(t===$)return q;let r=$;for(;n>q;)n&$&&(r=r*e%t),e=e*e%t,n>>=$;return r}function Nt(e,n){if(e===q||n<=q)throw new Error(`invert: expected positive integers, got n=${e} mod=${n}`);let t=z(e,n),r=n,o=q,i=$;for(;t!==q;){const s=r/t,c=r%t,f=o-i*s;r=t,t=c,o=i,i=f}if(r!==$)throw new Error("invert: does not exist");return z(o,n)}function Ee(e){const n=(e-$)/ct;let t,r,o;for(t=e-$,r=0;t%ct===q;t/=ct,r++);for(o=ct;o(r[o]="function",r),n);return pt(e,t)}function xe(e,n,t){if(t 0");if(t===q)return e.ONE;if(t===$)return n;let r=e.ONE,o=n;for(;t>q;)t&$&&(r=e.mul(r,o)),o=e.sqr(o),t>>=$;return r}function Se(e,n){const t=new Array(n.length),r=n.reduce((i,u,s)=>e.is0(u)?i:(t[s]=i,e.mul(i,u)),e.ONE),o=e.inv(r);return n.reduceRight((i,u,s)=>e.is0(u)?i:(t[s]=e.mul(i,t[s]),e.mul(i,u)),o),t}function Gt(e,n){const t=n!==void 0?n:e.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function Ie(e,n,t=!1,r={}){if(e<=q)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Gt(e,n);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const u=Be(e),s=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:Lt(o),ZERO:q,ONE:$,create:c=>z(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return q<=c&&cc===q,isOdd:c=>(c&$)===$,neg:c=>z(-c,e),eql:(c,f)=>c===f,sqr:c=>z(c*c,e),add:(c,f)=>z(c+f,e),sub:(c,f)=>z(c-f,e),mul:(c,f)=>z(c*f,e),pow:(c,f)=>xe(s,c,f),div:(c,f)=>z(c*Nt(f,e),e),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Nt(c,e),sqrt:r.sqrt||(c=>u(s,c)),invertBatch:c=>Se(s,c),cmov:(c,f,m)=>m?f:c,toBytes:c=>t?Tt(c,i):lt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?It(c):st(c)}});return Object.freeze(s)}function Ft(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const n=e.toString(2).length;return Math.ceil(n/8)}function Dt(e){const n=Ft(e);return n+Math.ceil(n/2)}function Te(e,n,t=!1){const r=e.length,o=Ft(n),i=Dt(n);if(r<16||r1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const u=t?st(e):It(e),s=z(u,n-$)+$;return t?Tt(s,o):lt(s,o)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Le=BigInt(0),Ht=BigInt(1);function Ue(e,n){const t=(o,i)=>{const u=i.negate();return o?u:i},r=o=>{const i=Math.ceil(n/o)+1,u=2**(o-1);return{windows:i,windowSize:u}};return{constTimeNegate:t,unsafeLadder(o,i){let u=e.ZERO,s=o;for(;i>Le;)i&Ht&&(u=u.add(s)),s=s.double(),i>>=Ht;return u},precomputeWindow(o,i){const{windows:u,windowSize:s}=r(i),c=[];let f=o,m=f;for(let S=0;S>=U,l>c&&(l-=w,u+=Ht);const a=B,g=B+Math.abs(l)-1,E=b%2!==0,A=l<0;l===0?m=m.add(t(E,i[a])):f=f.add(t(A,i[g]))}return{p:f,f:m}},wNAFCached(o,i,u,s){const c=o._WINDOW_SIZE||1;let f=i.get(o);return f||(f=this.precomputeWindow(o,c),c!==1&&i.set(o,s(f))),this.wNAF(c,f,u)}}}function Kt(e){return ve(e.Fp),pt(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Gt(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Oe(e){const n=Kt(e);pt(n,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:o}=n;if(t){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...n})}const{bytesToNumberBE:Ne,hexToBytes:He}=ye,ft={Err:class extends Error{constructor(n=""){super(n)}},_parseInt(e){const{Err:n}=ft;if(e.length<2||e[0]!==2)throw new n("Invalid signature integer tag");const t=e[1],r=e.subarray(2,t+2);if(!t||r.length!==t)throw new n("Invalid signature integer: wrong length");if(r[0]&128)throw new n("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new n("Invalid signature integer: unnecessary leading zero");return{d:Ne(r),l:e.subarray(t+2)}},toSig(e){const{Err:n}=ft,t=typeof e=="string"?He(e):e;if(!K(t))throw new Error("ui8a expected");let r=t.length;if(r<2||t[0]!=48)throw new n("Invalid signature tag");if(t[1]!==r-2)throw new n("Invalid signature: incorrect length");const{d:o,l:i}=ft._parseInt(t.subarray(2)),{d:u,l:s}=ft._parseInt(i);if(s.length)throw new n("Invalid signature: left bytes after parsing");return{r:o,s:u}},hexFromSig(e){const n=f=>Number.parseInt(f[0],16)&8?"00"+f:f,t=f=>{const m=f.toString(16);return m.length&1?`0${m}`:m},r=n(t(e.s)),o=n(t(e.r)),i=r.length/2,u=o.length/2,s=t(i),c=t(u);return`30${t(u+i+4)}02${c}${o}02${s}${r}`}},X=BigInt(0),Y=BigInt(1);BigInt(2);const Wt=BigInt(3);BigInt(4);function _e(e){const n=Oe(e),{Fp:t}=n,r=n.toBytes||((B,l,a)=>{const g=l.toAffine();return at(Uint8Array.from([4]),t.toBytes(g.x),t.toBytes(g.y))}),o=n.fromBytes||(B=>{const l=B.subarray(1),a=t.fromBytes(l.subarray(0,t.BYTES)),g=t.fromBytes(l.subarray(t.BYTES,2*t.BYTES));return{x:a,y:g}});function i(B){const{a:l,b:a}=n,g=t.sqr(B),E=t.mul(g,B);return t.add(t.add(E,t.mul(B,l)),a)}if(!t.eql(t.sqr(n.Gy),i(n.Gx)))throw new Error("bad generator point: equation left != right");function u(B){return typeof B=="bigint"&&Xt.eql(A,t.ZERO);return E(a)&&E(g)?b.ZERO:new b(a,g,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(l){const a=t.invertBatch(l.map(g=>g.pz));return l.map((g,E)=>g.toAffine(a[E])).map(b.fromAffine)}static fromHex(l){const a=b.fromAffine(o(M("pointHex",l)));return a.assertValidity(),a}static fromPrivateKey(l){return b.BASE.multiply(c(l))}_setWindowSize(l){this._WINDOW_SIZE=l,f.delete(this)}assertValidity(){if(this.is0()){if(n.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:l,y:a}=this.toAffine();if(!t.isValid(l)||!t.isValid(a))throw new Error("bad point: x or y not FE");const g=t.sqr(a),E=i(l);if(!t.eql(g,E))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:l}=this.toAffine();if(t.isOdd)return!t.isOdd(l);throw new Error("Field doesn't support isOdd")}equals(l){m(l);const{px:a,py:g,pz:E}=this,{px:A,py:H,pz:I}=l,y=t.eql(t.mul(a,I),t.mul(A,E)),v=t.eql(t.mul(g,I),t.mul(H,E));return y&&v}negate(){return new b(this.px,t.neg(this.py),this.pz)}double(){const{a:l,b:a}=n,g=t.mul(a,Wt),{px:E,py:A,pz:H}=this;let I=t.ZERO,y=t.ZERO,v=t.ZERO,x=t.mul(E,E),G=t.mul(A,A),O=t.mul(H,H),T=t.mul(E,A);return T=t.add(T,T),v=t.mul(E,H),v=t.add(v,v),I=t.mul(l,v),y=t.mul(g,O),y=t.add(I,y),I=t.sub(G,y),y=t.add(G,y),y=t.mul(I,y),I=t.mul(T,I),v=t.mul(g,v),O=t.mul(l,O),T=t.sub(x,O),T=t.mul(l,T),T=t.add(T,v),v=t.add(x,x),x=t.add(v,x),x=t.add(x,O),x=t.mul(x,T),y=t.add(y,x),O=t.mul(A,H),O=t.add(O,O),x=t.mul(O,T),I=t.sub(I,x),v=t.mul(O,G),v=t.add(v,v),v=t.add(v,v),new b(I,y,v)}add(l){m(l);const{px:a,py:g,pz:E}=this,{px:A,py:H,pz:I}=l;let y=t.ZERO,v=t.ZERO,x=t.ZERO;const G=n.a,O=t.mul(n.b,Wt);let T=t.mul(a,A),Z=t.mul(g,H),j=t.mul(E,I),d=t.add(a,g),h=t.add(A,H);d=t.mul(d,h),h=t.add(T,Z),d=t.sub(d,h),h=t.add(a,E);let p=t.add(A,I);return h=t.mul(h,p),p=t.add(T,j),h=t.sub(h,p),p=t.add(g,E),y=t.add(H,I),p=t.mul(p,y),y=t.add(Z,j),p=t.sub(p,y),x=t.mul(G,h),y=t.mul(O,j),x=t.add(y,x),y=t.sub(Z,x),x=t.add(Z,x),v=t.mul(y,x),Z=t.add(T,T),Z=t.add(Z,T),j=t.mul(G,j),h=t.mul(O,h),Z=t.add(Z,j),j=t.sub(T,j),j=t.mul(G,j),h=t.add(h,j),T=t.mul(Z,h),v=t.add(v,T),T=t.mul(p,h),y=t.mul(d,y),y=t.sub(y,T),T=t.mul(d,Z),x=t.mul(p,x),x=t.add(x,T),new b(y,v,x)}subtract(l){return this.add(l.negate())}is0(){return this.equals(b.ZERO)}wNAF(l){return U.wNAFCached(this,f,l,a=>{const g=t.invertBatch(a.map(E=>E.pz));return a.map((E,A)=>E.toAffine(g[A])).map(b.fromAffine)})}multiplyUnsafe(l){const a=b.ZERO;if(l===X)return a;if(s(l),l===Y)return this;const{endo:g}=n;if(!g)return U.unsafeLadder(this,l);let{k1neg:E,k1:A,k2neg:H,k2:I}=g.splitScalar(l),y=a,v=a,x=this;for(;A>X||I>X;)A&Y&&(y=y.add(x)),I&Y&&(v=v.add(x)),x=x.double(),A>>=Y,I>>=Y;return E&&(y=y.negate()),H&&(v=v.negate()),v=new b(t.mul(v.px,g.beta),v.py,v.pz),y.add(v)}multiply(l){s(l);let a=l,g,E;const{endo:A}=n;if(A){const{k1neg:H,k1:I,k2neg:y,k2:v}=A.splitScalar(a);let{p:x,f:G}=this.wNAF(I),{p:O,f:T}=this.wNAF(v);x=U.constTimeNegate(H,x),O=U.constTimeNegate(y,O),O=new b(t.mul(O.px,A.beta),O.py,O.pz),g=x.add(O),E=G.add(T)}else{const{p:H,f:I}=this.wNAF(a);g=H,E=I}return b.normalizeZ([g,E])[0]}multiplyAndAddUnsafe(l,a,g){const E=b.BASE,A=(I,y)=>y===X||y===Y||!I.equals(E)?I.multiplyUnsafe(y):I.multiply(y),H=A(this,a).add(A(l,g));return H.is0()?void 0:H}toAffine(l){const{px:a,py:g,pz:E}=this,A=this.is0();l==null&&(l=A?t.ONE:t.inv(E));const H=t.mul(a,l),I=t.mul(g,l),y=t.mul(E,l);if(A)return{x:t.ZERO,y:t.ZERO};if(!t.eql(y,t.ONE))throw new Error("invZ was invalid");return{x:H,y:I}}isTorsionFree(){const{h:l,isTorsionFree:a}=n;if(l===Y)return!0;if(a)return a(b,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:l,clearCofactor:a}=n;return l===Y?this:a?a(b,this):this.multiplyUnsafe(n.h)}toRawBytes(l=!0){return this.assertValidity(),r(b,this,l)}toHex(l=!0){return ot(this.toRawBytes(l))}};_(b,"BASE",new b(n.Gx,n.Gy,t.ONE)),_(b,"ZERO",new b(t.ZERO,t.ONE,t.ZERO));let S=b;const w=n.nBitLength,U=Ue(S,n.endo?Math.ceil(w/2):w);return{CURVE:n,ProjectivePoint:S,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:u}}function $e(e){const n=Kt(e);return pt(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}function Re(e){const n=$e(e),{Fp:t,n:r}=n,o=t.BYTES+1,i=2*t.BYTES+1;function u(d){return Xot(lt(d,n.nByteLength));function b(d){const h=r>>Y;return d>h}function B(d){return b(d)?s(-d):d}const l=(d,h,p)=>st(d.slice(h,p));class a{constructor(h,p,N){this.r=h,this.s=p,this.recovery=N,this.assertValidity()}static fromCompact(h){const p=n.nByteLength;return h=M("compactSignature",h,p*2),new a(l(h,0,p),l(h,p,2*p))}static fromDER(h){const{r:p,s:N}=ft.toSig(M("DER",h));return new a(p,N)}assertValidity(){if(!w(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!w(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(h){return new a(this.r,this.s,h)}recoverPublicKey(h){const{r:p,s:N,recovery:L}=this,R=y(M("msgHash",h));if(L==null||![0,1,2,3].includes(L))throw new Error("recovery id invalid");const P=L===2||L===3?p+n.n:p;if(P>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const k=L&1?"03":"02",tt=f.fromHex(k+U(P)),et=c(P),ht=s(-R*et),yt=s(N*et),nt=f.BASE.multiplyAndAddUnsafe(tt,ht,yt);if(!nt)throw new Error("point at infinify");return nt.assertValidity(),nt}hasHighS(){return b(this.s)}normalizeS(){return this.hasHighS()?new a(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return it(this.toDERHex())}toDERHex(){return ft.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return it(this.toCompactHex())}toCompactHex(){return U(this.r)+U(this.s)}}const g={isValidPrivateKey(d){try{return m(d),!0}catch{return!1}},normPrivateKeyToScalar:m,randomPrivateKey:()=>{const d=Dt(n.n);return Te(n.randomBytes(d),n.n)},precompute(d=8,h=f.BASE){return h._setWindowSize(d),h.multiply(BigInt(3)),h}};function E(d,h=!0){return f.fromPrivateKey(d).toRawBytes(h)}function A(d){const h=K(d),p=typeof d=="string",N=(h||p)&&d.length;return h?N===o||N===i:p?N===2*o||N===2*i:d instanceof f}function H(d,h,p=!0){if(A(d))throw new Error("first arg must be private key");if(!A(h))throw new Error("second arg must be public key");return f.fromHex(h).multiply(m(d)).toRawBytes(p)}const I=n.bits2int||function(d){const h=st(d),p=d.length*8-n.nBitLength;return p>0?h>>BigInt(p):h},y=n.bits2int_modN||function(d){return s(I(d))},v=Lt(n.nBitLength);function x(d){if(typeof d!="bigint")throw new Error("bigint expected");if(!(X<=d&&dut in p))throw new Error("sign() legacy options not supported");const{hash:N,randomBytes:L}=n;let{lowS:R,prehash:P,extraEntropy:k}=p;R==null&&(R=!0),d=M("msgHash",d),P&&(d=M("prehashed msgHash",N(d)));const tt=y(d),et=m(h),ht=[x(et),x(tt)];if(k!=null){const ut=k===!0?L(t.BYTES):k;ht.push(M("extraEntropy",ut))}const yt=at(...ht),nt=tt;function _t(ut){const dt=I(ut);if(!w(dt))return;const Qt=c(dt),gt=f.BASE.multiply(dt).toAffine(),F=s(gt.x);if(F===X)return;const wt=s(Qt*s(nt+F*et));if(wt===X)return;let Jt=(gt.x===F?0:2)|Number(gt.y&Y),te=wt;return R&&b(wt)&&(te=B(wt),Jt^=1),new a(F,te,Jt)}return{seed:yt,k2sig:_t}}const O={lowS:n.lowS,prehash:!1},T={lowS:n.lowS,prehash:!1};function Z(d,h,p=O){const{seed:N,k2sig:L}=G(d,h,p),R=n;return zt(R.hash.outputLen,R.nByteLength,R.hmac)(N,L)}f.BASE._setWindowSize(8);function j(d,h,p,N=T){var gt;const L=d;if(h=M("msgHash",h),p=M("publicKey",p),"strict"in N)throw new Error("options.strict was renamed to lowS");const{lowS:R,prehash:P}=N;let k,tt;try{if(typeof L=="string"||K(L))try{k=a.fromDER(L)}catch(F){if(!(F instanceof ft.Err))throw F;k=a.fromCompact(L)}else if(typeof L=="object"&&typeof L.r=="bigint"&&typeof L.s=="bigint"){const{r:F,s:wt}=L;k=new a(F,wt)}else throw new Error("PARSE");tt=f.fromHex(p)}catch(F){if(F.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(R&&k.hasHighS())return!1;P&&(h=n.hash(h));const{r:et,s:ht}=k,yt=y(h),nt=c(ht),_t=s(yt*nt),ut=s(et*nt),dt=(gt=f.BASE.multiplyAndAddUnsafe(tt,_t,ut))==null?void 0:gt.toAffine();return dt?s(dt.x)===et:!1}return{CURVE:n,getPublicKey:E,getSharedSecret:H,sign:Z,verify:j,ProjectivePoint:f,Signature:a,utils:g}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qe(e){return{hash:e,hmac:(n,...t)=>Vt(e,n,ie(...t)),randomBytes:ce}}function Ce(e,n){const t=r=>Re({...e,...qe(r)});return Object.freeze({...t(n),create:t})}function Ve(e,n,t,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(n,t,r);const o=BigInt(32),i=BigInt(4294967295),u=Number(t>>o&i),s=Number(t&i),c=r?4:0,f=r?0:4;e.setUint32(n+c,u,r),e.setUint32(n+f,s,r)}class Ze extends qt{constructor(t,r,o,i){super();_(this,"buffer");_(this,"view");_(this,"finished",!1);_(this,"length",0);_(this,"pos",0);_(this,"destroyed",!1);this.blockLen=t,this.outputLen=r,this.padOffset=o,this.isLE=i,this.buffer=new Uint8Array(t),this.view=vt(this.buffer)}update(t){bt(this);const{view:r,buffer:o,blockLen:i}=this;t=xt(t);const u=t.length;for(let s=0;si-s&&(this.process(o,0),s=0);for(let w=s;wS.length)throw new Error("_sha2: outputLen bigger than state");for(let w=0;we&n^~e&t,Pe=(e,n,t)=>e&n^e&t^n&t,ke=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]),Q=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),J=new Uint32Array(64);class ze extends Ze{constructor(){super(64,32,8,!1);_(this,"A",Q[0]|0);_(this,"B",Q[1]|0);_(this,"C",Q[2]|0);_(this,"D",Q[3]|0);_(this,"E",Q[4]|0);_(this,"F",Q[5]|0);_(this,"G",Q[6]|0);_(this,"H",Q[7]|0)}get(){const{A:t,B:r,C:o,D:i,E:u,F:s,G:c,H:f}=this;return[t,r,o,i,u,s,c,f]}set(t,r,o,i,u,s,c,f){this.A=t|0,this.B=r|0,this.C=o|0,this.D=i|0,this.E=u|0,this.F=s|0,this.G=c|0,this.H=f|0}process(t,r){for(let w=0;w<16;w++,r+=4)J[w]=t.getUint32(r,!1);for(let w=16;w<64;w++){const U=J[w-15],b=J[w-2],B=D(U,7)^D(U,18)^U>>>3,l=D(b,17)^D(b,19)^b>>>10;J[w]=l+J[w-7]+B+J[w-16]|0}let{A:o,B:i,C:u,D:s,E:c,F:f,G:m,H:S}=this;for(let w=0;w<64;w++){const U=D(c,6)^D(c,11)^D(c,25),b=S+U+je(c,f,m)+ke[w]+J[w]|0,l=(D(o,2)^D(o,13)^D(o,22))+Pe(o,i,u)|0;S=m,m=f,f=c,c=s+b|0,s=u,u=i,i=o,o=b+l|0}o=o+this.A|0,i=i+this.B|0,u=u+this.C|0,s=s+this.D|0,c=c+this.E|0,f=f+this.F|0,m=m+this.G|0,S=S+this.H|0,this.set(o,i,u,s,c,f,m,S)}roundClean(){J.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ye=se(()=>new ze);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xt=Ie(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),Me=Xt.create(BigInt("-3")),Ge=BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fe=Ce({a:Me,b:Ge,Fp:Xt,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Ye);C.bytesToHex=ot,C.concatBytes=at,C.hexToBytes=it,C.p256=Fe,Object.defineProperty(C,Symbol.toStringTag,{value:"Module"})});