@libp2p/peer-id 5.0.1 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPeerId = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PPeerId=(()=>{var sr=Object.defineProperty;var jo=Object.getOwnPropertyDescriptor;var Yo=Object.getOwnPropertyNames;var Wo=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var r in t)sr(e,r,{get:t[r],enumerable:!0})},Xo=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Yo(t))!Wo.call(e,o)&&o!==r&&sr(e,o,{get:()=>t[o],enumerable:!(n=jo(t,o))||n.enumerable});return e};var Qo=e=>Xo(sr({},"__esModule",{value:!0}),e);var Hc={};it(Hc,{peerIdFromCID:()=>Oc,peerIdFromMultihash:()=>hn,peerIdFromPrivateKey:()=>Dc,peerIdFromPublicKey:()=>Mo,peerIdFromString:()=>Nc});var ir=Symbol.for("@libp2p/peer-id");var Yt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ce=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ne=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},De=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Wt=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var hr={};it(hr,{base58btc:()=>J,base58flickr:()=>os});var zc=new Uint8Array(0);function gn(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function bt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function wn(e){return new TextEncoder().encode(e)}function En(e){return new TextDecoder().decode(e)}function Jo(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=e.length,a=e.charAt(0),h=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function p(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var y=0,u=0,b=0,E=S.length;b!==E&&S[b]===0;)b++,y++;for(var l=(E-b)*f+1>>>0,B=new Uint8Array(l);b!==E;){for(var U=S[b],_=0,A=l-1;(U!==0||_<u)&&A!==-1;A--,_++)U+=256*B[A]>>>0,B[A]=U%c>>>0,U=U/c>>>0;if(U!==0)throw new Error("Non-zero carry");u=_,b++}for(var v=l-u;v!==l&&B[v]===0;)v++;for(var L=a.repeat(y);v<l;++v)L+=e.charAt(B[v]);return L}function m(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var y=0;if(S[y]!==" "){for(var u=0,b=0;S[y]===a;)u++,y++;for(var E=(S.length-y)*h+1>>>0,l=new Uint8Array(E);S[y];){var B=r[S.charCodeAt(y)];if(B===255)return;for(var U=0,_=E-1;(B!==0||U<b)&&_!==-1;_--,U++)B+=c*l[_]>>>0,l[_]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");b=U,y++}if(S[y]!==" "){for(var A=E-b;A!==E&&l[A]===0;)A++;for(var v=new Uint8Array(u+(E-A)),L=u;A!==E;)v[L++]=l[A++];return v}}}function R(S){var y=m(S);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:p,decodeUnsafe:m,decode:R}}var ts=Jo,es=ts,Sn=es;var cr=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ar=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return An(this,t)}},fr=class{decoders;constructor(t){this.decoders=t}or(t){return An(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function An(e,t){return new fr({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ur=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new cr(t,r,n),this.decoder=new ar(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Xt({name:e,prefix:t,encode:r,decode:n}){return new ur(e,t,r,n)}function Tt({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Sn(r,e);return Xt({prefix:t,name:e,encode:n,decode:s=>bt(o(s))})}function rs(e,t,r,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=e.length;for(;e[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),c=0,a=0,h=0;for(let f=0;f<s;++f){let p=o[e[f]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|p,c+=r,c>=8&&(c-=8,i[h++]=255&a>>c)}if(c>=r||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return i}function ns(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<r-i]),n)for(;s.length*r&7;)s+="=";return s}function $({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Xt({prefix:t,name:e,encode(o){return ns(o,n,r)},decode(o){return rs(o,n,r,e)}})}var J=Tt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),os=Tt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dr={};it(dr,{base32:()=>Qt,base32hex:()=>as,base32hexpad:()=>us,base32hexpadupper:()=>hs,base32hexupper:()=>fs,base32pad:()=>is,base32padupper:()=>cs,base32upper:()=>ss,base32z:()=>ds});var Qt=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ss=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),is=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),cs=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),as=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),fs=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),us=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),hs=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ds=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ls=Tn,vn=128,ps=127,ms=~ps,xs=Math.pow(2,31);function Tn(e,t,r){t=t||[],r=r||0;for(var n=r;e>=xs;)t[r++]=e&255|vn,e/=128;for(;e&ms;)t[r++]=e&255|vn,e>>>=7;return t[r]=e|0,Tn.bytes=r-n+1,t}var ys=lr,bs=128,In=127;function lr(e,n){var r=0,n=n||0,o=0,s=n,i,c=e.length;do{if(s>=c)throw lr.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&In)<<o:(i&In)*Math.pow(2,o),o+=7}while(i>=bs);return lr.bytes=s-n,r}var gs=Math.pow(2,7),ws=Math.pow(2,14),Es=Math.pow(2,21),Bs=Math.pow(2,28),Ss=Math.pow(2,35),As=Math.pow(2,42),vs=Math.pow(2,49),Is=Math.pow(2,56),Ts=Math.pow(2,63),Rs=function(e){return e<gs?1:e<ws?2:e<Es?3:e<Bs?4:e<Ss?5:e<As?6:e<vs?7:e<Is?8:e<Ts?9:10},Ls={encode:ls,decode:ys,encodingLength:Rs},_s=Ls,he=_s;function de(e,t=0){return[he.decode(e,t),he.decode.bytes]}function Jt(e,t,r=0){return he.encode(e,t,r),t}function te(e){return he.encodingLength(e)}function Ht(e,t){let r=t.byteLength,n=te(e),o=n+te(r),s=new Uint8Array(o+r);return Jt(e,s,0),Jt(r,s,n),s.set(t,o),new ee(e,r,t,s)}function le(e){let t=bt(e),[r,n]=de(t),[o,s]=de(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ee(r,o,i,t)}function Rn(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&gn(e.bytes,r.bytes)}}var ee=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Ln(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Cs(r,pr(e),t??J.encoder);default:return Ns(r,pr(e),t??Qt.encoder)}}var _n=new WeakMap;function pr(e){let t=_n.get(e);if(t==null){let r=new Map;return _n.set(e,r),r}return t}var ht=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==pe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ds)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Ht(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Rn(t.multihash,n.multihash)}toString(t){return Ln(this,t)}toJSON(){return{"/":Ln(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??Un(n,o,s.bytes))}else if(r[Os]===!0){let{version:n,multihash:o,code:s}=r,i=le(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==pe)throw new Error(`Version 0 CID must use dag-pb (code: ${pe}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Un(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,pe,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=bt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new ee(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[p,m]=de(t.subarray(r));return r+=m,p},o=n(),s=pe;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),a=n(),h=r+a,f=h-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:h}}static parse(t,r){let[n,o]=Us(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return pr(s).set(n,t),s}};function Us(e,t){switch(e[0]){case"Q":{let r=t??J;return[J.prefix,r.decode(`${J.prefix}${e}`)]}case J.prefix:{let r=t??J;return[J.prefix,r.decode(e)]}case Qt.prefix:{let r=t??Qt;return[Qt.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Cs(e,t,r){let{prefix:n}=r;if(n!==J.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Ns(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var pe=112,Ds=18;function Un(e,t,r){let n=te(e),o=n+te(t),s=new Uint8Array(o+r.byteLength);return Jt(e,s,0),Jt(t,s,n),s.set(r,o),s}var Os=Symbol.for("@ipld/js-cid/CID");var mr={};it(mr,{identity:()=>gt});var Cn=0,Ps="identity",Nn=bt;function Ks(e){return Ht(Cn,Nn(e))}var gt={code:Cn,name:Ps,encode:Nn,digest:Ks};function Mt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Dn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Hs(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ne(e,...t){if(!Hs(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function On(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Dn(e.outputLen),Dn(e.blockLen)}function oe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Pn(e,t){ne(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var qt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Pe=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),dt=(e,t)=>e<<32-t|e>>>t;var fa=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Kn(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function me(e){return typeof e=="string"&&(e=Kn(e)),ne(e),e}function xr(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ne(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}var se=class{clone(){return this._cloneInto()}},ua={}.toString;function Ke(e){let t=n=>e().update(me(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function He(e=32){if(qt&&typeof qt.getRandomValues=="function")return qt.getRandomValues(new Uint8Array(e));if(qt&&typeof qt.randomBytes=="function")return qt.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function Ms(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),c=Number(r&s),a=n?4:0,h=n?0:4;e.setUint32(t+a,i,n),e.setUint32(t+h,c,n)}var Hn=(e,t,r)=>e&t^~e&r,Mn=(e,t,r)=>e&t^e&r^t&r,ie=class extends se{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Pe(this.buffer)}update(t){oe(this);let{view:r,buffer:n,blockLen:o}=this;t=me(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=Pe(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){oe(this),Pn(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let p=i;p<o;p++)r[p]=0;Ms(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=Pe(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=a/4,f=this.get();if(h>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<h;p++)c.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%r&&t.buffer.set(n),t}};var Me=BigInt(4294967295),yr=BigInt(32);function qn(e,t=!1){return t?{h:Number(e&Me),l:Number(e>>yr&Me)}:{h:Number(e>>yr&Me)|0,l:Number(e&Me)|0}}function qs(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let o=0;o<e.length;o++){let{h:s,l:i}=qn(e[o],t);[r[o],n[o]]=[s,i]}return[r,n]}var ks=(e,t)=>BigInt(e>>>0)<<yr|BigInt(t>>>0),zs=(e,t,r)=>e>>>r,Vs=(e,t,r)=>e<<32-r|t>>>r,Fs=(e,t,r)=>e>>>r|t<<32-r,$s=(e,t,r)=>e<<32-r|t>>>r,Zs=(e,t,r)=>e<<64-r|t>>>r-32,Gs=(e,t,r)=>e>>>r-32|t<<64-r,js=(e,t)=>t,Ys=(e,t)=>e,Ws=(e,t,r)=>e<<r|t>>>32-r,Xs=(e,t,r)=>t<<r|e>>>32-r,Qs=(e,t,r)=>t<<r-32|e>>>64-r,Js=(e,t,r)=>e<<r-32|t>>>64-r;function ti(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ei=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),ri=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,ni=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),oi=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,si=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),ii=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var ci={fromBig:qn,split:qs,toBig:ks,shrSH:zs,shrSL:Vs,rotrSH:Fs,rotrSL:$s,rotrBH:Zs,rotrBL:Gs,rotr32H:js,rotr32L:Ys,rotlSH:Ws,rotlSL:Xs,rotlBH:Qs,rotlBL:Js,add:ti,add3L:ei,add3H:ri,add4L:ni,add4H:oi,add5H:ii,add5L:si},D=ci;var[ai,fi]=D.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Rt=new Uint32Array(80),Lt=new Uint32Array(80),br=class extends ie{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:h,El:f,Fh:p,Fl:m,Gh:R,Gl:S,Hh:y,Hl:u}=this;return[t,r,n,o,s,i,c,a,h,f,p,m,R,S,y,u]}set(t,r,n,o,s,i,c,a,h,f,p,m,R,S,y,u){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=h|0,this.El=f|0,this.Fh=p|0,this.Fl=m|0,this.Gh=R|0,this.Gl=S|0,this.Hh=y|0,this.Hl=u|0}process(t,r){for(let l=0;l<16;l++,r+=4)Rt[l]=t.getUint32(r),Lt[l]=t.getUint32(r+=4);for(let l=16;l<80;l++){let B=Rt[l-15]|0,U=Lt[l-15]|0,_=D.rotrSH(B,U,1)^D.rotrSH(B,U,8)^D.shrSH(B,U,7),A=D.rotrSL(B,U,1)^D.rotrSL(B,U,8)^D.shrSL(B,U,7),v=Rt[l-2]|0,L=Lt[l-2]|0,G=D.rotrSH(v,L,19)^D.rotrBH(v,L,61)^D.shrSH(v,L,6),M=D.rotrSL(v,L,19)^D.rotrBL(v,L,61)^D.shrSL(v,L,6),O=D.add4L(A,M,Lt[l-7],Lt[l-16]),j=D.add4H(O,_,G,Rt[l-7],Rt[l-16]);Rt[l]=j|0,Lt[l]=O|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:h,Dl:f,Eh:p,El:m,Fh:R,Fl:S,Gh:y,Gl:u,Hh:b,Hl:E}=this;for(let l=0;l<80;l++){let B=D.rotrSH(p,m,14)^D.rotrSH(p,m,18)^D.rotrBH(p,m,41),U=D.rotrSL(p,m,14)^D.rotrSL(p,m,18)^D.rotrBL(p,m,41),_=p&R^~p&y,A=m&S^~m&u,v=D.add5L(E,U,A,fi[l],Lt[l]),L=D.add5H(v,b,B,_,ai[l],Rt[l]),G=v|0,M=D.rotrSH(n,o,28)^D.rotrBH(n,o,34)^D.rotrBH(n,o,39),O=D.rotrSL(n,o,28)^D.rotrBL(n,o,34)^D.rotrBL(n,o,39),j=n&s^n&c^s&c,w=o&i^o&a^i&a;b=y|0,E=u|0,y=R|0,u=S|0,R=p|0,S=m|0,{h:p,l:m}=D.add(h|0,f|0,L|0,G|0),h=c|0,f=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let I=D.add3L(G,O,w);n=D.add3H(I,L,M,j),o=I|0}({h:n,l:o}=D.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=D.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=D.add(this.Ch|0,this.Cl|0,c|0,a|0),{h,l:f}=D.add(this.Dh|0,this.Dl|0,h|0,f|0),{h:p,l:m}=D.add(this.Eh|0,this.El|0,p|0,m|0),{h:R,l:S}=D.add(this.Fh|0,this.Fl|0,R|0,S|0),{h:y,l:u}=D.add(this.Gh|0,this.Gl|0,y|0,u|0),{h:b,l:E}=D.add(this.Hh|0,this.Hl|0,b|0,E|0),this.set(n,o,s,i,c,a,h,f,p,m,R,S,y,u,b,E)}roundClean(){Rt.fill(0),Lt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var kn=Ke(()=>new br);var ke={};it(ke,{aInRange:()=>ct,abool:()=>lt,abytes:()=>ce,bitGet:()=>mi,bitLen:()=>Sr,bitMask:()=>ye,bitSet:()=>xi,bytesToHex:()=>Et,bytesToNumberBE:()=>Bt,bytesToNumberLE:()=>Ut,concatBytes:()=>St,createHmacDrbg:()=>Ar,ensureBytes:()=>Z,equalBytes:()=>li,hexToBytes:()=>zt,hexToNumber:()=>Br,inRange:()=>xe,isBytes:()=>_t,memoized:()=>Ft,notImplemented:()=>bi,numberToBytesBE:()=>Ct,numberToBytesLE:()=>Vt,numberToHexUnpadded:()=>kt,numberToVarBytesBE:()=>di,utf8ToBytes:()=>pi,validateObject:()=>xt});var Er=BigInt(0),qe=BigInt(1),ui=BigInt(2);function _t(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ce(e){if(!_t(e))throw new Error("Uint8Array expected")}function lt(e,t){if(typeof t!="boolean")throw new Error(`${e} must be valid boolean, got "${t}".`)}var hi=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Et(e){ce(e);let t="";for(let r=0;r<e.length;r++)t+=hi[e[r]];return t}function kt(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function Br(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}var wt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function zn(e){if(e>=wt._0&&e<=wt._9)return e-wt._0;if(e>=wt._A&&e<=wt._F)return e-(wt._A-10);if(e>=wt._a&&e<=wt._f)return e-(wt._a-10)}function zt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=zn(e.charCodeAt(s)),c=zn(e.charCodeAt(s+1));if(i===void 0||c===void 0){let a=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Bt(e){return Br(Et(e))}function Ut(e){return ce(e),Br(Et(Uint8Array.from(e).reverse()))}function Ct(e,t){return zt(e.toString(16).padStart(t*2,"0"))}function Vt(e,t){return Ct(e,t).reverse()}function di(e){return zt(kt(e))}function Z(e,t,r){let n;if(typeof t=="string")try{n=zt(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(_t(t))n=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(`${e} expected ${r} bytes, got ${o}`);return n}function St(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ce(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function li(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function pi(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}var gr=e=>typeof e=="bigint"&&Er<=e;function xe(e,t,r){return gr(e)&&gr(t)&&gr(r)&&t<=e&&e<r}function ct(e,t,r,n){if(!xe(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function Sr(e){let t;for(t=0;e>Er;e>>=qe,t+=1);return t}function mi(e,t){return e>>BigInt(t)&qe}function xi(e,t,r){return e|(r?qe:Er)<<BigInt(t)}var ye=e=>(ui<<BigInt(e-1))-qe,wr=e=>new Uint8Array(e),Vn=e=>Uint8Array.from(e);function Ar(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 n=wr(e),o=wr(e),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...p)=>r(o,n,...p),a=(p=wr())=>{o=c(Vn([0]),p),n=c(),p.length!==0&&(o=c(Vn([1]),p),n=c())},h=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,m=[];for(;p<t;){n=c();let R=n.slice();m.push(R),p+=n.length}return St(...m)};return(p,m)=>{i(),a(p);let R;for(;!(R=m(h()));)a();return i(),R}}var yi={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"||_t(e),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 xt(e,t,r={}){let n=(o,s,i)=>{let c=yi[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let a=e[o];if(!(i&&a===void 0)&&!c(a,e))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${s}`)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(r))n(o,s,!0);return e}var bi=()=>{throw new Error("not implemented")};function Ft(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let s=e(r,...n);return t.set(r,s),s}}var W=BigInt(0),V=BigInt(1),$t=BigInt(2),gi=BigInt(3),vr=BigInt(4),Fn=BigInt(5),$n=BigInt(8),wi=BigInt(9),Ei=BigInt(16);function k(e,t){let r=e%t;return r>=W?r:t+r}function Bi(e,t,r){if(r<=W||t<W)throw new Error("Expected power/modulo > 0");if(r===V)return W;let n=V;for(;t>W;)t&V&&(n=n*e%r),e=e*e%r,t>>=V;return n}function F(e,t,r){let n=e;for(;t-- >W;)n*=n,n%=r;return n}function ze(e,t){if(e===W||t<=W)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=k(e,t),n=t,o=W,s=V,i=V,c=W;for(;r!==W;){let h=n/r,f=n%r,p=o-i*h,m=s-c*h;n=r,r=f,o=i,s=c,i=p,c=m}if(n!==V)throw new Error("invert: does not exist");return k(o,t)}function Si(e){let t=(e-V)/$t,r,n,o;for(r=e-V,n=0;r%$t===W;r/=$t,n++);for(o=$t;o<e&&Bi(o,t,e)!==e-V;o++);if(n===1){let i=(e+V)/vr;return function(a,h){let f=a.pow(h,i);if(!a.eql(a.sqr(f),h))throw new Error("Cannot find square root");return f}}let s=(r+V)/$t;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let h=n,f=c.pow(c.mul(c.ONE,o),r),p=c.pow(a,s),m=c.pow(a,r);for(;!c.eql(m,c.ONE);){if(c.eql(m,c.ZERO))return c.ZERO;let R=1;for(let y=c.sqr(m);R<h&&!c.eql(y,c.ONE);R++)y=c.sqr(y);let S=c.pow(f,V<<BigInt(h-R-1));f=c.sqr(S),p=c.mul(p,S),m=c.mul(m,f),h=R}return p}}function Ai(e){if(e%vr===gi){let t=(e+V)/vr;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(e%$n===Fn){let t=(e-Fn)/$n;return function(n,o){let s=n.mul(o,$t),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,$t),i),h=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(h),o))throw new Error("Cannot find square root");return h}}return e%Ei,Si(e)}var Zn=(e,t)=>(k(e,t)&V)===V,vi=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ir(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=vi.reduce((n,o)=>(n[o]="function",n),t);return xt(e,r)}function Ii(e,t,r){if(r<W)throw new Error("Expected power > 0");if(r===W)return e.ONE;if(r===V)return t;let n=e.ONE,o=t;for(;r>W;)r&V&&(n=e.mul(n,o)),o=e.sqr(o),r>>=V;return n}function Ti(e,t){let r=new Array(t.length),n=t.reduce((s,i,c)=>e.is0(i)?s:(r[c]=s,e.mul(s,i)),e.ONE),o=e.inv(n);return t.reduceRight((s,i,c)=>e.is0(i)?s:(r[c]=e.mul(s,r[c]),e.mul(s,i)),o),r}function Tr(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Nt(e,t,r=!1,n={}){if(e<=W)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:o,nByteLength:s}=Tr(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Ai(e),c=Object.freeze({ORDER:e,BITS:o,BYTES:s,MASK:ye(o),ZERO:W,ONE:V,create:a=>k(a,e),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return W<=a&&a<e},is0:a=>a===W,isOdd:a=>(a&V)===V,neg:a=>k(-a,e),eql:(a,h)=>a===h,sqr:a=>k(a*a,e),add:(a,h)=>k(a+h,e),sub:(a,h)=>k(a-h,e),mul:(a,h)=>k(a*h,e),pow:(a,h)=>Ii(c,a,h),div:(a,h)=>k(a*ze(h,e),e),sqrN:a=>a*a,addN:(a,h)=>a+h,subN:(a,h)=>a-h,mulN:(a,h)=>a*h,inv:a=>ze(a,e),sqrt:n.sqrt||(a=>i(c,a)),invertBatch:a=>Ti(c,a),cmov:(a,h,f)=>f?h:a,toBytes:a=>r?Vt(a,s):Ct(a,s),fromBytes:a=>{if(a.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);return r?Ut(a):Bt(a)}});return Object.freeze(c)}function Gn(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function Rr(e){let t=Gn(e);return t+Math.ceil(t/2)}function jn(e,t,r=!1){let n=e.length,o=Gn(t),s=Rr(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=r?Bt(e):Ut(e),c=k(i,t-V)+V;return r?Vt(c,o):Ct(c,o)}var Li=BigInt(0),Lr=BigInt(1),_r=new WeakMap,Yn=new WeakMap;function Ve(e,t){let r=(s,i)=>{let c=i.negate();return s?c:i},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},o=s=>{n(s);let i=Math.ceil(t/s)+1,c=2**(s-1);return{windows:i,windowSize:c}};return{constTimeNegate:r,unsafeLadder(s,i){let c=e.ZERO,a=s;for(;i>Li;)i&Lr&&(c=c.add(a)),a=a.double(),i>>=Lr;return c},precomputeWindow(s,i){let{windows:c,windowSize:a}=o(i),h=[],f=s,p=f;for(let m=0;m<c;m++){p=f,h.push(p);for(let R=1;R<a;R++)p=p.add(f),h.push(p);f=p.double()}return h},wNAF(s,i,c){let{windows:a,windowSize:h}=o(s),f=e.ZERO,p=e.BASE,m=BigInt(2**s-1),R=2**s,S=BigInt(s);for(let y=0;y<a;y++){let u=y*h,b=Number(c&m);c>>=S,b>h&&(b-=R,c+=Lr);let E=u,l=u+Math.abs(b)-1,B=y%2!==0,U=b<0;b===0?p=p.add(r(B,i[E])):f=f.add(r(U,i[l]))}return{p:f,f:p}},wNAFCached(s,i,c){let a=Yn.get(s)||1,h=_r.get(s);return h||(h=this.precomputeWindow(s,a),a!==1&&_r.set(s,c(h))),this.wNAF(a,h,i)},setWindowSize(s,i){n(i),Yn.set(s,i),_r.delete(s)}}}function Fe(e,t,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((f,p)=>{if(!t.isValid(f))throw new Error(`wrong scalar at index ${p}`)}),r.forEach((f,p)=>{if(!(f instanceof e))throw new Error(`wrong point at index ${p}`)});let o=Sr(BigInt(r.length)),s=o>12?o-3:o>4?o-2:o?2:1,i=(1<<s)-1,c=new Array(i+1).fill(e.ZERO),a=Math.floor((t.BITS-1)/s)*s,h=e.ZERO;for(let f=a;f>=0;f-=s){c.fill(e.ZERO);for(let m=0;m<n.length;m++){let R=n[m],S=Number(R>>BigInt(f)&BigInt(i));c[S]=c[S].add(r[m])}let p=e.ZERO;for(let m=c.length-1,R=e.ZERO;m>0;m--)R=R.add(c[m]),p=p.add(R);if(h=h.add(p),f!==0)for(let m=0;m<s;m++)h=h.double()}return h}function be(e){return Ir(e.Fp),xt(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Tr(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var pt=BigInt(0),at=BigInt(1),$e=BigInt(2),_i=BigInt(8),Ui={zip215:!0};function Ci(e){let t=be(e);return xt(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Wn(e){let t=Ci(e),{Fp:r,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,h=$e<<BigInt(c*8)-at,f=r.create,p=Nt(t.n,t.nBitLength),m=t.uvRatio||((x,d)=>{try{return{isValid:!0,value:r.sqrt(x*r.inv(d))}}catch{return{isValid:!1,value:pt}}}),R=t.adjustScalarBytes||(x=>x),S=t.domain||((x,d,g)=>{if(lt("phflag",g),d.length||g)throw new Error("Contexts/pre-hash are not supported");return x});function y(x,d){ct("coordinate "+x,d,pt,h)}function u(x){if(!(x instanceof l))throw new Error("ExtendedPoint expected")}let b=Ft((x,d)=>{let{ex:g,ey:T,ez:C}=x,N=x.is0();d==null&&(d=N?_i:r.inv(C));let P=f(g*d),H=f(T*d),K=f(C*d);if(N)return{x:pt,y:at};if(K!==at)throw new Error("invZ was invalid");return{x:P,y:H}}),E=Ft(x=>{let{a:d,d:g}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:T,ey:C,ez:N,et:P}=x,H=f(T*T),K=f(C*C),q=f(N*N),z=f(q*q),X=f(H*d),Q=f(q*f(X+K)),et=f(z+f(g*f(H*K)));if(Q!==et)throw new Error("bad point: equation left != right (1)");let nt=f(T*C),Y=f(N*P);if(nt!==Y)throw new Error("bad point: equation left != right (2)");return!0});class l{constructor(d,g,T,C){this.ex=d,this.ey=g,this.ez=T,this.et=C,y("x",d),y("y",g),y("z",T),y("t",C),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof l)throw new Error("extended point not allowed");let{x:g,y:T}=d||{};return y("x",g),y("y",T),new l(g,T,at,f(g*T))}static normalizeZ(d){let g=r.invertBatch(d.map(T=>T.ez));return d.map((T,C)=>T.toAffine(g[C])).map(l.fromAffine)}static msm(d,g){return Fe(l,p,d,g)}_setWindowSize(d){_.setWindowSize(this,d)}assertValidity(){E(this)}equals(d){u(d);let{ex:g,ey:T,ez:C}=this,{ex:N,ey:P,ez:H}=d,K=f(g*H),q=f(N*C),z=f(T*H),X=f(P*C);return K===q&&z===X}is0(){return this.equals(l.ZERO)}negate(){return new l(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:d}=t,{ex:g,ey:T,ez:C}=this,N=f(g*g),P=f(T*T),H=f($e*f(C*C)),K=f(d*N),q=g+T,z=f(f(q*q)-N-P),X=K+P,Q=X-H,et=K-P,nt=f(z*Q),Y=f(X*et),st=f(z*et),yt=f(Q*X);return new l(nt,Y,yt,st)}add(d){u(d);let{a:g,d:T}=t,{ex:C,ey:N,ez:P,et:H}=this,{ex:K,ey:q,ez:z,et:X}=d;if(g===BigInt(-1)){let dn=f((N-C)*(q+K)),ln=f((N+C)*(q-K)),or=f(ln-dn);if(or===pt)return this.double();let pn=f(P*$e*X),mn=f(H*$e*z),xn=mn+pn,yn=ln+dn,bn=mn-pn,Fo=f(xn*or),$o=f(yn*bn),Zo=f(xn*bn),Go=f(or*yn);return new l(Fo,$o,Go,Zo)}let Q=f(C*K),et=f(N*q),nt=f(H*T*X),Y=f(P*z),st=f((C+N)*(K+q)-Q-et),yt=Y-nt,fe=Y+nt,ue=f(et-g*Q),qo=f(st*yt),ko=f(fe*ue),zo=f(st*ue),Vo=f(yt*fe);return new l(qo,ko,Vo,zo)}subtract(d){return this.add(d.negate())}wNAF(d){return _.wNAFCached(this,d,l.normalizeZ)}multiply(d){let g=d;ct("scalar",g,at,n);let{p:T,f:C}=this.wNAF(g);return l.normalizeZ([T,C])[0]}multiplyUnsafe(d){let g=d;return ct("scalar",g,pt,n),g===pt?U:this.equals(U)||g===at?this:this.equals(B)?this.wNAF(g).p:_.unsafeLadder(this,g)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return _.unsafeLadder(this,n).is0()}toAffine(d){return b(this,d)}clearCofactor(){let{h:d}=t;return d===at?this:this.multiplyUnsafe(d)}static fromHex(d,g=!1){let{d:T,a:C}=t,N=r.BYTES;d=Z("pointHex",d,N),lt("zip215",g);let P=d.slice(),H=d[N-1];P[N-1]=H&-129;let K=Ut(P),q=g?h:r.ORDER;ct("pointHex.y",K,pt,q);let z=f(K*K),X=f(z-at),Q=f(T*z-C),{isValid:et,value:nt}=m(X,Q);if(!et)throw new Error("Point.fromHex: invalid y coordinate");let Y=(nt&at)===at,st=(H&128)!==0;if(!g&&nt===pt&&st)throw new Error("Point.fromHex: x=0 and x_0=1");return st!==Y&&(nt=f(-nt)),l.fromAffine({x:nt,y:K})}static fromPrivateKey(d){return L(d).point}toRawBytes(){let{x:d,y:g}=this.toAffine(),T=Vt(g,r.BYTES);return T[T.length-1]|=d&at?128:0,T}toHex(){return Et(this.toRawBytes())}}l.BASE=new l(t.Gx,t.Gy,at,f(t.Gx*t.Gy)),l.ZERO=new l(pt,at,at,pt);let{BASE:B,ZERO:U}=l,_=Ve(l,c*8);function A(x){return k(x,n)}function v(x){return A(Ut(x))}function L(x){let d=c;x=Z("private key",x,d);let g=Z("hashed private key",s(x),2*d),T=R(g.slice(0,d)),C=g.slice(d,2*d),N=v(T),P=B.multiply(N),H=P.toRawBytes();return{head:T,prefix:C,scalar:N,point:P,pointBytes:H}}function G(x){return L(x).pointBytes}function M(x=new Uint8Array,...d){let g=St(...d);return v(s(S(g,Z("context",x),!!o)))}function O(x,d,g={}){x=Z("message",x),o&&(x=o(x));let{prefix:T,scalar:C,pointBytes:N}=L(d),P=M(g.context,T,x),H=B.multiply(P).toRawBytes(),K=M(g.context,H,N,x),q=A(P+K*C);ct("signature.s",q,pt,n);let z=St(H,Vt(q,r.BYTES));return Z("result",z,c*2)}let j=Ui;function w(x,d,g,T=j){let{context:C,zip215:N}=T,P=r.BYTES;x=Z("signature",x,2*P),d=Z("message",d),N!==void 0&&lt("zip215",N),o&&(d=o(d));let H=Ut(x.slice(P,2*P)),K,q,z;try{K=l.fromHex(g,N),q=l.fromHex(x.slice(0,P),N),z=B.multiplyUnsafe(H)}catch{return!1}if(!N&&K.isSmallOrder())return!1;let X=M(C,q.toRawBytes(),K.toRawBytes(),d);return q.add(K.multiplyUnsafe(X)).subtract(z).clearCofactor().equals(l.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:G,sign:O,verify:w,ExtendedPoint:l,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>i(r.BYTES),precompute(x=8,d=l.BASE){return d._setWindowSize(x),d.multiply(BigInt(3)),d}}}}var Ur=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Xn=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Na=BigInt(0),Ni=BigInt(1),Qn=BigInt(2),Da=BigInt(3),Di=BigInt(5),Oi=BigInt(8);function Pi(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Ur,c=e*e%s*e%s,a=F(c,Qn,s)*c%s,h=F(a,Ni,s)*e%s,f=F(h,Di,s)*h%s,p=F(f,t,s)*f%s,m=F(p,r,s)*p%s,R=F(m,n,s)*m%s,S=F(R,o,s)*R%s,y=F(S,o,s)*R%s,u=F(y,t,s)*f%s;return{pow_p_5_8:F(u,Qn,s)*e%s,b2:c}}function Ki(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Hi(e,t){let r=Ur,n=k(t*t*t,r),o=k(n*n*t,r),s=Pi(e*o).pow_p_5_8,i=k(e*n*s,r),c=k(t*i*i,r),a=i,h=k(i*Xn,r),f=c===e,p=c===k(-e,r),m=c===k(-e*Xn,r);return f&&(i=a),(p||m)&&(i=h),Zn(i,r)&&(i=k(-i,r)),{isValid:f||p,value:i}}var Mi=Nt(Ur,void 0,!0),qi={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Mi,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Oi,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:kn,randomBytes:He,adjustScalarBytes:Ki,uvRatio:Hi},Jn=Wn(qi);var Ze=32;function to(e,t,r){return Jn.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var Ge=class{type="Ed25519";raw;constructor(t){this.raw=Cr(t,Ze)}toMultihash(){return gt.digest(je(this))}toCID(){return ht.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Mt(this.raw,t.raw)}verify(t,r){return to(this.raw,r,t)}};function ro(e){return e=Cr(e,Ze),new Ge(e)}function Cr(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new Yt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}function At(e=0){return new Uint8Array(e)}var zi=Math.pow(2,7),Vi=Math.pow(2,14),Fi=Math.pow(2,21),no=Math.pow(2,28),oo=Math.pow(2,35),so=Math.pow(2,42),io=Math.pow(2,49),ot=128,Dt=127;function ge(e){if(e<zi)return 1;if(e<Vi)return 2;if(e<Fi)return 3;if(e<no)return 4;if(e<oo)return 5;if(e<so)return 6;if(e<io)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function co(e,t,r=0){switch(ge(e)){case 8:t[r++]=e&255|ot,e/=128;case 7:t[r++]=e&255|ot,e/=128;case 6:t[r++]=e&255|ot,e/=128;case 5:t[r++]=e&255|ot,e/=128;case 4:t[r++]=e&255|ot,e>>>=7;case 3:t[r++]=e&255|ot,e>>>=7;case 2:t[r++]=e&255|ot,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function ao(e,t){let r=e[t],n=0;if(n+=r&Dt,r<ot||(r=e[t+1],n+=(r&Dt)<<7,r<ot)||(r=e[t+2],n+=(r&Dt)<<14,r<ot)||(r=e[t+3],n+=(r&Dt)<<21,r<ot)||(r=e[t+4],n+=(r&Dt)*no,r<ot)||(r=e[t+5],n+=(r&Dt)*oo,r<ot)||(r=e[t+6],n+=(r&Dt)*so,r<ot)||(r=e[t+7],n+=(r&Dt)*io,r<ot))return n;throw new RangeError("Could not decode varint")}var Nr=new Float32Array([-0]),Ot=new Uint8Array(Nr.buffer);function fo(e,t,r){Nr[0]=e,t[r]=Ot[0],t[r+1]=Ot[1],t[r+2]=Ot[2],t[r+3]=Ot[3]}function uo(e,t){return Ot[0]=e[t],Ot[1]=e[t+1],Ot[2]=e[t+2],Ot[3]=e[t+3],Nr[0]}var Dr=new Float64Array([-0]),rt=new Uint8Array(Dr.buffer);function ho(e,t,r){Dr[0]=e,t[r]=rt[0],t[r+1]=rt[1],t[r+2]=rt[2],t[r+3]=rt[3],t[r+4]=rt[4],t[r+5]=rt[5],t[r+6]=rt[6],t[r+7]=rt[7]}function lo(e,t){return rt[0]=e[t],rt[1]=e[t+1],rt[2]=e[t+2],rt[3]=e[t+3],rt[4]=e[t+4],rt[5]=e[t+5],rt[6]=e[t+6],rt[7]=e[t+7],Dr[0]}var $i=BigInt(Number.MAX_SAFE_INTEGER),Zi=BigInt(Number.MIN_SAFE_INTEGER),ft=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Zt;if(t<$i&&t>Zi)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>po&&(o=0n,++n>po&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Zt;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Zt}},Zt=new ft(0,0);Zt.toBigInt=function(){return 0n};Zt.zzEncode=Zt.zzDecode=function(){return this};Zt.length=function(){return 1};var po=4294967296n;function mo(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function xo(e,t,r){if(r-t<1)return"";let o,s=[],i=0,c;for(;t<r;)c=e[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Or(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function mt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Ye(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Pr=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,mt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw mt(this,4);return Ye(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw mt(this,4);return Ye(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw mt(this,4);let t=uo(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw mt(this,4);let t=lo(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw mt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return xo(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw mt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw mt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new ft(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw mt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw mt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw mt(this,8);let t=Ye(this.buf,this.pos+=4),r=Ye(this.buf,this.pos+=4);return new ft(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=ao(this.buf,this.pos);return this.pos+=ge(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Kr(e){return new Pr(e instanceof Uint8Array?e:e.subarray())}function We(e,t,r){let n=Kr(e);return t.decode(n,void 0,r)}var Hr={};it(Hr,{base10:()=>Gi});var Gi=Tt({prefix:"9",name:"base10",alphabet:"0123456789"});var Mr={};it(Mr,{base16:()=>ji,base16upper:()=>Yi});var ji=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Yi=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qr={};it(qr,{base2:()=>Wi});var Wi=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var kr={};it(kr,{base256emoji:()=>ec});var bo=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Xi=bo.reduce((e,t,r)=>(e[r]=t,e),[]),Qi=bo.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function Ji(e){return e.reduce((t,r)=>(t+=Xi[r],t),"")}function tc(e){let t=[];for(let r of e){let n=Qi[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}var ec=Xt({prefix:"\u{1F680}",name:"base256emoji",encode:Ji,decode:tc});var zr={};it(zr,{base36:()=>rc,base36upper:()=>nc});var rc=Tt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),nc=Tt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vr={};it(Vr,{base64:()=>oc,base64pad:()=>sc,base64url:()=>ic,base64urlpad:()=>cc});var oc=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sc=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ic=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cc=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fr={};it(Fr,{base8:()=>ac});var ac=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var $r={};it($r,{identity:()=>fc});var fc=Xt({prefix:"\0",name:"identity",encode:e=>En(e),decode:e=>wn(e)});var gf=new TextEncoder,wf=new TextDecoder;var jr={};it(jr,{sha256:()=>we,sha512:()=>dc});function Gr({name:e,code:t,encode:r}){return new Zr(e,t,r)}var Zr=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Ht(this.code,r):r.then(n=>Ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};function wo(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var we=Gr({name:"sha2-256",code:18,encode:wo("SHA-256")}),dc=Gr({name:"sha2-512",code:19,encode:wo("SHA-512")});var Yr={...$r,...qr,...Fr,...Hr,...Mr,...dr,...zr,...hr,...Vr,...kr},Cf={...jr,...mr};function Bo(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Eo=Bo("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Wr=Bo("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=At(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),lc={utf8:Eo,"utf-8":Eo,hex:Yr.base16,latin1:Wr,ascii:Wr,binary:Wr,...Yr},Xe=lc;function Ee(e,t="utf8"){let r=Xe[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function Xr(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return At(i);o+i>t&&(n=At(t),o=0);let c=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),c}}var Gt=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Qr(){}var tn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},pc=Xr();function mc(e){return globalThis.Buffer!=null?At(e):pc(e)}var Se=class{len;head;tail;states;constructor(){this.len=0,this.head=new Gt(Qr,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Gt(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new en((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Qe,10,ft.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=ft.fromBigInt(t);return this._push(Qe,r.length(),r)}uint64Number(t){return this._push(co,ge(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=ft.fromBigInt(t).zzEncode();return this._push(Qe,r.length(),r)}sint64Number(t){let r=ft.fromNumber(t).zzEncode();return this._push(Qe,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Jr,1,t?1:0)}fixed32(t){return this._push(Be,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=ft.fromBigInt(t);return this._push(Be,4,r.lo)._push(Be,4,r.hi)}fixed64Number(t){let r=ft.fromNumber(t);return this._push(Be,4,r.lo)._push(Be,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(fo,4,t)}double(t){return this._push(ho,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Jr,1,0):this.uint32(r)._push(yc,r,t)}string(t){let r=mo(t);return r!==0?this.uint32(r)._push(Or,r,t):this._push(Jr,1,0)}fork(){return this.states=new tn(this),this.head=this.tail=new Gt(Qr,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Gt(Qr,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=mc(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Jr(e,t,r){t[r]=e&255}function xc(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var en=class extends Gt{next;constructor(t,r){super(xc,t,r),this.next=void 0}};function Qe(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Be(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function yc(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Se.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(bc,t,e),this},Se.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(gc,t,e),this});function bc(e,t,r){t.set(e,r)}function gc(e,t,r){e.length<40?Or(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Ee(e),r)}function rn(){return new Se}function Je(e,t){let r=rn();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ae;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(ae||(ae={}));function tr(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function nn(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return tr("enum",ae.VARINT,r,n)}function er(e,t){return tr("message",ae.LENGTH_DELIMITED,e,t)}var ut;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1"})(ut||(ut={}));var on;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1"})(on||(on={}));(function(e){e.codec=()=>nn(on)})(ut||(ut={}));var Ae;(function(e){let t;e.codec=()=>(t==null&&(t=er((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ut.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let c=r.uint32();switch(c>>>3){case 1:{s.Type=ut.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return s})),t),e.encode=r=>Je(r,e.codec()),e.decode=(r,n)=>We(r,e.codec(),n)})(Ae||(Ae={}));var sn;(function(e){let t;e.codec=()=>(t==null&&(t=er((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ut.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let c=r.uint32();switch(c>>>3){case 1:{s.Type=ut.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return s})),t),e.encode=r=>Je(r,e.codec()),e.decode=(r,n)=>We(r,e.codec(),n)})(sn||(sn={}));var Ec=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]),Pt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Kt=new Uint32Array(64),cn=class extends ie{constructor(){super(64,32,8,!1),this.A=Pt[0]|0,this.B=Pt[1]|0,this.C=Pt[2]|0,this.D=Pt[3]|0,this.E=Pt[4]|0,this.F=Pt[5]|0,this.G=Pt[6]|0,this.H=Pt[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,r,n,o,s,i,c,a]}set(t,r,n,o,s,i,c,a){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,r){for(let p=0;p<16;p++,r+=4)Kt[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let m=Kt[p-15],R=Kt[p-2],S=dt(m,7)^dt(m,18)^m>>>3,y=dt(R,17)^dt(R,19)^R>>>10;Kt[p]=y+Kt[p-7]+S+Kt[p-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:h,H:f}=this;for(let p=0;p<64;p++){let m=dt(c,6)^dt(c,11)^dt(c,25),R=f+m+Hn(c,a,h)+Ec[p]+Kt[p]|0,y=(dt(n,2)^dt(n,13)^dt(n,22))+Mn(n,o,s)|0;f=h,h=a,a=c,c=i+R|0,i=s,s=o,o=n,n=R+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(n,o,s,i,c,a,h,f)}roundClean(){Kt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var So=Ke(()=>new cn);function ve(e,t="utf8"){let r=Xe[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Ie=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var rr=class extends se{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,On(t);let n=me(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;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return oe(this),this.iHash.update(t),this}digestInto(t){oe(this),ne(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},an=(e,t,r)=>new rr(e,t).update(r).digest();an.create=(e,t)=>new rr(e,t);function Ao(e){e.lowS!==void 0&&lt("lowS",e.lowS),e.prehash!==void 0&&lt("prehash",e.prehash)}function Bc(e){let t=be(e);xt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.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})}var{bytesToNumberBE:Sc,hexToBytes:Ac}=ke,vt={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(e,t)=>{let{Err:r}=vt;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=kt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?kt(o.length/2|128):"";return`${kt(e)}${s}${o}${t}`},decode(e,t){let{Err:r}=vt,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let h=t.subarray(n,n+a);if(h.length!==a)throw new r("tlv.decode: length bytes not complete");if(h[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of h)i=i<<8|f;if(n+=a,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=vt;if(e<It)throw new t("integer: negative integers are not allowed");let r=kt(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected assertion");return r},decode(e){let{Err:t}=vt;if(e[0]&128)throw new t("Invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return Sc(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=vt,o=typeof e=="string"?Ac(e):e;ce(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("Invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:h,l:f}=n.decode(2,a);if(f.length)throw new t("Invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(h)}},hexFromSig(e){let{_tlv:t,_int:r}=vt,n=`${t.encode(2,r.encode(e.r))}${t.encode(2,r.encode(e.s))}`;return t.encode(48,n)}},It=BigInt(0),tt=BigInt(1),Eu=BigInt(2),vo=BigInt(3),Bu=BigInt(4);function vc(e){let t=Bc(e),{Fp:r}=t,n=Nt(t.n,t.nBitLength),o=t.toBytes||((y,u,b)=>{let E=u.toAffine();return St(Uint8Array.from([4]),r.toBytes(E.x),r.toBytes(E.y))}),s=t.fromBytes||(y=>{let u=y.subarray(1),b=r.fromBytes(u.subarray(0,r.BYTES)),E=r.fromBytes(u.subarray(r.BYTES,2*r.BYTES));return{x:b,y:E}});function i(y){let{a:u,b}=t,E=r.sqr(y),l=r.mul(E,y);return r.add(r.add(l,r.mul(y,u)),b)}if(!r.eql(r.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(y){return xe(y,tt,t.n)}function a(y){let{allowedPrivateKeyLengths:u,nByteLength:b,wrapPrivateKey:E,n:l}=t;if(u&&typeof y!="bigint"){if(_t(y)&&(y=Et(y)),typeof y!="string"||!u.includes(y.length))throw new Error("Invalid key");y=y.padStart(b*2,"0")}let B;try{B=typeof y=="bigint"?y:Bt(Z("private key",y,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof y}`)}return E&&(B=k(B,l)),ct("private key",B,tt,l),B}function h(y){if(!(y instanceof m))throw new Error("ProjectivePoint expected")}let f=Ft((y,u)=>{let{px:b,py:E,pz:l}=y;if(r.eql(l,r.ONE))return{x:b,y:E};let B=y.is0();u==null&&(u=B?r.ONE:r.inv(l));let U=r.mul(b,u),_=r.mul(E,u),A=r.mul(l,u);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(A,r.ONE))throw new Error("invZ was invalid");return{x:U,y:_}}),p=Ft(y=>{if(y.is0()){if(t.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:u,y:b}=y.toAffine();if(!r.isValid(u)||!r.isValid(b))throw new Error("bad point: x or y not FE");let E=r.sqr(b),l=i(u);if(!r.eql(E,l))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(u,b,E){if(this.px=u,this.py=b,this.pz=E,u==null||!r.isValid(u))throw new Error("x required");if(b==null||!r.isValid(b))throw new Error("y required");if(E==null||!r.isValid(E))throw new Error("z required");Object.freeze(this)}static fromAffine(u){let{x:b,y:E}=u||{};if(!u||!r.isValid(b)||!r.isValid(E))throw new Error("invalid affine point");if(u instanceof m)throw new Error("projective point not allowed");let l=B=>r.eql(B,r.ZERO);return l(b)&&l(E)?m.ZERO:new m(b,E,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){let b=r.invertBatch(u.map(E=>E.pz));return u.map((E,l)=>E.toAffine(b[l])).map(m.fromAffine)}static fromHex(u){let b=m.fromAffine(s(Z("pointHex",u)));return b.assertValidity(),b}static fromPrivateKey(u){return m.BASE.multiply(a(u))}static msm(u,b){return Fe(m,n,u,b)}_setWindowSize(u){S.setWindowSize(this,u)}assertValidity(){p(this)}hasEvenY(){let{y:u}=this.toAffine();if(r.isOdd)return!r.isOdd(u);throw new Error("Field doesn't support isOdd")}equals(u){h(u);let{px:b,py:E,pz:l}=this,{px:B,py:U,pz:_}=u,A=r.eql(r.mul(b,_),r.mul(B,l)),v=r.eql(r.mul(E,_),r.mul(U,l));return A&&v}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:u,b}=t,E=r.mul(b,vo),{px:l,py:B,pz:U}=this,_=r.ZERO,A=r.ZERO,v=r.ZERO,L=r.mul(l,l),G=r.mul(B,B),M=r.mul(U,U),O=r.mul(l,B);return O=r.add(O,O),v=r.mul(l,U),v=r.add(v,v),_=r.mul(u,v),A=r.mul(E,M),A=r.add(_,A),_=r.sub(G,A),A=r.add(G,A),A=r.mul(_,A),_=r.mul(O,_),v=r.mul(E,v),M=r.mul(u,M),O=r.sub(L,M),O=r.mul(u,O),O=r.add(O,v),v=r.add(L,L),L=r.add(v,L),L=r.add(L,M),L=r.mul(L,O),A=r.add(A,L),M=r.mul(B,U),M=r.add(M,M),L=r.mul(M,O),_=r.sub(_,L),v=r.mul(M,G),v=r.add(v,v),v=r.add(v,v),new m(_,A,v)}add(u){h(u);let{px:b,py:E,pz:l}=this,{px:B,py:U,pz:_}=u,A=r.ZERO,v=r.ZERO,L=r.ZERO,G=t.a,M=r.mul(t.b,vo),O=r.mul(b,B),j=r.mul(E,U),w=r.mul(l,_),I=r.add(b,E),x=r.add(B,U);I=r.mul(I,x),x=r.add(O,j),I=r.sub(I,x),x=r.add(b,l);let d=r.add(B,_);return x=r.mul(x,d),d=r.add(O,w),x=r.sub(x,d),d=r.add(E,l),A=r.add(U,_),d=r.mul(d,A),A=r.add(j,w),d=r.sub(d,A),L=r.mul(G,x),A=r.mul(M,w),L=r.add(A,L),A=r.sub(j,L),L=r.add(j,L),v=r.mul(A,L),j=r.add(O,O),j=r.add(j,O),w=r.mul(G,w),x=r.mul(M,x),j=r.add(j,w),w=r.sub(O,w),w=r.mul(G,w),x=r.add(x,w),O=r.mul(j,x),v=r.add(v,O),O=r.mul(d,x),A=r.mul(I,A),A=r.sub(A,O),O=r.mul(I,j),L=r.mul(d,L),L=r.add(L,O),new m(A,v,L)}subtract(u){return this.add(u.negate())}is0(){return this.equals(m.ZERO)}wNAF(u){return S.wNAFCached(this,u,m.normalizeZ)}multiplyUnsafe(u){ct("scalar",u,It,t.n);let b=m.ZERO;if(u===It)return b;if(u===tt)return this;let{endo:E}=t;if(!E)return S.unsafeLadder(this,u);let{k1neg:l,k1:B,k2neg:U,k2:_}=E.splitScalar(u),A=b,v=b,L=this;for(;B>It||_>It;)B&tt&&(A=A.add(L)),_&tt&&(v=v.add(L)),L=L.double(),B>>=tt,_>>=tt;return l&&(A=A.negate()),U&&(v=v.negate()),v=new m(r.mul(v.px,E.beta),v.py,v.pz),A.add(v)}multiply(u){let{endo:b,n:E}=t;ct("scalar",u,tt,E);let l,B;if(b){let{k1neg:U,k1:_,k2neg:A,k2:v}=b.splitScalar(u),{p:L,f:G}=this.wNAF(_),{p:M,f:O}=this.wNAF(v);L=S.constTimeNegate(U,L),M=S.constTimeNegate(A,M),M=new m(r.mul(M.px,b.beta),M.py,M.pz),l=L.add(M),B=G.add(O)}else{let{p:U,f:_}=this.wNAF(u);l=U,B=_}return m.normalizeZ([l,B])[0]}multiplyAndAddUnsafe(u,b,E){let l=m.BASE,B=(_,A)=>A===It||A===tt||!_.equals(l)?_.multiplyUnsafe(A):_.multiply(A),U=B(this,b).add(B(u,E));return U.is0()?void 0:U}toAffine(u){return f(this,u)}isTorsionFree(){let{h:u,isTorsionFree:b}=t;if(u===tt)return!0;if(b)return b(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:u,clearCofactor:b}=t;return u===tt?this:b?b(m,this):this.multiplyUnsafe(t.h)}toRawBytes(u=!0){return lt("isCompressed",u),this.assertValidity(),o(m,this,u)}toHex(u=!0){return lt("isCompressed",u),Et(this.toRawBytes(u))}}m.BASE=new m(t.Gx,t.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let R=t.nBitLength,S=Ve(m,t.endo?Math.ceil(R/2):R);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Ic(e){let t=be(e);return xt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Io(e){let t=Ic(e),{Fp:r,n}=t,o=r.BYTES+1,s=2*r.BYTES+1;function i(w){return k(w,n)}function c(w){return ze(w,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:h,weierstrassEquation:f,isWithinCurveOrder:p}=vc({...t,toBytes(w,I,x){let d=I.toAffine(),g=r.toBytes(d.x),T=St;return lt("isCompressed",x),x?T(Uint8Array.from([I.hasEvenY()?2:3]),g):T(Uint8Array.from([4]),g,r.toBytes(d.y))},fromBytes(w){let I=w.length,x=w[0],d=w.subarray(1);if(I===o&&(x===2||x===3)){let g=Bt(d);if(!xe(g,tt,r.ORDER))throw new Error("Point is not on curve");let T=f(g),C;try{C=r.sqrt(T)}catch(H){let K=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+K)}let N=(C&tt)===tt;return(x&1)===1!==N&&(C=r.neg(C)),{x:g,y:C}}else if(I===s&&x===4){let g=r.fromBytes(d.subarray(0,r.BYTES)),T=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:g,y:T}}else throw new Error(`Point of length ${I} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),m=w=>Et(Ct(w,t.nByteLength));function R(w){let I=n>>tt;return w>I}function S(w){return R(w)?i(-w):w}let y=(w,I,x)=>Bt(w.slice(I,x));class u{constructor(I,x,d){this.r=I,this.s=x,this.recovery=d,this.assertValidity()}static fromCompact(I){let x=t.nByteLength;return I=Z("compactSignature",I,x*2),new u(y(I,0,x),y(I,x,2*x))}static fromDER(I){let{r:x,s:d}=vt.toSig(Z("DER",I));return new u(x,d)}assertValidity(){ct("r",this.r,tt,n),ct("s",this.s,tt,n)}addRecoveryBit(I){return new u(this.r,this.s,I)}recoverPublicKey(I){let{r:x,s:d,recovery:g}=this,T=_(Z("msgHash",I));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let C=g===2||g===3?x+t.n:x;if(C>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let N=g&1?"03":"02",P=a.fromHex(N+m(C)),H=c(C),K=i(-T*H),q=i(d*H),z=a.BASE.multiplyAndAddUnsafe(P,K,q);if(!z)throw new Error("point at infinify");return z.assertValidity(),z}hasHighS(){return R(this.s)}normalizeS(){return this.hasHighS()?new u(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return zt(this.toDERHex())}toDERHex(){return vt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zt(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let b={isValidPrivateKey(w){try{return h(w),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let w=Rr(t.n);return jn(t.randomBytes(w),t.n)},precompute(w=8,I=a.BASE){return I._setWindowSize(w),I.multiply(BigInt(3)),I}};function E(w,I=!0){return a.fromPrivateKey(w).toRawBytes(I)}function l(w){let I=_t(w),x=typeof w=="string",d=(I||x)&&w.length;return I?d===o||d===s:x?d===2*o||d===2*s:w instanceof a}function B(w,I,x=!0){if(l(w))throw new Error("first arg must be private key");if(!l(I))throw new Error("second arg must be public key");return a.fromHex(I).multiply(h(w)).toRawBytes(x)}let U=t.bits2int||function(w){let I=Bt(w),x=w.length*8-t.nBitLength;return x>0?I>>BigInt(x):I},_=t.bits2int_modN||function(w){return i(U(w))},A=ye(t.nBitLength);function v(w){return ct(`num < 2^${t.nBitLength}`,w,It,A),Ct(w,t.nByteLength)}function L(w,I,x=G){if(["recovered","canonical"].some(Q=>Q in x))throw new Error("sign() legacy options not supported");let{hash:d,randomBytes:g}=t,{lowS:T,prehash:C,extraEntropy:N}=x;T==null&&(T=!0),w=Z("msgHash",w),Ao(x),C&&(w=Z("prehashed msgHash",d(w)));let P=_(w),H=h(I),K=[v(H),v(P)];if(N!=null&&N!==!1){let Q=N===!0?g(r.BYTES):N;K.push(Z("extraEntropy",Q))}let q=St(...K),z=P;function X(Q){let et=U(Q);if(!p(et))return;let nt=c(et),Y=a.BASE.multiply(et).toAffine(),st=i(Y.x);if(st===It)return;let yt=i(nt*i(z+st*H));if(yt===It)return;let fe=(Y.x===st?0:2)|Number(Y.y&tt),ue=yt;return T&&R(yt)&&(ue=S(yt),fe^=1),new u(st,ue,fe)}return{seed:q,k2sig:X}}let G={lowS:t.lowS,prehash:!1},M={lowS:t.lowS,prehash:!1};function O(w,I,x=G){let{seed:d,k2sig:g}=L(w,I,x),T=t;return Ar(T.hash.outputLen,T.nByteLength,T.hmac)(d,g)}a.BASE._setWindowSize(8);function j(w,I,x,d=M){let g=w;if(I=Z("msgHash",I),x=Z("publicKey",x),"strict"in d)throw new Error("options.strict was renamed to lowS");Ao(d);let{lowS:T,prehash:C}=d,N,P;try{if(typeof g=="string"||_t(g))try{N=u.fromDER(g)}catch(Y){if(!(Y instanceof vt.Err))throw Y;N=u.fromCompact(g)}else if(typeof g=="object"&&typeof g.r=="bigint"&&typeof g.s=="bigint"){let{r:Y,s:st}=g;N=new u(Y,st)}else throw new Error("PARSE");P=a.fromHex(x)}catch(Y){if(Y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(T&&N.hasHighS())return!1;C&&(I=t.hash(I));let{r:H,s:K}=N,q=_(I),z=c(K),X=i(q*z),Q=i(H*z),et=a.BASE.multiplyAndAddUnsafe(P,X,Q)?.toAffine();return et?i(et.x)===H:!1}return{CURVE:t,getPublicKey:E,getSharedSecret:B,sign:O,verify:j,ProjectivePoint:a,Signature:u,utils:b}}function Tc(e){return{hash:e,hmac:(t,...r)=>an(e,t,xr(...r)),randomBytes:He}}function To(e,t){let r=n=>Io({...e,...Tc(n)});return Object.freeze({...r(t),create:r})}var _o=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ro=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Rc=BigInt(1),fn=BigInt(2),Lo=(e,t)=>(e+t/fn)/t;function Lc(e){let t=_o,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),h=e*e*e%t,f=h*h*e%t,p=F(f,r,t)*f%t,m=F(p,r,t)*f%t,R=F(m,fn,t)*h%t,S=F(R,o,t)*R%t,y=F(S,s,t)*S%t,u=F(y,c,t)*y%t,b=F(u,a,t)*u%t,E=F(b,c,t)*y%t,l=F(E,r,t)*f%t,B=F(l,i,t)*S%t,U=F(B,n,t)*h%t,_=F(U,fn,t);if(!un.eql(un.sqr(_),e))throw new Error("Cannot find square root");return _}var un=Nt(_o,void 0,void 0,{sqrt:Lc}),jt=To({a:BigInt(0),b:BigInt(7),Fp:un,n:Ro,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=Ro,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Rc*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,i=BigInt("0x100000000000000000000000000000000"),c=Lo(s*e,t),a=Lo(-n*e,t),h=k(e-c*r-a*o,t),f=k(-c*n-a*s,t),p=h>i,m=f>i;if(p&&(h=t-h),m&&(f=t-f),h>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:p,k1:h,k2neg:m,k2:f}}}},So),Uu=BigInt(0);var Cu=jt.ProjectivePoint;function Uo(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function Co(e,t,r){let n=we.digest(r instanceof Uint8Array?r:r.subarray());if(Uo(n))return n.then(({digest:o})=>jt.verify(t,o,e)).catch(o=>{throw new Ie(String(o))});try{return jt.verify(t,n.digest,e)}catch(o){throw new Ie(String(o))}}var nr=class{type="secp256k1";raw;_key;constructor(t){this._key=Do(t),this.raw=No(this._key)}toMultihash(){return gt.digest(je(this))}toCID(){return ht.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Mt(this.raw,t.raw)}verify(t,r){return Co(this._key,r,t)}};function Oo(e){return new nr(e)}function No(e){return jt.ProjectivePoint.fromHex(e).toRawBytes(!0)}function Do(e){try{return jt.ProjectivePoint.fromHex(e),e}catch(t){throw new Ce(String(t))}}function Po(e){let{Type:t,Data:r}=Ae.decode(e.digest),n=r??new Uint8Array;switch(t){case ut.Ed25519:return ro(n);case ut.secp256k1:return Oo(n);default:throw new Wt}}function je(e){return Ae.encode({Type:ut[e.type],Data:e.raw})}var Ko=Symbol.for("nodejs.util.inspect.custom"),_c=114,Te=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[ir]=!0;toString(){return this.string==null&&(this.string=J.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ht.createV1(_c,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Mt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Mt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ko](){return`PeerId(${this.toString()})`}},Re=class extends Te{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Le=class extends Te{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},_e=class extends Te{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Uc=2336,Ue=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=gt.digest(Ee(this.url))}[Ko](){return`PeerId(${this.url})`}[ir]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ht.createV1(Uc,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=ve(t)),t.toString()===this.toString())}};var Cc=114,Ho=2336;function Nc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=le(J.decode(`z${e}`));else{if(t==null)throw new Yt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=le(t.decode(e))}return hn(r)}function Mo(e){if(e.type==="Ed25519")return new Le({multihash:e.toCID().multihash,publicKey:e});if(e.type==="secp256k1")return new _e({multihash:e.toCID().multihash,publicKey:e});if(e.type==="RSA")return new Re({multihash:e.toCID().multihash,publicKey:e});throw new Wt}function Dc(e){return Mo(e.publicKey)}function hn(e){if(Kc(e))return new Re({multihash:e});if(Pc(e))try{let t=Po(e);if(t.type==="Ed25519")return new Le({multihash:e,publicKey:t});if(t.type==="secp256k1")return new _e({multihash:e,publicKey:t})}catch{let r=ve(e.digest);return new Ue(new URL(r))}throw new De("Supplied PeerID Multihash is invalid")}function Oc(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Cc&&e.code!==Ho)throw new Ne("Supplied PeerID CID is invalid");if(e.code===Ho){let t=ve(e.multihash.digest);return new Ue(new URL(t))}return hn(e.multihash)}function Pc(e){return e.code===gt.code}function Kc(e){return e.code===we.code}return Qo(Hc);})();
2
+ "use strict";var Libp2PPeerId=(()=>{var ir=Object.defineProperty;var Yo=Object.getOwnPropertyDescriptor;var Wo=Object.getOwnPropertyNames;var Xo=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var r in t)ir(e,r,{get:t[r],enumerable:!0})},Qo=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Wo(t))!Xo.call(e,o)&&o!==r&&ir(e,o,{get:()=>t[o],enumerable:!(n=Yo(t,o))||n.enumerable});return e};var Jo=e=>Qo(ir({},"__esModule",{value:!0}),e);var Hc={};it(Hc,{peerIdFromCID:()=>Oc,peerIdFromMultihash:()=>dn,peerIdFromPrivateKey:()=>Dc,peerIdFromPublicKey:()=>qo,peerIdFromString:()=>Nc});var cr=Symbol.for("@libp2p/peer-id");var Yt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Ne=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var De=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},Oe=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Wt=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var dr={};it(dr,{base58btc:()=>J,base58flickr:()=>ss});var zc=new Uint8Array(0);function wn(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function bt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function En(e){return new TextEncoder().encode(e)}function Bn(e){return new TextDecoder().decode(e)}function ts(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=e.length,a=e.charAt(0),h=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function p(S){if(S instanceof Uint8Array||(ArrayBuffer.isView(S)?S=new Uint8Array(S.buffer,S.byteOffset,S.byteLength):Array.isArray(S)&&(S=Uint8Array.from(S))),!(S instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(S.length===0)return"";for(var y=0,u=0,b=0,E=S.length;b!==E&&S[b]===0;)b++,y++;for(var l=(E-b)*f+1>>>0,B=new Uint8Array(l);b!==E;){for(var U=S[b],_=0,A=l-1;(U!==0||_<u)&&A!==-1;A--,_++)U+=256*B[A]>>>0,B[A]=U%c>>>0,U=U/c>>>0;if(U!==0)throw new Error("Non-zero carry");u=_,b++}for(var v=l-u;v!==l&&B[v]===0;)v++;for(var L=a.repeat(y);v<l;++v)L+=e.charAt(B[v]);return L}function m(S){if(typeof S!="string")throw new TypeError("Expected String");if(S.length===0)return new Uint8Array;var y=0;if(S[y]!==" "){for(var u=0,b=0;S[y]===a;)u++,y++;for(var E=(S.length-y)*h+1>>>0,l=new Uint8Array(E);S[y];){var B=r[S.charCodeAt(y)];if(B===255)return;for(var U=0,_=E-1;(B!==0||U<b)&&_!==-1;_--,U++)B+=c*l[_]>>>0,l[_]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");b=U,y++}if(S[y]!==" "){for(var A=E-b;A!==E&&l[A]===0;)A++;for(var v=new Uint8Array(u+(E-A)),L=u;A!==E;)v[L++]=l[A++];return v}}}function R(S){var y=m(S);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:p,decodeUnsafe:m,decode:R}}var es=ts,rs=es,An=rs;var ar=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},fr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return vn(this,t)}},ur=class{decoders;constructor(t){this.decoders=t}or(t){return vn(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function vn(e,t){return new ur({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var hr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ar(t,r,n),this.decoder=new fr(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Xt({name:e,prefix:t,encode:r,decode:n}){return new hr(e,t,r,n)}function Tt({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=An(r,e);return Xt({prefix:t,name:e,encode:n,decode:s=>bt(o(s))})}function ns(e,t,r,n){let o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=e.length;for(;e[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),c=0,a=0,h=0;for(let f=0;f<s;++f){let p=o[e[f]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|p,c+=r,c>=8&&(c-=8,i[h++]=255&a>>c)}if(c>=r||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return i}function os(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],i+=8;i>r;)i-=r,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<r-i]),n)for(;s.length*r&7;)s+="=";return s}function $({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Xt({prefix:t,name:e,encode(o){return os(o,n,r)},decode(o){return ns(o,n,r,e)}})}var J=Tt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ss=Tt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var lr={};it(lr,{base32:()=>Qt,base32hex:()=>fs,base32hexpad:()=>hs,base32hexpadupper:()=>ds,base32hexupper:()=>us,base32pad:()=>cs,base32padupper:()=>as,base32upper:()=>is,base32z:()=>ls});var Qt=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),is=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),cs=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),as=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fs=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),us=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hs=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ds=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ls=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var pr={};it(pr,{base36:()=>he,base36upper:()=>ps});var he=Tt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ps=Tt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ms=Rn,In=128,xs=127,ys=~xs,bs=Math.pow(2,31);function Rn(e,t,r){t=t||[],r=r||0;for(var n=r;e>=bs;)t[r++]=e&255|In,e/=128;for(;e&ys;)t[r++]=e&255|In,e>>>=7;return t[r]=e|0,Rn.bytes=r-n+1,t}var gs=mr,ws=128,Tn=127;function mr(e,n){var r=0,n=n||0,o=0,s=n,i,c=e.length;do{if(s>=c)throw mr.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&Tn)<<o:(i&Tn)*Math.pow(2,o),o+=7}while(i>=ws);return mr.bytes=s-n,r}var Es=Math.pow(2,7),Bs=Math.pow(2,14),Ss=Math.pow(2,21),As=Math.pow(2,28),vs=Math.pow(2,35),Is=Math.pow(2,42),Ts=Math.pow(2,49),Rs=Math.pow(2,56),Ls=Math.pow(2,63),_s=function(e){return e<Es?1:e<Bs?2:e<Ss?3:e<As?4:e<vs?5:e<Is?6:e<Ts?7:e<Rs?8:e<Ls?9:10},Us={encode:ms,decode:gs,encodingLength:_s},Cs=Us,de=Cs;function le(e,t=0){return[de.decode(e,t),de.decode.bytes]}function Jt(e,t,r=0){return de.encode(e,t,r),t}function te(e){return de.encodingLength(e)}function Ht(e,t){let r=t.byteLength,n=te(e),o=n+te(r),s=new Uint8Array(o+r);return Jt(e,s,0),Jt(r,s,n),s.set(t,o),new ee(e,r,t,s)}function pe(e){let t=bt(e),[r,n]=le(t),[o,s]=le(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ee(r,o,i,t)}function Ln(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&wn(e.bytes,r.bytes)}}var ee=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function _n(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Ds(r,xr(e),t??J.encoder);default:return Os(r,xr(e),t??Qt.encoder)}}var Un=new WeakMap;function xr(e){let t=Un.get(e);if(t==null){let r=new Map;return Un.set(e,r),r}return t}var ht=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==me)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ps)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Ht(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Ln(t.multihash,n.multihash)}toString(t){return _n(this,t)}toJSON(){return{"/":_n(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??Cn(n,o,s.bytes))}else if(r[Ks]===!0){let{version:n,multihash:o,code:s}=r,i=pe(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==me)throw new Error(`Version 0 CID must use dag-pb (code: ${me}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Cn(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,me,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=bt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new ee(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[p,m]=le(t.subarray(r));return r+=m,p},o=n(),s=me;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),a=n(),h=r+a,f=h-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:h}}static parse(t,r){let[n,o]=Ns(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return xr(s).set(n,t),s}};function Ns(e,t){switch(e[0]){case"Q":{let r=t??J;return[J.prefix,r.decode(`${J.prefix}${e}`)]}case J.prefix:{let r=t??J;return[J.prefix,r.decode(e)]}case Qt.prefix:{let r=t??Qt;return[Qt.prefix,r.decode(e)]}case he.prefix:{let r=t??he;return[he.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Ds(e,t,r){let{prefix:n}=r;if(n!==J.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Os(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var me=112,Ps=18;function Cn(e,t,r){let n=te(e),o=n+te(t),s=new Uint8Array(o+r.byteLength);return Jt(e,s,0),Jt(t,s,n),s.set(r,o),s}var Ks=Symbol.for("@ipld/js-cid/CID");var yr={};it(yr,{identity:()=>gt});var Nn=0,Hs="identity",Dn=bt;function Ms(e){return Ht(Nn,Dn(e))}var gt={code:Nn,name:Hs,encode:Dn,digest:Ms};function Mt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function On(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function qs(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ne(e,...t){if(!qs(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Pn(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");On(e.outputLen),On(e.blockLen)}function oe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Kn(e,t){ne(e);let r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}var qt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Ke=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),dt=(e,t)=>e<<32-t|e>>>t;var ha=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Hn(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function xe(e){return typeof e=="string"&&(e=Hn(e)),ne(e),e}function br(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ne(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}var se=class{clone(){return this._cloneInto()}},da={}.toString;function He(e){let t=n=>e().update(xe(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Me(e=32){if(qt&&typeof qt.getRandomValues=="function")return qt.getRandomValues(new Uint8Array(e));if(qt&&typeof qt.randomBytes=="function")return qt.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function ks(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(r>>o&s),c=Number(r&s),a=n?4:0,h=n?0:4;e.setUint32(t+a,i,n),e.setUint32(t+h,c,n)}var Mn=(e,t,r)=>e&t^~e&r,qn=(e,t,r)=>e&t^e&r^t&r,ie=class extends se{constructor(t,r,n,o){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Ke(this.buffer)}update(t){oe(this);let{view:r,buffer:n,blockLen:o}=this;t=xe(t);let s=t.length;for(let i=0;i<s;){let c=Math.min(o-this.pos,s-i);if(c===o){let a=Ke(t);for(;o<=s-i;i+=o)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){oe(this),Kn(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let p=i;p<o;p++)r[p]=0;ks(n,o-8,BigInt(this.length*8),s),this.process(n,0);let c=Ke(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let h=a/4,f=this.get();if(h>f.length)throw new Error("_sha2: outputLen bigger than state");for(let p=0;p<h;p++)c.setUint32(4*p,f[p],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:c}=this;return t.length=o,t.pos=c,t.finished=s,t.destroyed=i,o%r&&t.buffer.set(n),t}};var qe=BigInt(4294967295),gr=BigInt(32);function kn(e,t=!1){return t?{h:Number(e&qe),l:Number(e>>gr&qe)}:{h:Number(e>>gr&qe)|0,l:Number(e&qe)|0}}function zs(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let o=0;o<e.length;o++){let{h:s,l:i}=kn(e[o],t);[r[o],n[o]]=[s,i]}return[r,n]}var Vs=(e,t)=>BigInt(e>>>0)<<gr|BigInt(t>>>0),Fs=(e,t,r)=>e>>>r,$s=(e,t,r)=>e<<32-r|t>>>r,Zs=(e,t,r)=>e>>>r|t<<32-r,Gs=(e,t,r)=>e<<32-r|t>>>r,js=(e,t,r)=>e<<64-r|t>>>r-32,Ys=(e,t,r)=>e>>>r-32|t<<64-r,Ws=(e,t)=>t,Xs=(e,t)=>e,Qs=(e,t,r)=>e<<r|t>>>32-r,Js=(e,t,r)=>t<<r|e>>>32-r,ti=(e,t,r)=>t<<r-32|e>>>64-r,ei=(e,t,r)=>e<<r-32|t>>>64-r;function ri(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ni=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),oi=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,si=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),ii=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,ci=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),ai=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var fi={fromBig:kn,split:zs,toBig:Vs,shrSH:Fs,shrSL:$s,rotrSH:Zs,rotrSL:Gs,rotrBH:js,rotrBL:Ys,rotr32H:Ws,rotr32L:Xs,rotlSH:Qs,rotlSL:Js,rotlBH:ti,rotlBL:ei,add:ri,add3L:ni,add3H:oi,add4L:si,add4H:ii,add5H:ai,add5L:ci},D=fi;var[ui,hi]=D.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Rt=new Uint32Array(80),Lt=new Uint32Array(80),wr=class extends ie{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:h,El:f,Fh:p,Fl:m,Gh:R,Gl:S,Hh:y,Hl:u}=this;return[t,r,n,o,s,i,c,a,h,f,p,m,R,S,y,u]}set(t,r,n,o,s,i,c,a,h,f,p,m,R,S,y,u){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=h|0,this.El=f|0,this.Fh=p|0,this.Fl=m|0,this.Gh=R|0,this.Gl=S|0,this.Hh=y|0,this.Hl=u|0}process(t,r){for(let l=0;l<16;l++,r+=4)Rt[l]=t.getUint32(r),Lt[l]=t.getUint32(r+=4);for(let l=16;l<80;l++){let B=Rt[l-15]|0,U=Lt[l-15]|0,_=D.rotrSH(B,U,1)^D.rotrSH(B,U,8)^D.shrSH(B,U,7),A=D.rotrSL(B,U,1)^D.rotrSL(B,U,8)^D.shrSL(B,U,7),v=Rt[l-2]|0,L=Lt[l-2]|0,G=D.rotrSH(v,L,19)^D.rotrBH(v,L,61)^D.shrSH(v,L,6),M=D.rotrSL(v,L,19)^D.rotrBL(v,L,61)^D.shrSL(v,L,6),O=D.add4L(A,M,Lt[l-7],Lt[l-16]),j=D.add4H(O,_,G,Rt[l-7],Rt[l-16]);Rt[l]=j|0,Lt[l]=O|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:h,Dl:f,Eh:p,El:m,Fh:R,Fl:S,Gh:y,Gl:u,Hh:b,Hl:E}=this;for(let l=0;l<80;l++){let B=D.rotrSH(p,m,14)^D.rotrSH(p,m,18)^D.rotrBH(p,m,41),U=D.rotrSL(p,m,14)^D.rotrSL(p,m,18)^D.rotrBL(p,m,41),_=p&R^~p&y,A=m&S^~m&u,v=D.add5L(E,U,A,hi[l],Lt[l]),L=D.add5H(v,b,B,_,ui[l],Rt[l]),G=v|0,M=D.rotrSH(n,o,28)^D.rotrBH(n,o,34)^D.rotrBH(n,o,39),O=D.rotrSL(n,o,28)^D.rotrBL(n,o,34)^D.rotrBL(n,o,39),j=n&s^n&c^s&c,w=o&i^o&a^i&a;b=y|0,E=u|0,y=R|0,u=S|0,R=p|0,S=m|0,{h:p,l:m}=D.add(h|0,f|0,L|0,G|0),h=c|0,f=a|0,c=s|0,a=i|0,s=n|0,i=o|0;let I=D.add3L(G,O,w);n=D.add3H(I,L,M,j),o=I|0}({h:n,l:o}=D.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=D.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=D.add(this.Ch|0,this.Cl|0,c|0,a|0),{h,l:f}=D.add(this.Dh|0,this.Dl|0,h|0,f|0),{h:p,l:m}=D.add(this.Eh|0,this.El|0,p|0,m|0),{h:R,l:S}=D.add(this.Fh|0,this.Fl|0,R|0,S|0),{h:y,l:u}=D.add(this.Gh|0,this.Gl|0,y|0,u|0),{h:b,l:E}=D.add(this.Hh|0,this.Hl|0,b|0,E|0),this.set(n,o,s,i,c,a,h,f,p,m,R,S,y,u,b,E)}roundClean(){Rt.fill(0),Lt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var zn=He(()=>new wr);var ze={};it(ze,{aInRange:()=>ct,abool:()=>lt,abytes:()=>ce,bitGet:()=>yi,bitLen:()=>vr,bitMask:()=>be,bitSet:()=>bi,bytesToHex:()=>Et,bytesToNumberBE:()=>Bt,bytesToNumberLE:()=>Ut,concatBytes:()=>St,createHmacDrbg:()=>Ir,ensureBytes:()=>Z,equalBytes:()=>mi,hexToBytes:()=>zt,hexToNumber:()=>Ar,inRange:()=>ye,isBytes:()=>_t,memoized:()=>Ft,notImplemented:()=>wi,numberToBytesBE:()=>Ct,numberToBytesLE:()=>Vt,numberToHexUnpadded:()=>kt,numberToVarBytesBE:()=>pi,utf8ToBytes:()=>xi,validateObject:()=>xt});var Sr=BigInt(0),ke=BigInt(1),di=BigInt(2);function _t(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function ce(e){if(!_t(e))throw new Error("Uint8Array expected")}function lt(e,t){if(typeof t!="boolean")throw new Error(`${e} must be valid boolean, got "${t}".`)}var li=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Et(e){ce(e);let t="";for(let r=0;r<e.length;r++)t+=li[e[r]];return t}function kt(e){let t=e.toString(16);return t.length&1?`0${t}`:t}function Ar(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return BigInt(e===""?"0":`0x${e}`)}var wt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Vn(e){if(e>=wt._0&&e<=wt._9)return e-wt._0;if(e>=wt._A&&e<=wt._F)return e-(wt._A-10);if(e>=wt._a&&e<=wt._f)return e-(wt._a-10)}function zt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);let t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Vn(e.charCodeAt(s)),c=Vn(e.charCodeAt(s+1));if(i===void 0||c===void 0){let a=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}n[o]=i*16+c}return n}function Bt(e){return Ar(Et(e))}function Ut(e){return ce(e),Ar(Et(Uint8Array.from(e).reverse()))}function Ct(e,t){return zt(e.toString(16).padStart(t*2,"0"))}function Vt(e,t){return Ct(e,t).reverse()}function pi(e){return zt(kt(e))}function Z(e,t,r){let n;if(typeof t=="string")try{n=zt(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else if(_t(t))n=Uint8Array.from(t);else throw new Error(`${e} must be hex string or Uint8Array`);let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(`${e} expected ${r} bytes, got ${o}`);return n}function St(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ce(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function mi(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return r===0}function xi(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}var Er=e=>typeof e=="bigint"&&Sr<=e;function ye(e,t,r){return Er(e)&&Er(t)&&Er(r)&&t<=e&&e<r}function ct(e,t,r,n){if(!ye(t,r,n))throw new Error(`expected valid ${e}: ${r} <= n < ${n}, got ${typeof t} ${t}`)}function vr(e){let t;for(t=0;e>Sr;e>>=ke,t+=1);return t}function yi(e,t){return e>>BigInt(t)&ke}function bi(e,t,r){return e|(r?ke:Sr)<<BigInt(t)}var be=e=>(di<<BigInt(e-1))-ke,Br=e=>new Uint8Array(e),Fn=e=>Uint8Array.from(e);function Ir(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 n=Br(e),o=Br(e),s=0,i=()=>{n.fill(1),o.fill(0),s=0},c=(...p)=>r(o,n,...p),a=(p=Br())=>{o=c(Fn([0]),p),n=c(),p.length!==0&&(o=c(Fn([1]),p),n=c())},h=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let p=0,m=[];for(;p<t;){n=c();let R=n.slice();m.push(R),p+=n.length}return St(...m)};return(p,m)=>{i(),a(p);let R;for(;!(R=m(h()));)a();return i(),R}}var gi={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"||_t(e),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 xt(e,t,r={}){let n=(o,s,i)=>{let c=gi[s];if(typeof c!="function")throw new Error(`Invalid validator "${s}", expected function`);let a=e[o];if(!(i&&a===void 0)&&!c(a,e))throw new Error(`Invalid param ${String(o)}=${a} (${typeof a}), expected ${s}`)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(r))n(o,s,!0);return e}var wi=()=>{throw new Error("not implemented")};function Ft(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let s=e(r,...n);return t.set(r,s),s}}var W=BigInt(0),V=BigInt(1),$t=BigInt(2),Ei=BigInt(3),Tr=BigInt(4),$n=BigInt(5),Zn=BigInt(8),Bi=BigInt(9),Si=BigInt(16);function k(e,t){let r=e%t;return r>=W?r:t+r}function Ai(e,t,r){if(r<=W||t<W)throw new Error("Expected power/modulo > 0");if(r===V)return W;let n=V;for(;t>W;)t&V&&(n=n*e%r),e=e*e%r,t>>=V;return n}function F(e,t,r){let n=e;for(;t-- >W;)n*=n,n%=r;return n}function Ve(e,t){if(e===W||t<=W)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=k(e,t),n=t,o=W,s=V,i=V,c=W;for(;r!==W;){let h=n/r,f=n%r,p=o-i*h,m=s-c*h;n=r,r=f,o=i,s=c,i=p,c=m}if(n!==V)throw new Error("invert: does not exist");return k(o,t)}function vi(e){let t=(e-V)/$t,r,n,o;for(r=e-V,n=0;r%$t===W;r/=$t,n++);for(o=$t;o<e&&Ai(o,t,e)!==e-V;o++);if(n===1){let i=(e+V)/Tr;return function(a,h){let f=a.pow(h,i);if(!a.eql(a.sqr(f),h))throw new Error("Cannot find square root");return f}}let s=(r+V)/$t;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let h=n,f=c.pow(c.mul(c.ONE,o),r),p=c.pow(a,s),m=c.pow(a,r);for(;!c.eql(m,c.ONE);){if(c.eql(m,c.ZERO))return c.ZERO;let R=1;for(let y=c.sqr(m);R<h&&!c.eql(y,c.ONE);R++)y=c.sqr(y);let S=c.pow(f,V<<BigInt(h-R-1));f=c.sqr(S),p=c.mul(p,S),m=c.mul(m,f),h=R}return p}}function Ii(e){if(e%Tr===Ei){let t=(e+V)/Tr;return function(n,o){let s=n.pow(o,t);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(e%Zn===$n){let t=(e-$n)/Zn;return function(n,o){let s=n.mul(o,$t),i=n.pow(s,t),c=n.mul(o,i),a=n.mul(n.mul(c,$t),i),h=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(h),o))throw new Error("Cannot find square root");return h}}return e%Si,vi(e)}var Gn=(e,t)=>(k(e,t)&V)===V,Ti=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Rr(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=Ti.reduce((n,o)=>(n[o]="function",n),t);return xt(e,r)}function Ri(e,t,r){if(r<W)throw new Error("Expected power > 0");if(r===W)return e.ONE;if(r===V)return t;let n=e.ONE,o=t;for(;r>W;)r&V&&(n=e.mul(n,o)),o=e.sqr(o),r>>=V;return n}function Li(e,t){let r=new Array(t.length),n=t.reduce((s,i,c)=>e.is0(i)?s:(r[c]=s,e.mul(s,i)),e.ONE),o=e.inv(n);return t.reduceRight((s,i,c)=>e.is0(i)?s:(r[c]=e.mul(s,r[c]),e.mul(s,i)),o),r}function Lr(e,t){let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Nt(e,t,r=!1,n={}){if(e<=W)throw new Error(`Expected Field ORDER > 0, got ${e}`);let{nBitLength:o,nByteLength:s}=Lr(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Ii(e),c=Object.freeze({ORDER:e,BITS:o,BYTES:s,MASK:be(o),ZERO:W,ONE:V,create:a=>k(a,e),isValid:a=>{if(typeof a!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);return W<=a&&a<e},is0:a=>a===W,isOdd:a=>(a&V)===V,neg:a=>k(-a,e),eql:(a,h)=>a===h,sqr:a=>k(a*a,e),add:(a,h)=>k(a+h,e),sub:(a,h)=>k(a-h,e),mul:(a,h)=>k(a*h,e),pow:(a,h)=>Ri(c,a,h),div:(a,h)=>k(a*Ve(h,e),e),sqrN:a=>a*a,addN:(a,h)=>a+h,subN:(a,h)=>a-h,mulN:(a,h)=>a*h,inv:a=>Ve(a,e),sqrt:n.sqrt||(a=>i(c,a)),invertBatch:a=>Li(c,a),cmov:(a,h,f)=>f?h:a,toBytes:a=>r?Vt(a,s):Ct(a,s),fromBytes:a=>{if(a.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);return r?Ut(a):Bt(a)}});return Object.freeze(c)}function jn(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function _r(e){let t=jn(e);return t+Math.ceil(t/2)}function Yn(e,t,r=!1){let n=e.length,o=jn(t),s=_r(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=r?Bt(e):Ut(e),c=k(i,t-V)+V;return r?Vt(c,o):Ct(c,o)}var Ui=BigInt(0),Ur=BigInt(1),Cr=new WeakMap,Wn=new WeakMap;function Fe(e,t){let r=(s,i)=>{let c=i.negate();return s?c:i},n=s=>{if(!Number.isSafeInteger(s)||s<=0||s>t)throw new Error(`Wrong window size=${s}, should be [1..${t}]`)},o=s=>{n(s);let i=Math.ceil(t/s)+1,c=2**(s-1);return{windows:i,windowSize:c}};return{constTimeNegate:r,unsafeLadder(s,i){let c=e.ZERO,a=s;for(;i>Ui;)i&Ur&&(c=c.add(a)),a=a.double(),i>>=Ur;return c},precomputeWindow(s,i){let{windows:c,windowSize:a}=o(i),h=[],f=s,p=f;for(let m=0;m<c;m++){p=f,h.push(p);for(let R=1;R<a;R++)p=p.add(f),h.push(p);f=p.double()}return h},wNAF(s,i,c){let{windows:a,windowSize:h}=o(s),f=e.ZERO,p=e.BASE,m=BigInt(2**s-1),R=2**s,S=BigInt(s);for(let y=0;y<a;y++){let u=y*h,b=Number(c&m);c>>=S,b>h&&(b-=R,c+=Ur);let E=u,l=u+Math.abs(b)-1,B=y%2!==0,U=b<0;b===0?p=p.add(r(B,i[E])):f=f.add(r(U,i[l]))}return{p:f,f:p}},wNAFCached(s,i,c){let a=Wn.get(s)||1,h=Cr.get(s);return h||(h=this.precomputeWindow(s,a),a!==1&&Cr.set(s,c(h))),this.wNAF(a,h,i)},setWindowSize(s,i){n(i),Wn.set(s,i),Cr.delete(s)}}}function $e(e,t,r,n){if(!Array.isArray(r)||!Array.isArray(n)||n.length!==r.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((f,p)=>{if(!t.isValid(f))throw new Error(`wrong scalar at index ${p}`)}),r.forEach((f,p)=>{if(!(f instanceof e))throw new Error(`wrong point at index ${p}`)});let o=vr(BigInt(r.length)),s=o>12?o-3:o>4?o-2:o?2:1,i=(1<<s)-1,c=new Array(i+1).fill(e.ZERO),a=Math.floor((t.BITS-1)/s)*s,h=e.ZERO;for(let f=a;f>=0;f-=s){c.fill(e.ZERO);for(let m=0;m<n.length;m++){let R=n[m],S=Number(R>>BigInt(f)&BigInt(i));c[S]=c[S].add(r[m])}let p=e.ZERO;for(let m=c.length-1,R=e.ZERO;m>0;m--)R=R.add(c[m]),p=p.add(R);if(h=h.add(p),f!==0)for(let m=0;m<s;m++)h=h.double()}return h}function ge(e){return Rr(e.Fp),xt(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Lr(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var pt=BigInt(0),at=BigInt(1),Ze=BigInt(2),Ci=BigInt(8),Ni={zip215:!0};function Di(e){let t=ge(e);return xt(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Xn(e){let t=Di(e),{Fp:r,n,prehash:o,hash:s,randomBytes:i,nByteLength:c,h:a}=t,h=Ze<<BigInt(c*8)-at,f=r.create,p=Nt(t.n,t.nBitLength),m=t.uvRatio||((x,d)=>{try{return{isValid:!0,value:r.sqrt(x*r.inv(d))}}catch{return{isValid:!1,value:pt}}}),R=t.adjustScalarBytes||(x=>x),S=t.domain||((x,d,g)=>{if(lt("phflag",g),d.length||g)throw new Error("Contexts/pre-hash are not supported");return x});function y(x,d){ct("coordinate "+x,d,pt,h)}function u(x){if(!(x instanceof l))throw new Error("ExtendedPoint expected")}let b=Ft((x,d)=>{let{ex:g,ey:T,ez:C}=x,N=x.is0();d==null&&(d=N?Ci:r.inv(C));let P=f(g*d),H=f(T*d),K=f(C*d);if(N)return{x:pt,y:at};if(K!==at)throw new Error("invZ was invalid");return{x:P,y:H}}),E=Ft(x=>{let{a:d,d:g}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:T,ey:C,ez:N,et:P}=x,H=f(T*T),K=f(C*C),q=f(N*N),z=f(q*q),X=f(H*d),Q=f(q*f(X+K)),et=f(z+f(g*f(H*K)));if(Q!==et)throw new Error("bad point: equation left != right (1)");let nt=f(T*C),Y=f(N*P);if(nt!==Y)throw new Error("bad point: equation left != right (2)");return!0});class l{constructor(d,g,T,C){this.ex=d,this.ey=g,this.ez=T,this.et=C,y("x",d),y("y",g),y("z",T),y("t",C),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(d){if(d instanceof l)throw new Error("extended point not allowed");let{x:g,y:T}=d||{};return y("x",g),y("y",T),new l(g,T,at,f(g*T))}static normalizeZ(d){let g=r.invertBatch(d.map(T=>T.ez));return d.map((T,C)=>T.toAffine(g[C])).map(l.fromAffine)}static msm(d,g){return $e(l,p,d,g)}_setWindowSize(d){_.setWindowSize(this,d)}assertValidity(){E(this)}equals(d){u(d);let{ex:g,ey:T,ez:C}=this,{ex:N,ey:P,ez:H}=d,K=f(g*H),q=f(N*C),z=f(T*H),X=f(P*C);return K===q&&z===X}is0(){return this.equals(l.ZERO)}negate(){return new l(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:d}=t,{ex:g,ey:T,ez:C}=this,N=f(g*g),P=f(T*T),H=f(Ze*f(C*C)),K=f(d*N),q=g+T,z=f(f(q*q)-N-P),X=K+P,Q=X-H,et=K-P,nt=f(z*Q),Y=f(X*et),st=f(z*et),yt=f(Q*X);return new l(nt,Y,yt,st)}add(d){u(d);let{a:g,d:T}=t,{ex:C,ey:N,ez:P,et:H}=this,{ex:K,ey:q,ez:z,et:X}=d;if(g===BigInt(-1)){let ln=f((N-C)*(q+K)),pn=f((N+C)*(q-K)),sr=f(pn-ln);if(sr===pt)return this.double();let mn=f(P*Ze*X),xn=f(H*Ze*z),yn=xn+mn,bn=pn+ln,gn=xn-mn,$o=f(yn*sr),Zo=f(bn*gn),Go=f(yn*gn),jo=f(sr*bn);return new l($o,Zo,jo,Go)}let Q=f(C*K),et=f(N*q),nt=f(H*T*X),Y=f(P*z),st=f((C+N)*(K+q)-Q-et),yt=Y-nt,fe=Y+nt,ue=f(et-g*Q),ko=f(st*yt),zo=f(fe*ue),Vo=f(st*ue),Fo=f(yt*fe);return new l(ko,zo,Fo,Vo)}subtract(d){return this.add(d.negate())}wNAF(d){return _.wNAFCached(this,d,l.normalizeZ)}multiply(d){let g=d;ct("scalar",g,at,n);let{p:T,f:C}=this.wNAF(g);return l.normalizeZ([T,C])[0]}multiplyUnsafe(d){let g=d;return ct("scalar",g,pt,n),g===pt?U:this.equals(U)||g===at?this:this.equals(B)?this.wNAF(g).p:_.unsafeLadder(this,g)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return _.unsafeLadder(this,n).is0()}toAffine(d){return b(this,d)}clearCofactor(){let{h:d}=t;return d===at?this:this.multiplyUnsafe(d)}static fromHex(d,g=!1){let{d:T,a:C}=t,N=r.BYTES;d=Z("pointHex",d,N),lt("zip215",g);let P=d.slice(),H=d[N-1];P[N-1]=H&-129;let K=Ut(P),q=g?h:r.ORDER;ct("pointHex.y",K,pt,q);let z=f(K*K),X=f(z-at),Q=f(T*z-C),{isValid:et,value:nt}=m(X,Q);if(!et)throw new Error("Point.fromHex: invalid y coordinate");let Y=(nt&at)===at,st=(H&128)!==0;if(!g&&nt===pt&&st)throw new Error("Point.fromHex: x=0 and x_0=1");return st!==Y&&(nt=f(-nt)),l.fromAffine({x:nt,y:K})}static fromPrivateKey(d){return L(d).point}toRawBytes(){let{x:d,y:g}=this.toAffine(),T=Vt(g,r.BYTES);return T[T.length-1]|=d&at?128:0,T}toHex(){return Et(this.toRawBytes())}}l.BASE=new l(t.Gx,t.Gy,at,f(t.Gx*t.Gy)),l.ZERO=new l(pt,at,at,pt);let{BASE:B,ZERO:U}=l,_=Fe(l,c*8);function A(x){return k(x,n)}function v(x){return A(Ut(x))}function L(x){let d=c;x=Z("private key",x,d);let g=Z("hashed private key",s(x),2*d),T=R(g.slice(0,d)),C=g.slice(d,2*d),N=v(T),P=B.multiply(N),H=P.toRawBytes();return{head:T,prefix:C,scalar:N,point:P,pointBytes:H}}function G(x){return L(x).pointBytes}function M(x=new Uint8Array,...d){let g=St(...d);return v(s(S(g,Z("context",x),!!o)))}function O(x,d,g={}){x=Z("message",x),o&&(x=o(x));let{prefix:T,scalar:C,pointBytes:N}=L(d),P=M(g.context,T,x),H=B.multiply(P).toRawBytes(),K=M(g.context,H,N,x),q=A(P+K*C);ct("signature.s",q,pt,n);let z=St(H,Vt(q,r.BYTES));return Z("result",z,c*2)}let j=Ni;function w(x,d,g,T=j){let{context:C,zip215:N}=T,P=r.BYTES;x=Z("signature",x,2*P),d=Z("message",d),N!==void 0&&lt("zip215",N),o&&(d=o(d));let H=Ut(x.slice(P,2*P)),K,q,z;try{K=l.fromHex(g,N),q=l.fromHex(x.slice(0,P),N),z=B.multiplyUnsafe(H)}catch{return!1}if(!N&&K.isSmallOrder())return!1;let X=M(C,q.toRawBytes(),K.toRawBytes(),d);return q.add(K.multiplyUnsafe(X)).subtract(z).clearCofactor().equals(l.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:G,sign:O,verify:w,ExtendedPoint:l,utils:{getExtendedPublicKey:L,randomPrivateKey:()=>i(r.BYTES),precompute(x=8,d=l.BASE){return d._setWindowSize(x),d.multiply(BigInt(3)),d}}}}var Nr=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Qn=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Oa=BigInt(0),Oi=BigInt(1),Jn=BigInt(2),Pa=BigInt(3),Pi=BigInt(5),Ki=BigInt(8);function Hi(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=Nr,c=e*e%s*e%s,a=F(c,Jn,s)*c%s,h=F(a,Oi,s)*e%s,f=F(h,Pi,s)*h%s,p=F(f,t,s)*f%s,m=F(p,r,s)*p%s,R=F(m,n,s)*m%s,S=F(R,o,s)*R%s,y=F(S,o,s)*R%s,u=F(y,t,s)*f%s;return{pow_p_5_8:F(u,Jn,s)*e%s,b2:c}}function Mi(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function qi(e,t){let r=Nr,n=k(t*t*t,r),o=k(n*n*t,r),s=Hi(e*o).pow_p_5_8,i=k(e*n*s,r),c=k(t*i*i,r),a=i,h=k(i*Qn,r),f=c===e,p=c===k(-e,r),m=c===k(-e*Qn,r);return f&&(i=a),(p||m)&&(i=h),Gn(i,r)&&(i=k(-i,r)),{isValid:f||p,value:i}}var ki=Nt(Nr,void 0,!0),zi={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:ki,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ki,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:zn,randomBytes:Me,adjustScalarBytes:Mi,uvRatio:qi},to=Xn(zi);var Ge=32;function eo(e,t,r){return to.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var je=class{type="Ed25519";raw;constructor(t){this.raw=Dr(t,Ge)}toMultihash(){return gt.digest(Ye(this))}toCID(){return ht.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Mt(this.raw,t.raw)}verify(t,r){return eo(this.raw,r,t)}};function no(e){return e=Dr(e,Ge),new je(e)}function Dr(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new Yt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}function At(e=0){return new Uint8Array(e)}var Fi=Math.pow(2,7),$i=Math.pow(2,14),Zi=Math.pow(2,21),oo=Math.pow(2,28),so=Math.pow(2,35),io=Math.pow(2,42),co=Math.pow(2,49),ot=128,Dt=127;function we(e){if(e<Fi)return 1;if(e<$i)return 2;if(e<Zi)return 3;if(e<oo)return 4;if(e<so)return 5;if(e<io)return 6;if(e<co)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ao(e,t,r=0){switch(we(e)){case 8:t[r++]=e&255|ot,e/=128;case 7:t[r++]=e&255|ot,e/=128;case 6:t[r++]=e&255|ot,e/=128;case 5:t[r++]=e&255|ot,e/=128;case 4:t[r++]=e&255|ot,e>>>=7;case 3:t[r++]=e&255|ot,e>>>=7;case 2:t[r++]=e&255|ot,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function fo(e,t){let r=e[t],n=0;if(n+=r&Dt,r<ot||(r=e[t+1],n+=(r&Dt)<<7,r<ot)||(r=e[t+2],n+=(r&Dt)<<14,r<ot)||(r=e[t+3],n+=(r&Dt)<<21,r<ot)||(r=e[t+4],n+=(r&Dt)*oo,r<ot)||(r=e[t+5],n+=(r&Dt)*so,r<ot)||(r=e[t+6],n+=(r&Dt)*io,r<ot)||(r=e[t+7],n+=(r&Dt)*co,r<ot))return n;throw new RangeError("Could not decode varint")}var Or=new Float32Array([-0]),Ot=new Uint8Array(Or.buffer);function uo(e,t,r){Or[0]=e,t[r]=Ot[0],t[r+1]=Ot[1],t[r+2]=Ot[2],t[r+3]=Ot[3]}function ho(e,t){return Ot[0]=e[t],Ot[1]=e[t+1],Ot[2]=e[t+2],Ot[3]=e[t+3],Or[0]}var Pr=new Float64Array([-0]),rt=new Uint8Array(Pr.buffer);function lo(e,t,r){Pr[0]=e,t[r]=rt[0],t[r+1]=rt[1],t[r+2]=rt[2],t[r+3]=rt[3],t[r+4]=rt[4],t[r+5]=rt[5],t[r+6]=rt[6],t[r+7]=rt[7]}function po(e,t){return rt[0]=e[t],rt[1]=e[t+1],rt[2]=e[t+2],rt[3]=e[t+3],rt[4]=e[t+4],rt[5]=e[t+5],rt[6]=e[t+6],rt[7]=e[t+7],Pr[0]}var Gi=BigInt(Number.MAX_SAFE_INTEGER),ji=BigInt(Number.MIN_SAFE_INTEGER),ft=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Zt;if(t<Gi&&t>ji)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>mo&&(o=0n,++n>mo&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Zt;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Zt}},Zt=new ft(0,0);Zt.toBigInt=function(){return 0n};Zt.zzEncode=Zt.zzDecode=function(){return this};Zt.length=function(){return 1};var mo=4294967296n;function xo(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function yo(e,t,r){if(r-t<1)return"";let o,s=[],i=0,c;for(;t<r;)c=e[t++],c<128?s[i++]=c:c>191&&c<224?s[i++]=(c&31)<<6|e[t++]&63:c>239&&c<365?(c=((c&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(c>>10),s[i++]=56320+(c&1023)):s[i++]=(c&15)<<12|(e[t++]&63)<<6|e[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Kr(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function mt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function We(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Hr=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,mt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw mt(this,4);return We(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw mt(this,4);return We(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw mt(this,4);let t=ho(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw mt(this,4);let t=po(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw mt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return yo(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw mt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw mt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new ft(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw mt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw mt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw mt(this,8);let t=We(this.buf,this.pos+=4),r=We(this.buf,this.pos+=4);return new ft(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=fo(this.buf,this.pos);return this.pos+=we(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Mr(e){return new Hr(e instanceof Uint8Array?e:e.subarray())}function Xe(e,t,r){let n=Mr(e);return t.decode(n,void 0,r)}var qr={};it(qr,{base10:()=>Yi});var Yi=Tt({prefix:"9",name:"base10",alphabet:"0123456789"});var kr={};it(kr,{base16:()=>Wi,base16upper:()=>Xi});var Wi=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Xi=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zr={};it(zr,{base2:()=>Qi});var Qi=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Vr={};it(Vr,{base256emoji:()=>nc});var go=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ji=go.reduce((e,t,r)=>(e[r]=t,e),[]),tc=go.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function ec(e){return e.reduce((t,r)=>(t+=Ji[r],t),"")}function rc(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=tc[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var nc=Xt({prefix:"\u{1F680}",name:"base256emoji",encode:ec,decode:rc});var Fr={};it(Fr,{base64:()=>oc,base64pad:()=>sc,base64url:()=>ic,base64urlpad:()=>cc});var oc=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sc=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ic=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cc=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $r={};it($r,{base8:()=>ac});var ac=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Zr={};it(Zr,{identity:()=>fc});var fc=Xt({prefix:"\0",name:"identity",encode:e=>Bn(e),decode:e=>En(e)});var wf=new TextEncoder,Ef=new TextDecoder;var Yr={};it(Yr,{sha256:()=>Ee,sha512:()=>dc});function jr({name:e,code:t,encode:r}){return new Gr(e,t,r)}var Gr=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Ht(this.code,r):r.then(n=>Ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Eo(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Ee=jr({name:"sha2-256",code:18,encode:Eo("SHA-256")}),dc=jr({name:"sha2-512",code:19,encode:Eo("SHA-512")});var Wr={...Zr,...zr,...$r,...qr,...kr,...lr,...pr,...dr,...Fr,...Vr},Nf={...Yr,...yr};function So(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Bo=So("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Xr=So("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=At(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),lc={utf8:Bo,"utf-8":Bo,hex:Wr.base16,latin1:Xr,ascii:Xr,binary:Xr,...Wr},Qe=lc;function Be(e,t="utf8"){let r=Qe[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function Qr(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return At(i);o+i>t&&(n=At(t),o=0);let c=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),c}}var Gt=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Jr(){}var en=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},pc=Qr();function mc(e){return globalThis.Buffer!=null?At(e):pc(e)}var Ae=class{len;head;tail;states;constructor(){this.len=0,this.head=new Gt(Jr,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new Gt(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new rn((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Je,10,ft.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=ft.fromBigInt(t);return this._push(Je,r.length(),r)}uint64Number(t){return this._push(ao,we(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=ft.fromBigInt(t).zzEncode();return this._push(Je,r.length(),r)}sint64Number(t){let r=ft.fromNumber(t).zzEncode();return this._push(Je,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(tn,1,t?1:0)}fixed32(t){return this._push(Se,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=ft.fromBigInt(t);return this._push(Se,4,r.lo)._push(Se,4,r.hi)}fixed64Number(t){let r=ft.fromNumber(t);return this._push(Se,4,r.lo)._push(Se,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(uo,4,t)}double(t){return this._push(lo,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(tn,1,0):this.uint32(r)._push(yc,r,t)}string(t){let r=xo(t);return r!==0?this.uint32(r)._push(Kr,r,t):this._push(tn,1,0)}fork(){return this.states=new en(this),this.head=this.tail=new Gt(Jr,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Gt(Jr,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=mc(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function tn(e,t,r){t[r]=e&255}function xc(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var rn=class extends Gt{next;constructor(t,r){super(xc,t,r),this.next=void 0}};function Je(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Se(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function yc(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Ae.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(bc,t,e),this},Ae.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(gc,t,e),this});function bc(e,t,r){t.set(e,r)}function gc(e,t,r){e.length<40?Kr(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Be(e),r)}function nn(){return new Ae}function tr(e,t){let r=nn();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ae;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(ae||(ae={}));function er(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function on(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(s,i){let c=t(s);i.int32(c)},n=function(s){let i=s.int32();return t(i)};return er("enum",ae.VARINT,r,n)}function rr(e,t){return er("message",ae.LENGTH_DELIMITED,e,t)}var ut;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1"})(ut||(ut={}));var sn;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1"})(sn||(sn={}));(function(e){e.codec=()=>on(sn)})(ut||(ut={}));var ve;(function(e){let t;e.codec=()=>(t==null&&(t=rr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ut.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let c=r.uint32();switch(c>>>3){case 1:{s.Type=ut.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return s})),t),e.encode=r=>tr(r,e.codec()),e.decode=(r,n)=>Xe(r,e.codec(),n)})(ve||(ve={}));var cn;(function(e){let t;e.codec=()=>(t==null&&(t=rr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ut.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let c=r.uint32();switch(c>>>3){case 1:{s.Type=ut.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(c&7);break}}}return s})),t),e.encode=r=>tr(r,e.codec()),e.decode=(r,n)=>Xe(r,e.codec(),n)})(cn||(cn={}));var Ec=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]),Pt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Kt=new Uint32Array(64),an=class extends ie{constructor(){super(64,32,8,!1),this.A=Pt[0]|0,this.B=Pt[1]|0,this.C=Pt[2]|0,this.D=Pt[3]|0,this.E=Pt[4]|0,this.F=Pt[5]|0,this.G=Pt[6]|0,this.H=Pt[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:c,H:a}=this;return[t,r,n,o,s,i,c,a]}set(t,r,n,o,s,i,c,a){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,r){for(let p=0;p<16;p++,r+=4)Kt[p]=t.getUint32(r,!1);for(let p=16;p<64;p++){let m=Kt[p-15],R=Kt[p-2],S=dt(m,7)^dt(m,18)^m>>>3,y=dt(R,17)^dt(R,19)^R>>>10;Kt[p]=y+Kt[p-7]+S+Kt[p-16]|0}let{A:n,B:o,C:s,D:i,E:c,F:a,G:h,H:f}=this;for(let p=0;p<64;p++){let m=dt(c,6)^dt(c,11)^dt(c,25),R=f+m+Mn(c,a,h)+Ec[p]+Kt[p]|0,y=(dt(n,2)^dt(n,13)^dt(n,22))+qn(n,o,s)|0;f=h,h=a,a=c,c=i+R|0,i=s,s=o,o=n,n=R+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,h=h+this.G|0,f=f+this.H|0,this.set(n,o,s,i,c,a,h,f)}roundClean(){Kt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Ao=He(()=>new an);function Ie(e,t="utf8"){let r=Qe[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Te=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}};var nr=class extends se{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,Pn(t);let n=xe(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;let o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?t.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(t){return oe(this),this.iHash.update(t),this}digestInto(t){oe(this),ne(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},fn=(e,t,r)=>new nr(e,t).update(r).digest();fn.create=(e,t)=>new nr(e,t);function vo(e){e.lowS!==void 0&&lt("lowS",e.lowS),e.prehash!==void 0&&lt("prehash",e.prehash)}function Bc(e){let t=ge(e);xt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.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})}var{bytesToNumberBE:Sc,hexToBytes:Ac}=ze,vt={Err:class extends Error{constructor(t=""){super(t)}},_tlv:{encode:(e,t)=>{let{Err:r}=vt;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=kt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?kt(o.length/2|128):"";return`${kt(e)}${s}${o}${t}`},decode(e,t){let{Err:r}=vt,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let h=t.subarray(n,n+a);if(h.length!==a)throw new r("tlv.decode: length bytes not complete");if(h[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let f of h)i=i<<8|f;if(n+=a,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=vt;if(e<It)throw new t("integer: negative integers are not allowed");let r=kt(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected assertion");return r},decode(e){let{Err:t}=vt;if(e[0]&128)throw new t("Invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return Sc(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=vt,o=typeof e=="string"?Ac(e):e;ce(o);let{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("Invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,s),{v:h,l:f}=n.decode(2,a);if(f.length)throw new t("Invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(h)}},hexFromSig(e){let{_tlv:t,_int:r}=vt,n=`${t.encode(2,r.encode(e.r))}${t.encode(2,r.encode(e.s))}`;return t.encode(48,n)}},It=BigInt(0),tt=BigInt(1),Bu=BigInt(2),Io=BigInt(3),Su=BigInt(4);function vc(e){let t=Bc(e),{Fp:r}=t,n=Nt(t.n,t.nBitLength),o=t.toBytes||((y,u,b)=>{let E=u.toAffine();return St(Uint8Array.from([4]),r.toBytes(E.x),r.toBytes(E.y))}),s=t.fromBytes||(y=>{let u=y.subarray(1),b=r.fromBytes(u.subarray(0,r.BYTES)),E=r.fromBytes(u.subarray(r.BYTES,2*r.BYTES));return{x:b,y:E}});function i(y){let{a:u,b}=t,E=r.sqr(y),l=r.mul(E,y);return r.add(r.add(l,r.mul(y,u)),b)}if(!r.eql(r.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(y){return ye(y,tt,t.n)}function a(y){let{allowedPrivateKeyLengths:u,nByteLength:b,wrapPrivateKey:E,n:l}=t;if(u&&typeof y!="bigint"){if(_t(y)&&(y=Et(y)),typeof y!="string"||!u.includes(y.length))throw new Error("Invalid key");y=y.padStart(b*2,"0")}let B;try{B=typeof y=="bigint"?y:Bt(Z("private key",y,b))}catch{throw new Error(`private key must be ${b} bytes, hex or bigint, not ${typeof y}`)}return E&&(B=k(B,l)),ct("private key",B,tt,l),B}function h(y){if(!(y instanceof m))throw new Error("ProjectivePoint expected")}let f=Ft((y,u)=>{let{px:b,py:E,pz:l}=y;if(r.eql(l,r.ONE))return{x:b,y:E};let B=y.is0();u==null&&(u=B?r.ONE:r.inv(l));let U=r.mul(b,u),_=r.mul(E,u),A=r.mul(l,u);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(A,r.ONE))throw new Error("invZ was invalid");return{x:U,y:_}}),p=Ft(y=>{if(y.is0()){if(t.allowInfinityPoint&&!r.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:u,y:b}=y.toAffine();if(!r.isValid(u)||!r.isValid(b))throw new Error("bad point: x or y not FE");let E=r.sqr(b),l=i(u);if(!r.eql(E,l))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class m{constructor(u,b,E){if(this.px=u,this.py=b,this.pz=E,u==null||!r.isValid(u))throw new Error("x required");if(b==null||!r.isValid(b))throw new Error("y required");if(E==null||!r.isValid(E))throw new Error("z required");Object.freeze(this)}static fromAffine(u){let{x:b,y:E}=u||{};if(!u||!r.isValid(b)||!r.isValid(E))throw new Error("invalid affine point");if(u instanceof m)throw new Error("projective point not allowed");let l=B=>r.eql(B,r.ZERO);return l(b)&&l(E)?m.ZERO:new m(b,E,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){let b=r.invertBatch(u.map(E=>E.pz));return u.map((E,l)=>E.toAffine(b[l])).map(m.fromAffine)}static fromHex(u){let b=m.fromAffine(s(Z("pointHex",u)));return b.assertValidity(),b}static fromPrivateKey(u){return m.BASE.multiply(a(u))}static msm(u,b){return $e(m,n,u,b)}_setWindowSize(u){S.setWindowSize(this,u)}assertValidity(){p(this)}hasEvenY(){let{y:u}=this.toAffine();if(r.isOdd)return!r.isOdd(u);throw new Error("Field doesn't support isOdd")}equals(u){h(u);let{px:b,py:E,pz:l}=this,{px:B,py:U,pz:_}=u,A=r.eql(r.mul(b,_),r.mul(B,l)),v=r.eql(r.mul(E,_),r.mul(U,l));return A&&v}negate(){return new m(this.px,r.neg(this.py),this.pz)}double(){let{a:u,b}=t,E=r.mul(b,Io),{px:l,py:B,pz:U}=this,_=r.ZERO,A=r.ZERO,v=r.ZERO,L=r.mul(l,l),G=r.mul(B,B),M=r.mul(U,U),O=r.mul(l,B);return O=r.add(O,O),v=r.mul(l,U),v=r.add(v,v),_=r.mul(u,v),A=r.mul(E,M),A=r.add(_,A),_=r.sub(G,A),A=r.add(G,A),A=r.mul(_,A),_=r.mul(O,_),v=r.mul(E,v),M=r.mul(u,M),O=r.sub(L,M),O=r.mul(u,O),O=r.add(O,v),v=r.add(L,L),L=r.add(v,L),L=r.add(L,M),L=r.mul(L,O),A=r.add(A,L),M=r.mul(B,U),M=r.add(M,M),L=r.mul(M,O),_=r.sub(_,L),v=r.mul(M,G),v=r.add(v,v),v=r.add(v,v),new m(_,A,v)}add(u){h(u);let{px:b,py:E,pz:l}=this,{px:B,py:U,pz:_}=u,A=r.ZERO,v=r.ZERO,L=r.ZERO,G=t.a,M=r.mul(t.b,Io),O=r.mul(b,B),j=r.mul(E,U),w=r.mul(l,_),I=r.add(b,E),x=r.add(B,U);I=r.mul(I,x),x=r.add(O,j),I=r.sub(I,x),x=r.add(b,l);let d=r.add(B,_);return x=r.mul(x,d),d=r.add(O,w),x=r.sub(x,d),d=r.add(E,l),A=r.add(U,_),d=r.mul(d,A),A=r.add(j,w),d=r.sub(d,A),L=r.mul(G,x),A=r.mul(M,w),L=r.add(A,L),A=r.sub(j,L),L=r.add(j,L),v=r.mul(A,L),j=r.add(O,O),j=r.add(j,O),w=r.mul(G,w),x=r.mul(M,x),j=r.add(j,w),w=r.sub(O,w),w=r.mul(G,w),x=r.add(x,w),O=r.mul(j,x),v=r.add(v,O),O=r.mul(d,x),A=r.mul(I,A),A=r.sub(A,O),O=r.mul(I,j),L=r.mul(d,L),L=r.add(L,O),new m(A,v,L)}subtract(u){return this.add(u.negate())}is0(){return this.equals(m.ZERO)}wNAF(u){return S.wNAFCached(this,u,m.normalizeZ)}multiplyUnsafe(u){ct("scalar",u,It,t.n);let b=m.ZERO;if(u===It)return b;if(u===tt)return this;let{endo:E}=t;if(!E)return S.unsafeLadder(this,u);let{k1neg:l,k1:B,k2neg:U,k2:_}=E.splitScalar(u),A=b,v=b,L=this;for(;B>It||_>It;)B&tt&&(A=A.add(L)),_&tt&&(v=v.add(L)),L=L.double(),B>>=tt,_>>=tt;return l&&(A=A.negate()),U&&(v=v.negate()),v=new m(r.mul(v.px,E.beta),v.py,v.pz),A.add(v)}multiply(u){let{endo:b,n:E}=t;ct("scalar",u,tt,E);let l,B;if(b){let{k1neg:U,k1:_,k2neg:A,k2:v}=b.splitScalar(u),{p:L,f:G}=this.wNAF(_),{p:M,f:O}=this.wNAF(v);L=S.constTimeNegate(U,L),M=S.constTimeNegate(A,M),M=new m(r.mul(M.px,b.beta),M.py,M.pz),l=L.add(M),B=G.add(O)}else{let{p:U,f:_}=this.wNAF(u);l=U,B=_}return m.normalizeZ([l,B])[0]}multiplyAndAddUnsafe(u,b,E){let l=m.BASE,B=(_,A)=>A===It||A===tt||!_.equals(l)?_.multiplyUnsafe(A):_.multiply(A),U=B(this,b).add(B(u,E));return U.is0()?void 0:U}toAffine(u){return f(this,u)}isTorsionFree(){let{h:u,isTorsionFree:b}=t;if(u===tt)return!0;if(b)return b(m,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:u,clearCofactor:b}=t;return u===tt?this:b?b(m,this):this.multiplyUnsafe(t.h)}toRawBytes(u=!0){return lt("isCompressed",u),this.assertValidity(),o(m,this,u)}toHex(u=!0){return lt("isCompressed",u),Et(this.toRawBytes(u))}}m.BASE=new m(t.Gx,t.Gy,r.ONE),m.ZERO=new m(r.ZERO,r.ONE,r.ZERO);let R=t.nBitLength,S=Fe(m,t.endo?Math.ceil(R/2):R);return{CURVE:t,ProjectivePoint:m,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Ic(e){let t=ge(e);return xt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function To(e){let t=Ic(e),{Fp:r,n}=t,o=r.BYTES+1,s=2*r.BYTES+1;function i(w){return k(w,n)}function c(w){return Ve(w,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:h,weierstrassEquation:f,isWithinCurveOrder:p}=vc({...t,toBytes(w,I,x){let d=I.toAffine(),g=r.toBytes(d.x),T=St;return lt("isCompressed",x),x?T(Uint8Array.from([I.hasEvenY()?2:3]),g):T(Uint8Array.from([4]),g,r.toBytes(d.y))},fromBytes(w){let I=w.length,x=w[0],d=w.subarray(1);if(I===o&&(x===2||x===3)){let g=Bt(d);if(!ye(g,tt,r.ORDER))throw new Error("Point is not on curve");let T=f(g),C;try{C=r.sqrt(T)}catch(H){let K=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+K)}let N=(C&tt)===tt;return(x&1)===1!==N&&(C=r.neg(C)),{x:g,y:C}}else if(I===s&&x===4){let g=r.fromBytes(d.subarray(0,r.BYTES)),T=r.fromBytes(d.subarray(r.BYTES,2*r.BYTES));return{x:g,y:T}}else throw new Error(`Point of length ${I} was invalid. Expected ${o} compressed bytes or ${s} uncompressed bytes`)}}),m=w=>Et(Ct(w,t.nByteLength));function R(w){let I=n>>tt;return w>I}function S(w){return R(w)?i(-w):w}let y=(w,I,x)=>Bt(w.slice(I,x));class u{constructor(I,x,d){this.r=I,this.s=x,this.recovery=d,this.assertValidity()}static fromCompact(I){let x=t.nByteLength;return I=Z("compactSignature",I,x*2),new u(y(I,0,x),y(I,x,2*x))}static fromDER(I){let{r:x,s:d}=vt.toSig(Z("DER",I));return new u(x,d)}assertValidity(){ct("r",this.r,tt,n),ct("s",this.s,tt,n)}addRecoveryBit(I){return new u(this.r,this.s,I)}recoverPublicKey(I){let{r:x,s:d,recovery:g}=this,T=_(Z("msgHash",I));if(g==null||![0,1,2,3].includes(g))throw new Error("recovery id invalid");let C=g===2||g===3?x+t.n:x;if(C>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let N=g&1?"03":"02",P=a.fromHex(N+m(C)),H=c(C),K=i(-T*H),q=i(d*H),z=a.BASE.multiplyAndAddUnsafe(P,K,q);if(!z)throw new Error("point at infinify");return z.assertValidity(),z}hasHighS(){return R(this.s)}normalizeS(){return this.hasHighS()?new u(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return zt(this.toDERHex())}toDERHex(){return vt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return zt(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let b={isValidPrivateKey(w){try{return h(w),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let w=_r(t.n);return Yn(t.randomBytes(w),t.n)},precompute(w=8,I=a.BASE){return I._setWindowSize(w),I.multiply(BigInt(3)),I}};function E(w,I=!0){return a.fromPrivateKey(w).toRawBytes(I)}function l(w){let I=_t(w),x=typeof w=="string",d=(I||x)&&w.length;return I?d===o||d===s:x?d===2*o||d===2*s:w instanceof a}function B(w,I,x=!0){if(l(w))throw new Error("first arg must be private key");if(!l(I))throw new Error("second arg must be public key");return a.fromHex(I).multiply(h(w)).toRawBytes(x)}let U=t.bits2int||function(w){let I=Bt(w),x=w.length*8-t.nBitLength;return x>0?I>>BigInt(x):I},_=t.bits2int_modN||function(w){return i(U(w))},A=be(t.nBitLength);function v(w){return ct(`num < 2^${t.nBitLength}`,w,It,A),Ct(w,t.nByteLength)}function L(w,I,x=G){if(["recovered","canonical"].some(Q=>Q in x))throw new Error("sign() legacy options not supported");let{hash:d,randomBytes:g}=t,{lowS:T,prehash:C,extraEntropy:N}=x;T==null&&(T=!0),w=Z("msgHash",w),vo(x),C&&(w=Z("prehashed msgHash",d(w)));let P=_(w),H=h(I),K=[v(H),v(P)];if(N!=null&&N!==!1){let Q=N===!0?g(r.BYTES):N;K.push(Z("extraEntropy",Q))}let q=St(...K),z=P;function X(Q){let et=U(Q);if(!p(et))return;let nt=c(et),Y=a.BASE.multiply(et).toAffine(),st=i(Y.x);if(st===It)return;let yt=i(nt*i(z+st*H));if(yt===It)return;let fe=(Y.x===st?0:2)|Number(Y.y&tt),ue=yt;return T&&R(yt)&&(ue=S(yt),fe^=1),new u(st,ue,fe)}return{seed:q,k2sig:X}}let G={lowS:t.lowS,prehash:!1},M={lowS:t.lowS,prehash:!1};function O(w,I,x=G){let{seed:d,k2sig:g}=L(w,I,x),T=t;return Ir(T.hash.outputLen,T.nByteLength,T.hmac)(d,g)}a.BASE._setWindowSize(8);function j(w,I,x,d=M){let g=w;if(I=Z("msgHash",I),x=Z("publicKey",x),"strict"in d)throw new Error("options.strict was renamed to lowS");vo(d);let{lowS:T,prehash:C}=d,N,P;try{if(typeof g=="string"||_t(g))try{N=u.fromDER(g)}catch(Y){if(!(Y instanceof vt.Err))throw Y;N=u.fromCompact(g)}else if(typeof g=="object"&&typeof g.r=="bigint"&&typeof g.s=="bigint"){let{r:Y,s:st}=g;N=new u(Y,st)}else throw new Error("PARSE");P=a.fromHex(x)}catch(Y){if(Y.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(T&&N.hasHighS())return!1;C&&(I=t.hash(I));let{r:H,s:K}=N,q=_(I),z=c(K),X=i(q*z),Q=i(H*z),et=a.BASE.multiplyAndAddUnsafe(P,X,Q)?.toAffine();return et?i(et.x)===H:!1}return{CURVE:t,getPublicKey:E,getSharedSecret:B,sign:O,verify:j,ProjectivePoint:a,Signature:u,utils:b}}function Tc(e){return{hash:e,hmac:(t,...r)=>fn(e,t,br(...r)),randomBytes:Me}}function Ro(e,t){let r=n=>To({...e,...Tc(n)});return Object.freeze({...r(t),create:r})}var Uo=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Lo=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Rc=BigInt(1),un=BigInt(2),_o=(e,t)=>(e+t/un)/t;function Lc(e){let t=Uo,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),h=e*e*e%t,f=h*h*e%t,p=F(f,r,t)*f%t,m=F(p,r,t)*f%t,R=F(m,un,t)*h%t,S=F(R,o,t)*R%t,y=F(S,s,t)*S%t,u=F(y,c,t)*y%t,b=F(u,a,t)*u%t,E=F(b,c,t)*y%t,l=F(E,r,t)*f%t,B=F(l,i,t)*S%t,U=F(B,n,t)*h%t,_=F(U,un,t);if(!hn.eql(hn.sqr(_),e))throw new Error("Cannot find square root");return _}var hn=Nt(Uo,void 0,void 0,{sqrt:Lc}),jt=Ro({a:BigInt(0),b:BigInt(7),Fp:hn,n:Lo,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=Lo,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Rc*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,i=BigInt("0x100000000000000000000000000000000"),c=_o(s*e,t),a=_o(-n*e,t),h=k(e-c*r-a*o,t),f=k(-c*n-a*s,t),p=h>i,m=f>i;if(p&&(h=t-h),m&&(f=t-f),h>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:p,k1:h,k2neg:m,k2:f}}}},Ao),Cu=BigInt(0);var Nu=jt.ProjectivePoint;function Co(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function No(e,t,r){let n=Ee.digest(r instanceof Uint8Array?r:r.subarray());if(Co(n))return n.then(({digest:o})=>jt.verify(t,o,e)).catch(o=>{throw new Te(String(o))});try{return jt.verify(t,n.digest,e)}catch(o){throw new Te(String(o))}}var or=class{type="secp256k1";raw;_key;constructor(t){this._key=Oo(t),this.raw=Do(this._key)}toMultihash(){return gt.digest(Ye(this))}toCID(){return ht.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:Mt(this.raw,t.raw)}verify(t,r){return No(this._key,r,t)}};function Po(e){return new or(e)}function Do(e){return jt.ProjectivePoint.fromHex(e).toRawBytes(!0)}function Oo(e){try{return jt.ProjectivePoint.fromHex(e),e}catch(t){throw new Ne(String(t))}}function Ko(e){let{Type:t,Data:r}=ve.decode(e.digest),n=r??new Uint8Array;switch(t){case ut.Ed25519:return no(n);case ut.secp256k1:return Po(n);default:throw new Wt}}function Ye(e){return ve.encode({Type:ut[e.type],Data:e.raw})}var Ho=Symbol.for("nodejs.util.inspect.custom"),_c=114,Re=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[cr]=!0;toString(){return this.string==null&&(this.string=J.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ht.createV1(_c,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return Mt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return Mt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ho](){return`PeerId(${this.toString()})`}},Le=class extends Re{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},_e=class extends Re{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Ue=class extends Re{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Uc=2336,Ce=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=gt.digest(Be(this.url))}[Ho](){return`PeerId(${this.url})`}[cr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ht.createV1(Uc,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=Ie(t)),t.toString()===this.toString())}};var Cc=114,Mo=2336;function Nc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=pe(J.decode(`z${e}`));else{if(t==null)throw new Yt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=pe(t.decode(e))}return dn(r)}function qo(e){if(e.type==="Ed25519")return new _e({multihash:e.toCID().multihash,publicKey:e});if(e.type==="secp256k1")return new Ue({multihash:e.toCID().multihash,publicKey:e});if(e.type==="RSA")return new Le({multihash:e.toCID().multihash,publicKey:e});throw new Wt}function Dc(e){return qo(e.publicKey)}function dn(e){if(Kc(e))return new Le({multihash:e});if(Pc(e))try{let t=Ko(e);if(t.type==="Ed25519")return new _e({multihash:e,publicKey:t});if(t.type==="secp256k1")return new Ue({multihash:e,publicKey:t})}catch{let r=Ie(e.digest);return new Ce(new URL(r))}throw new Oe("Supplied PeerID Multihash is invalid")}function Oc(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Cc&&e.code!==Mo)throw new De("Supplied PeerID CID is invalid");if(e.code===Mo){let t=Ie(e.multihash.digest);return new Ce(new URL(t))}return dn(e.multihash)}function Pc(e){return e.code===gt.code}function Kc(e){return e.code===Ee.code}return Jo(Hc);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/hashes/esm/utils.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/peer-id",
3
- "version": "5.0.1",
3
+ "version": "5.0.2",
4
4
  "description": "Implementation of @libp2p/interface-peer-id",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-id#readme",
@@ -54,8 +54,8 @@
54
54
  "test:electron-main": "aegir test -t electron-main"
55
55
  },
56
56
  "dependencies": {
57
- "@libp2p/crypto": "^5.0.1",
58
- "@libp2p/interface": "^2.0.1",
57
+ "@libp2p/crypto": "^5.0.2",
58
+ "@libp2p/interface": "^2.1.0",
59
59
  "multiformats": "^13.1.0",
60
60
  "uint8arrays": "^5.1.0"
61
61
  },