@libp2p/plaintext 2.0.25-ec73d59a6 → 2.0.26
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 +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/typedoc-urls.json +6 -0
- package/package.json +6 -6
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PPlaintext = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PPlaintext=(()=>{var Hr=Object.defineProperty;var Di=Object.getOwnPropertyDescriptor;var Ci=Object.getOwnPropertyNames;var Ti=Object.prototype.hasOwnProperty;var mt=(r,t)=>{for(var e in t)Hr(r,e,{get:t[e],enumerable:!0})},Ri=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ci(t))!Ti.call(r,o)&&o!==e&&Hr(r,o,{get:()=>t[o],enumerable:!(n=Di(t,o))||n.enumerable});return r};var Ui=r=>Ri(Hr({},"__esModule",{value:!0}),r);var af={};mt(af,{plaintext:()=>sf});var Mr=Symbol.for("@libp2p/peer-id");var nr=class extends Error{static name="UnexpectedPeerError";constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError"}},Ke=class extends Error{static name="InvalidCryptoExchangeError";constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError"}},tt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},he=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var de=class extends Error{static name="ProtocolError";constructor(t="Protocol error"){super(t),this.name="ProtocolError"}};var Pe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var go=Symbol.for("@libp2p/service-capabilities"),lf=Symbol.for("@libp2p/service-dependencies");var Gr={};mt(Gr,{base58btc:()=>W,base58flickr:()=>Mi});var Kf=new Uint8Array(0);function Eo(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Rt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function So(r){return new TextEncoder().encode(r)}function Ao(r){return new TextDecoder().decode(r)}function Ki(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function d(A){if(A instanceof Uint8Array||(ArrayBuffer.isView(A)?A=new Uint8Array(A.buffer,A.byteOffset,A.byteLength):Array.isArray(A)&&(A=Uint8Array.from(A))),!(A instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(A.length===0)return"";for(var y=0,U=0,K=0,V=A.length;K!==V&&A[K]===0;)K++,y++;for(var S=(V-K)*f+1>>>0,u=new Uint8Array(S);K!==V;){for(var m=A[K],v=0,B=S-1;(m!==0||v<U)&&B!==-1;B--,v++)m+=256*u[B]>>>0,u[B]=m%a>>>0,m=m/a>>>0;if(m!==0)throw new Error("Non-zero carry");U=v,K++}for(var I=S-U;I!==S&&u[I]===0;)I++;for(var R=c.repeat(y);I<S;++I)R+=r.charAt(u[I]);return R}function E(A){if(typeof A!="string")throw new TypeError("Expected String");if(A.length===0)return new Uint8Array;var y=0;if(A[y]!==" "){for(var U=0,K=0;A[y]===c;)U++,y++;for(var V=(A.length-y)*l+1>>>0,S=new Uint8Array(V);A[y];){var u=e[A.charCodeAt(y)];if(u===255)return;for(var m=0,v=V-1;(u!==0||m<K)&&v!==-1;v--,m++)u+=a*S[v]>>>0,S[v]=u%256>>>0,u=u/256>>>0;if(u!==0)throw new Error("Non-zero carry");K=m,y++}if(A[y]!==" "){for(var B=V-K;B!==V&&S[B]===0;)B++;for(var I=new Uint8Array(U+(V-B)),R=U;B!==V;)I[R++]=S[B++];return I}}}function L(A){var y=E(A);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:d,decodeUnsafe:E,decode:L}}var Pi=Ki,Ni=Pi,Bo=Ni;var qr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Vr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.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 Io(this,t)}},zr=class{decoders;constructor(t){this.decoders=t}or(t){return Io(this,t)}decode(t){let e=t[0],n=this.decoders[e];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 Io(r,t){return new zr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Fr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new qr(t,e,n),this.decoder=new Vr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function pe({name:r,prefix:t,encode:e,decode:n}){return new Fr(r,t,e,n)}function Vt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Bo(e,r);return pe({prefix:t,name:r,encode:n,decode:s=>Rt(o(s))})}function ki(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let l=0;l<o;++l){let f=t[r[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Oi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Hi(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function Z({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Hi(n);return pe({prefix:t,name:r,encode(s){return Oi(s,n,e)},decode(s){return ki(s,o,e,r)}})}var W=Vt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Mi=Vt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var jr={};mt(jr,{base32:()=>me,base32hex:()=>Fi,base32hexpad:()=>ji,base32hexpadupper:()=>Zi,base32hexupper:()=>Gi,base32pad:()=>Vi,base32padupper:()=>zi,base32upper:()=>qi,base32z:()=>Yi});var me=Z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qi=Z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Vi=Z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),zi=Z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Fi=Z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Gi=Z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ji=Z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zi=Z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yi=Z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Zr={};mt(Zr,{base36:()=>Ne,base36upper:()=>Wi});var Ne=Vt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Wi=Vt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Xi=Do,Lo=128,$i=127,Ji=~$i,Qi=Math.pow(2,31);function Do(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Qi;)t[e++]=r&255|Lo,r/=128;for(;r&Ji;)t[e++]=r&255|Lo,r>>>=7;return t[e]=r|0,Do.bytes=e-n+1,t}var ta=Yr,ea=128,_o=127;function Yr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Yr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&_o)<<o:(i&_o)*Math.pow(2,o),o+=7}while(i>=ea);return Yr.bytes=s-n,e}var ra=Math.pow(2,7),na=Math.pow(2,14),oa=Math.pow(2,21),sa=Math.pow(2,28),ia=Math.pow(2,35),aa=Math.pow(2,42),ca=Math.pow(2,49),fa=Math.pow(2,56),ua=Math.pow(2,63),la=function(r){return r<ra?1:r<na?2:r<oa?3:r<sa?4:r<ia?5:r<aa?6:r<ca?7:r<fa?8:r<ua?9:10},ha={encode:Xi,decode:ta,encodingLength:la},da=ha,ke=da;function Oe(r,t=0){return[ke.decode(r,t),ke.decode.bytes]}function ye(r,t,e=0){return ke.encode(r,t,e),t}function xe(r){return ke.encodingLength(r)}function At(r,t){let e=t.byteLength,n=xe(r),o=n+xe(e),s=new Uint8Array(o+e);return ye(r,s,0),ye(e,s,n),s.set(t,o),new be(r,e,t,s)}function Wr(r){let t=Rt(r),[e,n]=Oe(t),[o,s]=Oe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new be(e,o,i,t)}function Co(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Eo(r.bytes,e.bytes)}}var be=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function To(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ma(e,Xr(r),t??W.encoder);default:return ya(e,Xr(r),t??me.encoder)}}var Ro=new WeakMap;function Xr(r){let t=Ro.get(r);if(t==null){let e=new Map;return Ro.set(r,e),e}return t}var ct=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==He)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==xa)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=At(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Co(t.multihash,n.multihash)}toString(t){return To(this,t)}toJSON(){return{"/":To(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 e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Uo(n,o,s.bytes))}else if(e[ba]===!0){let{version:n,multihash:o,code:s}=e,i=Wr(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="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(e!==He)throw new Error(`Version 0 CID must use dag-pb (code: ${He}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Uo(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,He,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Rt(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new be(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[d,E]=Oe(t.subarray(e));return e+=E,d},o=n(),s=He;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),l=e+c,f=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(t,e){let[n,o]=pa(t,e),s=r.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 pa(r,t){switch(r[0]){case"Q":{let e=t??W;return[W.prefix,e.decode(`${W.prefix}${r}`)]}case W.prefix:{let e=t??W;return[W.prefix,e.decode(r)]}case me.prefix:{let e=t??me;return[me.prefix,e.decode(r)]}case Ne.prefix:{let e=t??Ne;return[Ne.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function ma(r,t,e){let{prefix:n}=e;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function ya(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var He=112,xa=18;function Uo(r,t,e){let n=xe(r),o=n+xe(t),s=new Uint8Array(o+e.byteLength);return ye(r,s,0),ye(t,s,n),s.set(e,o),s}var ba=Symbol.for("@ipld/js-cid/CID");var $r={};mt($r,{identity:()=>Lt});var Ko=0,wa="identity",Po=Rt;function ga(r){return At(Ko,Po(r))}var Lt={code:Ko,name:wa,encode:Po,digest:ga};function ft(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function vt(r=0){return new Uint8Array(r)}function yt(r=0){return new Uint8Array(r)}function sr(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=yt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var ko=Symbol.for("@achingbrain/uint8arraylist");function No(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function ir(r){return!!r?.[ko]}var et=class r{bufs;length;[ko]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ir(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ir(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=No(this.bufs,t);return e.buf[e.index]}set(t,e){let n=No(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ir(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return sr(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:sr(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,f=e>a&&e<=c;if(l&&f){if(t===a&&e===c){n.push(i);break}let d=t-a;n.push(i.subarray(d,d+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(f){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ir(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let d=0;d<s;d++)i[d]=-1;for(let d=0;d<o;d++)i[n[d]]=d;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,f;for(let d=e;d<=c;d+=f){f=0;for(let E=l;E>=0;E--){let L=this.get(d+E);if(n[E]!==L){f=Math.max(1,E-a[L]);break}}if(f===0)return d}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=yt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=vt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=vt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=vt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=yt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=vt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=vt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=vt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=vt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=vt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ft(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Jr={};mt(Jr,{base10:()=>Ea});var Ea=Vt({prefix:"9",name:"base10",alphabet:"0123456789"});var Qr={};mt(Qr,{base16:()=>Sa,base16upper:()=>Aa});var Sa=Z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Aa=Z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var tn={};mt(tn,{base2:()=>va});var va=Z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var en={};mt(en,{base256emoji:()=>Da});var Oo=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}"),Ba=Oo.reduce((r,t,e)=>(r[e]=t,r),[]),Ia=Oo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function La(r){return r.reduce((t,e)=>(t+=Ba[e],t),"")}function _a(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=Ia[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Da=pe({prefix:"\u{1F680}",name:"base256emoji",encode:La,decode:_a});var rn={};mt(rn,{base64:()=>Ca,base64pad:()=>Ta,base64url:()=>Ra,base64urlpad:()=>Ua});var Ca=Z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ta=Z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ra=Z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ua=Z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var nn={};mt(nn,{base8:()=>Ka});var Ka=Z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var on={};mt(on,{identity:()=>Pa});var Pa=pe({prefix:"\0",name:"identity",encode:r=>Ao(r),decode:r=>So(r)});var xu=new TextEncoder,bu=new TextDecoder;var cn={};mt(cn,{sha256:()=>ar,sha512:()=>Oa});function an({name:r,code:t,encode:e}){return new sn(r,t,e)}var sn=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?At(this.code,e):e.then(n=>At(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Mo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ar=an({name:"sha2-256",code:18,encode:Mo("SHA-256")}),Oa=an({name:"sha2-512",code:19,encode:Mo("SHA-512")});var fn={...on,...tn,...nn,...Jr,...Qr,...jr,...Zr,...Gr,...rn,...en},Cu={...cn,...$r};function Vo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var qo=Vo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),un=Vo("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=yt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ha={utf8:qo,"utf-8":qo,hex:fn.base16,latin1:un,ascii:un,binary:un,...fn},cr=Ha;function X(r,t="utf8"){let e=cr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function $(r,t="utf8"){let e=cr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Ma=parseInt("11111",2),ln=parseInt("10000000",2),qa=parseInt("01111111",2),zo={0:Me,1:Me,2:Va,3:Ga,4:ja,5:Fa,6:za,16:Me,22:Me,48:Me};function _t(r,t={offset:0}){let e=r[t.offset]&Ma;if(t.offset++,zo[e]!=null)return zo[e](r,t);throw new Error("No decoder for tag "+e)}function qe(r,t){let e=0;if((r[t.offset]&ln)===ln){let n=r[t.offset]&qa,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Me(r,t){qe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=_t(r,t);if(n===null)break;e.push(n)}return e}function Va(r,t){let e=qe(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function za(r,t){let e=qe(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let l=r[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let f=0;for(let d=0;d<c.length;d++)f+=c[d]<<d*7;a+=`.${f}`,c=[]}}return a}function Fa(r,t){return t.offset++,null}function Ga(r,t){let e=qe(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function ja(r,t){let e=qe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Za(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new et;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function hn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Za(r.byteLength);return new et(Uint8Array.from([t.byteLength|ln]),t)}function xt(r){let t=new et,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new et(Uint8Array.from([2]),hn(t),t)}function fr(r){let t=Uint8Array.from([0]),e=new et(t,r);return new et(Uint8Array.from([3]),hn(e),e)}function zt(r,t=48){let e=new et;for(let n of r)e.append(n);return new et(Uint8Array.from([t]),hn(e),e)}var Fo="1.2.840.10045.3.1.7",Go="1.3.132.0.34",jo="1.3.132.0.35";async function Zo(r,t,e,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,e.subarray());return n?.signal?.throwIfAborted(),s}var Ya=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Wa=Uint8Array.from([6,5,43,129,4,0,34]),Xa=Uint8Array.from([6,5,43,129,4,0,35]),$a={ext:!0,kty:"EC",crv:"P-256"},Ja={ext:!0,kty:"EC",crv:"P-384"},Qa={ext:!0,kty:"EC",crv:"P-521"},dn=32,pn=48,mn=66;function Yo(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===dn*2+1)return n=$(t.subarray(e,e+dn),"base64url"),o=$(t.subarray(e+dn),"base64url"),new ge({...$a,key_ops:["verify"],x:n,y:o});if(t.byteLength===pn*2+1)return n=$(t.subarray(e,e+pn),"base64url"),o=$(t.subarray(e+pn),"base64url"),new ge({...Ja,key_ops:["verify"],x:n,y:o});if(t.byteLength===mn*2+1)return n=$(t.subarray(e,e+mn),"base64url"),o=$(t.subarray(e+mn),"base64url"),new ge({...Qa,key_ops:["verify"],x:n,y:o});throw new tt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Wo(r){return zt([xt(Uint8Array.from([1])),zt([tc(r.crv)],160),zt([fr(new et(Uint8Array.from([4]),X(r.x??"","base64url"),X(r.y??"","base64url")))],161)]).subarray()}function tc(r){if(r==="P-256")return Ya;if(r==="P-384")return Wa;if(r==="P-521")return Xa;throw new tt(`Invalid curve ${r}`)}var ge=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Wo(this.jwk)),this._raw}toMultihash(){return Lt.digest(Ee(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}async verify(t,e,n){return Zo(this.jwk,e,t,n)}};var Qt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ec(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ur(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function te(r,...t){if(!ec(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Xo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ur(r.outputLen),ur(r.blockLen)}function Ae(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function $o(r,t){te(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Ut(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function lr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Bt(r,t){return r<<32-t|r>>>t}function Jo(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Ve(r){return typeof r=="string"&&(r=Jo(r)),te(r),r}function yn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];te(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Se=class{};function xn(r){let t=n=>r().update(Ve(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function hr(r=32){if(Qt&&typeof Qt.getRandomValues=="function")return Qt.getRandomValues(new Uint8Array(r));if(Qt&&typeof Qt.randomBytes=="function")return Uint8Array.from(Qt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function rc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),a=Number(e&s),c=n?4:0,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}function Qo(r,t,e){return r&t^~r&e}function ts(r,t,e){return r&t^r&e^t&e}var ze=class extends Se{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=lr(this.buffer)}update(t){Ae(this),t=Ve(t),te(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=lr(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ae(this),$o(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Ut(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let d=i;d<o;d++)e[d]=0;rc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=lr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,f[d],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Kt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var it=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var dr=BigInt(4294967295),es=BigInt(32);function nc(r,t=!1){return t?{h:Number(r&dr),l:Number(r>>es&dr)}:{h:Number(r>>es&dr)|0,l:Number(r&dr)|0}}function rs(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:a}=nc(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var bn=(r,t,e)=>r>>>e,wn=(r,t,e)=>r<<32-e|t>>>e,ee=(r,t,e)=>r>>>e|t<<32-e,re=(r,t,e)=>r<<32-e|t>>>e,Fe=(r,t,e)=>r<<64-e|t>>>e-32,Ge=(r,t,e)=>r>>>e-32|t<<64-e;function Dt(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var ns=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),os=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,ss=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),is=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,as=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),cs=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var sc=Uint32Array.from([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]),Ft=new Uint32Array(64),pr=class extends ze{constructor(t=32){super(64,t,8,!1),this.A=Kt[0]|0,this.B=Kt[1]|0,this.C=Kt[2]|0,this.D=Kt[3]|0,this.E=Kt[4]|0,this.F=Kt[5]|0,this.G=Kt[6]|0,this.H=Kt[7]|0}get(){let{A:t,B:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let d=0;d<16;d++,e+=4)Ft[d]=t.getUint32(e,!1);for(let d=16;d<64;d++){let E=Ft[d-15],L=Ft[d-2],A=Bt(E,7)^Bt(E,18)^E>>>3,y=Bt(L,17)^Bt(L,19)^L>>>10;Ft[d]=y+Ft[d-7]+A+Ft[d-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:l,H:f}=this;for(let d=0;d<64;d++){let E=Bt(a,6)^Bt(a,11)^Bt(a,25),L=f+E+Qo(a,c,l)+sc[d]+Ft[d]|0,y=(Bt(n,2)^Bt(n,13)^Bt(n,22))+ts(n,o,s)|0;f=l,l=c,c=a,a=i+L|0,i=s,s=o,o=n,n=L+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(n,o,s,i,a,c,l,f)}roundClean(){Ut(Ft)}destroy(){this.set(0,0,0,0,0,0,0,0),Ut(this.buffer)}};var fs=rs(["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(r=>BigInt(r))),ic=fs[0],ac=fs[1],Gt=new Uint32Array(80),jt=new Uint32Array(80),gn=class extends ze{constructor(t=64){super(128,t,16,!1),this.Ah=it[0]|0,this.Al=it[1]|0,this.Bh=it[2]|0,this.Bl=it[3]|0,this.Ch=it[4]|0,this.Cl=it[5]|0,this.Dh=it[6]|0,this.Dl=it[7]|0,this.Eh=it[8]|0,this.El=it[9]|0,this.Fh=it[10]|0,this.Fl=it[11]|0,this.Gh=it[12]|0,this.Gl=it[13]|0,this.Hh=it[14]|0,this.Hl=it[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:l,El:f,Fh:d,Fl:E,Gh:L,Gl:A,Hh:y,Hl:U}=this;return[t,e,n,o,s,i,a,c,l,f,d,E,L,A,y,U]}set(t,e,n,o,s,i,a,c,l,f,d,E,L,A,y,U){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=f|0,this.Fh=d|0,this.Fl=E|0,this.Gh=L|0,this.Gl=A|0,this.Hh=y|0,this.Hl=U|0}process(t,e){for(let S=0;S<16;S++,e+=4)Gt[S]=t.getUint32(e),jt[S]=t.getUint32(e+=4);for(let S=16;S<80;S++){let u=Gt[S-15]|0,m=jt[S-15]|0,v=ee(u,m,1)^ee(u,m,8)^bn(u,m,7),B=re(u,m,1)^re(u,m,8)^wn(u,m,7),I=Gt[S-2]|0,R=jt[S-2]|0,k=ee(I,R,19)^Fe(I,R,61)^bn(I,R,6),D=re(I,R,19)^Ge(I,R,61)^wn(I,R,6),P=ss(B,D,jt[S-7],jt[S-16]),T=is(P,v,k,Gt[S-7],Gt[S-16]);Gt[S]=T|0,jt[S]=P|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:l,Dl:f,Eh:d,El:E,Fh:L,Fl:A,Gh:y,Gl:U,Hh:K,Hl:V}=this;for(let S=0;S<80;S++){let u=ee(d,E,14)^ee(d,E,18)^Fe(d,E,41),m=re(d,E,14)^re(d,E,18)^Ge(d,E,41),v=d&L^~d&y,B=E&A^~E&U,I=as(V,m,B,ac[S],jt[S]),R=cs(I,K,u,v,ic[S],Gt[S]),k=I|0,D=ee(n,o,28)^Fe(n,o,34)^Fe(n,o,39),P=re(n,o,28)^Ge(n,o,34)^Ge(n,o,39),T=n&s^n&a^s&a,J=o&i^o&c^i&c;K=y|0,V=U|0,y=L|0,U=A|0,L=d|0,A=E|0,{h:d,l:E}=Dt(l|0,f|0,R|0,k|0),l=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let w=ns(k,P,J);n=os(w,R,D,T),o=w|0}({h:n,l:o}=Dt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Dt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=Dt(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=Dt(this.Dh|0,this.Dl|0,l|0,f|0),{h:d,l:E}=Dt(this.Eh|0,this.El|0,d|0,E|0),{h:L,l:A}=Dt(this.Fh|0,this.Fl|0,L|0,A|0),{h:y,l:U}=Dt(this.Gh|0,this.Gl|0,y|0,U|0),{h:K,l:V}=Dt(this.Hh|0,this.Hl|0,K|0,V|0),this.set(n,o,s,i,a,c,l,f,d,E,L,A,y,U,K,V)}roundClean(){Ut(Gt,jt)}destroy(){Ut(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var mr=xn(()=>new pr);var us=xn(()=>new gn);var vn=BigInt(0),An=BigInt(1);function ve(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Bn(r){if(!ve(r))throw new Error("Uint8Array expected")}function Ct(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function je(r){let t=r.toString(16);return t.length&1?"0"+t:t}function ds(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?vn:BigInt("0x"+r)}var ps=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",cc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Zt(r){if(Bn(r),ps)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=cc[r[e]];return t}var Pt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ls(r){if(r>=Pt._0&&r<=Pt._9)return r-Pt._0;if(r>=Pt.A&&r<=Pt.F)return r-(Pt.A-10);if(r>=Pt.a&&r<=Pt.f)return r-(Pt.a-10)}function Ze(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(ps)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=ls(r.charCodeAt(s)),a=ls(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function Nt(r){return ds(Zt(r))}function ne(r){return Bn(r),ds(Zt(Uint8Array.from(r).reverse()))}function oe(r,t){return Ze(r.toString(16).padStart(t*2,"0"))}function Be(r,t){return oe(r,t).reverse()}function G(r,t,e){let n;if(typeof t=="string")try{n=Ze(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ve(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Yt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Bn(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var En=r=>typeof r=="bigint"&&vn<=r;function yr(r,t,e){return En(r)&&En(t)&&En(e)&&t<=r&&r<e}function gt(r,t,e,n){if(!yr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function ms(r){let t;for(t=0;r>vn;r>>=An,t+=1);return t}var se=r=>(An<<BigInt(r))-An,Sn=r=>new Uint8Array(r),hs=r=>Uint8Array.from(r);function ys(r,t,e){if(typeof r!="number"||r<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 e!="function")throw new Error("hmacFn must be a function");let n=Sn(r),o=Sn(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...d)=>e(o,n,...d),c=(d=Sn(0))=>{o=a(hs([0]),d),n=a(),d.length!==0&&(o=a(hs([1]),d),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,E=[];for(;d<t;){n=a();let L=n.slice();E.push(L),d+=n.length}return Yt(...E)};return(d,E)=>{i(),c(d);let L;for(;!(L=E(l()));)c();return i(),L}}var fc={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ve(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function kt(r,t,e={}){let n=(o,s,i)=>{let a=fc[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function Ie(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var ht=BigInt(0),nt=BigInt(1),ie=BigInt(2),uc=BigInt(3),bs=BigInt(4),ws=BigInt(5),gs=BigInt(8);function F(r,t){let e=r%t;return e>=ht?e:t+e}function j(r,t,e){let n=r;for(;t-- >ht;)n*=n,n%=e;return n}function xr(r,t){if(r===ht)throw new Error("invert: expected non-zero number");if(t<=ht)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=ht,s=nt,i=nt,a=ht;for(;e!==ht;){let l=n/e,f=n%e,d=o-i*l,E=s-a*l;n=e,e=f,o=i,s=a,i=d,a=E}if(n!==nt)throw new Error("invert: does not exist");return F(o,t)}function Es(r,t){let e=(r.ORDER+nt)/bs,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function lc(r,t){let e=(r.ORDER-ws)/gs,n=r.mul(t,ie),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,ie),o),a=r.mul(s,r.sub(i,r.ONE));if(!r.eql(r.sqr(a),t))throw new Error("Cannot find square root");return a}function hc(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-nt,e=0;for(;t%ie===ht;)t/=ie,e++;let n=ie,o=Ot(r);for(;xs(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return Es;let s=o.pow(n,t),i=(t+nt)/ie;return function(c,l){if(c.is0(l))return l;if(xs(c,l)!==1)throw new Error("Cannot find square root");let f=e,d=c.mul(c.ONE,s),E=c.pow(l,t),L=c.pow(l,i);for(;!c.eql(E,c.ONE);){if(c.is0(E))return c.ZERO;let A=1,y=c.sqr(E);for(;!c.eql(y,c.ONE);)if(A++,y=c.sqr(y),A===f)throw new Error("Cannot find square root");let U=nt<<BigInt(f-A-1),K=c.pow(d,U);f=A,d=c.sqr(K),E=c.mul(E,d),L=c.mul(L,K)}return L}}function dc(r){return r%bs===uc?Es:r%gs===ws?lc:hc(r)}var Ss=(r,t)=>(F(r,t)&nt)===nt,pc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function In(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=pc.reduce((n,o)=>(n[o]="function",n),t);return kt(r,e)}function mc(r,t,e){if(e<ht)throw new Error("invalid exponent, negatives unsupported");if(e===ht)return r.ONE;if(e===nt)return t;let n=r.ONE,o=t;for(;e>ht;)e&nt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=nt;return n}function Le(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,a,c)=>r.is0(a)?i:(n[c]=i,r.mul(i,a)),r.ONE),s=r.inv(o);return t.reduceRight((i,a,c)=>r.is0(a)?i:(n[c]=r.mul(i,n[c]),r.mul(i,a)),s),n}function xs(r,t){let e=(r.ORDER-nt)/ie,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function Ln(r,t){t!==void 0&&ur(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Ot(r,t,e=!1,n={}){if(r<=ht)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=Ln(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:se(o),ZERO:ht,ONE:nt,create:c=>F(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ht<=c&&c<r},is0:c=>c===ht,isOdd:c=>(c&nt)===nt,neg:c=>F(-c,r),eql:(c,l)=>c===l,sqr:c=>F(c*c,r),add:(c,l)=>F(c+l,r),sub:(c,l)=>F(c-l,r),mul:(c,l)=>F(c*l,r),pow:(c,l)=>mc(a,c,l),div:(c,l)=>F(c*xr(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>xr(c,r),sqrt:n.sqrt||(c=>(i||(i=dc(r)),i(a,c))),toBytes:c=>e?Be(c,s):oe(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?ne(c):Nt(c)},invertBatch:c=>Le(a,c),cmov:(c,l,f)=>f?l:c});return Object.freeze(a)}function As(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function _n(r){let t=As(r);return t+Math.ceil(t/2)}function vs(r,t,e=!1){let n=r.length,o=As(t),s=_n(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?ne(r):Nt(r),a=F(i,t-nt)+nt;return e?Be(a,o):oe(a,o)}var Bs=BigInt(0),Un=BigInt(1);function Dn(r,t){let e=t.negate();return r?e:t}function Ls(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Cn(r,t){Ls(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=se(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function Is(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=Un);let l=t*n,f=l+Math.abs(a)-1,d=a===0,E=a<0,L=t%2!==0;return{nextN:c,offset:f,isZero:d,isNeg:E,isNegF:L,offsetF:l}}function yc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function xc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Tn=new WeakMap,_s=new WeakMap;function Rn(r){return _s.get(r)||1}function br(r,t){return{constTimeNegate:Dn,hasPrecomputes(e){return Rn(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Bs;)n&Un&&(o=o.add(s)),s=s.double(),n>>=Un;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Cn(n,t),i=[],a=e,c=a;for(let l=0;l<o;l++){c=a,i.push(c);for(let f=1;f<s;f++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=Cn(e,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:f,isZero:d,isNeg:E,isNegF:L,offsetF:A}=Is(o,c,a);o=l,d?i=i.add(Dn(L,n[A])):s=s.add(Dn(E,n[f]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Cn(e,t);for(let a=0;a<i.windows&&o!==Bs;a++){let{nextN:c,offset:l,isZero:f,isNeg:d}=Is(o,a,i);if(o=c,!f){let E=n[l];s=s.add(d?E.negate():E)}}return s},getPrecomputes(e,n,o){let s=Tn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Tn.set(n,o(s))),s},wNAFCached(e,n,o){let s=Rn(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Rn(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Ls(n,t),_s.set(e,n),Tn.delete(e)}}}function wr(r,t,e,n){yc(e,r),xc(n,t);let o=e.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,a=ms(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let l=se(c),f=new Array(Number(l)+1).fill(i),d=Math.floor((t.BITS-1)/c)*c,E=i;for(let L=d;L>=0;L-=c){f.fill(i);for(let y=0;y<s;y++){let U=n[y],K=Number(U>>BigInt(L)&l);f[K]=f[K].add(e[y])}let A=i;for(let y=f.length-1,U=i;y>0;y--)U=U.add(f[y]),A=A.add(U);if(E=E.add(A),L!==0)for(let y=0;y<c;y++)E=E.double()}return E}function Ye(r){return In(r.Fp),kt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ln(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Tt=BigInt(0),dt=BigInt(1),Ds=BigInt(2),bc=BigInt(8),wc={zip215:!0};function gc(r){let t=Ye(r);return kt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Cs(r){let t=gc(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=t,l=Ds<<BigInt(a*8)-dt,f=e.create,d=Ot(t.n,t.nBitLength);function E(x,h){let p=e.sqr(x),g=e.sqr(h),C=e.add(e.mul(t.a,p),g),N=e.add(e.ONE,e.mul(t.d,e.mul(p,g)));return e.eql(C,N)}if(!E(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let L=t.uvRatio||((x,h)=>{try{return{isValid:!0,value:e.sqrt(x*e.inv(h))}}catch{return{isValid:!1,value:Tt}}}),A=t.adjustScalarBytes||(x=>x),y=t.domain||((x,h,p)=>{if(Ct("phflag",p),h.length||p)throw new Error("Contexts/pre-hash are not supported");return x});function U(x,h,p=!1){let g=p?dt:Tt;gt("coordinate "+x,h,g,l)}function K(x){if(!(x instanceof u))throw new Error("ExtendedPoint expected")}let V=Ie((x,h)=>{let{ex:p,ey:g,ez:C}=x,N=x.is0();h==null&&(h=N?bc:e.inv(C));let O=f(p*h),H=f(g*h),M=f(C*h);if(N)return{x:Tt,y:dt};if(M!==dt)throw new Error("invZ was invalid");return{x:O,y:H}}),S=Ie(x=>{let{a:h,d:p}=t;if(x.is0())throw new Error("bad point: ZERO");let{ex:g,ey:C,ez:N,et:O}=x,H=f(g*g),M=f(C*C),z=f(N*N),Q=f(z*z),Y=f(H*h),st=f(z*f(Y+M)),pt=f(Q+f(p*f(H*M)));if(st!==pt)throw new Error("bad point: equation left != right (1)");let rt=f(g*C),at=f(N*O);if(rt!==at)throw new Error("bad point: equation left != right (2)");return!0});class u{constructor(h,p,g,C){U("x",h),U("y",p),U("z",g,!0),U("t",C),this.ex=h,this.ey=p,this.ez=g,this.et=C,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof u)throw new Error("extended point not allowed");let{x:p,y:g}=h||{};return U("x",p),U("y",g),new u(p,g,dt,f(p*g))}static normalizeZ(h){let p=Le(e,h.map(g=>g.ez));return h.map((g,C)=>g.toAffine(p[C])).map(u.fromAffine)}static msm(h,p){return wr(u,d,h,p)}_setWindowSize(h){B.setWindowSize(this,h)}assertValidity(){S(this)}equals(h){K(h);let{ex:p,ey:g,ez:C}=this,{ex:N,ey:O,ez:H}=h,M=f(p*H),z=f(N*C),Q=f(g*H),Y=f(O*C);return M===z&&Q===Y}is0(){return this.equals(u.ZERO)}negate(){return new u(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:h}=t,{ex:p,ey:g,ez:C}=this,N=f(p*p),O=f(g*g),H=f(Ds*f(C*C)),M=f(h*N),z=p+g,Q=f(f(z*z)-N-O),Y=M+O,st=Y-H,pt=M-O,rt=f(Q*st),at=f(Y*pt),wt=f(Q*pt),St=f(st*Y);return new u(rt,at,St,wt)}add(h){K(h);let{a:p,d:g}=t,{ex:C,ey:N,ez:O,et:H}=this,{ex:M,ey:z,ez:Q,et:Y}=h,st=f(C*M),pt=f(N*z),rt=f(H*g*Y),at=f(O*Q),wt=f((C+N)*(M+z)-st-pt),St=at-rt,Ue=at+rt,wo=f(pt-p*st),Bi=f(wt*St),Ii=f(Ue*wo),Li=f(wt*wo),_i=f(St*Ue);return new u(Bi,Ii,_i,Li)}subtract(h){return this.add(h.negate())}wNAF(h){return B.wNAFCached(this,h,u.normalizeZ)}multiply(h){let p=h;gt("scalar",p,dt,n);let{p:g,f:C}=this.wNAF(p);return u.normalizeZ([g,C])[0]}multiplyUnsafe(h,p=u.ZERO){let g=h;return gt("scalar",g,Tt,n),g===Tt?v:this.is0()||g===dt?this:B.wNAFCachedUnsafe(this,g,u.normalizeZ,p)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return B.unsafeLadder(this,n).is0()}toAffine(h){return V(this,h)}clearCofactor(){let{h}=t;return h===dt?this:this.multiplyUnsafe(h)}static fromHex(h,p=!1){let{d:g,a:C}=t,N=e.BYTES;h=G("pointHex",h,N),Ct("zip215",p);let O=h.slice(),H=h[N-1];O[N-1]=H&-129;let M=ne(O),z=p?l:e.ORDER;gt("pointHex.y",M,Tt,z);let Q=f(M*M),Y=f(Q-dt),st=f(g*Q-C),{isValid:pt,value:rt}=L(Y,st);if(!pt)throw new Error("Point.fromHex: invalid y coordinate");let at=(rt&dt)===dt,wt=(H&128)!==0;if(!p&&rt===Tt&&wt)throw new Error("Point.fromHex: x=0 and x_0=1");return wt!==at&&(rt=f(-rt)),u.fromAffine({x:rt,y:M})}static fromPrivateKey(h){let{scalar:p}=k(h);return m.multiply(p)}toRawBytes(){let{x:h,y:p}=this.toAffine(),g=Be(p,e.BYTES);return g[g.length-1]|=h&dt?128:0,g}toHex(){return Zt(this.toRawBytes())}}u.BASE=new u(t.Gx,t.Gy,dt,f(t.Gx*t.Gy)),u.ZERO=new u(Tt,dt,dt,Tt);let{BASE:m,ZERO:v}=u,B=br(u,a*8);function I(x){return F(x,n)}function R(x){return I(ne(x))}function k(x){let h=e.BYTES;x=G("private key",x,h);let p=G("hashed private key",s(x),2*h),g=A(p.slice(0,h)),C=p.slice(h,2*h),N=R(g);return{head:g,prefix:C,scalar:N}}function D(x){let{head:h,prefix:p,scalar:g}=k(x),C=m.multiply(g),N=C.toRawBytes();return{head:h,prefix:p,scalar:g,point:C,pointBytes:N}}function P(x){return D(x).pointBytes}function T(x=Uint8Array.of(),...h){let p=Yt(...h);return R(s(y(p,G("context",x),!!o)))}function J(x,h,p={}){x=G("message",x),o&&(x=o(x));let{prefix:g,scalar:C,pointBytes:N}=D(h),O=T(p.context,g,x),H=m.multiply(O).toRawBytes(),M=T(p.context,H,N,x),z=I(O+M*C);gt("signature.s",z,Tt,n);let Q=Yt(H,Be(z,e.BYTES));return G("result",Q,e.BYTES*2)}let w=wc;function b(x,h,p,g=w){let{context:C,zip215:N}=g,O=e.BYTES;x=G("signature",x,2*O),h=G("message",h),p=G("publicKey",p,O),N!==void 0&&Ct("zip215",N),o&&(h=o(h));let H=ne(x.slice(O,2*O)),M,z,Q;try{M=u.fromHex(p,N),z=u.fromHex(x.slice(0,O),N),Q=m.multiplyUnsafe(H)}catch{return!1}if(!N&&M.isSmallOrder())return!1;let Y=T(C,z.toRawBytes(),M.toRawBytes(),h);return z.add(M.multiplyUnsafe(Y)).subtract(Q).clearCofactor().equals(u.ZERO)}return m._setWindowSize(8),{CURVE:t,getPublicKey:P,sign:J,verify:b,ExtendedPoint:u,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>i(e.BYTES),precompute(x=8,h=u.BASE){return h._setWindowSize(x),h.multiply(BigInt(3)),h}}}}var Kn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ts=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ul=BigInt(0),Ec=BigInt(1),Rs=BigInt(2),Kl=BigInt(3),Sc=BigInt(5),Ac=BigInt(8);function vc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Kn,a=r*r%s*r%s,c=j(a,Rs,s)*a%s,l=j(c,Ec,s)*r%s,f=j(l,Sc,s)*l%s,d=j(f,t,s)*f%s,E=j(d,e,s)*d%s,L=j(E,n,s)*E%s,A=j(L,o,s)*L%s,y=j(A,o,s)*L%s,U=j(y,t,s)*f%s;return{pow_p_5_8:j(U,Rs,s)*r%s,b2:a}}function Bc(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Ic(r,t){let e=Kn,n=F(t*t*t,e),o=F(n*n*t,e),s=vc(r*o).pow_p_5_8,i=F(r*n*s,e),a=F(t*i*i,e),c=i,l=F(i*Ts,e),f=a===r,d=a===F(-r,e),E=a===F(-r*Ts,e);return f&&(i=c),(d||E)&&(i=l),Ss(i,e)&&(i=F(-i,e)),{isValid:f||d,value:i}}var Us=Ot(Kn,void 0,!0),Lc={a:Us.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Us,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Ac,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:us,randomBytes:hr,adjustScalarBytes:Bc,uvRatio:Ic},Ks=Cs(Lc);var _e=32;function Ps(r,t,e){return Ks.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var gr=class{type="Ed25519";raw;constructor(t){this.raw=Pn(t,_e)}toMultihash(){return Lt.digest(Ee(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,e,n){return n?.signal?.throwIfAborted(),Ps(this.raw,e,t)}};function Os(r){return r=Pn(r,_e),new gr(r)}function Pn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new tt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var _c=Math.pow(2,7),Dc=Math.pow(2,14),Cc=Math.pow(2,21),Nn=Math.pow(2,28),kn=Math.pow(2,35),On=Math.pow(2,42),Hn=Math.pow(2,49),q=128,ut=127;function Ht(r){if(r<_c)return 1;if(r<Dc)return 2;if(r<Cc)return 3;if(r<Nn)return 4;if(r<kn)return 5;if(r<On)return 6;if(r<Hn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Mn(r,t,e=0){switch(Ht(r)){case 8:t[e++]=r&255|q,r/=128;case 7:t[e++]=r&255|q,r/=128;case 6:t[e++]=r&255|q,r/=128;case 5:t[e++]=r&255|q,r/=128;case 4:t[e++]=r&255|q,r>>>=7;case 3:t[e++]=r&255|q,r>>>=7;case 2:t[e++]=r&255|q,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Tc(r,t,e=0){switch(Ht(r)){case 8:t.set(e++,r&255|q),r/=128;case 7:t.set(e++,r&255|q),r/=128;case 6:t.set(e++,r&255|q),r/=128;case 5:t.set(e++,r&255|q),r/=128;case 4:t.set(e++,r&255|q),r>>>=7;case 3:t.set(e++,r&255|q),r>>>=7;case 2:t.set(e++,r&255|q),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function qn(r,t){let e=r[t],n=0;if(n+=e&ut,e<q||(e=r[t+1],n+=(e&ut)<<7,e<q)||(e=r[t+2],n+=(e&ut)<<14,e<q)||(e=r[t+3],n+=(e&ut)<<21,e<q)||(e=r[t+4],n+=(e&ut)*Nn,e<q)||(e=r[t+5],n+=(e&ut)*kn,e<q)||(e=r[t+6],n+=(e&ut)*On,e<q)||(e=r[t+7],n+=(e&ut)*Hn,e<q))return n;throw new RangeError("Could not decode varint")}function Rc(r,t){let e=r.get(t),n=0;if(n+=e&ut,e<q||(e=r.get(t+1),n+=(e&ut)<<7,e<q)||(e=r.get(t+2),n+=(e&ut)<<14,e<q)||(e=r.get(t+3),n+=(e&ut)<<21,e<q)||(e=r.get(t+4),n+=(e&ut)*Nn,e<q)||(e=r.get(t+5),n+=(e&ut)*kn,e<q)||(e=r.get(t+6),n+=(e&ut)*On,e<q)||(e=r.get(t+7),n+=(e&ut)*Hn,e<q))return n;throw new RangeError("Could not decode varint")}function Hs(r,t,e=0){return t==null&&(t=yt(Ht(r))),t instanceof Uint8Array?Mn(r,t,e):Tc(r,t,e)}function Ms(r,t=0){return r instanceof Uint8Array?qn(r,t):Rc(r,t)}var Vn=new Float32Array([-0]),Wt=new Uint8Array(Vn.buffer);function qs(r,t,e){Vn[0]=r,t[e]=Wt[0],t[e+1]=Wt[1],t[e+2]=Wt[2],t[e+3]=Wt[3]}function Vs(r,t){return Wt[0]=r[t],Wt[1]=r[t+1],Wt[2]=r[t+2],Wt[3]=r[t+3],Vn[0]}var zn=new Float64Array([-0]),lt=new Uint8Array(zn.buffer);function zs(r,t,e){zn[0]=r,t[e]=lt[0],t[e+1]=lt[1],t[e+2]=lt[2],t[e+3]=lt[3],t[e+4]=lt[4],t[e+5]=lt[5],t[e+6]=lt[6],t[e+7]=lt[7]}function Fs(r,t){return lt[0]=r[t],lt[1]=r[t+1],lt[2]=r[t+2],lt[3]=r[t+3],lt[4]=r[t+4],lt[5]=r[t+5],lt[6]=r[t+6],lt[7]=r[t+7],zn[0]}var Kc=BigInt(Number.MAX_SAFE_INTEGER),Pc=BigInt(Number.MIN_SAFE_INTEGER),Et=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+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 e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(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,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ae;if(t<Kc&&t>Pc)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Gs&&(o=0n,++n>Gs&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ae;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ae}},ae=new Et(0,0);ae.toBigInt=function(){return 0n};ae.zzEncode=ae.zzDecode=function(){return this};ae.length=function(){return 1};var Gs=4294967296n;function js(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Zs(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[t++]&63)<<6|r[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 Fn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function It(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Er(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Gn=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,It(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 It(this,4);return Er(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw It(this,4);return Er(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw It(this,4);let t=Vs(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw It(this,4);let t=Fs(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw It(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Zs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw It(this,t);this.pos+=t}else do if(this.pos>=this.len)throw It(this);while((this.buf[this.pos++]&128)!==0);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 Et(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*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;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw It(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw It(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw It(this,8);let t=Er(this.buf,this.pos+=4),e=Er(this.buf,this.pos+=4);return new Et(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=qn(this.buf,this.pos);return this.pos+=Ht(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 jn(r){return new Gn(r instanceof Uint8Array?r:r.subarray())}function ce(r,t,e){let n=jn(r);return t.decode(n,void 0,e)}function Zn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return yt(i);o+i>t&&(n=yt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var fe=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Yn(){}var Xn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Nc=Zn();function kc(r){return globalThis.Buffer!=null?yt(r):Nc(r)}var Xe=class{len;head;tail;states;constructor(){this.len=0,this.head=new fe(Yn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new fe(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new $n((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(Sr,10,Et.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Et.fromBigInt(t);return this._push(Sr,e.length(),e)}uint64Number(t){return this._push(Mn,Ht(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 e=Et.fromBigInt(t).zzEncode();return this._push(Sr,e.length(),e)}sint64Number(t){let e=Et.fromNumber(t).zzEncode();return this._push(Sr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Wn,1,t?1:0)}fixed32(t){return this._push(We,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Et.fromBigInt(t);return this._push(We,4,e.lo)._push(We,4,e.hi)}fixed64Number(t){let e=Et.fromNumber(t);return this._push(We,4,e.lo)._push(We,4,e.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(qs,4,t)}double(t){return this._push(zs,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Wn,1,0):this.uint32(e)._push(Hc,e,t)}string(t){let e=js(t);return e!==0?this.uint32(e)._push(Fn,e,t):this._push(Wn,1,0)}fork(){return this.states=new Xn(this),this.head=this.tail=new fe(Yn,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 fe(Yn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=kc(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Wn(r,t,e){t[e]=r&255}function Oc(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var $n=class extends fe{next;constructor(t,e){super(Oc,t,e),this.next=void 0}};function Sr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function We(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Hc(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Xe.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Mc,t,r),this},Xe.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(qc,t,r),this});function Mc(r,t,e){t.set(r,e)}function qc(r,t,e){r.length<40?Fn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(X(r),e)}function Jn(){return new Xe}function ue(r,t){let e=Jn();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var De;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(De||(De={}));function Ar(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function $e(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return Ar("enum",De.VARINT,e,n)}function le(r,t){return Ar("message",De.LENGTH_DELIMITED,r,t)}var bt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(bt||(bt={}));var Qn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(Qn||(Qn={}));(function(r){r.codec=()=>$e(Qn)})(bt||(bt={}));var Xt;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ue(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(Xt||(Xt={}));var to;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),bt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=bt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ue(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(to||(to={}));var Je=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},vr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Xs={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new vr("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var $t=Xs;var tr={};mt(tr,{MAX_RSA_KEY_SIZE:()=>eo,generateRSAKeyPair:()=>ei,jwkToJWKKeyPair:()=>ri,jwkToPkcs1:()=>Gc,jwkToPkix:()=>so,jwkToRSAPrivateKey:()=>ao,pkcs1MessageToJwk:()=>no,pkcs1MessageToRSAPrivateKey:()=>io,pkcs1ToJwk:()=>Fc,pkcs1ToRSAPrivateKey:()=>Qs,pkixMessageToJwk:()=>oo,pkixMessageToRSAPublicKey:()=>Ir,pkixToJwk:()=>jc,pkixToRSAPublicKey:()=>ti});var Br=mr;var Ce=class{type="RSA";jwk;_raw;_multihash;constructor(t,e){this.jwk=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=tr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return ct.createV1(114,this._multihash)}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,e,n){return Js(this.jwk,e,t,n)}},Qe=class{type="RSA";jwk;_raw;publicKey;constructor(t,e){this.jwk=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=tr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}sign(t,e){return $s(this.jwk,t,e)}};var eo=8192,ro=18,Vc=1062,zc=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Fc(r){let t=_t(r);return no(t)}function no(r){return{n:$(r[1],"base64url"),e:$(r[2],"base64url"),d:$(r[3],"base64url"),p:$(r[4],"base64url"),q:$(r[5],"base64url"),dp:$(r[6],"base64url"),dq:$(r[7],"base64url"),qi:$(r[8],"base64url"),kty:"RSA"}}function Gc(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new tt("JWK was missing components");return zt([xt(Uint8Array.from([0])),xt(X(r.n,"base64url")),xt(X(r.e,"base64url")),xt(X(r.d,"base64url")),xt(X(r.p,"base64url")),xt(X(r.q,"base64url")),xt(X(r.dp,"base64url")),xt(X(r.dq,"base64url")),xt(X(r.qi,"base64url"))]).subarray()}function jc(r){let t=_t(r,{offset:0});return oo(t)}function oo(r){let t=_t(r[1],{offset:0});return{kty:"RSA",n:$(t[0],"base64url"),e:$(t[1],"base64url")}}function so(r){if(r.n==null||r.e==null)throw new tt("JWK was missing components");return zt([zc,fr(zt([xt(X(r.n,"base64url")),xt(X(r.e,"base64url"))]))]).subarray()}function Qs(r){let t=_t(r);return io(t)}function io(r){let t=no(r);return ao(t)}function ti(r,t){if(r.byteLength>=Vc)throw new he("Key size is too large");let e=_t(r,{offset:0});return Ir(e,r,t)}function Ir(r,t,e){let n=oo(r);if(e==null){let o=Br(Xt.encode({Type:bt.RSA,Data:t}));e=At(ro,o)}return new Ce(n,e)}function ao(r){if(oi(r)>eo)throw new tt("Key size is too large");let t=ri(r),e=Br(Xt.encode({Type:bt.RSA,Data:so(t.publicKey)})),n=At(ro,e);return new Qe(t.privateKey,new Ce(t.publicKey,n))}async function ei(r){if(r>eo)throw new tt("Key size is too large");let t=await ni(r),e=Br(Xt.encode({Type:bt.RSA,Data:so(t.publicKey)})),n=At(ro,e);return new Qe(t.privateKey,new Ce(t.publicKey,n))}function ri(r){if(r==null)throw new tt("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var si="1.2.840.113549.1.1.1";async function ni(r,t){let e=await $t.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await Zc(e,t);return{privateKey:n[0],publicKey:n[1]}}async function $s(r,t,e){let n=await $t.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);e?.signal?.throwIfAborted();let o=await $t.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return e?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Js(r,t,e,n){let o=await $t.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let s=await $t.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,e instanceof Uint8Array?e:e.subarray());return n?.signal?.throwIfAborted(),s}async function Zc(r,t){if(r.privateKey==null||r.publicKey==null)throw new tt("Private and public key are required");let e=await Promise.all([$t.get().subtle.exportKey("jwk",r.privateKey),$t.get().subtle.exportKey("jwk",r.publicKey)]);return t?.signal?.throwIfAborted(),e}function oi(r){if(r.kty!=="RSA")throw new tt("invalid key type");if(r.n==null)throw new tt("invalid key modulus");return X(r.n,"base64url").length*8}var Lr=class extends Se{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Xo(t);let n=Ve(e);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),Ut(s)}update(t){return Ae(this),this.iHash.update(t),this}digestInto(t){Ae(this),te(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:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},co=(r,t,e)=>new Lr(r,t).update(e).digest();co.create=(r,t)=>new Lr(r,t);function ii(r){r.lowS!==void 0&&Ct("lowS",r.lowS),r.prehash!==void 0&&Ct("prehash",r.prehash)}function Yc(r){let t=Ye(r);kt(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var lo=class extends Error{constructor(t=""){super(t)}},Mt={Err:lo,_tlv:{encode:(r,t)=>{let{Err:e}=Mt;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=je(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?je(o.length/2|128):"";return je(r)+s+o+t},decode(r,t){let{Err:e}=Mt,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let f of l)i=i<<8|f;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=Mt;if(r<qt)throw new t("integer: negative integers are not allowed");let e=je(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=Mt;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Nt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Mt,o=G("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:l,l:f}=n.decode(2,c);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=Mt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}};function fo(r,t){return Zt(oe(r,t))}var qt=BigInt(0),ot=BigInt(1),ad=BigInt(2),uo=BigInt(3),Wc=BigInt(4);function Xc(r){let t=Yc(r),{Fp:e}=t,n=Ot(t.n,t.nBitLength),o=t.toBytes||((S,u,m)=>{let v=u.toAffine();return Yt(Uint8Array.from([4]),e.toBytes(v.x),e.toBytes(v.y))}),s=t.fromBytes||(S=>{let u=S.subarray(1),m=e.fromBytes(u.subarray(0,e.BYTES)),v=e.fromBytes(u.subarray(e.BYTES,2*e.BYTES));return{x:m,y:v}});function i(S){let{a:u,b:m}=t,v=e.sqr(S),B=e.mul(v,S);return e.add(e.add(B,e.mul(S,u)),m)}function a(S,u){let m=e.sqr(u),v=i(S);return e.eql(m,v)}if(!a(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let c=e.mul(e.pow(t.a,uo),Wc),l=e.mul(e.sqr(t.b),BigInt(27));if(e.is0(e.add(c,l)))throw new Error("bad curve params: a or b");function f(S){return yr(S,ot,t.n)}function d(S){let{allowedPrivateKeyLengths:u,nByteLength:m,wrapPrivateKey:v,n:B}=t;if(u&&typeof S!="bigint"){if(ve(S)&&(S=Zt(S)),typeof S!="string"||!u.includes(S.length))throw new Error("invalid private key");S=S.padStart(m*2,"0")}let I;try{I=typeof S=="bigint"?S:Nt(G("private key",S,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof S)}return v&&(I=F(I,B)),gt("private key",I,ot,B),I}function E(S){if(!(S instanceof y))throw new Error("ProjectivePoint expected")}let L=Ie((S,u)=>{let{px:m,py:v,pz:B}=S;if(e.eql(B,e.ONE))return{x:m,y:v};let I=S.is0();u==null&&(u=I?e.ONE:e.inv(B));let R=e.mul(m,u),k=e.mul(v,u),D=e.mul(B,u);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(D,e.ONE))throw new Error("invZ was invalid");return{x:R,y:k}}),A=Ie(S=>{if(S.is0()){if(t.allowInfinityPoint&&!e.is0(S.py))return;throw new Error("bad point: ZERO")}let{x:u,y:m}=S.toAffine();if(!e.isValid(u)||!e.isValid(m))throw new Error("bad point: x or y not FE");if(!a(u,m))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class y{constructor(u,m,v){if(u==null||!e.isValid(u))throw new Error("x required");if(m==null||!e.isValid(m)||e.is0(m))throw new Error("y required");if(v==null||!e.isValid(v))throw new Error("z required");this.px=u,this.py=m,this.pz=v,Object.freeze(this)}static fromAffine(u){let{x:m,y:v}=u||{};if(!u||!e.isValid(m)||!e.isValid(v))throw new Error("invalid affine point");if(u instanceof y)throw new Error("projective point not allowed");let B=I=>e.eql(I,e.ZERO);return B(m)&&B(v)?y.ZERO:new y(m,v,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(u){let m=Le(e,u.map(v=>v.pz));return u.map((v,B)=>v.toAffine(m[B])).map(y.fromAffine)}static fromHex(u){let m=y.fromAffine(s(G("pointHex",u)));return m.assertValidity(),m}static fromPrivateKey(u){return y.BASE.multiply(d(u))}static msm(u,m){return wr(y,n,u,m)}_setWindowSize(u){V.setWindowSize(this,u)}assertValidity(){A(this)}hasEvenY(){let{y:u}=this.toAffine();if(e.isOdd)return!e.isOdd(u);throw new Error("Field doesn't support isOdd")}equals(u){E(u);let{px:m,py:v,pz:B}=this,{px:I,py:R,pz:k}=u,D=e.eql(e.mul(m,k),e.mul(I,B)),P=e.eql(e.mul(v,k),e.mul(R,B));return D&&P}negate(){return new y(this.px,e.neg(this.py),this.pz)}double(){let{a:u,b:m}=t,v=e.mul(m,uo),{px:B,py:I,pz:R}=this,k=e.ZERO,D=e.ZERO,P=e.ZERO,T=e.mul(B,B),J=e.mul(I,I),w=e.mul(R,R),b=e.mul(B,I);return b=e.add(b,b),P=e.mul(B,R),P=e.add(P,P),k=e.mul(u,P),D=e.mul(v,w),D=e.add(k,D),k=e.sub(J,D),D=e.add(J,D),D=e.mul(k,D),k=e.mul(b,k),P=e.mul(v,P),w=e.mul(u,w),b=e.sub(T,w),b=e.mul(u,b),b=e.add(b,P),P=e.add(T,T),T=e.add(P,T),T=e.add(T,w),T=e.mul(T,b),D=e.add(D,T),w=e.mul(I,R),w=e.add(w,w),T=e.mul(w,b),k=e.sub(k,T),P=e.mul(w,J),P=e.add(P,P),P=e.add(P,P),new y(k,D,P)}add(u){E(u);let{px:m,py:v,pz:B}=this,{px:I,py:R,pz:k}=u,D=e.ZERO,P=e.ZERO,T=e.ZERO,J=t.a,w=e.mul(t.b,uo),b=e.mul(m,I),_=e.mul(v,R),x=e.mul(B,k),h=e.add(m,v),p=e.add(I,R);h=e.mul(h,p),p=e.add(b,_),h=e.sub(h,p),p=e.add(m,B);let g=e.add(I,k);return p=e.mul(p,g),g=e.add(b,x),p=e.sub(p,g),g=e.add(v,B),D=e.add(R,k),g=e.mul(g,D),D=e.add(_,x),g=e.sub(g,D),T=e.mul(J,p),D=e.mul(w,x),T=e.add(D,T),D=e.sub(_,T),T=e.add(_,T),P=e.mul(D,T),_=e.add(b,b),_=e.add(_,b),x=e.mul(J,x),p=e.mul(w,p),_=e.add(_,x),x=e.sub(b,x),x=e.mul(J,x),p=e.add(p,x),b=e.mul(_,p),P=e.add(P,b),b=e.mul(g,p),D=e.mul(h,D),D=e.sub(D,b),b=e.mul(h,_),T=e.mul(g,T),T=e.add(T,b),new y(D,P,T)}subtract(u){return this.add(u.negate())}is0(){return this.equals(y.ZERO)}wNAF(u){return V.wNAFCached(this,u,y.normalizeZ)}multiplyUnsafe(u){let{endo:m,n:v}=t;gt("scalar",u,qt,v);let B=y.ZERO;if(u===qt)return B;if(this.is0()||u===ot)return this;if(!m||V.hasPrecomputes(this))return V.wNAFCachedUnsafe(this,u,y.normalizeZ);let{k1neg:I,k1:R,k2neg:k,k2:D}=m.splitScalar(u),P=B,T=B,J=this;for(;R>qt||D>qt;)R&ot&&(P=P.add(J)),D&ot&&(T=T.add(J)),J=J.double(),R>>=ot,D>>=ot;return I&&(P=P.negate()),k&&(T=T.negate()),T=new y(e.mul(T.px,m.beta),T.py,T.pz),P.add(T)}multiply(u){let{endo:m,n:v}=t;gt("scalar",u,ot,v);let B,I;if(m){let{k1neg:R,k1:k,k2neg:D,k2:P}=m.splitScalar(u),{p:T,f:J}=this.wNAF(k),{p:w,f:b}=this.wNAF(P);T=V.constTimeNegate(R,T),w=V.constTimeNegate(D,w),w=new y(e.mul(w.px,m.beta),w.py,w.pz),B=T.add(w),I=J.add(b)}else{let{p:R,f:k}=this.wNAF(u);B=R,I=k}return y.normalizeZ([B,I])[0]}multiplyAndAddUnsafe(u,m,v){let B=y.BASE,I=(k,D)=>D===qt||D===ot||!k.equals(B)?k.multiplyUnsafe(D):k.multiply(D),R=I(this,m).add(I(u,v));return R.is0()?void 0:R}toAffine(u){return L(this,u)}isTorsionFree(){let{h:u,isTorsionFree:m}=t;if(u===ot)return!0;if(m)return m(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:u,clearCofactor:m}=t;return u===ot?this:m?m(y,this):this.multiplyUnsafe(t.h)}toRawBytes(u=!0){return Ct("isCompressed",u),this.assertValidity(),o(y,this,u)}toHex(u=!0){return Ct("isCompressed",u),Zt(this.toRawBytes(u))}}y.BASE=new y(t.Gx,t.Gy,e.ONE),y.ZERO=new y(e.ZERO,e.ONE,e.ZERO);let{endo:U,nBitLength:K}=t,V=br(y,U?Math.ceil(K/2):K);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:d,weierstrassEquation:i,isWithinCurveOrder:f}}function $c(r){let t=Ye(r);return kt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ai(r){let t=$c(r),{Fp:e,n,nByteLength:o,nBitLength:s}=t,i=e.BYTES+1,a=2*e.BYTES+1;function c(w){return F(w,n)}function l(w){return xr(w,n)}let{ProjectivePoint:f,normPrivateKeyToScalar:d,weierstrassEquation:E,isWithinCurveOrder:L}=Xc({...t,toBytes(w,b,_){let x=b.toAffine(),h=e.toBytes(x.x),p=Yt;return Ct("isCompressed",_),_?p(Uint8Array.from([b.hasEvenY()?2:3]),h):p(Uint8Array.from([4]),h,e.toBytes(x.y))},fromBytes(w){let b=w.length,_=w[0],x=w.subarray(1);if(b===i&&(_===2||_===3)){let h=Nt(x);if(!yr(h,ot,e.ORDER))throw new Error("Point is not on curve");let p=E(h),g;try{g=e.sqrt(p)}catch(O){let H=O instanceof Error?": "+O.message:"";throw new Error("Point is not on curve"+H)}let C=(g&ot)===ot;return(_&1)===1!==C&&(g=e.neg(g)),{x:h,y:g}}else if(b===a&&_===4){let h=e.fromBytes(x.subarray(0,e.BYTES)),p=e.fromBytes(x.subarray(e.BYTES,2*e.BYTES));return{x:h,y:p}}else{let h=i,p=a;throw new Error("invalid Point, expected length of "+h+", or uncompressed "+p+", got "+b)}}});function A(w){let b=n>>ot;return w>b}function y(w){return A(w)?c(-w):w}let U=(w,b,_)=>Nt(w.slice(b,_));class K{constructor(b,_,x){gt("r",b,ot,n),gt("s",_,ot,n),this.r=b,this.s=_,x!=null&&(this.recovery=x),Object.freeze(this)}static fromCompact(b){let _=o;return b=G("compactSignature",b,_*2),new K(U(b,0,_),U(b,_,2*_))}static fromDER(b){let{r:_,s:x}=Mt.toSig(G("DER",b));return new K(_,x)}assertValidity(){}addRecoveryBit(b){return new K(this.r,this.s,b)}recoverPublicKey(b){let{r:_,s:x,recovery:h}=this,p=B(G("msgHash",b));if(h==null||![0,1,2,3].includes(h))throw new Error("recovery id invalid");let g=h===2||h===3?_+t.n:_;if(g>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let C=(h&1)===0?"02":"03",N=f.fromHex(C+fo(g,e.BYTES)),O=l(g),H=c(-p*O),M=c(x*O),z=f.BASE.multiplyAndAddUnsafe(N,H,M);if(!z)throw new Error("point at infinify");return z.assertValidity(),z}hasHighS(){return A(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Ze(this.toDERHex())}toDERHex(){return Mt.hexFromSig(this)}toCompactRawBytes(){return Ze(this.toCompactHex())}toCompactHex(){let b=o;return fo(this.r,b)+fo(this.s,b)}}let V={isValidPrivateKey(w){try{return d(w),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let w=_n(t.n);return vs(t.randomBytes(w),t.n)},precompute(w=8,b=f.BASE){return b._setWindowSize(w),b.multiply(BigInt(3)),b}};function S(w,b=!0){return f.fromPrivateKey(w).toRawBytes(b)}function u(w){if(typeof w=="bigint")return!1;if(w instanceof f)return!0;let _=G("key",w).length,x=e.BYTES,h=x+1,p=2*x+1;if(!(t.allowedPrivateKeyLengths||o===h))return _===h||_===p}function m(w,b,_=!0){if(u(w)===!0)throw new Error("first arg must be private key");if(u(b)===!1)throw new Error("second arg must be public key");return f.fromHex(b).multiply(d(w)).toRawBytes(_)}let v=t.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");let b=Nt(w),_=w.length*8-s;return _>0?b>>BigInt(_):b},B=t.bits2int_modN||function(w){return c(v(w))},I=se(s);function R(w){return gt("num < 2^"+s,w,qt,I),oe(w,o)}function k(w,b,_=D){if(["recovered","canonical"].some(Y=>Y in _))throw new Error("sign() legacy options not supported");let{hash:x,randomBytes:h}=t,{lowS:p,prehash:g,extraEntropy:C}=_;p==null&&(p=!0),w=G("msgHash",w),ii(_),g&&(w=G("prehashed msgHash",x(w)));let N=B(w),O=d(b),H=[R(O),R(N)];if(C!=null&&C!==!1){let Y=C===!0?h(e.BYTES):C;H.push(G("extraEntropy",Y))}let M=Yt(...H),z=N;function Q(Y){let st=v(Y);if(!L(st))return;let pt=l(st),rt=f.BASE.multiply(st).toAffine(),at=c(rt.x);if(at===qt)return;let wt=c(pt*c(z+at*O));if(wt===qt)return;let St=(rt.x===at?0:2)|Number(rt.y&ot),Ue=wt;return p&&A(wt)&&(Ue=y(wt),St^=1),new K(at,Ue,St)}return{seed:M,k2sig:Q}}let D={lowS:t.lowS,prehash:!1},P={lowS:t.lowS,prehash:!1};function T(w,b,_=D){let{seed:x,k2sig:h}=k(w,b,_),p=t;return ys(p.hash.outputLen,p.nByteLength,p.hmac)(x,h)}f.BASE._setWindowSize(8);function J(w,b,_,x=P){let h=w;b=G("msgHash",b),_=G("publicKey",_);let{lowS:p,prehash:g,format:C}=x;if(ii(x),"strict"in x)throw new Error("options.strict was renamed to lowS");if(C!==void 0&&C!=="compact"&&C!=="der")throw new Error("format must be compact or der");let N=typeof h=="string"||ve(h),O=!N&&!C&&typeof h=="object"&&h!==null&&typeof h.r=="bigint"&&typeof h.s=="bigint";if(!N&&!O)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let H,M;try{if(O&&(H=new K(h.r,h.s)),N){try{C!=="compact"&&(H=K.fromDER(h))}catch(St){if(!(St instanceof Mt.Err))throw St}!H&&C!=="der"&&(H=K.fromCompact(h))}M=f.fromHex(_)}catch{return!1}if(!H||p&&H.hasHighS())return!1;g&&(b=t.hash(b));let{r:z,s:Q}=H,Y=B(b),st=l(Q),pt=c(Y*st),rt=c(z*st),at=f.BASE.multiplyAndAddUnsafe(M,pt,rt)?.toAffine();return at?c(at.x)===z:!1}return{CURVE:t,getPublicKey:S,getSharedSecret:m,sign:T,verify:J,ProjectivePoint:f,Signature:K,utils:V}}function Jc(r){return{hash:r,hmac:(t,...e)=>co(r,t,yn(...e)),randomBytes:hr}}function ci(r,t){let e=n=>ai({...r,...Jc(n)});return{...e(t),create:e}}var li=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),fi=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Qc=BigInt(0),tf=BigInt(1),ho=BigInt(2),ui=(r,t)=>(r+t/ho)/t;function ef(r){let t=li,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,f=l*l*r%t,d=j(f,e,t)*f%t,E=j(d,e,t)*f%t,L=j(E,ho,t)*l%t,A=j(L,o,t)*L%t,y=j(A,s,t)*A%t,U=j(y,a,t)*y%t,K=j(U,c,t)*U%t,V=j(K,a,t)*y%t,S=j(V,e,t)*f%t,u=j(S,i,t)*A%t,m=j(u,n,t)*l%t,v=j(m,ho,t);if(!po.eql(po.sqr(v),r))throw new Error("Cannot find square root");return v}var po=Ot(li,void 0,void 0,{sqrt:ef}),Te=ci({a:Qc,b:BigInt(7),Fp:po,n:fi,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=fi,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-tf*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=ui(s*r,t),c=ui(-n*r,t),l=F(r-a*e-c*o,t),f=F(-a*n-c*s,t),d=l>i,E=f>i;if(d&&(l=t-l),E&&(f=t-f),l>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:d,k1:l,k2neg:E,k2:f}}}},mr);function hi(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var di=33;function pi(r,t,e,n){let o=ar.digest(e instanceof Uint8Array?e:e.subarray());if(hi(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Te.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new Je(String(s))});try{return n?.signal?.throwIfAborted(),Te.verify(t,o.digest,r)}catch(s){throw new Je(String(s))}}var _r=class{type="secp256k1";raw;_key;constructor(t){this._key=yi(t),this.raw=mi(this._key)}toMultihash(){return Lt.digest(Ee(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ft(this.raw,t.raw)}verify(t,e,n){return pi(this._key,e,t,n)}};function xi(r){return new _r(r)}function mi(r){return Te.ProjectivePoint.fromHex(r).toRawBytes(!0)}function yi(r){try{return Te.ProjectivePoint.fromHex(r),r}catch(t){throw new he(String(t))}}function bi(r){if(r.byteLength===_e)return Os(r);if(r.byteLength===di)return xi(r);let t=_t(r),e=t[1]?.[0];if(e===Fo||e===Go||e===jo)return Yo(t);if(t[0]?.[0]===si)return Ir(t,r);throw new tt("Could not extract public key from raw bytes")}function Ee(r){return Xt.encode({Type:bt[r.type],Data:r.raw})}var wi=Symbol.for("nodejs.util.inspect.custom"),rf=114,er=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()})`}[Mr]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(rf,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ft(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ft(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[wi](){return`PeerId(${this.toString()})`}},Dr=class extends er{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Cr=class extends er{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Tr=class extends er{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},nf=2336,mo=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Lt.digest(X(this.url))}[wi](){return`PeerId(${this.url})`}[Mr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(nf,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=$(t)),t.toString()===this.toString())}};function gi(r){if(r.type==="Ed25519")return new Cr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Tr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new Dr({multihash:r.toCID().multihash,publicKey:r});throw new Pe}function Re(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Rr=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function rr(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Rr(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Rr(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var yo=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=Re(),this.haveNext=Re()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Re(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Re(),await rr(this.readNext.promise,e?.signal,e)}};function Ei(){return new yo}var Ur=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function Si(r,t){let e=Ei();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let a of i)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new et;return{read:async i=>{if(i?.signal?.throwIfAborted(),i?.bytes==null){let{done:c,value:l}=await rr(n.next(),i?.signal);return c===!0?null:l}for(;o.byteLength<i.bytes;){let{value:c,done:l}=await rr(n.next(),i?.signal);if(l===!0)throw new Ur("unexpected end of input");o.append(c)}let a=o.sublist(0,i.bytes);return o.consume(i.bytes),a},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,a):await e.push(i.subarray(),a)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var Kr=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Pr=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Nr=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Ai(r,t={}){let e=Si(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=Ht(t.maxDataLength));let n=t?.lengthDecoder??Ms,o=t?.lengthEncoder??Hs;return{read:async i=>{let a=-1,c=new et;for(;;){c.append(await e.read({...i,bytes:1}));try{a=n(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(a<0)throw new Kr("Invalid message length");if(t?.maxLengthLength!=null&&c.byteLength>t.maxLengthLength)throw new Nr("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new Pr("message length too long");return e.read({...i,bytes:a})},write:async(i,a)=>{await e.write(new et(o(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new et(...i.flatMap(l=>[o(l.byteLength),l]));await e.write(c,a)},unwrap:()=>e.unwrap()}}function vi(r,t){let e=Ai(r,t),n={read:async(o,s)=>{let i=await e.read(s);return o.decode(i)},write:async(o,s,i)=>{await e.write(s.encode(o),i)},writeV:async(o,s,i)=>{await e.writeV(o.map(a=>s.encode(a)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var kr;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.id!=null&&(n.uint32(10),n.bytes(e.id)),e.pubkey!=null&&(n.uint32(18),Or.codec().encode(e.pubkey,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.id=e.bytes();break}case 2:{s.pubkey=Or.codec().decode(e,e.uint32(),{limits:o.limits?.pubkey});break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ue(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(kr||(kr={}));var Jt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(Jt||(Jt={}));var xo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(xo||(xo={}));(function(r){r.codec=()=>$e(xo)})(Jt||(Jt={}));var Or;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Jt.codec().encode(e.Type,n)),e.Data!=null&&e.Data.byteLength>0&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={Data:vt(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=Jt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>ue(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(Or||(Or={}));var of="/plaintext/2.0.0",bo=class{protocol=of;privateKey;log;constructor(t){this.privateKey=t.privateKey,this.log=t.logger.forComponent("libp2p:plaintext")}[Symbol.toStringTag]="@libp2p/plaintext";[go]=["@libp2p/connection-encryption"];async secureInbound(t,e){return this._encrypt(t,e)}async secureOutbound(t,e){return this._encrypt(t,e)}async _encrypt(t,e){let n=vi(t).pb(kr);this.log("write pubkey exchange to peer %p",e?.remotePeer);let o=this.privateKey.publicKey,[,s]=await Promise.all([n.write({id:o.toMultihash().bytes,pubkey:{Type:Jt[o.type],Data:o.raw}},e),n.read(e)]),i;try{if(s.pubkey==null)throw new de("Public key missing");if(s.pubkey.Data.byteLength===0)throw new de("Public key data too short");if(s.id==null)throw new de("Remote id missing");let a=bi(s.pubkey.Data);if(i=gi(a),!ft(i.toMultihash().bytes,s.id))throw new Ke("Public key did not match id")}catch(a){throw this.log.error(a),new Ke("Invalid public key - "+a.message)}if(e?.remotePeer!=null&&!i.equals(e?.remotePeer))throw new nr;return this.log("plaintext key exchange completed successfully with peer %p",i),{conn:n.unwrap().unwrap(),remotePeer:i}}};function sf(){return r=>new bo(r)}return Ui(af);})();
|
|
2
|
+
"use strict";var Libp2PPlaintext=(()=>{var Mr=Object.defineProperty;var Ti=Object.getOwnPropertyDescriptor;var Di=Object.getOwnPropertyNames;var Ri=Object.prototype.hasOwnProperty;var mt=(r,t)=>{for(var e in t)Mr(r,e,{get:t[e],enumerable:!0})},Ui=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Di(t))!Ri.call(r,o)&&o!==e&&Mr(r,o,{get:()=>t[o],enumerable:!(n=Ti(t,o))||n.enumerable});return r};var Ki=r=>Ui(Mr({},"__esModule",{value:!0}),r);var fu={};mt(fu,{plaintext:()=>uu});var qr=Symbol.for("@libp2p/peer-id");var nr=class extends Error{static name="UnexpectedPeerError";constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError"}},Ke=class extends Error{static name="InvalidCryptoExchangeError";constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError"}},tt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},he=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var de=class extends Error{static name="ProtocolError";constructor(t="Protocol error"){super(t),this.name="ProtocolError"}};var Pe=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var So=Symbol.for("@libp2p/service-capabilities"),pu=Symbol.for("@libp2p/service-dependencies");var jr={};mt(jr,{base58btc:()=>X,base58flickr:()=>qi});var Nu=new Uint8Array(0);function Ao(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Ut(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function vo(r){return new TextEncoder().encode(r)}function Bo(r){return new TextDecoder().decode(r)}function Pi(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(A){if(A instanceof Uint8Array||(ArrayBuffer.isView(A)?A=new Uint8Array(A.buffer,A.byteOffset,A.byteLength):Array.isArray(A)&&(A=Uint8Array.from(A))),!(A instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(A.length===0)return"";for(var y=0,U=0,K=0,V=A.length;K!==V&&A[K]===0;)K++,y++;for(var S=(V-K)*u+1>>>0,f=new Uint8Array(S);K!==V;){for(var m=A[K],v=0,B=S-1;(m!==0||v<U)&&B!==-1;B--,v++)m+=256*f[B]>>>0,f[B]=m%a>>>0,m=m/a>>>0;if(m!==0)throw new Error("Non-zero carry");U=v,K++}for(var I=S-U;I!==S&&f[I]===0;)I++;for(var R=c.repeat(y);I<S;++I)R+=r.charAt(f[I]);return R}function E(A){if(typeof A!="string")throw new TypeError("Expected String");if(A.length===0)return new Uint8Array;var y=0;if(A[y]!==" "){for(var U=0,K=0;A[y]===c;)U++,y++;for(var V=(A.length-y)*l+1>>>0,S=new Uint8Array(V);A[y];){var f=e[A.charCodeAt(y)];if(f===255)return;for(var m=0,v=V-1;(f!==0||m<K)&&v!==-1;v--,m++)f+=a*S[v]>>>0,S[v]=f%256>>>0,f=f/256>>>0;if(f!==0)throw new Error("Non-zero carry");K=m,y++}if(A[y]!==" "){for(var B=V-K;B!==V&&S[B]===0;)B++;for(var I=new Uint8Array(U+(V-B)),R=U;B!==V;)I[R++]=S[B++];return I}}}function L(A){var y=E(A);if(y)return y;throw new Error(`Non-${t} character`)}return{encode:d,decodeUnsafe:E,decode:L}}var Ni=Pi,ki=Ni,Lo=ki;var Vr=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},zr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.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 _o(this,t)}},Fr=class{decoders;constructor(t){this.decoders=t}or(t){return _o(this,t)}decode(t){let e=t[0],n=this.decoders[e];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 _o(r,t){return new Fr({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Gr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Vr(t,e,n),this.decoder=new zr(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function pe({name:r,prefix:t,encode:e,decode:n}){return new Gr(r,t,e,n)}function zt({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Lo(e,r);return pe({prefix:t,name:r,encode:n,decode:s=>Ut(o(s))})}function Oi(r,t,e,n){let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),i=0,a=0,c=0;for(let l=0;l<o;++l){let u=t[r[l]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|u,i+=e,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=e||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Hi(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<e-i]),n)for(;(s.length*e&7)!==0;)s+="=";return s}function Mi(r){let t={};for(let e=0;e<r.length;++e)t[r[e]]=e;return t}function Z({name:r,prefix:t,bitsPerChar:e,alphabet:n}){let o=Mi(n);return pe({prefix:t,name:r,encode(s){return Hi(s,n,e)},decode(s){return Oi(s,o,e,r)}})}var X=zt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qi=zt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Zr={};mt(Zr,{base32:()=>me,base32hex:()=>Gi,base32hexpad:()=>Zi,base32hexpadupper:()=>Wi,base32hexupper:()=>ji,base32pad:()=>zi,base32padupper:()=>Fi,base32upper:()=>Vi,base32z:()=>Yi});var me=Z({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vi=Z({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zi=Z({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Fi=Z({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Gi=Z({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ji=Z({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Zi=Z({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Wi=Z({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yi=Z({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Wr={};mt(Wr,{base36:()=>Ne,base36upper:()=>Xi});var Ne=zt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xi=zt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $i=Do,Co=128,Ji=127,Qi=~Ji,ta=Math.pow(2,31);function Do(r,t,e){t=t||[],e=e||0;for(var n=e;r>=ta;)t[e++]=r&255|Co,r/=128;for(;r&Qi;)t[e++]=r&255|Co,r>>>=7;return t[e]=r|0,Do.bytes=e-n+1,t}var ea=Yr,ra=128,To=127;function Yr(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Yr.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&To)<<o:(i&To)*Math.pow(2,o),o+=7}while(i>=ra);return Yr.bytes=s-n,e}var na=Math.pow(2,7),oa=Math.pow(2,14),sa=Math.pow(2,21),ia=Math.pow(2,28),aa=Math.pow(2,35),ca=Math.pow(2,42),ua=Math.pow(2,49),fa=Math.pow(2,56),la=Math.pow(2,63),ha=function(r){return r<na?1:r<oa?2:r<sa?3:r<ia?4:r<aa?5:r<ca?6:r<ua?7:r<fa?8:r<la?9:10},da={encode:$i,decode:ea,encodingLength:ha},pa=da,ke=pa;function Oe(r,t=0){return[ke.decode(r,t),ke.decode.bytes]}function ye(r,t,e=0){return ke.encode(r,t,e),t}function be(r){return ke.encodingLength(r)}function vt(r,t){let e=t.byteLength,n=be(r),o=n+be(e),s=new Uint8Array(o+e);return ye(r,s,0),ye(e,s,n),s.set(t,o),new xe(r,e,t,s)}function Xr(r){let t=Ut(r),[e,n]=Oe(t),[o,s]=Oe(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new xe(e,o,i,t)}function Ro(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Ao(r.bytes,e.bytes)}}var xe=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Uo(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ya(e,$r(r),t??X.encoder);default:return ba(e,$r(r),t??me.encoder)}}var Ko=new WeakMap;function $r(r){let t=Ko.get(r);if(t==null){let e=new Map;return Ko.set(r,e),e}return t}var ct=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==He)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==xa)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=vt(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Ro(t.multihash,n.multihash)}toString(t){return Uo(this,t)}toJSON(){return{"/":Uo(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 e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new r(n,o,s,i??Po(n,o,s.bytes))}else if(e[wa]===!0){let{version:n,multihash:o,code:s}=e,i=Xr(o);return r.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="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(e!==He)throw new Error(`Version 0 CID must use dag-pb (code: ${He}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Po(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,He,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,o=Ut(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new xe(e.multihashCode,e.digestSize,s,o);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[d,E]=Oe(t.subarray(e));return e+=E,d},o=n(),s=He;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),c=n(),l=e+c,u=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,e){let[n,o]=ma(t,e),s=r.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return $r(s).set(n,t),s}};function ma(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case me.prefix:{let e=t??me;return[me.prefix,e.decode(r)]}case Ne.prefix:{let e=t??Ne;return[Ne.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function ya(r,t,e){let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o}function ba(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o}var He=112,xa=18;function Po(r,t,e){let n=be(r),o=n+be(t),s=new Uint8Array(o+e.byteLength);return ye(r,s,0),ye(t,s,n),s.set(e,o),s}var wa=Symbol.for("@ipld/js-cid/CID");var Jr={};mt(Jr,{identity:()=>_t});var No=0,ga="identity",ko=Ut;function Ea(r){return vt(No,ko(r))}var _t={code:No,name:ga,encode:ko,digest:Ea};function ut(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Bt(r=0){return new Uint8Array(r)}function yt(r=0){return new Uint8Array(r)}function sr(r,t){t==null&&(t=r.reduce((o,s)=>o+s.length,0));let e=yt(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}var Ho=Symbol.for("@achingbrain/uint8arraylist");function Oo(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function ir(r){return!!r?.[Ho]}var et=class r{bufs;length;[Ho]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ir(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ir(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Oo(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Oo(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ir(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return sr(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:sr(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),s=new r;return s.length=o,s.bufs=[...n],s}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,u=e>a&&e<=c;if(l&&u){if(t===a&&e===c){n.push(i);break}let d=t-a;n.push(i.subarray(d,d+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(u){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ir(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let d=0;d<s;d++)i[d]=-1;for(let d=0;d<o;d++)i[n[d]]=d;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let d=e;d<=c;d+=u){u=0;for(let E=l;E>=0;E--){let L=this.get(d+E);if(n[E]!==L){u=Math.max(1,E-a[L]);break}}if(u===0)return d}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=yt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=Bt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=Bt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=Bt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=yt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=Bt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=Bt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=Bt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=Bt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=Bt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ut(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,s)=>o+s.byteLength,0)),n.length=e,n}};var Qr={};mt(Qr,{base10:()=>Sa});var Sa=zt({prefix:"9",name:"base10",alphabet:"0123456789"});var tn={};mt(tn,{base16:()=>Aa,base16upper:()=>va});var Aa=Z({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),va=Z({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var en={};mt(en,{base2:()=>Ba});var Ba=Z({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var rn={};mt(rn,{base256emoji:()=>Ta});var Mo=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}"),Ia=Mo.reduce((r,t,e)=>(r[e]=t,r),[]),La=Mo.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function _a(r){return r.reduce((t,e)=>(t+=Ia[e],t),"")}function Ca(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=La[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Ta=pe({prefix:"\u{1F680}",name:"base256emoji",encode:_a,decode:Ca});var nn={};mt(nn,{base64:()=>Da,base64pad:()=>Ra,base64url:()=>Ua,base64urlpad:()=>Ka});var Da=Z({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ra=Z({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ua=Z({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ka=Z({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var on={};mt(on,{base8:()=>Pa});var Pa=Z({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var sn={};mt(sn,{identity:()=>Na});var Na=pe({prefix:"\0",name:"identity",encode:r=>Bo(r),decode:r=>vo(r)});var gf=new TextEncoder,Ef=new TextDecoder;var un={};mt(un,{sha256:()=>ar,sha512:()=>Ha});function cn({name:r,code:t,encode:e}){return new an(r,t,e)}var an=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?vt(this.code,e):e.then(n=>vt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Vo(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var ar=cn({name:"sha2-256",code:18,encode:Vo("SHA-256")}),Ha=cn({name:"sha2-512",code:19,encode:Vo("SHA-512")});var fn={...sn,...en,...on,...Qr,...tn,...Zr,...Wr,...jr,...nn,...rn},Uf={...un,...Jr};function Fo(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var zo=Fo("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ln=Fo("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=yt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ma={utf8:zo,"utf-8":zo,hex:fn.base16,latin1:ln,ascii:ln,binary:ln,...fn},cr=Ma;function $(r,t="utf8"){let e=cr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function W(r,t="utf8"){let e=cr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var qa=parseInt("11111",2),hn=parseInt("10000000",2),Va=parseInt("01111111",2),Go={0:Me,1:Me,2:za,3:ja,4:Za,5:Ga,6:Fa,16:Me,22:Me,48:Me};function Ct(r,t={offset:0}){let e=r[t.offset]&qa;if(t.offset++,Go[e]!=null)return Go[e](r,t);throw new Error("No decoder for tag "+e)}function qe(r,t){let e=0;if((r[t.offset]&hn)===hn){let n=r[t.offset]&Va,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=r[t.offset].toString(16).padStart(2,"0");e=parseInt(o,16)}else e=r[t.offset],t.offset++;return e}function Me(r,t){qe(r,t);let e=[];for(;!(t.offset>=r.byteLength);){let n=Ct(r,t);if(n===null)break;e.push(n)}return e}function za(r,t){let e=qe(r,t),n=t.offset,o=t.offset+e,s=[];for(let i=n;i<o;i++)i===n&&r[i]===0||s.push(r[i]);return t.offset+=e,Uint8Array.from(s)}function Fa(r,t){let e=qe(r,t),n=t.offset+e,o=r[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let l=r[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let u=0;for(let d=0;d<c.length;d++)u+=c[d]<<d*7;a+=`.${u}`,c=[]}}return a}function Ga(r,t){return t.offset++,null}function ja(r,t){let e=qe(r,t),n=r[t.offset];t.offset++;let o=r.subarray(t.offset,t.offset+e-1);if(t.offset+=e,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Za(r,t){let e=qe(r,t),n=r.subarray(t.offset,t.offset+e);return t.offset+=e,n}function Wa(r){let t=r.toString(16);t.length%2===1&&(t="0"+t);let e=new et;for(let n=0;n<t.length;n+=2)e.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return e}function dn(r){if(r.byteLength<128)return Uint8Array.from([r.byteLength]);let t=Wa(r.byteLength);return new et(Uint8Array.from([t.byteLength|hn]),t)}function bt(r){let t=new et,e=128;return(r.subarray()[0]&e)===e&&t.append(Uint8Array.from([0])),t.append(r),new et(Uint8Array.from([2]),dn(t),t)}function ur(r){let t=Uint8Array.from([0]),e=new et(t,r);return new et(Uint8Array.from([3]),dn(e),e)}function Ft(r,t=48){let e=new et;for(let n of r)e.append(n);return new et(Uint8Array.from([t]),dn(e),e)}var jo="1.2.840.10045.3.1.7",Zo="1.3.132.0.34",Wo="1.3.132.0.35";async function Yo(r,t,e,n){let o=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:r.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,e.subarray());return n?.signal?.throwIfAborted(),s}var Ya=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Xa=Uint8Array.from([6,5,43,129,4,0,34]),$a=Uint8Array.from([6,5,43,129,4,0,35]),Ja={ext:!0,kty:"EC",crv:"P-256"},Qa={ext:!0,kty:"EC",crv:"P-384"},tc={ext:!0,kty:"EC",crv:"P-521"},pn=32,mn=48,yn=66;function Xo(r){let t=r[1][1][0],e=1,n,o;if(t.byteLength===pn*2+1)return n=W(t.subarray(e,e+pn),"base64url"),o=W(t.subarray(e+pn),"base64url"),new ge({...Ja,key_ops:["verify"],x:n,y:o});if(t.byteLength===mn*2+1)return n=W(t.subarray(e,e+mn),"base64url"),o=W(t.subarray(e+mn),"base64url"),new ge({...Qa,key_ops:["verify"],x:n,y:o});if(t.byteLength===yn*2+1)return n=W(t.subarray(e,e+yn),"base64url"),o=W(t.subarray(e+yn),"base64url"),new ge({...tc,key_ops:["verify"],x:n,y:o});throw new tt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function $o(r){return Ft([bt(Uint8Array.from([1])),Ft([ec(r.crv)],160),Ft([ur(new et(Uint8Array.from([4]),$(r.x??"","base64url"),$(r.y??"","base64url")))],161)]).subarray()}function ec(r){if(r==="P-256")return Ya;if(r==="P-384")return Xa;if(r==="P-521")return $a;throw new tt(`Invalid curve ${r}`)}var ge=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=$o(this.jwk)),this._raw}toMultihash(){return _t.digest(Ee(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ut(this.raw,t.raw)}async verify(t,e,n){return Yo(this.jwk,e,t,n)}};var Qt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function rc(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function fr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function te(r,...t){if(!rc(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Jo(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");fr(r.outputLen),fr(r.blockLen)}function Ae(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Qo(r,t){te(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}function Kt(...r){for(let t=0;t<r.length;t++)r[t].fill(0)}function lr(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function It(r,t){return r<<32-t|r>>>t}function ts(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}function Ve(r){return typeof r=="string"&&(r=ts(r)),te(r),r}function bn(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];te(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Se=class{};function xn(r){let t=n=>r().update(Ve(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function hr(r=32){if(Qt&&typeof Qt.getRandomValues=="function")return Qt.getRandomValues(new Uint8Array(r));if(Qt&&typeof Qt.randomBytes=="function")return Uint8Array.from(Qt.randomBytes(r));throw new Error("crypto.getRandomValues must be defined")}function nc(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(e>>o&s),a=Number(e&s),c=n?4:0,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}function es(r,t,e){return r&t^~r&e}function rs(r,t,e){return r&t^r&e^t&e}var ze=class extends Se{constructor(t,e,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=lr(this.buffer)}update(t){Ae(this),t=Ve(t),te(t);let{view:e,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=lr(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ae(this),Qo(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;e[i++]=128,Kt(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let d=i;d<o;d++)e[d]=0;nc(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=lr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,u[d],s)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}},Pt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var it=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var dr=BigInt(4294967295),ns=BigInt(32);function oc(r,t=!1){return t?{h:Number(r&dr),l:Number(r>>ns&dr)}:{h:Number(r>>ns&dr)|0,l:Number(r&dr)|0}}function os(r,t=!1){let e=r.length,n=new Uint32Array(e),o=new Uint32Array(e);for(let s=0;s<e;s++){let{h:i,l:a}=oc(r[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var wn=(r,t,e)=>r>>>e,gn=(r,t,e)=>r<<32-e|t>>>e,ee=(r,t,e)=>r>>>e|t<<32-e,re=(r,t,e)=>r<<32-e|t>>>e,Fe=(r,t,e)=>r<<64-e|t>>>e-32,Ge=(r,t,e)=>r>>>e-32|t<<64-e;function Tt(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var ss=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),is=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,as=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),cs=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,us=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),fs=(r,t,e,n,o,s)=>t+e+n+o+s+(r/2**32|0)|0;var ic=Uint32Array.from([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]),Gt=new Uint32Array(64),pr=class extends ze{constructor(t=32){super(64,t,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:e,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,e,n,o,s,i,a,c]}set(t,e,n,o,s,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let d=0;d<16;d++,e+=4)Gt[d]=t.getUint32(e,!1);for(let d=16;d<64;d++){let E=Gt[d-15],L=Gt[d-2],A=It(E,7)^It(E,18)^E>>>3,y=It(L,17)^It(L,19)^L>>>10;Gt[d]=y+Gt[d-7]+A+Gt[d-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){let E=It(a,6)^It(a,11)^It(a,25),L=u+E+es(a,c,l)+ic[d]+Gt[d]|0,y=(It(n,2)^It(n,13)^It(n,22))+rs(n,o,s)|0;u=l,l=c,c=a,a=i+L|0,i=s,s=o,o=n,n=L+y|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,s,i,a,c,l,u)}roundClean(){Kt(Gt)}destroy(){this.set(0,0,0,0,0,0,0,0),Kt(this.buffer)}};var ls=os(["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(r=>BigInt(r))),ac=ls[0],cc=ls[1],jt=new Uint32Array(80),Zt=new Uint32Array(80),En=class extends ze{constructor(t=64){super(128,t,16,!1),this.Ah=it[0]|0,this.Al=it[1]|0,this.Bh=it[2]|0,this.Bl=it[3]|0,this.Ch=it[4]|0,this.Cl=it[5]|0,this.Dh=it[6]|0,this.Dl=it[7]|0,this.Eh=it[8]|0,this.El=it[9]|0,this.Fh=it[10]|0,this.Fl=it[11]|0,this.Gh=it[12]|0,this.Gl=it[13]|0,this.Hh=it[14]|0,this.Hl=it[15]|0}get(){let{Ah:t,Al:e,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:l,El:u,Fh:d,Fl:E,Gh:L,Gl:A,Hh:y,Hl:U}=this;return[t,e,n,o,s,i,a,c,l,u,d,E,L,A,y,U]}set(t,e,n,o,s,i,a,c,l,u,d,E,L,A,y,U){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=E|0,this.Gh=L|0,this.Gl=A|0,this.Hh=y|0,this.Hl=U|0}process(t,e){for(let S=0;S<16;S++,e+=4)jt[S]=t.getUint32(e),Zt[S]=t.getUint32(e+=4);for(let S=16;S<80;S++){let f=jt[S-15]|0,m=Zt[S-15]|0,v=ee(f,m,1)^ee(f,m,8)^wn(f,m,7),B=re(f,m,1)^re(f,m,8)^gn(f,m,7),I=jt[S-2]|0,R=Zt[S-2]|0,k=ee(I,R,19)^Fe(I,R,61)^wn(I,R,6),C=re(I,R,19)^Ge(I,R,61)^gn(I,R,6),P=as(B,C,Zt[S-7],Zt[S-16]),D=cs(P,v,k,jt[S-7],jt[S-16]);jt[S]=D|0,Zt[S]=P|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:l,Dl:u,Eh:d,El:E,Fh:L,Fl:A,Gh:y,Gl:U,Hh:K,Hl:V}=this;for(let S=0;S<80;S++){let f=ee(d,E,14)^ee(d,E,18)^Fe(d,E,41),m=re(d,E,14)^re(d,E,18)^Ge(d,E,41),v=d&L^~d&y,B=E&A^~E&U,I=us(V,m,B,cc[S],Zt[S]),R=fs(I,K,f,v,ac[S],jt[S]),k=I|0,C=ee(n,o,28)^Fe(n,o,34)^Fe(n,o,39),P=re(n,o,28)^Ge(n,o,34)^Ge(n,o,39),D=n&s^n&a^s&a,J=o&i^o&c^i&c;K=y|0,V=U|0,y=L|0,U=A|0,L=d|0,A=E|0,{h:d,l:E}=Tt(l|0,u|0,R|0,k|0),l=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let w=ss(k,P,J);n=is(w,R,C,D),o=w|0}({h:n,l:o}=Tt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Tt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=Tt(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=Tt(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:E}=Tt(this.Eh|0,this.El|0,d|0,E|0),{h:L,l:A}=Tt(this.Fh|0,this.Fl|0,L|0,A|0),{h:y,l:U}=Tt(this.Gh|0,this.Gl|0,y|0,U|0),{h:K,l:V}=Tt(this.Hh|0,this.Hl|0,K|0,V|0),this.set(n,o,s,i,a,c,l,u,d,E,L,A,y,U,K,V)}roundClean(){Kt(jt,Zt)}destroy(){Kt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var mr=xn(()=>new pr);var hs=xn(()=>new En);var Bn=BigInt(0),vn=BigInt(1);function ve(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function In(r){if(!ve(r))throw new Error("Uint8Array expected")}function Dt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}function je(r){let t=r.toString(16);return t.length&1?"0"+t:t}function ms(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Bn:BigInt("0x"+r)}var ys=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",uc=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Wt(r){if(In(r),ys)return r.toHex();let t="";for(let e=0;e<r.length;e++)t+=uc[r[e]];return t}var Nt={_0:48,_9:57,A:65,F:70,a:97,f:102};function ds(r){if(r>=Nt._0&&r<=Nt._9)return r-Nt._0;if(r>=Nt.A&&r<=Nt.F)return r-(Nt.A-10);if(r>=Nt.a&&r<=Nt.f)return r-(Nt.a-10)}function Ze(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);if(ys)return Uint8Array.fromHex(r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,s=0;o<e;o++,s+=2){let i=ds(r.charCodeAt(s)),a=ds(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function kt(r){return ms(Wt(r))}function ne(r){return In(r),ms(Wt(Uint8Array.from(r).reverse()))}function oe(r,t){return Ze(r.toString(16).padStart(t*2,"0"))}function Be(r,t){return oe(r,t).reverse()}function G(r,t,e){let n;if(typeof t=="string")try{n=Ze(t)}catch(s){throw new Error(r+" must be hex string or Uint8Array, cause: "+s)}else if(ve(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function Yt(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];In(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let s=r[n];e.set(s,o),o+=s.length}return e}var Sn=r=>typeof r=="bigint"&&Bn<=r;function yr(r,t,e){return Sn(r)&&Sn(t)&&Sn(e)&&t<=r&&r<e}function gt(r,t,e,n){if(!yr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function bs(r){let t;for(t=0;r>Bn;r>>=vn,t+=1);return t}var se=r=>(vn<<BigInt(r))-vn,An=r=>new Uint8Array(r),ps=r=>Uint8Array.from(r);function xs(r,t,e){if(typeof r!="number"||r<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 e!="function")throw new Error("hmacFn must be a function");let n=An(r),o=An(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...d)=>e(o,n,...d),c=(d=An(0))=>{o=a(ps([0]),d),n=a(),d.length!==0&&(o=a(ps([1]),d),n=a())},l=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let d=0,E=[];for(;d<t;){n=a();let L=n.slice();E.push(L),d+=n.length}return Yt(...E)};return(d,E)=>{i(),c(d);let L;for(;!(L=E(l()));)c();return i(),L}}var fc={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ve(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Ot(r,t,e={}){let n=(o,s,i)=>{let a=fc[s];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+s+", got "+c)};for(let[o,s]of Object.entries(t))n(o,s,!1);for(let[o,s]of Object.entries(e))n(o,s,!0);return r}function Ie(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let s=r(e,...n);return t.set(e,s),s}}var ht=BigInt(0),nt=BigInt(1),ie=BigInt(2),lc=BigInt(3),gs=BigInt(4),Es=BigInt(5),Ss=BigInt(8);function F(r,t){let e=r%t;return e>=ht?e:t+e}function j(r,t,e){let n=r;for(;t-- >ht;)n*=n,n%=e;return n}function br(r,t){if(r===ht)throw new Error("invert: expected non-zero number");if(t<=ht)throw new Error("invert: expected positive modulus, got "+t);let e=F(r,t),n=t,o=ht,s=nt,i=nt,a=ht;for(;e!==ht;){let l=n/e,u=n%e,d=o-i*l,E=s-a*l;n=e,e=u,o=i,s=a,i=d,a=E}if(n!==nt)throw new Error("invert: does not exist");return F(o,t)}function As(r,t){let e=(r.ORDER+nt)/gs,n=r.pow(t,e);if(!r.eql(r.sqr(n),t))throw new Error("Cannot find square root");return n}function hc(r,t){let e=(r.ORDER-Es)/Ss,n=r.mul(t,ie),o=r.pow(n,e),s=r.mul(t,o),i=r.mul(r.mul(s,ie),o),a=r.mul(s,r.sub(i,r.ONE));if(!r.eql(r.sqr(a),t))throw new Error("Cannot find square root");return a}function dc(r){if(r<BigInt(3))throw new Error("sqrt is not defined for small field");let t=r-nt,e=0;for(;t%ie===ht;)t/=ie,e++;let n=ie,o=Ht(r);for(;ws(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return As;let s=o.pow(n,t),i=(t+nt)/ie;return function(c,l){if(c.is0(l))return l;if(ws(c,l)!==1)throw new Error("Cannot find square root");let u=e,d=c.mul(c.ONE,s),E=c.pow(l,t),L=c.pow(l,i);for(;!c.eql(E,c.ONE);){if(c.is0(E))return c.ZERO;let A=1,y=c.sqr(E);for(;!c.eql(y,c.ONE);)if(A++,y=c.sqr(y),A===u)throw new Error("Cannot find square root");let U=nt<<BigInt(u-A-1),K=c.pow(d,U);u=A,d=c.sqr(K),E=c.mul(E,d),L=c.mul(L,K)}return L}}function pc(r){return r%gs===lc?As:r%Ss===Es?hc:dc(r)}var vs=(r,t)=>(F(r,t)&nt)===nt,mc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ln(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=mc.reduce((n,o)=>(n[o]="function",n),t);return Ot(r,e)}function yc(r,t,e){if(e<ht)throw new Error("invalid exponent, negatives unsupported");if(e===ht)return r.ONE;if(e===nt)return t;let n=r.ONE,o=t;for(;e>ht;)e&nt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=nt;return n}function Le(r,t,e=!1){let n=new Array(t.length).fill(e?r.ZERO:void 0),o=t.reduce((i,a,c)=>r.is0(a)?i:(n[c]=i,r.mul(i,a)),r.ONE),s=r.inv(o);return t.reduceRight((i,a,c)=>r.is0(a)?i:(n[c]=r.mul(i,n[c]),r.mul(i,a)),s),n}function ws(r,t){let e=(r.ORDER-nt)/ie,n=r.pow(t,e),o=r.eql(n,r.ONE),s=r.eql(n,r.ZERO),i=r.eql(n,r.neg(r.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function _n(r,t){t!==void 0&&fr(t);let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Ht(r,t,e=!1,n={}){if(r<=ht)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:s}=_n(r,t);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:s,MASK:se(o),ZERO:ht,ONE:nt,create:c=>F(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ht<=c&&c<r},is0:c=>c===ht,isOdd:c=>(c&nt)===nt,neg:c=>F(-c,r),eql:(c,l)=>c===l,sqr:c=>F(c*c,r),add:(c,l)=>F(c+l,r),sub:(c,l)=>F(c-l,r),mul:(c,l)=>F(c*l,r),pow:(c,l)=>yc(a,c,l),div:(c,l)=>F(c*br(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>br(c,r),sqrt:n.sqrt||(c=>(i||(i=pc(r)),i(a,c))),toBytes:c=>e?Be(c,s):oe(c,s),fromBytes:c=>{if(c.length!==s)throw new Error("Field.fromBytes: expected "+s+" bytes, got "+c.length);return e?ne(c):kt(c)},invertBatch:c=>Le(a,c),cmov:(c,l,u)=>u?l:c});return Object.freeze(a)}function Bs(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Cn(r){let t=Bs(r);return t+Math.ceil(t/2)}function Is(r,t,e=!1){let n=r.length,o=Bs(t),s=Cn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=e?ne(r):kt(r),a=F(i,t-nt)+nt;return e?Be(a,o):oe(a,o)}var Ls=BigInt(0),Kn=BigInt(1);function Tn(r,t){let e=t.negate();return r?e:t}function Cs(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Dn(r,t){Cs(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1),o=2**r,s=se(r),i=BigInt(r);return{windows:e,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function _s(r,t,e){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=e,a=Number(r&o),c=r>>i;a>n&&(a-=s,c+=Kn);let l=t*n,u=l+Math.abs(a)-1,d=a===0,E=a<0,L=t%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:E,isNegF:L,offsetF:l}}function bc(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function xc(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Rn=new WeakMap,Ts=new WeakMap;function Un(r){return Ts.get(r)||1}function xr(r,t){return{constTimeNegate:Tn,hasPrecomputes(e){return Un(e)!==1},unsafeLadder(e,n,o=r.ZERO){let s=e;for(;n>Ls;)n&Kn&&(o=o.add(s)),s=s.double(),n>>=Kn;return o},precomputeWindow(e,n){let{windows:o,windowSize:s}=Dn(n,t),i=[],a=e,c=a;for(let l=0;l<o;l++){c=a,i.push(c);for(let u=1;u<s;u++)c=c.add(a),i.push(c);a=c.double()}return i},wNAF(e,n,o){let s=r.ZERO,i=r.BASE,a=Dn(e,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:u,isZero:d,isNeg:E,isNegF:L,offsetF:A}=_s(o,c,a);o=l,d?i=i.add(Tn(L,n[A])):s=s.add(Tn(E,n[u]))}return{p:s,f:i}},wNAFUnsafe(e,n,o,s=r.ZERO){let i=Dn(e,t);for(let a=0;a<i.windows&&o!==Ls;a++){let{nextN:c,offset:l,isZero:u,isNeg:d}=_s(o,a,i);if(o=c,!u){let E=n[l];s=s.add(d?E.negate():E)}}return s},getPrecomputes(e,n,o){let s=Rn.get(n);return s||(s=this.precomputeWindow(n,e),e!==1&&Rn.set(n,o(s))),s},wNAFCached(e,n,o){let s=Un(e);return this.wNAF(s,this.getPrecomputes(s,e,o),n)},wNAFCachedUnsafe(e,n,o,s){let i=Un(e);return i===1?this.unsafeLadder(e,n,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,o),n,s)},setWindowSize(e,n){Cs(n,t),Ts.set(e,n),Rn.delete(e)}}}function wr(r,t,e,n){bc(e,r),xc(n,t);let o=e.length,s=n.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,a=bs(BigInt(o)),c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);let l=se(c),u=new Array(Number(l)+1).fill(i),d=Math.floor((t.BITS-1)/c)*c,E=i;for(let L=d;L>=0;L-=c){u.fill(i);for(let y=0;y<s;y++){let U=n[y],K=Number(U>>BigInt(L)&l);u[K]=u[K].add(e[y])}let A=i;for(let y=u.length-1,U=i;y>0;y--)U=U.add(u[y]),A=A.add(U);if(E=E.add(A),L!==0)for(let y=0;y<c;y++)E=E.double()}return E}function We(r){return Ln(r.Fp),Ot(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({..._n(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Rt=BigInt(0),dt=BigInt(1),Ds=BigInt(2),wc=BigInt(8),gc={zip215:!0};function Ec(r){let t=We(r);return Ot(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Rs(r){let t=Ec(r),{Fp:e,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=t,l=Ds<<BigInt(a*8)-dt,u=e.create,d=Ht(t.n,t.nBitLength);function E(b,h){let p=e.sqr(b),g=e.sqr(h),T=e.add(e.mul(t.a,p),g),N=e.add(e.ONE,e.mul(t.d,e.mul(p,g)));return e.eql(T,N)}if(!E(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let L=t.uvRatio||((b,h)=>{try{return{isValid:!0,value:e.sqrt(b*e.inv(h))}}catch{return{isValid:!1,value:Rt}}}),A=t.adjustScalarBytes||(b=>b),y=t.domain||((b,h,p)=>{if(Dt("phflag",p),h.length||p)throw new Error("Contexts/pre-hash are not supported");return b});function U(b,h,p=!1){let g=p?dt:Rt;gt("coordinate "+b,h,g,l)}function K(b){if(!(b instanceof f))throw new Error("ExtendedPoint expected")}let V=Ie((b,h)=>{let{ex:p,ey:g,ez:T}=b,N=b.is0();h==null&&(h=N?wc:e.inv(T));let O=u(p*h),H=u(g*h),M=u(T*h);if(N)return{x:Rt,y:dt};if(M!==dt)throw new Error("invZ was invalid");return{x:O,y:H}}),S=Ie(b=>{let{a:h,d:p}=t;if(b.is0())throw new Error("bad point: ZERO");let{ex:g,ey:T,ez:N,et:O}=b,H=u(g*g),M=u(T*T),z=u(N*N),Q=u(z*z),Y=u(H*h),st=u(z*u(Y+M)),pt=u(Q+u(p*u(H*M)));if(st!==pt)throw new Error("bad point: equation left != right (1)");let rt=u(g*T),at=u(N*O);if(rt!==at)throw new Error("bad point: equation left != right (2)");return!0});class f{constructor(h,p,g,T){U("x",h),U("y",p),U("z",g,!0),U("t",T),this.ex=h,this.ey=p,this.ez=g,this.et=T,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(h){if(h instanceof f)throw new Error("extended point not allowed");let{x:p,y:g}=h||{};return U("x",p),U("y",g),new f(p,g,dt,u(p*g))}static normalizeZ(h){let p=Le(e,h.map(g=>g.ez));return h.map((g,T)=>g.toAffine(p[T])).map(f.fromAffine)}static msm(h,p){return wr(f,d,h,p)}_setWindowSize(h){B.setWindowSize(this,h)}assertValidity(){S(this)}equals(h){K(h);let{ex:p,ey:g,ez:T}=this,{ex:N,ey:O,ez:H}=h,M=u(p*H),z=u(N*T),Q=u(g*H),Y=u(O*T);return M===z&&Q===Y}is0(){return this.equals(f.ZERO)}negate(){return new f(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:h}=t,{ex:p,ey:g,ez:T}=this,N=u(p*p),O=u(g*g),H=u(Ds*u(T*T)),M=u(h*N),z=p+g,Q=u(u(z*z)-N-O),Y=M+O,st=Y-H,pt=M-O,rt=u(Q*st),at=u(Y*pt),wt=u(Q*pt),At=u(st*Y);return new f(rt,at,At,wt)}add(h){K(h);let{a:p,d:g}=t,{ex:T,ey:N,ez:O,et:H}=this,{ex:M,ey:z,ez:Q,et:Y}=h,st=u(T*M),pt=u(N*z),rt=u(H*g*Y),at=u(O*Q),wt=u((T+N)*(M+z)-st-pt),At=at-rt,Ue=at+rt,Eo=u(pt-p*st),Ii=u(wt*At),Li=u(Ue*Eo),_i=u(wt*Eo),Ci=u(At*Ue);return new f(Ii,Li,Ci,_i)}subtract(h){return this.add(h.negate())}wNAF(h){return B.wNAFCached(this,h,f.normalizeZ)}multiply(h){let p=h;gt("scalar",p,dt,n);let{p:g,f:T}=this.wNAF(p);return f.normalizeZ([g,T])[0]}multiplyUnsafe(h,p=f.ZERO){let g=h;return gt("scalar",g,Rt,n),g===Rt?v:this.is0()||g===dt?this:B.wNAFCachedUnsafe(this,g,f.normalizeZ,p)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return B.unsafeLadder(this,n).is0()}toAffine(h){return V(this,h)}clearCofactor(){let{h}=t;return h===dt?this:this.multiplyUnsafe(h)}static fromHex(h,p=!1){let{d:g,a:T}=t,N=e.BYTES;h=G("pointHex",h,N),Dt("zip215",p);let O=h.slice(),H=h[N-1];O[N-1]=H&-129;let M=ne(O),z=p?l:e.ORDER;gt("pointHex.y",M,Rt,z);let Q=u(M*M),Y=u(Q-dt),st=u(g*Q-T),{isValid:pt,value:rt}=L(Y,st);if(!pt)throw new Error("Point.fromHex: invalid y coordinate");let at=(rt&dt)===dt,wt=(H&128)!==0;if(!p&&rt===Rt&&wt)throw new Error("Point.fromHex: x=0 and x_0=1");return wt!==at&&(rt=u(-rt)),f.fromAffine({x:rt,y:M})}static fromPrivateKey(h){let{scalar:p}=k(h);return m.multiply(p)}toRawBytes(){let{x:h,y:p}=this.toAffine(),g=Be(p,e.BYTES);return g[g.length-1]|=h&dt?128:0,g}toHex(){return Wt(this.toRawBytes())}}f.BASE=new f(t.Gx,t.Gy,dt,u(t.Gx*t.Gy)),f.ZERO=new f(Rt,dt,dt,Rt);let{BASE:m,ZERO:v}=f,B=xr(f,a*8);function I(b){return F(b,n)}function R(b){return I(ne(b))}function k(b){let h=e.BYTES;b=G("private key",b,h);let p=G("hashed private key",s(b),2*h),g=A(p.slice(0,h)),T=p.slice(h,2*h),N=R(g);return{head:g,prefix:T,scalar:N}}function C(b){let{head:h,prefix:p,scalar:g}=k(b),T=m.multiply(g),N=T.toRawBytes();return{head:h,prefix:p,scalar:g,point:T,pointBytes:N}}function P(b){return C(b).pointBytes}function D(b=Uint8Array.of(),...h){let p=Yt(...h);return R(s(y(p,G("context",b),!!o)))}function J(b,h,p={}){b=G("message",b),o&&(b=o(b));let{prefix:g,scalar:T,pointBytes:N}=C(h),O=D(p.context,g,b),H=m.multiply(O).toRawBytes(),M=D(p.context,H,N,b),z=I(O+M*T);gt("signature.s",z,Rt,n);let Q=Yt(H,Be(z,e.BYTES));return G("result",Q,e.BYTES*2)}let w=gc;function x(b,h,p,g=w){let{context:T,zip215:N}=g,O=e.BYTES;b=G("signature",b,2*O),h=G("message",h),p=G("publicKey",p,O),N!==void 0&&Dt("zip215",N),o&&(h=o(h));let H=ne(b.slice(O,2*O)),M,z,Q;try{M=f.fromHex(p,N),z=f.fromHex(b.slice(0,O),N),Q=m.multiplyUnsafe(H)}catch{return!1}if(!N&&M.isSmallOrder())return!1;let Y=D(T,z.toRawBytes(),M.toRawBytes(),h);return z.add(M.multiplyUnsafe(Y)).subtract(Q).clearCofactor().equals(f.ZERO)}return m._setWindowSize(8),{CURVE:t,getPublicKey:P,sign:J,verify:x,ExtendedPoint:f,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>i(e.BYTES),precompute(b=8,h=f.BASE){return h._setWindowSize(b),h.multiply(BigInt(3)),h}}}}var Pn=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Us=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Nl=BigInt(0),Sc=BigInt(1),Ks=BigInt(2),kl=BigInt(3),Ac=BigInt(5),vc=BigInt(8);function Bc(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),s=Pn,a=r*r%s*r%s,c=j(a,Ks,s)*a%s,l=j(c,Sc,s)*r%s,u=j(l,Ac,s)*l%s,d=j(u,t,s)*u%s,E=j(d,e,s)*d%s,L=j(E,n,s)*E%s,A=j(L,o,s)*L%s,y=j(A,o,s)*L%s,U=j(y,t,s)*u%s;return{pow_p_5_8:j(U,Ks,s)*r%s,b2:a}}function Ic(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Lc(r,t){let e=Pn,n=F(t*t*t,e),o=F(n*n*t,e),s=Bc(r*o).pow_p_5_8,i=F(r*n*s,e),a=F(t*i*i,e),c=i,l=F(i*Us,e),u=a===r,d=a===F(-r,e),E=a===F(-r*Us,e);return u&&(i=c),(d||E)&&(i=l),vs(i,e)&&(i=F(-i,e)),{isValid:u||d,value:i}}var Ps=Ht(Pn,void 0,!0),_c={a:Ps.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ps,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:vc,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:hs,randomBytes:hr,adjustScalarBytes:Ic,uvRatio:Lc},Ns=Rs(_c);var Ye=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},gr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var ks={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new gr("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var St=ks;var _e=32;var Nn,Cc=(async()=>{try{return await St.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function Tc(r,t,e){if(r.buffer instanceof ArrayBuffer){let n=await St.get().subtle.importKey("raw",r.buffer,{name:"Ed25519"},!1,["verify"]);return await St.get().subtle.verify({name:"Ed25519"},n,t,e instanceof Uint8Array?e:e.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Dc(r,t,e){return Ns.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}async function Os(r,t,e){return Nn==null&&(Nn=await Cc),Nn?Tc(r,t,e):Dc(r,t,e)}function Er(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}var Sr=class{type="Ed25519";raw;constructor(t){this.raw=kn(t,_e)}toMultihash(){return _t.digest(Ee(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ut(this.raw,t.raw)}verify(t,e,n){n?.signal?.throwIfAborted();let o=Os(this.raw,e,t);return Er(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function qs(r){return r=kn(r,_e),new Sr(r)}function kn(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new tt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}var Rc=Math.pow(2,7),Uc=Math.pow(2,14),Kc=Math.pow(2,21),On=Math.pow(2,28),Hn=Math.pow(2,35),Mn=Math.pow(2,42),qn=Math.pow(2,49),q=128,ft=127;function Mt(r){if(r<Rc)return 1;if(r<Uc)return 2;if(r<Kc)return 3;if(r<On)return 4;if(r<Hn)return 5;if(r<Mn)return 6;if(r<qn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Vn(r,t,e=0){switch(Mt(r)){case 8:t[e++]=r&255|q,r/=128;case 7:t[e++]=r&255|q,r/=128;case 6:t[e++]=r&255|q,r/=128;case 5:t[e++]=r&255|q,r/=128;case 4:t[e++]=r&255|q,r>>>=7;case 3:t[e++]=r&255|q,r>>>=7;case 2:t[e++]=r&255|q,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Pc(r,t,e=0){switch(Mt(r)){case 8:t.set(e++,r&255|q),r/=128;case 7:t.set(e++,r&255|q),r/=128;case 6:t.set(e++,r&255|q),r/=128;case 5:t.set(e++,r&255|q),r/=128;case 4:t.set(e++,r&255|q),r>>>=7;case 3:t.set(e++,r&255|q),r>>>=7;case 2:t.set(e++,r&255|q),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function zn(r,t){let e=r[t],n=0;if(n+=e&ft,e<q||(e=r[t+1],n+=(e&ft)<<7,e<q)||(e=r[t+2],n+=(e&ft)<<14,e<q)||(e=r[t+3],n+=(e&ft)<<21,e<q)||(e=r[t+4],n+=(e&ft)*On,e<q)||(e=r[t+5],n+=(e&ft)*Hn,e<q)||(e=r[t+6],n+=(e&ft)*Mn,e<q)||(e=r[t+7],n+=(e&ft)*qn,e<q))return n;throw new RangeError("Could not decode varint")}function Nc(r,t){let e=r.get(t),n=0;if(n+=e&ft,e<q||(e=r.get(t+1),n+=(e&ft)<<7,e<q)||(e=r.get(t+2),n+=(e&ft)<<14,e<q)||(e=r.get(t+3),n+=(e&ft)<<21,e<q)||(e=r.get(t+4),n+=(e&ft)*On,e<q)||(e=r.get(t+5),n+=(e&ft)*Hn,e<q)||(e=r.get(t+6),n+=(e&ft)*Mn,e<q)||(e=r.get(t+7),n+=(e&ft)*qn,e<q))return n;throw new RangeError("Could not decode varint")}function Vs(r,t,e=0){return t==null&&(t=yt(Mt(r))),t instanceof Uint8Array?Vn(r,t,e):Pc(r,t,e)}function zs(r,t=0){return r instanceof Uint8Array?zn(r,t):Nc(r,t)}var Fn=new Float32Array([-0]),Xt=new Uint8Array(Fn.buffer);function Fs(r,t,e){Fn[0]=r,t[e]=Xt[0],t[e+1]=Xt[1],t[e+2]=Xt[2],t[e+3]=Xt[3]}function Gs(r,t){return Xt[0]=r[t],Xt[1]=r[t+1],Xt[2]=r[t+2],Xt[3]=r[t+3],Fn[0]}var Gn=new Float64Array([-0]),lt=new Uint8Array(Gn.buffer);function js(r,t,e){Gn[0]=r,t[e]=lt[0],t[e+1]=lt[1],t[e+2]=lt[2],t[e+3]=lt[3],t[e+4]=lt[4],t[e+5]=lt[5],t[e+6]=lt[6],t[e+7]=lt[7]}function Zs(r,t){return lt[0]=r[t],lt[1]=r[t+1],lt[2]=r[t+2],lt[3]=r[t+3],lt[4]=r[t+4],lt[5]=r[t+5],lt[6]=r[t+6],lt[7]=r[t+7],Gn[0]}var Oc=BigInt(Number.MAX_SAFE_INTEGER),Hc=BigInt(Number.MIN_SAFE_INTEGER),Et=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+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 e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(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,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ae;if(t<Oc&&t>Hc)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Ws&&(o=0n,++n>Ws&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return ae;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):ae}},ae=new Et(0,0);ae.toBigInt=function(){return 0n};ae.zzEncode=ae.zzDecode=function(){return this};ae.length=function(){return 1};var Ws=4294967296n;function Ys(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Xs(r,t,e){if(e-t<1)return"";let o,s=[],i=0,a;for(;t<e;)a=r[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[t++]&63)<<6|r[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 jn(r,t,e){let n=e,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Lt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Ar(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Zn=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,Lt(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 Lt(this,4);return Ar(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Lt(this,4);return Ar(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Lt(this,4);let t=Gs(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Lt(this,4);let t=Zs(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Lt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Xs(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Lt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Lt(this);while((this.buf[this.pos++]&128)!==0);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 Et(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*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;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Lt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Lt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Lt(this,8);let t=Ar(this.buf,this.pos+=4),e=Ar(this.buf,this.pos+=4);return new Et(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=zn(this.buf,this.pos);return this.pos+=Mt(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 Wn(r){return new Zn(r instanceof Uint8Array?r:r.subarray())}function ce(r,t,e){let n=Wn(r);return t.decode(n,void 0,e)}function Yn(r){let t=r??8192,e=t>>>1,n,o=t;return function(i){if(i<1||i>e)return yt(i);o+i>t&&(n=yt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var ue=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Xn(){}var Jn=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Mc=Yn();function qc(r){return globalThis.Buffer!=null?yt(r):Mc(r)}var $e=class{len;head;tail;states;constructor(){this.len=0,this.head=new ue(Xn,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ue(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Qn((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(vr,10,Et.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Et.fromBigInt(t);return this._push(vr,e.length(),e)}uint64Number(t){return this._push(Vn,Mt(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 e=Et.fromBigInt(t).zzEncode();return this._push(vr,e.length(),e)}sint64Number(t){let e=Et.fromNumber(t).zzEncode();return this._push(vr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push($n,1,t?1:0)}fixed32(t){return this._push(Xe,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Et.fromBigInt(t);return this._push(Xe,4,e.lo)._push(Xe,4,e.hi)}fixed64Number(t){let e=Et.fromNumber(t);return this._push(Xe,4,e.lo)._push(Xe,4,e.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(Fs,4,t)}double(t){return this._push(js,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push($n,1,0):this.uint32(e)._push(zc,e,t)}string(t){let e=Ys(t);return e!==0?this.uint32(e)._push(jn,e,t):this._push($n,1,0)}fork(){return this.states=new Jn(this),this.head=this.tail=new ue(Xn,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 ue(Xn,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=qc(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function $n(r,t,e){t[e]=r&255}function Vc(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Qn=class extends ue{next;constructor(t,e){super(Vc,t,e),this.next=void 0}};function vr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Xe(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function zc(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&($e.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Fc,t,r),this},$e.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Gc,t,r),this});function Fc(r,t,e){t.set(r,e)}function Gc(r,t,e){r.length<40?jn(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set($(r),e)}function to(){return new $e}function fe(r,t){let e=to();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Ce;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Ce||(Ce={}));function Br(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function Je(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return Br("enum",Ce.VARINT,e,n)}function le(r,t){return Br("message",Ce.LENGTH_DELIMITED,r,t)}var xt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(xt||(xt={}));var eo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(eo||(eo={}));(function(r){r.codec=()=>Je(eo)})(xt||(xt={}));var $t;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),xt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=xt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>fe(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})($t||($t={}));var ro;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),xt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=xt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>fe(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(ro||(ro={}));var tr={};mt(tr,{MAX_RSA_KEY_SIZE:()=>no,generateRSAKeyPair:()=>ni,jwkToJWKKeyPair:()=>oi,jwkToPkcs1:()=>Yc,jwkToPkix:()=>ao,jwkToRSAPrivateKey:()=>uo,pkcs1MessageToJwk:()=>so,pkcs1MessageToRSAPrivateKey:()=>co,pkcs1ToJwk:()=>Wc,pkcs1ToRSAPrivateKey:()=>ei,pkixMessageToJwk:()=>io,pkixMessageToRSAPublicKey:()=>Lr,pkixToJwk:()=>Xc,pkixToRSAPublicKey:()=>ri});var Ir=mr;var Te=class{type="RSA";jwk;_raw;_multihash;constructor(t,e){this.jwk=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=tr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return ct.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ut(this.raw,t.raw)}verify(t,e,n){return ti(this.jwk,e,t,n)}},Qe=class{type="RSA";jwk;_raw;publicKey;constructor(t,e){this.jwk=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=tr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ut(this.raw,t.raw)}sign(t,e){return Qs(this.jwk,t,e)}};var no=8192,oo=18,jc=1062,Zc=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function Wc(r){let t=Ct(r);return so(t)}function so(r){return{n:W(r[1],"base64url"),e:W(r[2],"base64url"),d:W(r[3],"base64url"),p:W(r[4],"base64url"),q:W(r[5],"base64url"),dp:W(r[6],"base64url"),dq:W(r[7],"base64url"),qi:W(r[8],"base64url"),kty:"RSA"}}function Yc(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new tt("JWK was missing components");return Ft([bt(Uint8Array.from([0])),bt($(r.n,"base64url")),bt($(r.e,"base64url")),bt($(r.d,"base64url")),bt($(r.p,"base64url")),bt($(r.q,"base64url")),bt($(r.dp,"base64url")),bt($(r.dq,"base64url")),bt($(r.qi,"base64url"))]).subarray()}function Xc(r){let t=Ct(r,{offset:0});return io(t)}function io(r){let t=Ct(r[1],{offset:0});return{kty:"RSA",n:W(t[0],"base64url"),e:W(t[1],"base64url")}}function ao(r){if(r.n==null||r.e==null)throw new tt("JWK was missing components");return Ft([Zc,ur(Ft([bt($(r.n,"base64url")),bt($(r.e,"base64url"))]))]).subarray()}function ei(r){let t=Ct(r);return co(t)}function co(r){let t=so(r);return uo(t)}function ri(r,t){if(r.byteLength>=jc)throw new he("Key size is too large");let e=Ct(r,{offset:0});return Lr(e,r,t)}function Lr(r,t,e){let n=io(r);if(e==null){let o=Ir($t.encode({Type:xt.RSA,Data:t}));e=vt(oo,o)}return new Te(n,e)}function uo(r){if(ii(r)>no)throw new tt("Key size is too large");let t=oi(r),e=Ir($t.encode({Type:xt.RSA,Data:ao(t.publicKey)})),n=vt(oo,e);return new Qe(t.privateKey,new Te(t.publicKey,n))}async function ni(r){if(r>no)throw new tt("Key size is too large");let t=await si(r),e=Ir($t.encode({Type:xt.RSA,Data:ao(t.publicKey)})),n=vt(oo,e);return new Qe(t.privateKey,new Te(t.publicKey,n))}function oi(r){if(r==null)throw new tt("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var ai="1.2.840.113549.1.1.1";async function si(r,t){let e=await St.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await $c(e,t);return{privateKey:n[0],publicKey:n[1]}}async function Qs(r,t,e){let n=await St.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);e?.signal?.throwIfAborted();let o=await St.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return e?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function ti(r,t,e,n){let o=await St.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let s=await St.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,t,e instanceof Uint8Array?e:e.subarray());return n?.signal?.throwIfAborted(),s}async function $c(r,t){if(r.privateKey==null||r.publicKey==null)throw new tt("Private and public key are required");let e=await Promise.all([St.get().subtle.exportKey("jwk",r.privateKey),St.get().subtle.exportKey("jwk",r.publicKey)]);return t?.signal?.throwIfAborted(),e}function ii(r){if(r.kty!=="RSA")throw new tt("invalid key type");if(r.n==null)throw new tt("invalid key modulus");return $(r.n,"base64url").length*8}var _r=class extends Se{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Jo(t);let n=Ve(e);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),Kt(s)}update(t){return Ae(this),this.iHash.update(t),this}digestInto(t){Ae(this),te(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:e,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},fo=(r,t,e)=>new _r(r,t).update(e).digest();fo.create=(r,t)=>new _r(r,t);function ci(r){r.lowS!==void 0&&Dt("lowS",r.lowS),r.prehash!==void 0&&Dt("prehash",r.prehash)}function Jc(r){let t=We(r);Ot(t,{a:"field",b:"field"},{allowInfinityPoint:"boolean",allowedPrivateKeyLengths:"array",clearCofactor:"function",fromBytes:"function",isTorsionFree:"function",toBytes:"function",wrapPrivateKey:"boolean"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endo: CURVE.a must be 0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function')}return Object.freeze({...t})}var po=class extends Error{constructor(t=""){super(t)}},qt={Err:po,_tlv:{encode:(r,t)=>{let{Err:e}=qt;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=je(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let s=n>127?je(o.length/2|128):"";return je(r)+s+o+t},decode(r,t){let{Err:e}=qt,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of l)i=i<<8|u;if(n+=c,i<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=qt;if(r<Vt)throw new t("integer: negative integers are not allowed");let e=je(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=qt;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return kt(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=qt,o=G("signature",r),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=qt,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),s=n+o;return t.encode(48,s)}};function lo(r,t){return Wt(oe(r,t))}var Vt=BigInt(0),ot=BigInt(1),yd=BigInt(2),ho=BigInt(3),Qc=BigInt(4);function tu(r){let t=Jc(r),{Fp:e}=t,n=Ht(t.n,t.nBitLength),o=t.toBytes||((S,f,m)=>{let v=f.toAffine();return Yt(Uint8Array.from([4]),e.toBytes(v.x),e.toBytes(v.y))}),s=t.fromBytes||(S=>{let f=S.subarray(1),m=e.fromBytes(f.subarray(0,e.BYTES)),v=e.fromBytes(f.subarray(e.BYTES,2*e.BYTES));return{x:m,y:v}});function i(S){let{a:f,b:m}=t,v=e.sqr(S),B=e.mul(v,S);return e.add(e.add(B,e.mul(S,f)),m)}function a(S,f){let m=e.sqr(f),v=i(S);return e.eql(m,v)}if(!a(t.Gx,t.Gy))throw new Error("bad curve params: generator point");let c=e.mul(e.pow(t.a,ho),Qc),l=e.mul(e.sqr(t.b),BigInt(27));if(e.is0(e.add(c,l)))throw new Error("bad curve params: a or b");function u(S){return yr(S,ot,t.n)}function d(S){let{allowedPrivateKeyLengths:f,nByteLength:m,wrapPrivateKey:v,n:B}=t;if(f&&typeof S!="bigint"){if(ve(S)&&(S=Wt(S)),typeof S!="string"||!f.includes(S.length))throw new Error("invalid private key");S=S.padStart(m*2,"0")}let I;try{I=typeof S=="bigint"?S:kt(G("private key",S,m))}catch{throw new Error("invalid private key, expected hex or "+m+" bytes, got "+typeof S)}return v&&(I=F(I,B)),gt("private key",I,ot,B),I}function E(S){if(!(S instanceof y))throw new Error("ProjectivePoint expected")}let L=Ie((S,f)=>{let{px:m,py:v,pz:B}=S;if(e.eql(B,e.ONE))return{x:m,y:v};let I=S.is0();f==null&&(f=I?e.ONE:e.inv(B));let R=e.mul(m,f),k=e.mul(v,f),C=e.mul(B,f);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(C,e.ONE))throw new Error("invZ was invalid");return{x:R,y:k}}),A=Ie(S=>{if(S.is0()){if(t.allowInfinityPoint&&!e.is0(S.py))return;throw new Error("bad point: ZERO")}let{x:f,y:m}=S.toAffine();if(!e.isValid(f)||!e.isValid(m))throw new Error("bad point: x or y not FE");if(!a(f,m))throw new Error("bad point: equation left != right");if(!S.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class y{constructor(f,m,v){if(f==null||!e.isValid(f))throw new Error("x required");if(m==null||!e.isValid(m)||e.is0(m))throw new Error("y required");if(v==null||!e.isValid(v))throw new Error("z required");this.px=f,this.py=m,this.pz=v,Object.freeze(this)}static fromAffine(f){let{x:m,y:v}=f||{};if(!f||!e.isValid(m)||!e.isValid(v))throw new Error("invalid affine point");if(f instanceof y)throw new Error("projective point not allowed");let B=I=>e.eql(I,e.ZERO);return B(m)&&B(v)?y.ZERO:new y(m,v,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(f){let m=Le(e,f.map(v=>v.pz));return f.map((v,B)=>v.toAffine(m[B])).map(y.fromAffine)}static fromHex(f){let m=y.fromAffine(s(G("pointHex",f)));return m.assertValidity(),m}static fromPrivateKey(f){return y.BASE.multiply(d(f))}static msm(f,m){return wr(y,n,f,m)}_setWindowSize(f){V.setWindowSize(this,f)}assertValidity(){A(this)}hasEvenY(){let{y:f}=this.toAffine();if(e.isOdd)return!e.isOdd(f);throw new Error("Field doesn't support isOdd")}equals(f){E(f);let{px:m,py:v,pz:B}=this,{px:I,py:R,pz:k}=f,C=e.eql(e.mul(m,k),e.mul(I,B)),P=e.eql(e.mul(v,k),e.mul(R,B));return C&&P}negate(){return new y(this.px,e.neg(this.py),this.pz)}double(){let{a:f,b:m}=t,v=e.mul(m,ho),{px:B,py:I,pz:R}=this,k=e.ZERO,C=e.ZERO,P=e.ZERO,D=e.mul(B,B),J=e.mul(I,I),w=e.mul(R,R),x=e.mul(B,I);return x=e.add(x,x),P=e.mul(B,R),P=e.add(P,P),k=e.mul(f,P),C=e.mul(v,w),C=e.add(k,C),k=e.sub(J,C),C=e.add(J,C),C=e.mul(k,C),k=e.mul(x,k),P=e.mul(v,P),w=e.mul(f,w),x=e.sub(D,w),x=e.mul(f,x),x=e.add(x,P),P=e.add(D,D),D=e.add(P,D),D=e.add(D,w),D=e.mul(D,x),C=e.add(C,D),w=e.mul(I,R),w=e.add(w,w),D=e.mul(w,x),k=e.sub(k,D),P=e.mul(w,J),P=e.add(P,P),P=e.add(P,P),new y(k,C,P)}add(f){E(f);let{px:m,py:v,pz:B}=this,{px:I,py:R,pz:k}=f,C=e.ZERO,P=e.ZERO,D=e.ZERO,J=t.a,w=e.mul(t.b,ho),x=e.mul(m,I),_=e.mul(v,R),b=e.mul(B,k),h=e.add(m,v),p=e.add(I,R);h=e.mul(h,p),p=e.add(x,_),h=e.sub(h,p),p=e.add(m,B);let g=e.add(I,k);return p=e.mul(p,g),g=e.add(x,b),p=e.sub(p,g),g=e.add(v,B),C=e.add(R,k),g=e.mul(g,C),C=e.add(_,b),g=e.sub(g,C),D=e.mul(J,p),C=e.mul(w,b),D=e.add(C,D),C=e.sub(_,D),D=e.add(_,D),P=e.mul(C,D),_=e.add(x,x),_=e.add(_,x),b=e.mul(J,b),p=e.mul(w,p),_=e.add(_,b),b=e.sub(x,b),b=e.mul(J,b),p=e.add(p,b),x=e.mul(_,p),P=e.add(P,x),x=e.mul(g,p),C=e.mul(h,C),C=e.sub(C,x),x=e.mul(h,_),D=e.mul(g,D),D=e.add(D,x),new y(C,P,D)}subtract(f){return this.add(f.negate())}is0(){return this.equals(y.ZERO)}wNAF(f){return V.wNAFCached(this,f,y.normalizeZ)}multiplyUnsafe(f){let{endo:m,n:v}=t;gt("scalar",f,Vt,v);let B=y.ZERO;if(f===Vt)return B;if(this.is0()||f===ot)return this;if(!m||V.hasPrecomputes(this))return V.wNAFCachedUnsafe(this,f,y.normalizeZ);let{k1neg:I,k1:R,k2neg:k,k2:C}=m.splitScalar(f),P=B,D=B,J=this;for(;R>Vt||C>Vt;)R&ot&&(P=P.add(J)),C&ot&&(D=D.add(J)),J=J.double(),R>>=ot,C>>=ot;return I&&(P=P.negate()),k&&(D=D.negate()),D=new y(e.mul(D.px,m.beta),D.py,D.pz),P.add(D)}multiply(f){let{endo:m,n:v}=t;gt("scalar",f,ot,v);let B,I;if(m){let{k1neg:R,k1:k,k2neg:C,k2:P}=m.splitScalar(f),{p:D,f:J}=this.wNAF(k),{p:w,f:x}=this.wNAF(P);D=V.constTimeNegate(R,D),w=V.constTimeNegate(C,w),w=new y(e.mul(w.px,m.beta),w.py,w.pz),B=D.add(w),I=J.add(x)}else{let{p:R,f:k}=this.wNAF(f);B=R,I=k}return y.normalizeZ([B,I])[0]}multiplyAndAddUnsafe(f,m,v){let B=y.BASE,I=(k,C)=>C===Vt||C===ot||!k.equals(B)?k.multiplyUnsafe(C):k.multiply(C),R=I(this,m).add(I(f,v));return R.is0()?void 0:R}toAffine(f){return L(this,f)}isTorsionFree(){let{h:f,isTorsionFree:m}=t;if(f===ot)return!0;if(m)return m(y,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:f,clearCofactor:m}=t;return f===ot?this:m?m(y,this):this.multiplyUnsafe(t.h)}toRawBytes(f=!0){return Dt("isCompressed",f),this.assertValidity(),o(y,this,f)}toHex(f=!0){return Dt("isCompressed",f),Wt(this.toRawBytes(f))}}y.BASE=new y(t.Gx,t.Gy,e.ONE),y.ZERO=new y(e.ZERO,e.ONE,e.ZERO);let{endo:U,nBitLength:K}=t,V=xr(y,U?Math.ceil(K/2):K);return{CURVE:t,ProjectivePoint:y,normPrivateKeyToScalar:d,weierstrassEquation:i,isWithinCurveOrder:u}}function eu(r){let t=We(r);return Ot(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ui(r){let t=eu(r),{Fp:e,n,nByteLength:o,nBitLength:s}=t,i=e.BYTES+1,a=2*e.BYTES+1;function c(w){return F(w,n)}function l(w){return br(w,n)}let{ProjectivePoint:u,normPrivateKeyToScalar:d,weierstrassEquation:E,isWithinCurveOrder:L}=tu({...t,toBytes(w,x,_){let b=x.toAffine(),h=e.toBytes(b.x),p=Yt;return Dt("isCompressed",_),_?p(Uint8Array.from([x.hasEvenY()?2:3]),h):p(Uint8Array.from([4]),h,e.toBytes(b.y))},fromBytes(w){let x=w.length,_=w[0],b=w.subarray(1);if(x===i&&(_===2||_===3)){let h=kt(b);if(!yr(h,ot,e.ORDER))throw new Error("Point is not on curve");let p=E(h),g;try{g=e.sqrt(p)}catch(O){let H=O instanceof Error?": "+O.message:"";throw new Error("Point is not on curve"+H)}let T=(g&ot)===ot;return(_&1)===1!==T&&(g=e.neg(g)),{x:h,y:g}}else if(x===a&&_===4){let h=e.fromBytes(b.subarray(0,e.BYTES)),p=e.fromBytes(b.subarray(e.BYTES,2*e.BYTES));return{x:h,y:p}}else{let h=i,p=a;throw new Error("invalid Point, expected length of "+h+", or uncompressed "+p+", got "+x)}}});function A(w){let x=n>>ot;return w>x}function y(w){return A(w)?c(-w):w}let U=(w,x,_)=>kt(w.slice(x,_));class K{constructor(x,_,b){gt("r",x,ot,n),gt("s",_,ot,n),this.r=x,this.s=_,b!=null&&(this.recovery=b),Object.freeze(this)}static fromCompact(x){let _=o;return x=G("compactSignature",x,_*2),new K(U(x,0,_),U(x,_,2*_))}static fromDER(x){let{r:_,s:b}=qt.toSig(G("DER",x));return new K(_,b)}assertValidity(){}addRecoveryBit(x){return new K(this.r,this.s,x)}recoverPublicKey(x){let{r:_,s:b,recovery:h}=this,p=B(G("msgHash",x));if(h==null||![0,1,2,3].includes(h))throw new Error("recovery id invalid");let g=h===2||h===3?_+t.n:_;if(g>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let T=(h&1)===0?"02":"03",N=u.fromHex(T+lo(g,e.BYTES)),O=l(g),H=c(-p*O),M=c(b*O),z=u.BASE.multiplyAndAddUnsafe(N,H,M);if(!z)throw new Error("point at infinify");return z.assertValidity(),z}hasHighS(){return A(this.s)}normalizeS(){return this.hasHighS()?new K(this.r,c(-this.s),this.recovery):this}toDERRawBytes(){return Ze(this.toDERHex())}toDERHex(){return qt.hexFromSig(this)}toCompactRawBytes(){return Ze(this.toCompactHex())}toCompactHex(){let x=o;return lo(this.r,x)+lo(this.s,x)}}let V={isValidPrivateKey(w){try{return d(w),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let w=Cn(t.n);return Is(t.randomBytes(w),t.n)},precompute(w=8,x=u.BASE){return x._setWindowSize(w),x.multiply(BigInt(3)),x}};function S(w,x=!0){return u.fromPrivateKey(w).toRawBytes(x)}function f(w){if(typeof w=="bigint")return!1;if(w instanceof u)return!0;let _=G("key",w).length,b=e.BYTES,h=b+1,p=2*b+1;if(!(t.allowedPrivateKeyLengths||o===h))return _===h||_===p}function m(w,x,_=!0){if(f(w)===!0)throw new Error("first arg must be private key");if(f(x)===!1)throw new Error("second arg must be public key");return u.fromHex(x).multiply(d(w)).toRawBytes(_)}let v=t.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");let x=kt(w),_=w.length*8-s;return _>0?x>>BigInt(_):x},B=t.bits2int_modN||function(w){return c(v(w))},I=se(s);function R(w){return gt("num < 2^"+s,w,Vt,I),oe(w,o)}function k(w,x,_=C){if(["recovered","canonical"].some(Y=>Y in _))throw new Error("sign() legacy options not supported");let{hash:b,randomBytes:h}=t,{lowS:p,prehash:g,extraEntropy:T}=_;p==null&&(p=!0),w=G("msgHash",w),ci(_),g&&(w=G("prehashed msgHash",b(w)));let N=B(w),O=d(x),H=[R(O),R(N)];if(T!=null&&T!==!1){let Y=T===!0?h(e.BYTES):T;H.push(G("extraEntropy",Y))}let M=Yt(...H),z=N;function Q(Y){let st=v(Y);if(!L(st))return;let pt=l(st),rt=u.BASE.multiply(st).toAffine(),at=c(rt.x);if(at===Vt)return;let wt=c(pt*c(z+at*O));if(wt===Vt)return;let At=(rt.x===at?0:2)|Number(rt.y&ot),Ue=wt;return p&&A(wt)&&(Ue=y(wt),At^=1),new K(at,Ue,At)}return{seed:M,k2sig:Q}}let C={lowS:t.lowS,prehash:!1},P={lowS:t.lowS,prehash:!1};function D(w,x,_=C){let{seed:b,k2sig:h}=k(w,x,_),p=t;return xs(p.hash.outputLen,p.nByteLength,p.hmac)(b,h)}u.BASE._setWindowSize(8);function J(w,x,_,b=P){let h=w;x=G("msgHash",x),_=G("publicKey",_);let{lowS:p,prehash:g,format:T}=b;if(ci(b),"strict"in b)throw new Error("options.strict was renamed to lowS");if(T!==void 0&&T!=="compact"&&T!=="der")throw new Error("format must be compact or der");let N=typeof h=="string"||ve(h),O=!N&&!T&&typeof h=="object"&&h!==null&&typeof h.r=="bigint"&&typeof h.s=="bigint";if(!N&&!O)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let H,M;try{if(O&&(H=new K(h.r,h.s)),N){try{T!=="compact"&&(H=K.fromDER(h))}catch(At){if(!(At instanceof qt.Err))throw At}!H&&T!=="der"&&(H=K.fromCompact(h))}M=u.fromHex(_)}catch{return!1}if(!H||p&&H.hasHighS())return!1;g&&(x=t.hash(x));let{r:z,s:Q}=H,Y=B(x),st=l(Q),pt=c(Y*st),rt=c(z*st),at=u.BASE.multiplyAndAddUnsafe(M,pt,rt)?.toAffine();return at?c(at.x)===z:!1}return{CURVE:t,getPublicKey:S,getSharedSecret:m,sign:D,verify:J,ProjectivePoint:u,Signature:K,utils:V}}function ru(r){return{hash:r,hmac:(t,...e)=>fo(r,t,bn(...e)),randomBytes:hr}}function fi(r,t){let e=n=>ui({...r,...ru(n)});return{...e(t),create:e}}var di=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),li=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),nu=BigInt(0),ou=BigInt(1),mo=BigInt(2),hi=(r,t)=>(r+t/mo)/t;function su(r){let t=di,e=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,u=l*l*r%t,d=j(u,e,t)*u%t,E=j(d,e,t)*u%t,L=j(E,mo,t)*l%t,A=j(L,o,t)*L%t,y=j(A,s,t)*A%t,U=j(y,a,t)*y%t,K=j(U,c,t)*U%t,V=j(K,a,t)*y%t,S=j(V,e,t)*u%t,f=j(S,i,t)*A%t,m=j(f,n,t)*l%t,v=j(m,mo,t);if(!yo.eql(yo.sqr(v),r))throw new Error("Cannot find square root");return v}var yo=Ht(di,void 0,void 0,{sqrt:su}),De=fi({a:nu,b:BigInt(7),Fp:yo,n:li,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=li,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ou*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=e,i=BigInt("0x100000000000000000000000000000000"),a=hi(s*r,t),c=hi(-n*r,t),l=F(r-a*e-c*o,t),u=F(-a*n-c*s,t),d=l>i,E=u>i;if(d&&(l=t-l),E&&(u=t-u),l>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:d,k1:l,k2neg:E,k2:u}}}},mr);var pi=33;function mi(r,t,e,n){let o=ar.digest(e instanceof Uint8Array?e:e.subarray());if(Er(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),De.verify(t,s,r))).catch(s=>{throw s.name==="AbortError"?s:new Ye(String(s))});try{return n?.signal?.throwIfAborted(),De.verify(t,o.digest,r)}catch(s){throw new Ye(String(s))}}var Cr=class{type="secp256k1";raw;_key;constructor(t){this._key=bi(t),this.raw=yi(this._key)}toMultihash(){return _t.digest(Ee(this))}toCID(){return ct.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ut(this.raw,t.raw)}verify(t,e,n){return mi(this._key,e,t,n)}};function xi(r){return new Cr(r)}function yi(r){return De.ProjectivePoint.fromHex(r).toRawBytes(!0)}function bi(r){try{return De.ProjectivePoint.fromHex(r),r}catch(t){throw new he(String(t))}}function wi(r){if(r.byteLength===_e)return qs(r);if(r.byteLength===pi)return xi(r);let t=Ct(r),e=t[1]?.[0];if(e===jo||e===Zo||e===Wo)return Xo(t);if(t[0]?.[0]===ai)return Lr(t,r);throw new tt("Could not extract public key from raw bytes")}function Ee(r){return $t.encode({Type:xt[r.type],Data:r.raw})}var gi=Symbol.for("nodejs.util.inspect.custom"),iu=114,er=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()})`}[qr]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ct.createV1(iu,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ut(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ut(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[gi](){return`PeerId(${this.toString()})`}},Tr=class extends er{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Dr=class extends er{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Rr=class extends er{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},au=2336,bo=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=_t.digest($(this.url))}[gi](){return`PeerId(${this.url})`}[qr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ct.createV1(au,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=W(t)),t.toString()===this.toString())}};function Ei(r){if(r.type==="Ed25519")return new Dr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Rr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new Tr({multihash:r.toCID().multihash,publicKey:r});throw new Pe}function Re(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Ur=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function rr(r,t,e){if(t==null)return r;if(t.aborted)return r.catch(()=>{}),Promise.reject(new Ur(e?.errorMessage,e?.errorCode,e?.errorName));let n,o=new Ur(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((s,i)=>{n=()=>{i(o)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var xo=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=Re(),this.haveNext=Re()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Re(),t}async throw(t){return this.ended=!0,this.error=t,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return this.ended=!0,this.nextResult=t,this.haveNext.resolve(),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Re(),await rr(this.readNext.promise,e?.signal,e)}};function Si(){return new xo}var Kr=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};function Ai(r,t){let e=Si();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let a of i)await e.push(a);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let o=new et;return{read:async i=>{if(i?.signal?.throwIfAborted(),i?.bytes==null){let{done:c,value:l}=await rr(n.next(),i?.signal);return c===!0?null:l}for(;o.byteLength<i.bytes;){let{value:c,done:l}=await rr(n.next(),i?.signal);if(l===!0)throw new Kr("unexpected end of input");o.append(c)}let a=o.sublist(0,i.bytes);return o.consume(i.bytes),a},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,a):await e.push(i.subarray(),a)},unwrap:()=>{if(o.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield o:yield*o,yield*i}()}return r}}}var Pr=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Nr=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},kr=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function vi(r,t={}){let e=Ai(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=Mt(t.maxDataLength));let n=t?.lengthDecoder??zs,o=t?.lengthEncoder??Vs;return{read:async i=>{let a=-1,c=new et;for(;;){c.append(await e.read({...i,bytes:1}));try{a=n(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(a<0)throw new Pr("Invalid message length");if(t?.maxLengthLength!=null&&c.byteLength>t.maxLengthLength)throw new kr("message length length too long");if(a>-1)break}if(t?.maxDataLength!=null&&a>t.maxDataLength)throw new Nr("message length too long");return e.read({...i,bytes:a})},write:async(i,a)=>{await e.write(new et(o(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new et(...i.flatMap(l=>[o(l.byteLength),l]));await e.write(c,a)},unwrap:()=>e.unwrap()}}function Bi(r,t){let e=vi(r,t),n={read:async(o,s)=>{let i=await e.read(s);return o.decode(i)},write:async(o,s,i)=>{await e.write(s.encode(o),i)},writeV:async(o,s,i)=>{await e.writeV(o.map(a=>s.encode(a)),i)},pb:o=>({read:async s=>n.read(o,s),write:async(s,i)=>n.write(s,o,i),writeV:async(s,i)=>n.writeV(s,o,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var Or;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.id!=null&&(n.uint32(10),n.bytes(e.id)),e.pubkey!=null&&(n.uint32(18),Hr.codec().encode(e.pubkey,n)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.id=e.bytes();break}case 2:{s.pubkey=Hr.codec().decode(e,e.uint32(),{limits:o.limits?.pubkey});break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>fe(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(Or||(Or={}));var Jt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1",r.ECDSA="ECDSA"})(Jt||(Jt={}));var wo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1",r[r.ECDSA=3]="ECDSA"})(wo||(wo={}));(function(r){r.codec=()=>Je(wo)})(Jt||(Jt={}));var Hr;(function(r){let t;r.codec=()=>(t==null&&(t=le((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),Jt.codec().encode(e.Type,n)),e.Data!=null&&e.Data.byteLength>0&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let s={Data:Bt(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let a=e.uint32();switch(a>>>3){case 1:{s.Type=Jt.codec().decode(e);break}case 2:{s.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return s})),t),r.encode=e=>fe(e,r.codec()),r.decode=(e,n)=>ce(e,r.codec(),n)})(Hr||(Hr={}));var cu="/plaintext/2.0.0",go=class{protocol=cu;privateKey;log;constructor(t){this.privateKey=t.privateKey,this.log=t.logger.forComponent("libp2p:plaintext")}[Symbol.toStringTag]="@libp2p/plaintext";[So]=["@libp2p/connection-encryption"];async secureInbound(t,e){return this._encrypt(t,e)}async secureOutbound(t,e){return this._encrypt(t,e)}async _encrypt(t,e){let n=Bi(t).pb(Or);this.log("write pubkey exchange to peer %p",e?.remotePeer);let o=this.privateKey.publicKey,[,s]=await Promise.all([n.write({id:o.toMultihash().bytes,pubkey:{Type:Jt[o.type],Data:o.raw}},e),n.read(e)]),i;try{if(s.pubkey==null)throw new de("Public key missing");if(s.pubkey.Data.byteLength===0)throw new de("Public key data too short");if(s.id==null)throw new de("Remote id missing");let a=wi(s.pubkey.Data);if(i=Ei(a),!ut(i.toMultihash().bytes,s.id))throw new Ke("Public key did not match id")}catch(a){throw this.log.error(a),new Ke("Invalid public key - "+a.message)}if(e?.remotePeer!=null&&!i.equals(e?.remotePeer))throw new nr;return this.log("plaintext key exchange completed successfully with peer %p",i),{conn:n.unwrap().unwrap(),remotePeer:i}}};function uu(){return r=>new go(r)}return Ki(fu);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|