@a.annzzz/directdeposit-widget
Version:
A plug-and-play React component for connecting a Web3 wallet and displaying deposit schedule information.
3 lines (2 loc) • 28 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("./index-CxEAEOcL.cjs");/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const zt=BigInt(0),qt=BigInt(1);function dt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Tt(e){if(!dt(e))throw new Error("Uint8Array expected")}function ut(e,n){if(typeof n!="boolean")throw new Error(e+" boolean expected, got "+n)}function wt(e){const n=e.toString(16);return n.length&1?"0"+n:n}function Wt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?zt:BigInt("0x"+e)}const Dt=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",le=Array.from({length:256},(e,n)=>n.toString(16).padStart(2,"0"));function lt(e){if(Tt(e),Dt)return e.toHex();let n="";for(let t=0;t<e.length;t++)n+=le[e[t]];return n}const G={_0:48,_9:57,A:65,F:70,a:97,f:102};function _t(e){if(e>=G._0&&e<=G._9)return e-G._0;if(e>=G.A&&e<=G.F)return e-(G.A-10);if(e>=G.a&&e<=G.f)return e-(G.a-10)}function gt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Dt)return Uint8Array.fromHex(e);const n=e.length,t=n/2;if(n%2)throw new Error("hex string expected, got unpadded hex of length "+n);const r=new Uint8Array(t);for(let i=0,s=0;i<t;i++,s+=2){const c=_t(e.charCodeAt(s)),u=_t(e.charCodeAt(s+1));if(c===void 0||u===void 0){const o=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+o+'" at index '+s)}r[i]=c*16+u}return r}function nt(e){return Wt(lt(e))}function Gt(e){return Tt(e),Wt(lt(Uint8Array.from(e).reverse()))}function ht(e,n){return gt(e.toString(16).padStart(n*2,"0"))}function Xt(e,n){return ht(e,n).reverse()}function P(e,n,t){let r;if(typeof n=="string")try{r=gt(n)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else if(dt(n))r=Uint8Array.from(n);else throw new Error(e+" must be hex string or Uint8Array");const i=r.length;if(typeof t=="number"&&i!==t)throw new Error(e+" of length "+t+" expected, got "+i);return r}function mt(...e){let n=0;for(let r=0;r<e.length;r++){const i=e[r];Tt(i),n+=i.length}const t=new Uint8Array(n);for(let r=0,i=0;r<e.length;r++){const s=e[r];t.set(s,i),i+=s.length}return t}const Bt=e=>typeof e=="bigint"&&zt<=e;function Ut(e,n,t){return Bt(e)&&Bt(n)&&Bt(t)&&n<=e&&e<t}function st(e,n,t,r){if(!Ut(n,t,r))throw new Error("expected valid "+e+": "+t+" <= n < "+r+", got "+n)}function de(e){let n;for(n=0;e>zt;e>>=qt,n+=1);return n}const pt=e=>(qt<<BigInt(e))-qt,vt=e=>new Uint8Array(e),Ct=e=>Uint8Array.from(e);function he(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=vt(e),i=vt(e),s=0;const c=()=>{r.fill(1),i.fill(0),s=0},u=(...A)=>t(i,r,...A),o=(A=vt(0))=>{i=u(Ct([0]),A),r=u(),A.length!==0&&(i=u(Ct([1]),A),r=u())},d=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let A=0;const N=[];for(;A<n;){r=u();const R=r.slice();N.push(R),A+=r.length}return mt(...N)};return(A,N)=>{c(),o(A);let R;for(;!(R=N(d()));)o();return c(),R}}const we={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"||dt(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 yt(e,n,t={}){const r=(i,s,c)=>{const u=we[s];if(typeof u!="function")throw new Error("invalid validator function");const o=e[i];if(!(c&&o===void 0)&&!u(o,e))throw new Error("param "+String(i)+" is invalid. Expected "+s+", got "+o)};for(const[i,s]of Object.entries(n))r(i,s,!1);for(const[i,s]of Object.entries(t))r(i,s,!0);return e}function Vt(e){const n=new WeakMap;return(t,...r)=>{const i=n.get(t);if(i!==void 0)return i;const s=e(t,...r);return n.set(t,s),s}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const j=BigInt(0),C=BigInt(1),et=BigInt(2),ge=BigInt(3),Ft=BigInt(4),Qt=BigInt(5),Jt=BigInt(8);function M(e,n){const t=e%n;return t>=j?t:n+t}function Y(e,n,t){let r=e;for(;n-- >j;)r*=r,r%=t;return r}function Ht(e,n){if(e===j)throw new Error("invert: expected non-zero number");if(n<=j)throw new Error("invert: expected positive modulus, got "+n);let t=M(e,n),r=n,i=j,s=C;for(;t!==j;){const u=r/t,o=r%t,d=i-s*u;r=t,t=o,i=s,s=d}if(r!==C)throw new Error("invert: does not exist");return M(i,n)}function te(e,n){const t=(e.ORDER+C)/Ft,r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}function me(e,n){const t=(e.ORDER-Qt)/Jt,r=e.mul(n,et),i=e.pow(r,t),s=e.mul(n,i),c=e.mul(e.mul(s,et),i),u=e.mul(s,e.sub(c,e.ONE));if(!e.eql(e.sqr(u),n))throw new Error("Cannot find square root");return u}function pe(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let n=e-C,t=0;for(;n%et===j;)n/=et,t++;let r=et;const i=kt(e);for(;Mt(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return te;let s=i.pow(r,n);const c=(n+C)/et;return function(o,d){if(o.is0(d))return d;if(Mt(o,d)!==1)throw new Error("Cannot find square root");let m=t,A=o.mul(o.ONE,s),N=o.pow(d,n),R=o.pow(d,c);for(;!o.eql(N,o.ONE);){if(o.is0(N))return o.ZERO;let Z=1,g=o.sqr(N);for(;!o.eql(g,o.ONE);)if(Z++,g=o.sqr(g),Z===m)throw new Error("Cannot find square root");const k=C<<BigInt(m-Z-1),z=o.pow(A,k);m=Z,A=o.sqr(z),N=o.mul(N,A),R=o.mul(R,z)}return R}}function ye(e){return e%Ft===ge?te:e%Jt===Qt?me:pe(e)}const be=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ee(e){const n={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=be.reduce((r,i)=>(r[i]="function",r),n);return yt(e,t)}function Be(e,n,t){if(t<j)throw new Error("invalid exponent, negatives unsupported");if(t===j)return e.ONE;if(t===C)return n;let r=e.ONE,i=n;for(;t>j;)t&C&&(r=e.mul(r,i)),i=e.sqr(i),t>>=C;return r}function ee(e,n,t=!1){const r=new Array(n.length).fill(t?e.ZERO:void 0),i=n.reduce((c,u,o)=>e.is0(u)?c:(r[o]=c,e.mul(c,u)),e.ONE),s=e.inv(i);return n.reduceRight((c,u,o)=>e.is0(u)?c:(r[o]=e.mul(c,r[o]),e.mul(c,u)),s),r}function Mt(e,n){const t=(e.ORDER-C)/et,r=e.pow(n,t),i=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),c=e.eql(r,e.neg(e.ONE));if(!i&&!s&&!c)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function ne(e,n){n!==void 0&&$.anumber(n);const t=n!==void 0?n:e.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function kt(e,n,t=!1,r={}){if(e<=j)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:i,nByteLength:s}=ne(e,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const u=Object.freeze({ORDER:e,isLE:t,BITS:i,BYTES:s,MASK:pt(i),ZERO:j,ONE:C,create:o=>M(o,e),isValid:o=>{if(typeof o!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof o);return j<=o&&o<e},is0:o=>o===j,isOdd:o=>(o&C)===C,neg:o=>M(-o,e),eql:(o,d)=>o===d,sqr:o=>M(o*o,e),add:(o,d)=>M(o+d,e),sub:(o,d)=>M(o-d,e),mul:(o,d)=>M(o*d,e),pow:(o,d)=>Be(u,o,d),div:(o,d)=>M(o*Ht(d,e),e),sqrN:o=>o*o,addN:(o,d)=>o+d,subN:(o,d)=>o-d,mulN:(o,d)=>o*d,inv:o=>Ht(o,e),sqrt:r.sqrt||(o=>(c||(c=ye(e)),c(u,o))),toBytes:o=>t?Xt(o,s):ht(o,s),fromBytes:o=>{if(o.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+o.length);return t?Gt(o):nt(o)},invertBatch:o=>ee(u,o),cmov:(o,d,m)=>m?d:o});return Object.freeze(u)}function re(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 oe(e){const n=re(e);return n+Math.ceil(n/2)}function ve(e,n,t=!1){const r=e.length,i=re(n),s=oe(n);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const c=t?Gt(e):nt(e),u=M(c,n-C)+C;return t?Xt(u,i):ht(u,i)}class ie extends $.Hash{constructor(n,t){super(),this.finished=!1,this.destroyed=!1,$.ahash(n);const r=$.toBytes(t);if(this.iHash=n.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,s=new Uint8Array(i);s.set(r.length>i?n.create().update(r).digest():r);for(let c=0;c<s.length;c++)s[c]^=54;this.iHash.update(s),this.oHash=n.create();for(let c=0;c<s.length;c++)s[c]^=106;this.oHash.update(s),$.clean(s)}update(n){return $.aexists(this),this.iHash.update(n),this}digestInto(n){$.aexists(this),$.abytes(n,this.outputLen),this.finished=!0,this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),this.destroy()}digest(){const n=new Uint8Array(this.oHash.outputLen);return this.digestInto(n),n}_cloneInto(n){n||(n=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:i,destroyed:s,blockLen:c,outputLen:u}=this;return n=n,n.finished=i,n.destroyed=s,n.blockLen=c,n.outputLen=u,n.oHash=t._cloneInto(n.oHash),n.iHash=r._cloneInto(n.iHash),n}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const se=(e,n,t)=>new ie(e,n).update(t).digest();se.create=(e,n)=>new ie(e,n);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const jt=BigInt(0),Lt=BigInt(1);function xt(e,n){const t=n.negate();return e?t:n}function ce(e,n){if(!Number.isSafeInteger(e)||e<=0||e>n)throw new Error("invalid window size, expected [1.."+n+"], got W="+e)}function St(e,n){ce(e,n);const t=Math.ceil(n/e)+1,r=2**(e-1),i=2**e,s=pt(e),c=BigInt(e);return{windows:t,windowSize:r,mask:s,maxNumber:i,shiftBy:c}}function Yt(e,n,t){const{windowSize:r,mask:i,maxNumber:s,shiftBy:c}=t;let u=Number(e&i),o=e>>c;u>r&&(u-=s,o+=Lt);const d=n*r,m=d+Math.abs(u)-1,A=u===0,N=u<0,R=n%2!==0;return{nextN:o,offset:m,isZero:A,isNeg:N,isNegF:R,offsetF:d}}function xe(e,n){if(!Array.isArray(e))throw new Error("array expected");e.forEach((t,r)=>{if(!(t instanceof n))throw new Error("invalid point at index "+r)})}function Se(e,n){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((t,r)=>{if(!n.isValid(t))throw new Error("invalid scalar at index "+r)})}const At=new WeakMap,fe=new WeakMap;function It(e){return fe.get(e)||1}function Ae(e,n){return{constTimeNegate:xt,hasPrecomputes(t){return It(t)!==1},unsafeLadder(t,r,i=e.ZERO){let s=t;for(;r>jt;)r&Lt&&(i=i.add(s)),s=s.double(),r>>=Lt;return i},precomputeWindow(t,r){const{windows:i,windowSize:s}=St(r,n),c=[];let u=t,o=u;for(let d=0;d<i;d++){o=u,c.push(o);for(let m=1;m<s;m++)o=o.add(u),c.push(o);u=o.double()}return c},wNAF(t,r,i){let s=e.ZERO,c=e.BASE;const u=St(t,n);for(let o=0;o<u.windows;o++){const{nextN:d,offset:m,isZero:A,isNeg:N,isNegF:R,offsetF:Z}=Yt(i,o,u);i=d,A?c=c.add(xt(R,r[Z])):s=s.add(xt(N,r[m]))}return{p:s,f:c}},wNAFUnsafe(t,r,i,s=e.ZERO){const c=St(t,n);for(let u=0;u<c.windows&&i!==jt;u++){const{nextN:o,offset:d,isZero:m,isNeg:A}=Yt(i,u,c);if(i=o,!m){const N=r[d];s=s.add(A?N.negate():N)}}return s},getPrecomputes(t,r,i){let s=At.get(r);return s||(s=this.precomputeWindow(r,t),t!==1&&At.set(r,i(s))),s},wNAFCached(t,r,i){const s=It(t);return this.wNAF(s,this.getPrecomputes(s,t,i),r)},wNAFCachedUnsafe(t,r,i,s){const c=It(t);return c===1?this.unsafeLadder(t,r,s):this.wNAFUnsafe(c,this.getPrecomputes(c,t,i),r,s)},setWindowSize(t,r){ce(r,n),fe.set(t,r),At.delete(t)}}}function Ie(e,n,t,r){xe(t,e),Se(r,n);const i=t.length,s=r.length;if(i!==s)throw new Error("arrays of points and scalars must have equal length");const c=e.ZERO,u=de(BigInt(i));let o=1;u>12?o=u-3:u>4?o=u-2:u>0&&(o=2);const d=pt(o),m=new Array(Number(d)+1).fill(c),A=Math.floor((n.BITS-1)/o)*o;let N=c;for(let R=A;R>=0;R-=o){m.fill(c);for(let g=0;g<s;g++){const k=r[g],z=Number(k>>BigInt(R)&d);m[z]=m[z].add(t[g])}let Z=c;for(let g=m.length-1,k=c;g>0;g--)k=k.add(m[g]),Z=Z.add(k);if(N=N.add(Z),R!==0)for(let g=0;g<o;g++)N=N.double()}return N}function ae(e){return Ee(e.Fp),yt(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ne(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Pt(e){e.lowS!==void 0&&ut("lowS",e.lowS),e.prehash!==void 0&&ut("prehash",e.prehash)}function Ne(e){const n=ae(e);yt(n,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});const{endo:t,Fp:r,a:i}=n;if(t){if(!r.eql(i,r.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...n})}class Oe extends Error{constructor(n=""){super(n)}}const X={Err:Oe,_tlv:{encode:(e,n)=>{const{Err:t}=X;if(e<0||e>256)throw new t("tlv.encode: wrong tag");if(n.length&1)throw new t("tlv.encode: unpadded data");const r=n.length/2,i=wt(r);if(i.length/2&128)throw new t("tlv.encode: long form length too big");const s=r>127?wt(i.length/2|128):"";return wt(e)+s+i+n},decode(e,n){const{Err:t}=X;let r=0;if(e<0||e>256)throw new t("tlv.encode: wrong tag");if(n.length<2||n[r++]!==e)throw new t("tlv.decode: wrong tlv");const i=n[r++],s=!!(i&128);let c=0;if(!s)c=i;else{const o=i&127;if(!o)throw new t("tlv.decode(long): indefinite length not supported");if(o>4)throw new t("tlv.decode(long): byte length is too big");const d=n.subarray(r,r+o);if(d.length!==o)throw new t("tlv.decode: length bytes not complete");if(d[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const m of d)c=c<<8|m;if(r+=o,c<128)throw new t("tlv.decode(long): not minimal encoding")}const u=n.subarray(r,r+c);if(u.length!==c)throw new t("tlv.decode: wrong value length");return{v:u,l:n.subarray(r+c)}}},_int:{encode(e){const{Err:n}=X;if(e<F)throw new n("integer: negative integers are not allowed");let t=wt(e);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new n("unexpected DER parsing assertion: unpadded hex");return t},decode(e){const{Err:n}=X;if(e[0]&128)throw new n("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new n("invalid signature integer: unnecessary leading zero");return nt(e)}},toSig(e){const{Err:n,_int:t,_tlv:r}=X,i=P("signature",e),{v:s,l:c}=r.decode(48,i);if(c.length)throw new n("invalid signature: left bytes after parsing");const{v:u,l:o}=r.decode(2,s),{v:d,l:m}=r.decode(2,o);if(m.length)throw new n("invalid signature: left bytes after parsing");return{r:t.decode(u),s:t.decode(d)}},hexFromSig(e){const{_tlv:n,_int:t}=X,r=n.encode(2,t.encode(e.r)),i=n.encode(2,t.encode(e.s)),s=r+i;return n.encode(48,s)}};function Nt(e,n){return lt(ht(e,n))}const F=BigInt(0),T=BigInt(1);BigInt(2);const Ot=BigInt(3),qe=BigInt(4);function He(e){const n=Ne(e),{Fp:t}=n,r=kt(n.n,n.nBitLength),i=n.toBytes||((x,f,h)=>{const p=f.toAffine();return mt(Uint8Array.from([4]),t.toBytes(p.x),t.toBytes(p.y))}),s=n.fromBytes||(x=>{const f=x.subarray(1),h=t.fromBytes(f.subarray(0,t.BYTES)),p=t.fromBytes(f.subarray(t.BYTES,2*t.BYTES));return{x:h,y:p}});function c(x){const{a:f,b:h}=n,p=t.sqr(x),B=t.mul(p,x);return t.add(t.add(B,t.mul(x,f)),h)}function u(x,f){const h=t.sqr(f),p=c(x);return t.eql(h,p)}if(!u(n.Gx,n.Gy))throw new Error("bad curve params: generator point");const o=t.mul(t.pow(n.a,Ot),qe),d=t.mul(t.sqr(n.b),BigInt(27));if(t.is0(t.add(o,d)))throw new Error("bad curve params: a or b");function m(x){return Ut(x,T,n.n)}function A(x){const{allowedPrivateKeyLengths:f,nByteLength:h,wrapPrivateKey:p,n:B}=n;if(f&&typeof x!="bigint"){if(dt(x)&&(x=lt(x)),typeof x!="string"||!f.includes(x.length))throw new Error("invalid private key");x=x.padStart(h*2,"0")}let O;try{O=typeof x=="bigint"?x:nt(P("private key",x,h))}catch{throw new Error("invalid private key, expected hex or "+h+" bytes, got "+typeof x)}return p&&(O=M(O,B)),st("private key",O,T,B),O}function N(x){if(!(x instanceof g))throw new Error("ProjectivePoint expected")}const R=Vt((x,f)=>{const{px:h,py:p,pz:B}=x;if(t.eql(B,t.ONE))return{x:h,y:p};const O=x.is0();f==null&&(f=O?t.ONE:t.inv(B));const H=t.mul(h,f),q=t.mul(p,f),y=t.mul(B,f);if(O)return{x:t.ZERO,y:t.ZERO};if(!t.eql(y,t.ONE))throw new Error("invZ was invalid");return{x:H,y:q}}),Z=Vt(x=>{if(x.is0()){if(n.allowInfinityPoint&&!t.is0(x.py))return;throw new Error("bad point: ZERO")}const{x:f,y:h}=x.toAffine();if(!t.isValid(f)||!t.isValid(h))throw new Error("bad point: x or y not FE");if(!u(f,h))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class g{constructor(f,h,p){if(f==null||!t.isValid(f))throw new Error("x required");if(h==null||!t.isValid(h)||t.is0(h))throw new Error("y required");if(p==null||!t.isValid(p))throw new Error("z required");this.px=f,this.py=h,this.pz=p,Object.freeze(this)}static fromAffine(f){const{x:h,y:p}=f||{};if(!f||!t.isValid(h)||!t.isValid(p))throw new Error("invalid affine point");if(f instanceof g)throw new Error("projective point not allowed");const B=O=>t.eql(O,t.ZERO);return B(h)&&B(p)?g.ZERO:new g(h,p,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){const h=ee(t,f.map(p=>p.pz));return f.map((p,B)=>p.toAffine(h[B])).map(g.fromAffine)}static fromHex(f){const h=g.fromAffine(s(P("pointHex",f)));return h.assertValidity(),h}static fromPrivateKey(f){return g.BASE.multiply(A(f))}static msm(f,h){return Ie(g,r,f,h)}_setWindowSize(f){W.setWindowSize(this,f)}assertValidity(){Z(this)}hasEvenY(){const{y:f}=this.toAffine();if(t.isOdd)return!t.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){N(f);const{px:h,py:p,pz:B}=this,{px:O,py:H,pz:q}=f,y=t.eql(t.mul(h,q),t.mul(O,B)),I=t.eql(t.mul(p,q),t.mul(H,B));return y&&I}negate(){return new g(this.px,t.neg(this.py),this.pz)}double(){const{a:f,b:h}=n,p=t.mul(h,Ot),{px:B,py:O,pz:H}=this;let q=t.ZERO,y=t.ZERO,I=t.ZERO,b=t.mul(B,B),U=t.mul(O,O),l=t.mul(H,H),a=t.mul(B,O);return a=t.add(a,a),I=t.mul(B,H),I=t.add(I,I),q=t.mul(f,I),y=t.mul(p,l),y=t.add(q,y),q=t.sub(U,y),y=t.add(U,y),y=t.mul(q,y),q=t.mul(a,q),I=t.mul(p,I),l=t.mul(f,l),a=t.sub(b,l),a=t.mul(f,a),a=t.add(a,I),I=t.add(b,b),b=t.add(I,b),b=t.add(b,l),b=t.mul(b,a),y=t.add(y,b),l=t.mul(O,H),l=t.add(l,l),b=t.mul(l,a),q=t.sub(q,b),I=t.mul(l,U),I=t.add(I,I),I=t.add(I,I),new g(q,y,I)}add(f){N(f);const{px:h,py:p,pz:B}=this,{px:O,py:H,pz:q}=f;let y=t.ZERO,I=t.ZERO,b=t.ZERO;const U=n.a,l=t.mul(n.b,Ot);let a=t.mul(h,O),w=t.mul(p,H),S=t.mul(B,q),E=t.add(h,p),v=t.add(O,H);E=t.mul(E,v),v=t.add(a,w),E=t.sub(E,v),v=t.add(h,B);let L=t.add(O,q);return v=t.mul(v,L),L=t.add(a,S),v=t.sub(v,L),L=t.add(p,B),y=t.add(H,q),L=t.mul(L,y),y=t.add(w,S),L=t.sub(L,y),b=t.mul(U,v),y=t.mul(l,S),b=t.add(y,b),y=t.sub(w,b),b=t.add(w,b),I=t.mul(y,b),w=t.add(a,a),w=t.add(w,a),S=t.mul(U,S),v=t.mul(l,v),w=t.add(w,S),S=t.sub(a,S),S=t.mul(U,S),v=t.add(v,S),a=t.mul(w,v),I=t.add(I,a),a=t.mul(L,v),y=t.mul(E,y),y=t.sub(y,a),a=t.mul(E,w),b=t.mul(L,b),b=t.add(b,a),new g(y,I,b)}subtract(f){return this.add(f.negate())}is0(){return this.equals(g.ZERO)}wNAF(f){return W.wNAFCached(this,f,g.normalizeZ)}multiplyUnsafe(f){const{endo:h,n:p}=n;st("scalar",f,F,p);const B=g.ZERO;if(f===F)return B;if(this.is0()||f===T)return this;if(!h||W.hasPrecomputes(this))return W.wNAFCachedUnsafe(this,f,g.normalizeZ);let{k1neg:O,k1:H,k2neg:q,k2:y}=h.splitScalar(f),I=B,b=B,U=this;for(;H>F||y>F;)H&T&&(I=I.add(U)),y&T&&(b=b.add(U)),U=U.double(),H>>=T,y>>=T;return O&&(I=I.negate()),q&&(b=b.negate()),b=new g(t.mul(b.px,h.beta),b.py,b.pz),I.add(b)}multiply(f){const{endo:h,n:p}=n;st("scalar",f,T,p);let B,O;if(h){const{k1neg:H,k1:q,k2neg:y,k2:I}=h.splitScalar(f);let{p:b,f:U}=this.wNAF(q),{p:l,f:a}=this.wNAF(I);b=W.constTimeNegate(H,b),l=W.constTimeNegate(y,l),l=new g(t.mul(l.px,h.beta),l.py,l.pz),B=b.add(l),O=U.add(a)}else{const{p:H,f:q}=this.wNAF(f);B=H,O=q}return g.normalizeZ([B,O])[0]}multiplyAndAddUnsafe(f,h,p){const B=g.BASE,O=(q,y)=>y===F||y===T||!q.equals(B)?q.multiplyUnsafe(y):q.multiply(y),H=O(this,h).add(O(f,p));return H.is0()?void 0:H}toAffine(f){return R(this,f)}isTorsionFree(){const{h:f,isTorsionFree:h}=n;if(f===T)return!0;if(h)return h(g,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:f,clearCofactor:h}=n;return f===T?this:h?h(g,this):this.multiplyUnsafe(n.h)}toRawBytes(f=!0){return ut("isCompressed",f),this.assertValidity(),i(g,this,f)}toHex(f=!0){return ut("isCompressed",f),lt(this.toRawBytes(f))}}g.BASE=new g(n.Gx,n.Gy,t.ONE),g.ZERO=new g(t.ZERO,t.ONE,t.ZERO);const{endo:k,nBitLength:z}=n,W=Ae(g,k?Math.ceil(z/2):z);return{CURVE:n,ProjectivePoint:g,normPrivateKeyToScalar:A,weierstrassEquation:c,isWithinCurveOrder:m}}function Le(e){const n=ae(e);return yt(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}function Re(e){const n=Le(e),{Fp:t,n:r,nByteLength:i,nBitLength:s}=n,c=t.BYTES+1,u=2*t.BYTES+1;function o(l){return M(l,r)}function d(l){return Ht(l,r)}const{ProjectivePoint:m,normPrivateKeyToScalar:A,weierstrassEquation:N,isWithinCurveOrder:R}=He({...n,toBytes(l,a,w){const S=a.toAffine(),E=t.toBytes(S.x),v=mt;return ut("isCompressed",w),w?v(Uint8Array.from([a.hasEvenY()?2:3]),E):v(Uint8Array.from([4]),E,t.toBytes(S.y))},fromBytes(l){const a=l.length,w=l[0],S=l.subarray(1);if(a===c&&(w===2||w===3)){const E=nt(S);if(!Ut(E,T,t.ORDER))throw new Error("Point is not on curve");const v=N(E);let L;try{L=t.sqrt(v)}catch(K){const V=K instanceof Error?": "+K.message:"";throw new Error("Point is not on curve"+V)}const _=(L&T)===T;return(w&1)===1!==_&&(L=t.neg(L)),{x:E,y:L}}else if(a===u&&w===4){const E=t.fromBytes(S.subarray(0,t.BYTES)),v=t.fromBytes(S.subarray(t.BYTES,2*t.BYTES));return{x:E,y:v}}else{const E=c,v=u;throw new Error("invalid Point, expected length of "+E+", or uncompressed "+v+", got "+a)}}});function Z(l){const a=r>>T;return l>a}function g(l){return Z(l)?o(-l):l}const k=(l,a,w)=>nt(l.slice(a,w));class z{constructor(a,w,S){st("r",a,T,r),st("s",w,T,r),this.r=a,this.s=w,S!=null&&(this.recovery=S),Object.freeze(this)}static fromCompact(a){const w=i;return a=P("compactSignature",a,w*2),new z(k(a,0,w),k(a,w,2*w))}static fromDER(a){const{r:w,s:S}=X.toSig(P("DER",a));return new z(w,S)}assertValidity(){}addRecoveryBit(a){return new z(this.r,this.s,a)}recoverPublicKey(a){const{r:w,s:S,recovery:E}=this,v=B(P("msgHash",a));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");const L=E===2||E===3?w+n.n:w;if(L>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const _=(E&1)===0?"02":"03",D=m.fromHex(_+Nt(L,t.BYTES)),K=d(L),V=o(-v*K),rt=o(S*K),Q=m.BASE.multiplyAndAddUnsafe(D,V,rt);if(!Q)throw new Error("point at infinify");return Q.assertValidity(),Q}hasHighS(){return Z(this.s)}normalizeS(){return this.hasHighS()?new z(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return gt(this.toDERHex())}toDERHex(){return X.hexFromSig(this)}toCompactRawBytes(){return gt(this.toCompactHex())}toCompactHex(){const a=i;return Nt(this.r,a)+Nt(this.s,a)}}const W={isValidPrivateKey(l){try{return A(l),!0}catch{return!1}},normPrivateKeyToScalar:A,randomPrivateKey:()=>{const l=oe(n.n);return ve(n.randomBytes(l),n.n)},precompute(l=8,a=m.BASE){return a._setWindowSize(l),a.multiply(BigInt(3)),a}};function x(l,a=!0){return m.fromPrivateKey(l).toRawBytes(a)}function f(l){if(typeof l=="bigint")return!1;if(l instanceof m)return!0;const w=P("key",l).length,S=t.BYTES,E=S+1,v=2*S+1;if(!(n.allowedPrivateKeyLengths||i===E))return w===E||w===v}function h(l,a,w=!0){if(f(l)===!0)throw new Error("first arg must be private key");if(f(a)===!1)throw new Error("second arg must be public key");return m.fromHex(a).multiply(A(l)).toRawBytes(w)}const p=n.bits2int||function(l){if(l.length>8192)throw new Error("input is too large");const a=nt(l),w=l.length*8-s;return w>0?a>>BigInt(w):a},B=n.bits2int_modN||function(l){return o(p(l))},O=pt(s);function H(l){return st("num < 2^"+s,l,F,O),ht(l,i)}function q(l,a,w=y){if(["recovered","canonical"].some(J=>J in w))throw new Error("sign() legacy options not supported");const{hash:S,randomBytes:E}=n;let{lowS:v,prehash:L,extraEntropy:_}=w;v==null&&(v=!0),l=P("msgHash",l),Pt(w),L&&(l=P("prehashed msgHash",S(l)));const D=B(l),K=A(a),V=[H(K),H(D)];if(_!=null&&_!==!1){const J=_===!0?E(t.BYTES):_;V.push(P("extraEntropy",J))}const rt=mt(...V),Q=D;function bt(J){const ot=p(J);if(!R(ot))return;const Et=d(ot),ct=m.BASE.multiply(ot).toAffine(),tt=o(ct.x);if(tt===F)return;const ft=o(Et*o(Q+tt*K));if(ft===F)return;let at=(ct.x===tt?0:2)|Number(ct.y&T),it=ft;return v&&Z(ft)&&(it=g(ft),at^=1),new z(tt,it,at)}return{seed:rt,k2sig:bt}}const y={lowS:n.lowS,prehash:!1},I={lowS:n.lowS,prehash:!1};function b(l,a,w=y){const{seed:S,k2sig:E}=q(l,a,w),v=n;return he(v.hash.outputLen,v.nByteLength,v.hmac)(S,E)}m.BASE._setWindowSize(8);function U(l,a,w,S=I){var at;const E=l;a=P("msgHash",a),w=P("publicKey",w);const{lowS:v,prehash:L,format:_}=S;if(Pt(S),"strict"in S)throw new Error("options.strict was renamed to lowS");if(_!==void 0&&_!=="compact"&&_!=="der")throw new Error("format must be compact or der");const D=typeof E=="string"||dt(E),K=!D&&!_&&typeof E=="object"&&E!==null&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!D&&!K)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let V,rt;try{if(K&&(V=new z(E.r,E.s)),D){try{_!=="compact"&&(V=z.fromDER(E))}catch(it){if(!(it instanceof X.Err))throw it}!V&&_!=="der"&&(V=z.fromCompact(E))}rt=m.fromHex(w)}catch{return!1}if(!V||v&&V.hasHighS())return!1;L&&(a=n.hash(a));const{r:Q,s:bt}=V,J=B(a),ot=d(bt),Et=o(J*ot),ct=o(Q*ot),tt=(at=m.BASE.multiplyAndAddUnsafe(rt,Et,ct))==null?void 0:at.toAffine();return tt?o(tt.x)===Q:!1}return{CURVE:n,getPublicKey:x,getSharedSecret:h,sign:b,verify:U,ProjectivePoint:m,Signature:z,utils:W}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Ze(e){return{hash:e,hmac:(n,...t)=>se(e,n,$.concatBytes(...t)),randomBytes:$.randomBytes}}function ze(e,n){const t=r=>Re({...e,...Ze(r)});return{...t(n),create:t}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ue=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Kt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Te=BigInt(0),Ue=BigInt(1),Rt=BigInt(2),$t=(e,n)=>(e+n/Rt)/n;function ke(e){const n=ue,t=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),c=BigInt(23),u=BigInt(44),o=BigInt(88),d=e*e*e%n,m=d*d*e%n,A=Y(m,t,n)*m%n,N=Y(A,t,n)*m%n,R=Y(N,Rt,n)*d%n,Z=Y(R,i,n)*R%n,g=Y(Z,s,n)*Z%n,k=Y(g,u,n)*g%n,z=Y(k,o,n)*k%n,W=Y(z,u,n)*g%n,x=Y(W,t,n)*m%n,f=Y(x,c,n)*Z%n,h=Y(f,r,n)*d%n,p=Y(h,Rt,n);if(!Zt.eql(Zt.sqr(p),e))throw new Error("Cannot find square root");return p}const Zt=kt(ue,void 0,void 0,{sqrt:ke}),_e=ze({a:Te,b:BigInt(7),Fp:Zt,n:Kt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const n=Kt,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ue*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,c=BigInt("0x100000000000000000000000000000000"),u=$t(s*e,n),o=$t(-r*e,n);let d=M(e-u*t-o*i,n),m=M(-u*r-o*s,n);const A=d>c,N=m>c;if(A&&(d=n-d),N&&(m=n-m),d>c||m>c)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:A,k1:d,k2neg:N,k2:m}}}},$.sha256);exports.secp256k1=_e;
//# sourceMappingURL=secp256k1-BBdJd11C.cjs.map