@libp2p/crypto 5.1.23-4a6c5d11a → 5.1.23-87dca02b0
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 +3 -3
- package/package.json +2 -2
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PCrypto = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PCrypto=(()=>{var yn=Object.defineProperty;var Ca=Object.getOwnPropertyDescriptor;var Ka=Object.getOwnPropertyNames;var Oa=Object.prototype.hasOwnProperty;var it=(e,t)=>{for(var r in t)yn(e,r,{get:t[r],enumerable:!0})},Ua=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ka(t))!Oa.call(e,o)&&o!==r&&yn(e,o,{get:()=>t[o],enumerable:!(n=Ca(t,o))||n.enumerable});return e};var Fa=e=>Ua(yn({},"__esModule",{value:!0}),e);var Nu={};it(Nu,{hmac:()=>Er,keys:()=>Wo,pbkdf2:()=>Qo,randomBytes:()=>Ko});var Er={};it(Er,{create:()=>bn});function Na(e){return e.buffer instanceof ArrayBuffer}function ot(e){return Na(e)?e:e.slice()}var ze=class extends Error{constructor(t="An error occurred while signing a message"){super(t),this.name="SigningError"}},je=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},xr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var W={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new xr("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 es={SHA1:20,SHA256:32,SHA512:64};var ka={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},Pa=async(e,t)=>{let r=await W.get().subtle.sign({name:"HMAC"},e,ot(t));return new Uint8Array(r,0,r.byteLength)};async function bn(e,t){let r=ka[e],n=await W.get().subtle.importKey("raw",ot(t),{name:"HMAC",hash:{name:r}},!1,["sign"]);return{async digest(o){return Pa(n,o)},length:es[e]}}var Wo={};it(Wo,{generateEphemeralKeyPair:()=>Aa,generateKeyPair:()=>Au,generateKeyPairFromSeed:()=>Bu,keyStretcher:()=>va,privateKeyFromCryptoKeyPair:()=>Ou,privateKeyFromProtobuf:()=>_u,privateKeyFromRaw:()=>Ru,privateKeyToCryptoKeyPair:()=>Ku,privateKeyToProtobuf:()=>Lu,publicKeyFromMultihash:()=>Tu,publicKeyFromProtobuf:()=>vu,publicKeyFromRaw:()=>Iu,publicKeyToProtobuf:()=>ie});var M=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},ge=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}},Ve=class extends Error{static name="InvalidPrivateKeyError";constructor(t="Invalid private key"){super(t),this.name="InvalidPrivateKeyError"}};var qt=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Sn={};it(Sn,{base58btc:()=>nt,base58flickr:()=>Ya});var $u=new Uint8Array(0);function ns(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Et(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return ne(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return ne(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function os(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}var rs=4096;function ss(e){let t=e.length;if(t<=rs)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.subarray(n,n+=rs));return r}function Ma(e){return e?.buffer instanceof ArrayBuffer}function ne(e){return Ma(e)?e:e.slice()}function qa(e,t,r){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),a=i.charCodeAt(0);if(n[a]!==255)throw new TypeError(i+" is ambiguous");if(n[a]=s,r){var c=i.toLowerCase().charCodeAt(0),f=i.toUpperCase().charCodeAt(0);c!==a&&(n[c]=s),f!==a&&(n[f]=s)}}var u=e.length,l=e.charAt(0),y=Math.log(u)/Math.log(256),p=Math.log(256)/Math.log(u);function _(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var w=0,m=0,B=0,v=x.length;B!==v&&x[B]===0;)B++,w++;for(var k=(v-B)*p+1>>>0,P=new Uint8Array(k);B!==v;){for(var U=x[B],K=0,O=k-1;(U!==0||K<m)&&O!==-1;O--,K++)U+=256*P[O]>>>0,P[O]=U%u>>>0,U=U/u>>>0;if(U!==0)throw new Error("Non-zero carry");m=K,B++}for(var q=k-m;q!==k&&P[q]===0;)q++;for(var D=l.repeat(w);q<k;++q)D+=e.charAt(P[q]);return D}function S(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var w=0;if(x[w]!==" "){for(var m=0,B=0;x[w]===l;)m++,w++;for(var v=(x.length-w)*y+1>>>0,k=new Uint8Array(v);x[w];){var P=n[x.charCodeAt(w)];if(P===255)return;for(var U=0,K=v-1;(P!==0||U<B)&&K!==-1;K--,U++)P+=u*k[K]>>>0,k[K]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");B=U,w++}if(x[w]!==" "){for(var O=v-B;O!==v&&k[O]===0;)O++;for(var q=new Uint8Array(m+(v-O)),D=m;O!==v;)q[D++]=k[O++];return q}}}function L(x){var w=S(x);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:_,decodeUnsafe:S,decode:L}}var Ha=qa,za=Ha,as=za;var gn=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},wn=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return cs(this,t)}},xn=class{decoders;constructor(t){this.decoders=t}or(t){return cs(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function cs(e,t){return new xn({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var En=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new gn(t,r,n),this.decoder=new wn(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function we({name:e,prefix:t,encode:r,decode:n}){return new En(e,t,r,n)}function Ht({name:e,prefix:t,alphabet:r,caseInsensitive:n=!1}){let{encode:o,decode:s}=as(r,e,n);return we({prefix:t,name:e,encode:o,decode:i=>Et(s(i))})}function ja(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,c=0;for(let f=0;f<o;++f){let u=t[e[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,i+=r,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Va(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>r;)i-=r,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Za(e,t){let r={};for(let n=0;n<e.length;++n)if(r[e[n]]=n,t){let o=e[n].toLowerCase(),s=e[n].toUpperCase();o!==e[n]&&(r[o]=n),s!==e[n]&&(r[s]=n)}return r}function et({name:e,prefix:t,bitsPerChar:r,alphabet:n,caseInsensitive:o=!1}){let s=Za(n,o);return we({prefix:t,name:e,encode(i){return Va(i,n,r)},decode(i){return ja(i,s,r,e)}})}var nt=Ht({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ya=Ht({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var An={};it(An,{base32:()=>xe,base32hex:()=>Wa,base32hexpad:()=>Qa,base32hexpadupper:()=>tc,base32hexupper:()=>Ja,base32pad:()=>Ga,base32padupper:()=>Xa,base32upper:()=>$a,base32z:()=>ec});var xe=et({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),$a=et({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),Ga=et({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Xa=et({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Wa=et({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),Ja=et({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),Qa=et({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),tc=et({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),ec=et({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bn={};it(Bn,{base36:()=>Ze,base36upper:()=>rc});var Ze=Ht({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),rc=Ht({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var nc=ls,fs=128,oc=127,sc=~oc,ic=Math.pow(2,31);function ls(e,t,r){t=t||[],r=r||0;for(var n=r;e>=ic;)t[r++]=e&255|fs,e/=128;for(;e≻)t[r++]=e&255|fs,e>>>=7;return t[r]=e|0,ls.bytes=r-n+1,t}var ac=vn,cc=128,us=127;function vn(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw vn.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&us)<<o:(i&us)*Math.pow(2,o),o+=7}while(i>=cc);return vn.bytes=s-n,r}var fc=Math.pow(2,7),uc=Math.pow(2,14),lc=Math.pow(2,21),hc=Math.pow(2,28),dc=Math.pow(2,35),pc=Math.pow(2,42),mc=Math.pow(2,49),yc=Math.pow(2,56),bc=Math.pow(2,63),gc=function(e){return e<fc?1:e<uc?2:e<lc?3:e<hc?4:e<dc?5:e<pc?6:e<mc?7:e<yc?8:e<bc?9:10},wc={encode:nc,decode:ac,encodingLength:gc},xc=wc,Ye=xc;function $e(e,t=0){let r=Ye.decode(e,t),n=Ye.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&e[t+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[r,n]}function Ee(e,t,r=0){return Ye.encode(e,t,r),t}function Se(e){return Ye.encodingLength(e)}function Dt(e,t){let r=t.byteLength,n=Se(e),o=n+Se(r),s=new Uint8Array(o+r);return Ee(e,s,0),Ee(r,s,n),s.set(t,o),new Ae(e,r,t,s)}function hs(e){let t=Et(e),[r,n]=$e(t),[o,s]=$e(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Ae(r,o,i,t)}function ds(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&ns(e.bytes,r.bytes)}}var Ae=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=ne(n),this.bytes=ne(o)}};function ps(e,t){let{bytes:r,version:n}=e;return n===0?Sc(r,In(e),t??nt.encoder):Ac(r,In(e),t??xe.encoder)}var ms=new WeakMap;function In(e){let t=ms.get(e);if(t==null){let r=new Map;return ms.set(e,r),r}return t}var St=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=ne(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Bc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Dt(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&ds(t.multihash,n.multihash)}toString(t){return ps(this,t)}toJSON(){return{"/":ps(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??ys(n,o,s.bytes))}else if(r[vc]===!0){let{version:n,multihash:o,code:s}=r,i=hs(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Xe)throw new Error(`Version 0 CID must use dag-pb (code: ${Xe}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ys(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Xe,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Et(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new Ae(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[l,y]=$e(t.subarray(r));return r+=y,l},o=n(),s=Xe;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),c=n(),f=r+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,r){let[n,o]=Ec(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return In(s).set(n,t),s}};function Ec(e,t){switch(e[0]){case"Q":{let r=t??nt;return[nt.prefix,r.decode(`${nt.prefix}${e}`)]}case nt.prefix:{let r=t??nt;return[nt.prefix,r.decode(e)]}case xe.prefix:{let r=t??xe;return[xe.prefix,r.decode(e)]}case Ze.prefix:{let r=t??Ze;return[Ze.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Sc(e,t,r){let{prefix:n}=r;if(n!==nt.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Ac(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var Xe=112,Bc=18;function ys(e,t,r){let n=Se(e),o=n+Se(t),s=new Uint8Array(o+r.byteLength);return Ee(e,s,0),Ee(t,s,n),s.set(r,o),s}var vc=Symbol.for("@ipld/js-cid/CID");var Tn={};it(Tn,{identity:()=>oe});var bs=0,Ic="identity",gs=Et;function Tc(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return Dt(bs,gs(e))}var oe={code:bs,name:Ic,encode:gs,digest:Tc};function at(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}var _n="1.2.840.10045.3.1.7",Rn="1.3.132.0.34",Ln="1.3.132.0.35";async function ws(e="P-256"){let t=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:e},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",t.publicKey),privateKey:await crypto.subtle.exportKey("jwk",t.privateKey)}}async function xs(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["sign"]);r?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,ot(t.subarray()));return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Es(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,ot(t),ot(r.subarray()));return n?.signal?.throwIfAborted(),s}function Ft(e=0){return new Uint8Array(e)}function mt(e=0){return new Uint8Array(e)}function _c(e){return e?.buffer instanceof ArrayBuffer}function Ss(e){if(_c(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function Ct(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=mt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return Ss(r)}var Bs=Symbol.for("@achingbrain/uint8arraylist");function As(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function Ar(e){return!!e?.[Bs]}var ut=class e{bufs;length;[Bs]=!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 r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Ar(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Ar(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=As(this.bufs,t);return r.buf[r.index]}set(t,r){let n=As(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(Ar(t))for(let n=0;n<t.length;n++)this.set(r+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,r){let{bufs:n,length:o}=this._subList(t,r);return Ct(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Ct(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=n,s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===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 f=t>=a&&t<c,u=r>a&&r<=c;if(f&&u){if(t===a&&r===c){n.push(i);break}let l=t-a;n.push(i.subarray(l,l+(r-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(u){if(r===c){n.push(i);break}n.push(i.subarray(0,r-a));break}n.push(i)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!Ar(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(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;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 l=0;l<s;l++)i[l]=-1;for(let l=0;l<o;l++)i[n[l]]=l;let a=i,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=r;l<=c;l+=u){u=0;for(let y=f;y>=0;y--){let p=this.get(l+y);if(n[y]!==p){u=Math.max(1,y-a[p]);break}}if(u===0)return l}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Ft(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Ft(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Ft(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=mt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Ft(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Ft(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Ft(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Ft(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Ft(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!at(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var Dn={};it(Dn,{base10:()=>Rc});var Rc=Ht({prefix:"9",name:"base10",alphabet:"0123456789"});var Cn={};it(Cn,{base16:()=>Lc,base16upper:()=>Dc});var Lc=et({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),Dc=et({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var Kn={};it(Kn,{base2:()=>Cc});var Cc=et({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var On={};it(On,{base256emoji:()=>Nc});var vs=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}"),Kc=vs.reduce((e,t,r)=>(e[r]=t,e),[]),Oc=vs.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Uc(e){return e.reduce((t,r)=>(t+=Kc[r],t),"")}function Fc(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Oc[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var Nc=we({prefix:"\u{1F680}",name:"base256emoji",encode:Uc,decode:Fc});var Fn={};it(Fn,{base64:()=>Un,base64pad:()=>kc,base64url:()=>Pc,base64urlpad:()=>Mc});var Un=et({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),kc=et({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pc=et({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mc=et({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Nn={};it(Nn,{base8:()=>qc});var qc=et({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var kn={};it(kn,{identity:()=>Hc});var Hc=we({prefix:"\0",name:"identity",encode:e=>ss(Et(e)),decode:e=>Et(os(e))});var Cl=new TextEncoder,Kl=new TextDecoder;var qn={};it(qn,{sha256:()=>Br,sha512:()=>Zc});var Vc=20;function Mn({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Pn(e,t,r,n,o)}var Pn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Vc,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Is(n,this.code,r?.truncate):n.then(o=>Is(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Is(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Dt(t,e)}function _s(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Br=Mn({name:"sha2-256",code:18,encode:_s("SHA-256")}),Zc=Mn({name:"sha2-512",code:19,encode:_s("SHA-512")});var Hn={...kn,...Kn,...Nn,...Dn,...Cn,...An,...Bn,...Sn,...Fn,...On},Vl={...qn,...Tn};function Ls(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Rs=Ls("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),zn=Ls("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=mt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Yc={utf8:Rs,"utf-8":Rs,hex:Hn.base16,latin1:zn,ascii:zn,binary:zn,...Hn},vr=Yc;function $(e,t="utf8"){let r=vr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function H(e,t="utf8"){let r=vr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var $c=parseInt("11111",2),jn=parseInt("10000000",2),Gc=parseInt("01111111",2),Ds={0:We,1:We,2:Xc,3:Qc,4:tf,5:Jc,6:Wc,16:We,22:We,48:We};function yt(e,t={offset:0}){let r=e[t.offset]&$c;if(t.offset++,Ds[r]!=null)return Ds[r](e,t);throw new Error("No decoder for tag "+r)}function Je(e,t){let r=0;if((e[t.offset]&jn)===jn){let n=e[t.offset]&Gc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++){if(t.offset>=e.byteLength)throw new Error("invalid DER element length");o+=e[t.offset].toString(16).padStart(2,"0")}r=parseInt(o,16)}else r=e[t.offset],t.offset++;if(!Number.isInteger(r)||r<0||r>e.byteLength-t.offset)throw new Error("invalid DER element length");return r}function We(e,t){Je(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=yt(e,t);if(n===null)break;r.push(n)}return r}function Xc(e,t){let r=Je(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function Wc(e,t){let r=Je(e,t),n=t.offset+r,o=e[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 f=e[t.offset];if(t.offset++,c.push(f&127),f<128){c.reverse();let u=0;for(let l=0;l<c.length;l++)u+=c[l]<<l*7;a+=`.${u}`,c=[]}}return a}function Jc(e,t){return t.offset++,null}function Qc(e,t){let r=Je(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function tf(e,t){let r=Je(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function ef(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new ut;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Ir(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=ef(e.byteLength);return new ut(Uint8Array.from([t.byteLength|jn]),t)}function lt(e){let t=new ut,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new ut(Uint8Array.from([2]),Ir(t),t)}function Qe(e){let t=Uint8Array.from([0]),r=new ut(t,e);return new ut(Uint8Array.from([3]),Ir(r),r)}function Cs(e){return new ut(Uint8Array.from([4]),Ir(e),e)}function vt(e,t=48){let r=new ut;for(let n of e)r.append(n);return new ut(Uint8Array.from([t]),Ir(r),r)}var rf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),nf=Uint8Array.from([6,5,43,129,4,0,34]),of=Uint8Array.from([6,5,43,129,4,0,35]),Ks={ext:!0,kty:"EC",crv:"P-256"},Os={ext:!0,kty:"EC",crv:"P-384"},Us={ext:!0,kty:"EC",crv:"P-521"},Be=32,ve=48,Ie=66;function Fs(e){let t=yt(e);return Vn(t)}function Vn(e){let t=e[1],r=H(t,"base64url"),n=e[2][1][0],o=1,s,i;if(t.byteLength===Be)return s=H(n.subarray(o,o+Be),"base64url"),i=H(n.subarray(o+Be),"base64url"),new Nt({...Ks,key_ops:["sign"],d:r,x:s,y:i});if(t.byteLength===ve)return s=H(n.subarray(o,o+ve),"base64url"),i=H(n.subarray(o+ve),"base64url"),new Nt({...Os,key_ops:["sign"],d:r,x:s,y:i});if(t.byteLength===Ie)return s=H(n.subarray(o,o+Ie),"base64url"),i=H(n.subarray(o+Ie),"base64url"),new Nt({...Us,key_ops:["sign"],d:r,x:s,y:i});throw new M(`Private key length was wrong length, got ${t.byteLength}, expected 32, 48 or 66`)}function Zn(e){let t=yt(e);return Yn(t)}function Yn(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===Be*2+1)return n=H(t.subarray(r,r+Be),"base64url"),o=H(t.subarray(r+Be),"base64url"),new se({...Ks,key_ops:["verify"],x:n,y:o});if(t.byteLength===ve*2+1)return n=H(t.subarray(r,r+ve),"base64url"),o=H(t.subarray(r+ve),"base64url"),new se({...Os,key_ops:["verify"],x:n,y:o});if(t.byteLength===Ie*2+1)return n=H(t.subarray(r,r+Ie),"base64url"),o=H(t.subarray(r+Ie),"base64url"),new se({...Us,key_ops:["verify"],x:n,y:o});throw new M(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function Ns(e){return vt([lt(Uint8Array.from([1])),Cs($(e.d??"","base64url")),vt([Ps(e.crv)],160),vt([Qe(new ut(Uint8Array.from([4]),$(e.x??"","base64url"),$(e.y??"","base64url")))],161)]).subarray()}function ks(e){return vt([lt(Uint8Array.from([1])),vt([Ps(e.crv)],160),vt([Qe(new ut(Uint8Array.from([4]),$(e.x??"","base64url"),$(e.y??"","base64url")))],161)]).subarray()}function Ps(e){if(e==="P-256")return rf;if(e==="P-384")return nf;if(e==="P-521")return of;throw new M(`Invalid curve ${e}`)}async function Ms(e="P-256"){let t=await ws(e);return new Nt(t.privateKey)}var se=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ks(this.jwk)),this._raw}toMultihash(){return oe.digest(ie(this))}toCID(){return St.createV1(114,this.toMultihash())}toString(){return nt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}async verify(t,r,n){return Es(this.jwk,r,t,n)}},Nt=class{type="ECDSA";jwk;publicKey;_raw;constructor(t){this.jwk=t,this.publicKey=new se({crv:t.crv,ext:t.ext,key_ops:["verify"],kty:"EC",x:t.x,y:t.y})}get raw(){return this._raw==null&&(this._raw=Ns(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}async sign(t,r){return xs(this.jwk,t,r)}};var Tr=BigInt(4294967295),qs=BigInt(32);function sf(e,t=!1){return t?{h:Number(e&Tr),l:Number(e>>qs&Tr)}:{h:Number(e>>qs&Tr)|0,l:Number(e&Tr)|0}}function Hs(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=sf(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var af=e=>e/2**32|0,cf=e=>e>>>0;function zs(e,t,r,n){let o=af(r),s=cf(r);e.setUint32(t,n?s:o,n),e.setUint32(t+4,n?o:s,n)}var $n=(e,t,r)=>e>>>r,Gn=(e,t,r)=>e<<32-r|t>>>r,ae=(e,t,r)=>e>>>r|t<<32-r,ce=(e,t,r)=>e<<32-r|t>>>r,tr=(e,t,r)=>e<<64-r|t>>>r-32,er=(e,t,r)=>e>>>r-32|t<<64-r;function Kt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var js=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Vs=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Zs=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Ys=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,$s=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Gs=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;function _r(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var Xn=e=>e?`"${e}" `:"";function bt(e,t=""){if(typeof e!="number")throw new TypeError(Xn(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(Xn(t)+"expected integer >= 0, got "+e);return e}function gt(e,t,r=""){if(_r(e)&&(t===void 0||e.length===t))return e;t!==void 0&&bt(t,"length");let n=_r(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=Xn(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function Te(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(bt(e.outputLen),bt(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var Xs=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)};function _e(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Rr(e,t){gt(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function At(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Re(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function It(e,t){return e<<32-t|e>>>t}function Lr(e,t){return e<<t|e>>>32-t>>>0}var Js=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",uf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Dr(e){if(gt(e),Js)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=uf[e[r]];return t}function Ws(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function Cr(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(Js)try{return Uint8Array.fromHex(e)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Ws(e.charCodeAt(s)),a=Ws(e.charCodeAt(s+1));if(i===void 0||a===void 0){let c=e[s]+e[s+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function lf(e){if(typeof e!="string")throw new TypeError("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Wn(e,t=""){return typeof e=="string"?lf(e):gt(e,void 0,t)}function Jn(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];gt(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function Qn(e,t,r="opts"){return Xs(e,"defaults"),t!==void 0&&Xs(t,r),Object.assign(e,t)}function rr(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=Qn({},t,"info");let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function Qs(e=32){bt(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var to=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Kr(e,t,r){return e&t^~e&r}function Or(e,t,r){return e&t^e&r^t&r}var fe=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Re(this.buffer)}update(t){_e(this),gt(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length,i=!1;for(let a=0;a<s;){let c=Math.min(o-this.pos,s-a);if(c===o){let f=Re(t);for(;o<=s-a;a+=o)this.process(f,a);i=!0;continue}n.set(a===0&&c===s?t:t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=t.length,i&&this.roundClean(),this}digestInto(t){_e(this),Rr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),zs(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let a=t===r?n:Re(t),c=this.outputLen,f=c/4,u=this.get();if(c%4||f>u.length)throw new Error("invalid outputLen");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=o,t.length=n,t.pos=i,i&&t.buffer.set(r),t}clone(){return this._cloneInto()}},ti=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ei=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var hf=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]),zt=new Uint32Array(64),eo=class extends fe{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,r){super(64,t,8,!1),this.A=r[0]|0,this.B=r[1]|0,this.C=r[2]|0,this.D=r[3]|0,this.E=r[4]|0,this.F=r[5]|0,this.G=r[6]|0,this.H=r[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,r,n,o,s,i,a,c]}set(t,r,n,o,s,i,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let l=0;l<16;l++,r+=4)zt[l]=t.getUint32(r,!1);for(let l=16;l<64;l++){let y=zt[l-15],p=zt[l-2],_=It(y,7)^It(y,18)^y>>>3,S=It(p,17)^It(p,19)^p>>>10;zt[l]=S+zt[l-7]+_+zt[l-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let y=It(a,6)^It(a,11)^It(a,25),p=u+y+Kr(a,c,f)+hf[l]+zt[l]|0,S=(It(n,2)^It(n,13)^It(n,22))+Or(n,o,s)|0;u=f,f=c,c=a,a=i+p|0,i=s,s=o,o=n,n=p+S|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,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,a,c,f,u)}roundClean(){At(zt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),At(this.buffer)}},ro=class extends eo{constructor(){super(32,ti)}};var ri=Hs(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),df=ri[0],pf=ri[1],jt=new Uint32Array(80),Vt=new Uint32Array(80),no=class extends fe{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(t,r){super(128,t,16,!1),this.Ah=r[0]|0,this.Al=r[1]|0,this.Bh=r[2]|0,this.Bl=r[3]|0,this.Ch=r[4]|0,this.Cl=r[5]|0,this.Dh=r[6]|0,this.Dl=r[7]|0,this.Eh=r[8]|0,this.El=r[9]|0,this.Fh=r[10]|0,this.Fl=r[11]|0,this.Gh=r[12]|0,this.Gl=r[13]|0,this.Hh=r[14]|0,this.Hl=r[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:y,Gh:p,Gl:_,Hh:S,Hl:L}=this;return[t,r,n,o,s,i,a,c,f,u,l,y,p,_,S,L]}set(t,r,n,o,s,i,a,c,f,u,l,y,p,_,S,L){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=y|0,this.Gh=p|0,this.Gl=_|0,this.Hh=S|0,this.Hl=L|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let m=0;m<16;m++,r+=4)jt[m]=t.getUint32(r),Vt[m]=t.getUint32(r+=4);for(let m=16;m<80;m++){let B=jt[m-15]|0,v=Vt[m-15]|0,k=ae(B,v,1)^ae(B,v,8)^$n(B,v,7),P=ce(B,v,1)^ce(B,v,8)^Gn(B,v,7),U=jt[m-2]|0,K=Vt[m-2]|0,O=ae(U,K,19)^tr(U,K,61)^$n(U,K,6),q=ce(U,K,19)^er(U,K,61)^Gn(U,K,6),D=Zs(P,q,Vt[m-7],Vt[m-16]),G=Ys(D,k,O,jt[m-7],jt[m-16]);jt[m]=G|0,Vt[m]=D|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:y,Fh:p,Fl:_,Gh:S,Gl:L,Hh:x,Hl:w}=this;for(let m=0;m<80;m++){let B=ae(l,y,14)^ae(l,y,18)^tr(l,y,41),v=ce(l,y,14)^ce(l,y,18)^er(l,y,41),k=l&p^~l&S,P=y&_^~y&L,U=$s(w,v,P,pf[m],Vt[m]),K=Gs(U,x,B,k,df[m],jt[m]),O=U|0,q=ae(n,o,28)^tr(n,o,34)^tr(n,o,39),D=ce(n,o,28)^er(n,o,34)^er(n,o,39),G=n&s^n&a^s&a,R=o&i^o&c^i&c;x=S|0,w=L|0,S=p|0,L=_|0,p=l|0,_=y|0,{h:l,l:y}=Kt(f|0,u|0,K|0,O|0),f=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let T=js(O,D,R);n=Vs(T,K,q,G),o=T|0}({h:n,l:o}=Kt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Kt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=Kt(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Kt(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:y}=Kt(this.Eh|0,this.El|0,l|0,y|0),{h:p,l:_}=Kt(this.Fh|0,this.Fl|0,p|0,_|0),{h:S,l:L}=Kt(this.Gh|0,this.Gl|0,S|0,L|0),{h:x,l:w}=Kt(this.Hh|0,this.Hl|0,x|0,w|0),this.set(n,o,s,i,a,c,f,u,l,y,p,_,S,L,x,w)}roundClean(){At(jt,Vt)}destroy(){this.destroyed=!0,At(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},oo=class extends no{constructor(){super(64,ei)}};var Zt=rr(()=>new ro,to(1));var nr=rr(()=>new oo,to(3));function Fr(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`"${t}" expected array, got type=${typeof e}`);for(let n=0;n<e.length;n++)r(e[n],`${t}[${n}]`);return e}var V=(e,t,r)=>gt(e,t,r),so=bt;function oi(e,t=""){if(typeof e!="string"){let r=t&&`"${t}" `;throw new TypeError(r+"expected string, got type="+typeof e)}return e}function Yt(e,t="object"){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof e}`);return e}function ue(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}var or=Dr,Bt=(...e)=>Jn(...e),Le=e=>Cr(e),Gt=_r,le=e=>Qs(e),Ur=BigInt(0),ni=BigInt(1),mf=e=>e?`"${e}" `:"";function dt(e,t=""){if(typeof e!="boolean")throw new TypeError(mf(t)+"expected boolean, got type="+typeof e);return e}function Nr(e){if(typeof e=="bigint"){if(!$t(e))throw new RangeError("positive bigint expected, got "+e)}else so(e);return e}function Xt(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function sr(e){let t=Nr(e).toString(16);return t.length&1?"0"+t:t}function si(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Ur:BigInt("0x"+e)}function Ot(e){return si(Dr(e))}function he(e){return si(Dr(Pr(gt(e)).reverse()))}function kr(e,t){if(bt(t),t===0)throw new Error("zero output length is invalid");e=Nr(e);let r=t*2,n=e.toString(16);if(n.length>r)throw new RangeError("number is too large");return Cr(n.padStart(r,"0"))}function io(e,t){return kr(e,t).reverse()}function Pr(e){return Uint8Array.from(V(e))}function $t(e){return typeof e=="bigint"&&Ur<=e}function ao(e,t,r){return $t(e)&&$t(t)&&$t(r)&&t<=e&&e<r}function De(e,t,r,n){if(!ao(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ce(e){if(e<Ur)throw new Error("expected non-negative bigint, got "+e);return e===Ur?0:e.toString(2).length}var ir=e=>(Xt(e,"n"),(ni<<BigInt(e))-ni);function ii(e,t,r){if(bt(e,"hashLen"),bt(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=L=>new Uint8Array(L),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),a=1e3,c=n(e),f=n(e),u=0,l=()=>{c.fill(1),f.fill(0),u=0},y=(...L)=>r(f,Bt(c,...L)),p=(L=o)=>{f=y(s,L),c=y(),L.length!==0&&(f=y(i,L),c=y())},_=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let L=0,x=[];for(;L<t;){c=y();let w=c.slice();x.push(w),L+=c.length}return Bt(...x)};return(L,x)=>{l(),p(L);let w;for(;(w=x(_()))===void 0;)p();return l(),w}}function pt(e,t={},r={},n="object"){Yt(e,n),Yt(t,"fields"),Yt(r,"optFields");function o(i,a,c){let f=n==="object"?`param "${String(i)}"`:`"${n}.${String(i)}"`,u=e[i];if(!Object.hasOwn(e,i)&&(c?u!==void 0:a!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(c&&u===void 0)return;let l=typeof u;if(l!==a||u===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${l}`)}let s=(i,a)=>Object.entries(i).forEach(([c,f])=>o(c,f,a));s(t,!1),s(r,!0)}var rt=BigInt(0),Z=BigInt(1),Wt=BigInt(2),fi=BigInt(3),co=BigInt(4),ui=BigInt(5),yf=BigInt(7),li=BigInt(8),bf=BigInt(9),gf=BigInt(15),hi=BigInt(16),wf=BigInt("0x10000000000000000");function J(e,t){if(t<=rt)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=rt?r:t+r}function di(e,t,r){if(r<=Z)throw new Error("pow: expected modulus > 1, got "+r);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<rt)throw new Error("invalid exponent, negatives unsupported");if(t===rt)return Z;if(t===Z)return e;let n=e%r;if(n<rt&&(n+=r),t<wf){let a=Z;for(;t>rt;)t&Z&&(a=a*n%r),n=n*n%r,t>>=Z;return a}let o=[];for(;t>rt;)o.push(Number(t&gf)),t>>=co;let s=new Array(16);s[0]=Z,s[1]=n;for(let a=2;a<16;a++)s[a]=s[a-1]*n%r;let i=s[o[o.length-1]];for(let a=o.length-2;a>=0;a--){i=i*i%r,i=i*i%r,i=i*i%r,i=i*i%r;let c=o[a];c!==0&&(i=i*s[c]%r)}return i}function X(e,t,r){if(r<=Z)throw new Error("pow2: expected modulus > 1, got "+r);if(t<rt)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >rt;)n*=n,n%=r;return n}function ai(e,t){if(e===rt)throw new Error("invert: expected non-zero number");if(t<=Z)throw new Error("invert: expected modulus > 1, got "+t);let r=J(e,t),n=t,o=rt,s=Z;for(;r!==rt;){let a=n/r,c=n-r*a,f=o-s*a;n=r,r=c,o=s,s=f}if(n!==Z)throw new Error("invert: does not exist");return J(o,t)}function pi(e,t){if(t<=Z)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=J(e,t);if(r===rt)throw new Error("invertCt: expected non-zero number");let n=di(r,t-Wt,t);if(J(r*n,t)!==Z)throw new Error("invertCt: does not exist");return n}function fo(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function uo(e,t){if((e&Z)===rt)throw new Error(t+": expected odd modulus, got "+e)}function mi(e,t){let r=e,n=(r.ORDER+Z)/co,o=r.pow(t,n);return fo(r,o,t),o}function xf(e,t){let r=e,n=(r.ORDER-ui)/li,o=r.mul(t,Wt),s=r.pow(o,n),i=r.mul(t,s),a=r.mul(r.mul(i,Wt),s),c=r.mul(i,r.sub(a,r.ONE));return fo(r,c,t),c}function Ef(e){let t=Oe(e),r=yi(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+yf)/hi;return((a,c)=>{let f=a,u=f.pow(c,i),l=f.mul(u,n),y=f.mul(u,o),p=f.mul(u,s),_=f.eql(f.sqr(l),c),S=f.eql(f.sqr(y),c);u=f.cmov(u,l,_),l=f.cmov(p,y,S);let L=f.eql(f.sqr(l),c),x=f.cmov(u,l,L);return fo(f,x,c),x})}function yi(e){if(e<fi)throw new Error("sqrt is not defined for small field");uo(e,"tonelliShanks");let t=e-Z,r=0;for(;t%Wt===rt;)t/=Wt,r++;let n=Wt,o=Oe(e);for(;ar(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return mi;let s=o.pow(n,t),i=(t+Z)/Wt;return function(c,f){let u=c;if(u.is0(f))return f;if(ar(u,f)!==1)throw new Error("Cannot find square root");let l=r,y=u.mul(u.ONE,s),p=u.pow(f,t),_=u.pow(f,i);for(;!u.eql(p,u.ONE);){if(u.is0(p))throw new Error("Cannot find square root: probably non-prime P");let S=1,L=u.sqr(p);for(;!u.eql(L,u.ONE);)if(S++,L=u.sqr(L),S===l)throw new Error("Cannot find square root");let x=Z<<BigInt(l-S-1),w=u.pow(y,x);l=S,y=u.sqr(w),p=u.mul(p,y),_=u.mul(_,w)}return _}}function Sf(e){return uo(e,"Fp.sqrt"),e%co===fi?mi:e%li===ui?xf:e%hi===bf?Ef(e):yi(e)}var bi=(e,t)=>(J(e,t)&Z)===Z,Af=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ke(e){if(Yt(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);Xt(e.BYTES,"BYTES"),Xt(e.BITS,"BITS");for(let t of Af)ue(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Z)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function qr(e,t,r=!1){Ke(e),Fr(t,"nums"),dt(r,"passZero");let n=e,o=new Array(t.length).fill(r?n.ZERO:void 0),s=t.reduce((a,c,f)=>n.is0(c)?a:(o[f]=a,n.mul(a,c)),n.ONE),i=n.inv(s);return t.reduceRight((a,c,f)=>n.is0(c)?a:(o[f]=n.mul(a,o[f]),n.mul(a,c)),i),o}function ar(e,t){Ke(e);let r=e;uo(r.ORDER,"FpLegendre");let n=(r.ORDER-Z)/Wt,o=r.pow(t,n),s=r.eql(o,r.ONE),i=r.eql(o,r.ZERO),a=r.eql(o,r.neg(r.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function Bf(e,t){if(t!==void 0&&so(t),e<=rt)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Ce(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${r})`);let n=t!==void 0?t:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var ci=new WeakMap,Mr=class{ORDER;BITS;BYTES;isLE;ZERO=rt;ONE=Z;_lengths;_mod;constructor(t,r={}){if(t<=Z)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=Bf(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return J(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return rt<=t&&t<this.ORDER}is0(t){return t===rt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Z)===Z}neg(t){return J(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return J(t*t,this.ORDER)}add(t,r){return J(t+r,this.ORDER)}sub(t,r){return J(t-r,this.ORDER)}mul(t,r){return J(t*r,this.ORDER)}pow(t,r){return di(t,r,this.ORDER)}div(t,r){return J(t*ai(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return ai(t,this.ORDER)}sqrt(t){let r=ci.get(this);return r||ci.set(this,r=Sf(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?io(t,this.BYTES):kr(t,this.BYTES)}fromBytes(t,r=!1){V(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,s?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=s?he(t):Ot(t);if(a&&(c=J(c,i)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return qr(this,t,!0)}cmov(t,r,n){return dt(n,"condition"),n?r:t}};function Oe(e,t={}){return Object.freeze(Mr.prototype),new Mr(e,t)}function gi(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Z)throw new Error("field order must be greater than 1");let t=Ce(e-Z);return Math.ceil(t/8)}function Hr(e){let t=gi(e);return t+Math.ceil(t/2)}function zr(e,t,r=!1){V(e);let n=e.length,o=gi(t),s=Math.max(Hr(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?he(e):Ot(e),a=J(i,t-Z)+Z;return r?io(a,o):kr(a,o)}var po=BigInt(0),cr=BigInt(1),vf=BigInt(4),lo=16,wi=128,If=5,xi=2**31;function Jt(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);ue(t.fromAffine,"Point.fromAffine"),ue(t.fromBytes,"Point.fromBytes"),ue(t.fromHex,"Point.fromHex"),Yt(t.BASE,"Point.BASE"),Yt(t.ZERO,"Point.ZERO"),Ke(t.Fp),Ke(t.Fn)}function jr(e,t){Jt(e),Si(t,e);let r=qr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function Tf(e,t,r=1){if(!Number.isSafeInteger(e)||e<r||e>t)throw new Error("invalid window size, expected ["+r+".."+t+"], got W="+e)}function _f(e,t){let r=e*(4*t+128);if(r>xi)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+xi/2**20+" MiB")}function mo(e,t){if(e!==void 0){ue(e,"randomBytes");try{let r=e(t);if(!Gt(r)||r.length!==t)return}catch{return}return e}}function Si(e,t){Fr(e,"points"),e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function Rf(e,t,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,o)=>{if(!(r===void 0?t.isValid(n):$t(n)&&n<r))throw new Error("invalid scalar at index "+o)})}var Ai=new WeakMap;function ho(e){return Ai.get(e)||1}function Lf(e,t){let r=e.double(),n=[e];for(let o=1;o<t;o++)n.push(n[o-1].add(r));return n}function Df(e,t){let r=2**t,n=r/2,o=BigInt(r-1),s=[];for(;e>po;){let i=0;e&cr&&(i=Number(e&o),i>=n&&(i-=r),e-=BigInt(i)),s.push(i),e>>=cr}return s}function Cf(e,t,r){let n=2**t,o=n/2,s=BigInt(n-1),i=BigInt(t),a=[];for(let c=0;c<r;c++){let f=Number(e&s);e>>=i,f>o&&(f-=n,e+=cr),a.push(f)}if(e!==po)throw new Error("invalid wnaf");return a}function Kf(e,t,r){let n=0;for(let s of r)n=Math.max(n,s.length);let o=e;for(let s=n-1;s>=0;s--){s!==n-1&&(o=o.double());for(let i=0;i<r.length;i++){let a=r[i][s];if(a){let c=t[i][Math.abs(a)-1>>1];o=o.add(a<0?c.negate():c)}}}return o}var Ue=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(t,r){Jt(t),this.randomBytes=mo(r,lo),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,r,n){let o=Math.ceil(n/r)+1,s=2**(r-1),i=[],a=t;for(let c=0;c<o;c++){let f=a;for(let u=0;u<s;u++)i.push(f),f=f.add(a);a=i[i.length-1].double()}return{W:r,bits:n,windows:o,comp:i}}wnafCachedCT(t,r){let{W:n,windows:o,comp:s}=t,i=2**(n-1),a=Cf(r,n,o),c=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let l=a[u],y=u*i,p=Math.abs(l)-1,_=s[y];for(let L=1;L<i;L++)_=L===p?s[y+L]:_;let S=_.negate();l===0?f=f.add(s[y]):c=c.add(l<0?S:_)}return{p:c,f}}getWnafPrecomputes(t,r,n,o){let s=this.wnafPrecomputes.get(r),i=s?.find(a=>a.W===t&&a.bits===n);return i||(i=this.buildWnafTable(r,t,n),typeof o=="function"&&(i={...i,comp:o(i.comp)}),s||(s=[],this.wnafPrecomputes.set(r,s)),s.push(i)),i}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,r){if(this.assertPoint(t),!ao(r,cr,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,n,o){let s=ho(t);return s===1?this.fixedWindowCT(t,r,n):this.wnafCachedCT(this.getWnafPrecomputes(s,t,n,o),r)}mulCT(t,r,n){return this.validateMulInput(t,r),this.runCT(t,r,this.bits,n)}mulCTBlinded(t,r,n){if(this.validateMulInput(t,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+wi,s=this.randomBytes(lo);if(!Gt(s)||s.length!==lo)throw new Error("randomBytes returned invalid byte array");s[0]=s[0]&63|128;let i=r+Ot(s)*this.Point.Fn.ORDER;return this.runCT(t,i,o,n)}fixedWindowCT(t,r,n){let o=If,s=1<<o,i=ir(o),a=new Array(s);a[0]=this.ZERO;for(let u=1;u<s;u++)a[u]=a[u-1].add(t);let c=Math.ceil(n/o),f=this.ZERO;for(let u=c-1;u>=0;u--){if(u!==c-1)for(let p=0;p<o;p++)f=f.double();let l=Number(r>>BigInt(u*o)&i),y=a[0];for(let p=1;p<s;p++)y=p===l?a[p]:y;f=f.add(y)}return{p:f,f}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===cr?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,r,n,o){return this.shouldBlind(t,n)?this.mulCTBlinded(t,r,o):this.mulCT(t,r,o)}mulUnsafe(t,r,n){if(this.assertPoint(t),!$t(r))throw new Error("invalid scalar");let o=ho(t);if(o===1||r>=this.Point.Fn.ORDER)return Vr(this.Point,[t],[r],!0);let s=this.getWnafPrecomputes(o,t,this.bits,n);return this.wnafCachedCT(s,r).p}setWindowSize(t,r){this.assertPoint(t),Tf(r,this.bits);let n=Math.ceil((this.bits+wi)/r)+1;_f(n*2**(r-1),this.Point.Fp.BYTES),Ai.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return ho(t)!==1}};function Vr(e,t,r,n=!1){if(Jt(e),Si(t,e),dt(n,"allowOversized"),Rf(r,e.Fn,n?e.Fn.ORDER**vf:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let o=t.map(i=>Lf(i,4)),s=r.map(i=>Df(i,4));return Kf(e.ZERO,o,s)}function Ei(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ke(t),t}else return Oe(e,{isLE:r})}function Zr(e,t,r={},n){if(e!=="weierstrass"&&e!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);pt(r);for(let c of["p","n","h"]){let f=t[c];if(!($t(f)&&f!==po))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Ei(t.p,r.Fp,n),s=Ei(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function Yr(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var $r=BigInt(0),Gr=BigInt(1),Xr=BigInt(2),Of=BigInt(4),Bi=BigInt(8);function Uf(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}function vi(e,t={}){pt(t,{},{},"extraOpts");let r=t,n=Zr("edwards",e,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:a}=i;if(ar(o,i.a)!==1)throw new Error("edwards: CURVE.a must be a square in Fp for complete addition formulas");if(ar(o,i.d)!==-1)throw new Error("edwards: CURVE.d must be a non-square in Fp for complete addition formulas");pt(r,{},{uvRatio:"function",randomBytes:"function"});let c=r.randomBytes===void 0?le:r.randomBytes,f=Xr<<BigInt(o.BYTES*8)-Gr;function u(w){if(!o.isOdd)throw new Error("Field does not have .isOdd()");return o.isOdd(w)}let l=r.uvRatio===void 0?(w,m)=>{try{return{isValid:!0,value:o.sqrt(o.div(w,m))}}catch{return{isValid:!1,value:$r}}}:r.uvRatio;if(!Uf(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");let y=o.eql(i.a,o.neg(o.ONE))?w=>o.neg(w):o.eql(i.a,o.ONE)?w=>w:w=>o.mul(i.a,w);function p(w,m,B=!1){let v=B?Gr:$r;return De("coordinate "+w,m,v,f),m}function _(w){if(!(w instanceof S))throw new Error("EdwardsPoint expected")}class S{static BASE=new S(i.Gx,i.Gy,o.ONE,o.mul(i.Gx,i.Gy));static ZERO=new S(o.ZERO,o.ONE,o.ONE,o.ZERO);static Fp=o;static Fn=s;X;Y;Z;T;constructor(m,B,v,k){this.X=p("x",m),this.Y=p("y",B),this.Z=p("z",v,!0),this.T=p("t",k),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){if(m instanceof S)throw new Error("extended point not allowed");let{x:B,y:v}=m||{};return p("x",B),p("y",v),new S(B,v,o.ONE,o.mul(B,v))}static fromBytes(m,B=!1){let v=o.BYTES,{a:k,d:P}=i;m=Pr(V(m,v,"point")),dt(B,"zip215");let U=Pr(m),K=m[v-1];U[v-1]=K&-129;let O=he(U),q=B?f:o.ORDER;De("point.y",O,$r,q);let D=o.sqr(O),G=o.sub(D,o.ONE),R=o.sub(o.mulN(P,D),k),{isValid:T,value:h}=l(G,R);if(!T)throw new Error("bad point: invalid y coordinate");let b=u(h),E=(K&128)!==0;if(!B&&o.is0(h)&&E)throw new Error("bad point: x=0 and x_0=1");return E!==b&&(h=o.neg(h)),S.fromAffine({x:h,y:O})}static fromHex(m,B=!1){return S.fromBytes(Le(m),B)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=6,B=!0){return x.setWindowSize(this,m),B||this.multiply(Xr),this}assertValidity(){let m=this,{a:B,d:v}=i;if(m.is0())throw new Error("bad point: ZERO");let{X:k,Y:P,Z:U,T:K}=m,O=o.sqr(k),q=o.sqr(P),D=o.sqr(U),G=o.sqr(D),R=o.mul(O,B),T=o.mul(o.add(R,q),D),h=o.add(G,o.mul(v,o.mul(O,q)));if(!o.eql(T,h))throw new Error("bad point: equation left != right (1)");let b=o.mul(k,P),E=o.mul(U,K);if(!o.eql(b,E))throw new Error("bad point: equation left != right (2)")}equals(m){_(m);let{X:B,Y:v,Z:k}=this,{X:P,Y:U,Z:K}=m,O=o.mul(B,K),q=o.mul(P,k),D=o.mul(v,K),G=o.mul(U,k);return o.eql(O,q)&&o.eql(D,G)}is0(){return this.equals(S.ZERO)}negate(){return new S(o.neg(this.X),this.Y,this.Z,o.neg(this.T))}double(){let{X:m,Y:B,Z:v}=this,k=o.sqr(m),P=o.sqr(B),U=o.mul(o.sqr(v),Xr),K=y(k),O=o.addN(m,B),q=o.sub(o.subN(o.sqr(O),k),P),D=o.addN(K,P),G=o.subN(D,U),R=o.subN(K,P),T=o.mul(q,G),h=o.mul(D,R),b=o.mul(q,R),E=o.mul(G,D);return new S(T,h,E,b)}add(m){_(m);let{d:B}=i,{X:v,Y:k,Z:P,T:U}=this,{X:K,Y:O,Z:q,T:D}=m,G=o.mul(v,K),R=o.mul(k,O),T=o.mul(o.mulN(U,B),D),h=o.mul(P,q),b=o.sub(o.subN(o.mulN(o.addN(v,k),o.addN(K,O)),G),R),E=o.subN(h,T),C=o.addN(h,T),g=o.sub(R,y(G)),d=o.mul(b,E),A=o.mul(C,g),I=o.mul(b,g),F=o.mul(E,C);return new S(d,A,F,I)}subtract(m){return _(m),this.add(m.negate())}multiply(m){if(!s.isValidNot0(m))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:B,f:v}=x.mulSecret(this,m,a,L);return L([B,v])[0]}multiplyUnsafe(m){if(!s.isValid(m))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return m===$r?S.ZERO:this.is0()||m===Gr?this:x.mulUnsafe(this,m,L)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return x.mulUnsafe(this,i.n).is0()}toAffine(m){let B=this,v=m;if(v!=null&&typeof v!="bigint")throw new TypeError('"invertedZ" expected bigint, got type='+typeof v);let{X:k,Y:P,Z:U}=B,K=B.is0();v==null&&(v=K?o.create(Bi):o.inv(U));let O=o.mul(k,v),q=o.mul(P,v),D=o.mul(U,v);if(K)return{x:o.ZERO,y:o.ONE};if(!o.eql(D,o.ONE))throw new Error("invZ was invalid");return{x:O,y:q}}clearCofactor(){return a===Gr?this:a===Xr?this.double():a===Of?this.double().double():a===Bi?this.double().double().double():this.multiplyUnsafe(a)}toBytes(){let{x:m,y:B}=this.toAffine(),v=o.toBytes(B);return v[v.length-1]|=u(m)?128:0,v}toHex(){return or(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let L=w=>jr(S,w),x=new Ue(S,c);return x.bits>=6&&S.BASE.precompute(6),Object.freeze(S.prototype),Object.freeze(S),S}function Ii(e,t,r={}){if(Jt(e),typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;pt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function",toMontgomery:"function",toMontgomerySecret:"function"});let{prehash:s}=o,{BASE:i,Fp:a,Fn:c}=e,f=n.outputLen,u=2*a.BYTES;if(f!==void 0&&(Xt(f,"hash.outputLen"),f!==u))throw new Error(`hash.outputLen must be ${u}, got ${f}`);let l=o.randomBytes===void 0?le:o.randomBytes,y=o.toMontgomery,p=o.toMontgomerySecret,_=o.adjustScalarBytes===void 0?R=>R:o.adjustScalarBytes,S=o.domain===void 0?(R,T,h)=>{if(dt(h,"phflag"),T.length||h)throw new Error("Contexts/pre-hash are not supported");return R}:o.domain;function L(R){return c.create(he(R))}function x(R){let T=K.secretKey;V(R,K.secretKey,"secretKey");let h=V(n(R),2*T,"hashedSecretKey"),b=_(h.slice(0,T)),E=h.slice(T,2*T),C=L(b);return{head:b,prefix:E,scalar:C}}function w(R){let{head:T,prefix:h,scalar:b}=x(R),E=i.multiply(b),C=E.toBytes();return{head:T,prefix:h,scalar:b,point:E,pointBytes:C}}function m(R){return w(R).pointBytes}function B(R=Uint8Array.of(),...T){let h=Bt(...T);return L(n(S(h,V(R,void 0,"context"),!!s)))}function v(R,T,h={}){pt(h,{},{},"options"),R=V(R,void 0,"message"),s&&(R=s(R));let{prefix:b,scalar:E,pointBytes:C}=w(T),g=B(h.context,b,R),d=i.multiply(g).toBytes(),A=B(h.context,d,C,R),I=c.create(g+A*E);if(!c.isValid(I))throw new Error("sign failed: invalid s");let F=Bt(d,c.toBytes(I));return V(F,K.signature,"result")}let k={zip215:o.zip215};function P(R,T,h,b=k){pt(b);let{context:E}=b,C=b.zip215===void 0?!!k.zip215:b.zip215,g=K.signature;R=V(R,g,"signature"),T=V(T,void 0,"message"),h=V(h,K.publicKey,"publicKey"),C!==void 0&&dt(C,"zip215"),s&&(T=s(T));let d=g/2,A=R.subarray(0,d),I=he(R.subarray(d,g)),F,N,j;try{F=e.fromBytes(h,C),N=e.fromBytes(A,C),j=i.multiplyUnsafe(I)}catch{return!1}if(!C&&F.isSmallOrder())return!1;let z=B(E,A,h,T);return N.add(F.multiplyUnsafe(z)).subtract(j).clearCofactor().is0()}let U=a.BYTES,K={secretKey:U,publicKey:U,signature:2*U,seed:U};function O(R){return R=R===void 0?l(K.seed):R,V(R,K.seed,"seed")}function q(R){return Gt(R)&&R.length===K.secretKey}function D(R,T){try{return!!e.fromBytes(R,T===void 0?k.zip215:T)}catch{return!1}}let G={getExtendedPublicKey:w,randomSecretKey:O,isValidSecretKey:q,isValidPublicKey:D,toMontgomery(R){if(y===void 0)throw new Error("Montgomery conversion is not supported for this curve");return y(e.fromBytes(R))},toMontgomerySecret(R){if(p===void 0)throw new Error("Montgomery conversion is not supported for this curve");return p(R)}};return Object.freeze(K),Object.freeze(G),Object.freeze({keygen:Yr(O,m),getPublicKey:m,sign:v,verify:P,utils:G,Point:e,lengths:K})}var yo=BigInt(1),Ti=BigInt(2);var Ff=BigInt(5),Nf=BigInt(8),bo=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),kf={p:bo,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Nf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Pf(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=bo,a=e*e%s*e%s,c=X(a,Ti,s)*a%s,f=X(c,yo,s)*e%s,u=X(f,Ff,s)*f%s,l=X(u,t,s)*u%s,y=X(l,r,s)*l%s,p=X(y,n,s)*y%s,_=X(p,o,s)*p%s,S=X(_,o,s)*p%s,L=X(S,t,s)*u%s;return{pow_p_5_8:X(L,Ti,s)*e%s,b2:a}}function Li(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var _i=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Mf(e,t){let r=bo,n=J(t*t*t,r),o=J(n*n*t,r),s=Pf(e*o).pow_p_5_8,i=J(e*n*s,r),a=J(t*i*i,r),c=i,f=J(i*_i,r),u=a===e,l=a===J(-e,r),y=a===J(-e*_i,r);return u&&(i=c),(l||y)&&(i=f),bi(i,r)&&(i=J(-i,r)),{isValid:u||l,value:i}}var go=vi(kf,{uvRatio:Mf}),Ri=go.Fp;function qf(e){let{y:t}=e;return Ri.toBytes(Ri.div(yo+t,yo-t))}function Hf(e){let t=go.Fp.BYTES;return gt(e,t),Li(nr(e.subarray(0,t))).subarray(0,t)}function zf(e){return Ii(go,nr,Object.assign({adjustScalarBytes:Li,toMontgomery:qf,toMontgomerySecret:Hf,zip215:!0},e))}var Fe=zf({});var Qt=32,wt=64,Wr=32;var Ne,Di=(async()=>{try{return await W.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function Ci(){let e=Fe.utils.randomSecretKey(),t=Fe.getPublicKey(e);return{privateKey:Fi(e,t),publicKey:t}}function Ki(e){if(e.length!==Wr)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let t=e,r=Fe.getPublicKey(t);return{privateKey:Fi(t,r),publicKey:r}}async function jf(e,t){let r;e.length===wt?r=e.subarray(0,32):r=e;let n={crv:"Ed25519",kty:"OKP",x:H(e.subarray(32),"base64url"),d:H(r,"base64url"),ext:!0,key_ops:["sign"]},o=await W.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),s=await W.get().subtle.sign({name:"Ed25519"},o,ot(t instanceof Uint8Array?t:t.subarray()));return new Uint8Array(s,0,s.byteLength)}function Vf(e,t){let r=e.subarray(0,Wr);return Fe.sign(t instanceof Uint8Array?t:t.subarray(),r)}async function Oi(e,t){return Ne==null&&(Ne=await Di),Ne?jf(e,t):Vf(e,t)}async function Zf(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await W.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await W.get().subtle.verify({name:"Ed25519"},n,ot(t),ot(r instanceof Uint8Array?r:r.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function Yf(e,t,r){return Fe.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Ui(e,t,r){return Ne==null&&(Ne=await Di),Ne?Zf(e,t,r):Yf(e,t,r)}function Fi(e,t){let r=new Uint8Array(wt);for(let n=0;n<Wr;n++)r[n]=e[n],r[Wr+n]=t[n];return r}function wo(e,t){let r=$(e,"base64urlpad");if(t!=null){if(r.length>t)throw new Error("byte array longer than desired length");r=Ct([new Uint8Array(t-r.length),r])}return r}function ke(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var fr=class{type="Ed25519";raw;constructor(t){this.raw=Pe(t,Qt)}toMultihash(){return oe.digest(ie(this))}toCID(){return St.createV1(114,this.toMultihash())}toString(){return nt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Ui(this.raw,r,t);return ke(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}},de=class{type="Ed25519";raw;publicKey;constructor(t,r){this.raw=Pe(t,wt),this.publicKey=new fr(r)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}sign(t,r){r?.signal?.throwIfAborted();let n=Oi(this.raw,t);return ke(n)?n.then(o=>(r?.signal?.throwIfAborted(),o)):(r?.signal?.throwIfAborted(),n)}};function xo(e){if(e.length>wt){e=Pe(e,wt+Qt);let n=e.subarray(0,wt),o=e.subarray(wt,e.length);return new de(n,o)}e=Pe(e,wt);let t=e.subarray(0,wt),r=e.subarray(Qt);return new de(t,r)}function Jr(e){return e=Pe(e,Qt),new fr(e)}async function ki(){let{privateKey:e,publicKey:t}=Ci();return new de(e,t)}async function Pi(e){let{privateKey:t,publicKey:r}=Ki(e);return new de(t,r)}function Pe(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new M(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var $f=Math.pow(2,7),Gf=Math.pow(2,14),Xf=Math.pow(2,21),Mi=Math.pow(2,28),qi=Math.pow(2,35),Hi=Math.pow(2,42),zi=Math.pow(2,49),ht=128,te=127;function ur(e){if(e<$f)return 1;if(e<Gf)return 2;if(e<Xf)return 3;if(e<Mi)return 4;if(e<qi)return 5;if(e<Hi)return 6;if(e<zi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ji(e,t,r=0){switch(ur(e)){case 8:t[r++]=e&255|ht,e/=128;case 7:t[r++]=e&255|ht,e/=128;case 6:t[r++]=e&255|ht,e/=128;case 5:t[r++]=e&255|ht,e/=128;case 4:t[r++]=e&255|ht,e>>>=7;case 3:t[r++]=e&255|ht,e>>>=7;case 2:t[r++]=e&255|ht,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Vi(e,t){let r=e[t],n=0;if(n+=r&te,r<ht||(r=e[t+1],n+=(r&te)<<7,r<ht)||(r=e[t+2],n+=(r&te)<<14,r<ht)||(r=e[t+3],n+=(r&te)<<21,r<ht)||(r=e[t+4],n+=(r&te)*Mi,r<ht)||(r=e[t+5],n+=(r&te)*qi,r<ht)||(r=e[t+6],n+=(r&te)*Hi,r<ht)||(r=e[t+7],n+=(r&te)*zi,r<ht))return n;throw new RangeError("Could not decode varint")}var Eo=new Float32Array([-0]),ee=new Uint8Array(Eo.buffer);function Zi(e,t,r){Eo[0]=e,t[r]=ee[0],t[r+1]=ee[1],t[r+2]=ee[2],t[r+3]=ee[3]}function Yi(e,t){return ee[0]=e[t],ee[1]=e[t+1],ee[2]=e[t+2],ee[3]=e[t+3],Eo[0]}var So=new Float64Array([-0]),ct=new Uint8Array(So.buffer);function $i(e,t,r){So[0]=e,t[r]=ct[0],t[r+1]=ct[1],t[r+2]=ct[2],t[r+3]=ct[3],t[r+4]=ct[4],t[r+5]=ct[5],t[r+6]=ct[6],t[r+7]=ct[7]}function Gi(e,t){return ct[0]=e[t],ct[1]=e[t+1],ct[2]=e[t+2],ct[3]=e[t+3],ct[4]=e[t+4],ct[5]=e[t+5],ct[6]=e[t+6],ct[7]=e[t+7],So[0]}var Wf=BigInt(Number.MAX_SAFE_INTEGER),Jf=BigInt(Number.MIN_SAFE_INTEGER),xt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return pe;if(t<Wf&&t>Jf)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Xi&&(o=0n,++n>Xi&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return pe;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):pe}},pe=new xt(0,0);pe.toBigInt=function(){return 0n};pe.zzEncode=pe.zzDecode=function(){return this};pe.length=function(){return 1};var Xi=4294967296n;function Wi(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ji(e,t,r){if(r-t<1)return"";let o,s=[],i=0,a;for(;t<r;)a=e[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Ao(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Tt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Qr(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Bo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=ot(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,Tt(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 Tt(this,4);return Qr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Tt(this,4);return Qr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Tt(this,4);let t=Yi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Tt(this,4);let t=Gi(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Tt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ji(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Tt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Tt(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 xt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Tt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Tt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Tt(this,8);let t=Qr(this.buf,this.pos+=4),r=Qr(this.buf,this.pos+=4);return new xt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Vi(this.buf,this.pos);return this.pos+=ur(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 lr(e){return new Bo(e instanceof Uint8Array?e:e.subarray())}function tn(e,t,r){let n=lr(e);return t.decode(n,void 0,r)}function vo(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return mt(i);o+i>t&&(n=mt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var me=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Io(){}var _o=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Qf=vo();function tu(e){return globalThis.Buffer!=null?mt(e):Qf(e)}var dr=class{len;head;tail;states;constructor(){this.len=0,this.head=new me(Io,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new me(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Ro((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(en,10,xt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=xt.fromBigInt(t);return this._push(en,r.length(),r)}uint64Number(t){return this._push(ji,ur(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=xt.fromBigInt(t).zzEncode();return this._push(en,r.length(),r)}sint64Number(t){let r=xt.fromNumber(t).zzEncode();return this._push(en,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(To,1,t?1:0)}fixed32(t){return this._push(hr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=xt.fromBigInt(t);return this._push(hr,4,r.lo)._push(hr,4,r.hi)}fixed64Number(t){let r=xt.fromNumber(t);return this._push(hr,4,r.lo)._push(hr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Zi,4,t)}double(t){return this._push($i,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(To,1,0):this.uint32(r)._push(ru,r,t)}string(t){let r=Wi(t);return r!==0?this.uint32(r)._push(Ao,r,t):this._push(To,1,0)}fork(){return this.states=new _o(this),this.head=this.tail=new me(Io,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 me(Io,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=tu(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function To(e,t,r){t[r]=e&255}function eu(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Ro=class extends me{next;constructor(t,r){super(eu,t,r),this.next=void 0}};function en(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function hr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function ru(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(dr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(nu,t,e),this},dr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(ou,t,e),this});function nu(e,t,r){t.set(e,r)}function ou(e,t,r){e.length<40?Ao(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set($(e),r)}function Lo(){return new dr}function rn(e,t){let r=Lo();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*nn(e,t,r){let n=lr(e);yield*t.stream(n,void 0,"$",r)}var on={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function sn(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function Do(e){function t(s){if(e[s.toString()]==null)throw new Error("Invalid enum value");return e[s]}let r=function(i,a){let c=t(i);a.int32(c)},n=function(i){let a=i.int32();return t(a)},o=function*(i){let a=i.int32();yield t(a)};return sn("enum",on.VARINT,r,n,o)}function an(e,t,r){return sn("message",on.LENGTH_DELIMITED,e,t,r)}var Y;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(Y||(Y={}));var Co;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Co||(Co={}));(function(e){e.codec=()=>Do(Co)})(Y||(Y={}));var Ut;(function(e){let t;e.codec=()=>(t==null&&(t=an((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),Y.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let c={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{c.Type=Y.codec().decode(s);break}case 2:{c.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return c},function*(s,i,a,c={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:Y.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return rn(s,e.codec())}e.encode=r;function n(s,i){return tn(s,e.codec(),i)}e.decode=n;function o(s,i){return nn(s,e.codec(),i)}e.stream=o})(Ut||(Ut={}));var pr;(function(e){let t;e.codec=()=>(t==null&&(t=an((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),Y.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let c={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{c.Type=Y.codec().decode(s);break}case 2:{c.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return c},function*(s,i,a,c={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:Y.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return rn(s,e.codec())}e.encode=r;function n(s,i){return tn(s,e.codec(),i)}e.decode=n;function o(s,i){return nn(s,e.codec(),i)}e.stream=o})(pr||(pr={}));function Ko(e){if(isNaN(e)||e<=0)throw new M("random bytes length must be a Number bigger than 0");return crypto.getRandomValues(new Uint8Array(e))}var yr={};it(yr,{MAX_RSA_KEY_SIZE:()=>Oo,generateRSAKeyPair:()=>qo,jwkToJWKKeyPair:()=>na,jwkToPkcs1:()=>cu,jwkToPkix:()=>ko,jwkToRSAPrivateKey:()=>un,pkcs1MessageToJwk:()=>Fo,pkcs1MessageToRSAPrivateKey:()=>cn,pkcs1ToJwk:()=>au,pkcs1ToRSAPrivateKey:()=>Po,pkixMessageToJwk:()=>No,pkixMessageToRSAPublicKey:()=>fn,pkixToJwk:()=>fu,pkixToRSAPublicKey:()=>Mo});var Me=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=yr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return St.createV1(114,this._multihash)}toString(){return nt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}verify(t,r,n){return ra(this.jwk,r,t,n)}},mr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=yr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}sign(t,r){return ea(this.jwk,t,r)}};var Oo=8192,Uo=18,su=1062,iu=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function au(e){let t=yt(e);return Fo(t)}function Fo(e){return{n:H(e[1],"base64url"),e:H(e[2],"base64url"),d:H(e[3],"base64url"),p:H(e[4],"base64url"),q:H(e[5],"base64url"),dp:H(e[6],"base64url"),dq:H(e[7],"base64url"),qi:H(e[8],"base64url"),kty:"RSA"}}function cu(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new M("JWK was missing components");return vt([lt(Uint8Array.from([0])),lt($(e.n,"base64url")),lt($(e.e,"base64url")),lt($(e.d,"base64url")),lt($(e.p,"base64url")),lt($(e.q,"base64url")),lt($(e.dp,"base64url")),lt($(e.dq,"base64url")),lt($(e.qi,"base64url"))]).subarray()}function fu(e){let t=yt(e,{offset:0});return No(t)}function No(e){let t=yt(e[1],{offset:0});return{kty:"RSA",n:H(t[0],"base64url"),e:H(t[1],"base64url")}}function ko(e){if(e.n==null||e.e==null)throw new M("JWK was missing components");return vt([iu,Qe(vt([lt($(e.n,"base64url")),lt($(e.e,"base64url"))]))]).subarray()}function Po(e){let t=yt(e);return cn(t)}function cn(e){let t=Fo(e);return un(t)}function Mo(e,t){if(e.byteLength>=su)throw new ge("Key size is too large");let r=yt(e,{offset:0});return fn(r,e,t)}function fn(e,t,r){let n=No(e);if(r==null){let o=Zt(Ut.encode({Type:Y.RSA,Data:t}));r=Dt(Uo,o)}return new Me(n,r)}function un(e){if(sa(e)>Oo)throw new M("Key size is too large");let t=na(e),r=Zt(Ut.encode({Type:Y.RSA,Data:ko(t.publicKey)})),n=Dt(Uo,r);return new mr(t.privateKey,new Me(t.publicKey,n))}async function qo(e){if(e>Oo)throw new M("Key size is too large");let t=await oa(e),r=Zt(Ut.encode({Type:Y.RSA,Data:ko(t.publicKey)})),n=Dt(Uo,r);return new mr(t.privateKey,new Me(t.publicKey,n))}function na(e){if(e==null)throw new M("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}var ia="1.2.840.113549.1.1.1";async function oa(e,t){let r=await W.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await uu(r,t);return{privateKey:n[0],publicKey:n[1]}}async function ea(e,t,r){let n=await W.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await W.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,ot(t instanceof Uint8Array?t:t.subarray()));return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function ra(e,t,r,n){let o=await W.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let s=await W.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,ot(t),ot(r instanceof Uint8Array?r:r.subarray()));return n?.signal?.throwIfAborted(),s}async function uu(e,t){if(e.privateKey==null||e.publicKey==null)throw new M("Private and public key are required");let r=await Promise.all([W.get().subtle.exportKey("jwk",e.privateKey),W.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function sa(e){if(e.kty!=="RSA")throw new M("invalid key type");if(e.n==null)throw new M("invalid key modulus");return $(e.n,"base64url").length*8}var ln=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(Te(t),gt(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),At(o)}update(t){return _e(this),this.iHash.update(t),this}digestInto(t){_e(this),Rr(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a,canXOF:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.canXOF=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},hn=(()=>{let e=((t,r,n)=>new ln(t,r).update(n).digest());return e.create=(t,r)=>new ln(t,r),e})();var lu=BigInt(0),Ho=class extends Error{constructor(t=""){super(t)}},kt={Err:Ho,_tlv:{encode:(e,t)=>{let{Err:r}=kt;if(Xt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(oi(t,"data"),t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=sr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?sr(o.length/2|128):"";return sr(e)+s+o+t},decode(e,t){let{Err:r}=kt;t=V(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.decode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=c,i<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=kt;if(Nr(e),e<lu)throw new t("integer: negative integers are not allowed");let r=sr(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=kt;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Ot(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=kt,o=V(e,void 0,"signature"),{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:f,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=kt;pt(e,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}},zo=(Object.freeze(kt._tlv),Object.freeze(kt._int),Object.freeze(kt));var aa=(e,t)=>(e+(e>=0?t:-t)/ca)/t;function hu(e,t,r){De("scalar",e,Pt,r);let[[n,o],[s,i]]=t,a=aa(i*e,r),c=aa(-o*e,r),f=e-a*n-c*s,u=-a*o-c*i,l=f<Pt,y=u<Pt;l&&(f=-f),y&&(u=-u);let p=ir(Math.ceil(Ce(r)/2))+ye;if(f<Pt||f>=p||u<Pt||u>=p)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:f,k2neg:y,k2:u}}function Zo(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function jo(e,t){pt(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return dt(r.lowS,"lowS"),dt(r.prehash,"prehash"),r.format!==void 0&&Zo(r.format),r}var Pt=BigInt(0),ye=BigInt(1),ca=BigInt(2),Vo=BigInt(3),du=BigInt(4);function fa(e,t={}){let r=Zr("weierstrass",e,t),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:a}=s;pt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f}=t,u=t.randomBytes===void 0?le:t.randomBytes;if(c&&(!n.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=la(n,o);function y(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function p(T,h,b){if(f&&h.is0())return Uint8Array.of(0);let{x:E,y:C}=h.toAffine(),g=n.toBytes(E);if(dt(b,"isCompressed"),b){y();let d=!n.isOdd(C);return Bt(ua(d),g)}else return Bt(Uint8Array.of(4),g,n.toBytes(C))}function _(T){V(T,void 0,"Point");let{publicKey:h,publicKeyUncompressed:b}=l,E=T.length,C=T[0],g=T.subarray(1);if(f&&E===1&&C===0)return{x:n.ZERO,y:n.ZERO};if(E===h&&(C===2||C===3)){let d=n.fromBytes(g);if(!n.isValid(d))throw new Error("bad point: is not on curve, wrong x");let A=m(d),I;try{I=n.sqrt(A)}catch(j){let z=j instanceof Error?": "+j.message:"";throw new Error("bad point: is not on curve, sqrt error"+z)}y();let F=n.isOdd(I);return(C&1)===1!==F&&(I=n.neg(I)),{x:d,y:I}}else if(E===b&&C===4){let d=n.BYTES,A=n.fromBytes(g.subarray(0,d)),I=n.fromBytes(g.subarray(d,d*2));if(!B(A,I))throw new Error("bad point: is not on curve");return{x:A,y:I}}else throw new Error(`bad point: got length ${E}, expected compressed=${h} or uncompressed=${b}`)}let S=t.toBytes===void 0?p:t.toBytes,L=t.fromBytes===void 0?_:t.fromBytes,x=n.mul(s.b,Vo),w=n.is0(s.a)?T=>n.ZERO:T=>n.mul(s.a,T);function m(T){let h=n.sqr(T),b=n.mul(h,T);return n.add(n.add(b,n.mul(T,s.a)),s.b)}function B(T,h){let b=n.sqr(h),E=m(T);return n.eql(b,E)}if(!B(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let v=n.mul(n.pow(s.a,Vo),du),k=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(v,k)))throw new Error("bad curve params: a or b");function P(T,h,b=!1){if(!n.isValid(h)||b&&n.is0(h))throw new Error(`bad point coordinate ${T}`);return h}function U(T){if(!(T instanceof D))throw new Error("Weierstrass Point expected")}function K(T){if(!c||!c.basises)throw new Error("no endo");return hu(T,c.basises,o.ORDER)}function O(T,h,b,E){if(!o.isValid(E))throw new RangeError("invalid scalar: out of range");if(c){let{k1neg:C,k1:g,k2neg:d,k2:A}=K(E),I=new D(n.mul(b.X,c.beta),b.Y,b.Z);T.push(C?b.negate():b,d?I.negate():I),h.push(g,A)}else T.push(b),h.push(E)}let q=new WeakSet;class D{static BASE=new D(s.Gx,s.Gy,n.ONE);static ZERO=new D(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(h,b,E){this.X=P("x",h),this.Y=P("y",b,!0),this.Z=P("z",E),Object.freeze(this)}static CURVE(){return s}static fromAffine(h){let{x:b,y:E}=h||{};if(!h||!n.isValid(b)||!n.isValid(E))throw new Error("invalid affine point");if(h instanceof D)throw new Error("projective point not allowed");return n.is0(b)&&n.is0(E)?D.ZERO:new D(b,E,n.ONE)}static fromBytes(h){let b=D.fromAffine(L(V(h,void 0,"point")));return b.assertValidity(),b}static fromHex(h){return D.fromBytes(Le(h))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(h=6,b=!0){return R.setWindowSize(this,h),b||this.multiply(Vo),this}assertValidity(){let h=this;if(h.is0()){if(t.allowInfinityPoint&&n.is0(h.X)&&n.eql(h.Y,n.ONE)&&n.is0(h.Z))return;throw new Error("bad point: ZERO")}if(q.has(h))return;let{x:b,y:E}=h.toAffine();if(!n.isValid(b)||!n.isValid(E))throw new Error("bad point: x or y not field elements");if(!B(b,E))throw new Error("bad point: equation left != right");if(!h.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");q.add(h)}hasEvenY(){let{y:h}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(h)}equals(h){U(h);let{X:b,Y:E,Z:C}=this,{X:g,Y:d,Z:A}=h,I=n.eql(n.mul(b,A),n.mul(g,C)),F=n.eql(n.mul(E,A),n.mul(d,C));return I&&F}negate(){return new D(this.X,n.neg(this.Y),this.Z)}double(){let{X:h,Y:b,Z:E}=this,C=n.ZERO,g=n.ZERO,d=n.ZERO,A=n.mul(h,h),I=n.mul(b,b),F=n.mul(E,E),N=n.mul(h,b);return N=n.add(N,N),d=n.mul(h,E),d=n.add(d,d),C=w(d),g=n.mul(x,F),g=n.add(C,g),C=n.sub(I,g),g=n.add(I,g),g=n.mul(C,g),C=n.mul(N,C),d=n.mul(x,d),F=w(F),N=n.sub(A,F),N=w(N),N=n.add(N,d),d=n.add(A,A),A=n.add(d,A),A=n.add(A,F),A=n.mul(A,N),g=n.add(g,A),F=n.mul(b,E),F=n.add(F,F),A=n.mul(F,N),C=n.sub(C,A),d=n.mul(F,I),d=n.add(d,d),d=n.add(d,d),new D(C,g,d)}add(h){U(h);let{X:b,Y:E,Z:C}=this,{X:g,Y:d,Z:A}=h,I=n.ZERO,F=n.ZERO,N=n.ZERO,j=n.mul(b,g),z=n.mul(E,d),Q=n.mul(C,A),ft=n.add(b,E),tt=n.add(g,d);ft=n.mul(ft,tt),tt=n.add(j,z),ft=n.sub(ft,tt),tt=n.add(b,C);let st=n.add(g,A);return tt=n.mul(tt,st),st=n.add(j,Q),tt=n.sub(tt,st),st=n.add(E,C),I=n.add(d,A),st=n.mul(st,I),I=n.add(z,Q),st=n.sub(st,I),N=w(tt),I=n.mul(x,Q),N=n.add(I,N),I=n.sub(z,N),N=n.add(z,N),F=n.mul(I,N),z=n.add(j,j),z=n.add(z,j),Q=w(Q),tt=n.mul(x,tt),z=n.add(z,Q),Q=n.sub(j,Q),Q=w(Q),tt=n.add(tt,Q),j=n.mul(z,tt),F=n.add(F,j),j=n.mul(st,tt),I=n.mul(ft,I),I=n.sub(I,j),j=n.mul(ft,z),N=n.mul(st,N),N=n.add(N,j),new D(I,F,N)}subtract(h){return U(h),this.add(h.negate())}is0(){return this.equals(D.ZERO)}multiply(h){if(!o.isValidNot0(h))throw new RangeError("invalid scalar: out of range");let{p:b,f:E}=R.mulSecret(this,h,i,G);return G([b,E])[0]}multiplyUnsafe(h){let b=this,E=h;if(!o.isValid(E))throw new RangeError("invalid scalar: out of range");if(E===Pt||b.is0())return D.ZERO;if(E===ye)return b;if(R.hasWindowSize(this))return R.mulUnsafe(b,E,G);let C=[],g=[];return O(C,g,b,E),Vr(D,C,g)}mulAddUnsafe(h,b,E){U(b);let C=[],g=[];return O(C,g,this,h),O(C,g,b,E),Vr(D,C,g)}toAffine(h){let b=this,E=h;if(E!=null&&!n.isValid(E))throw new RangeError('"invertedZ" expected valid field element');let{X:C,Y:g,Z:d}=b;if(n.eql(d,n.ONE))return{x:C,y:g};let A=b.is0();E==null&&(E=A?n.ONE:n.inv(d));let I=n.mul(C,E),F=n.mul(g,E),N=n.mul(d,E);if(A)return{x:n.ZERO,y:n.ZERO};if(!n.eql(N,n.ONE))throw new Error("invZ was invalid");return{x:I,y:F}}isTorsionFree(){let{isTorsionFree:h}=t;return i===ye?!0:h?h(D,this):R.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:h}=t;return i===ye?this:h?h(D,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===ye?this.is0():this.clearCofactor().is0()}toBytes(h=!0){return dt(h,"isCompressed"),this.assertValidity(),S(D,this,h)}toHex(h=!0){return or(this.toBytes(h))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let G=T=>jr(D,T),R=new Ue(D,u);return R.bits>=6&&D.BASE.precompute(6),Object.freeze(D.prototype),Object.freeze(D),D}function ua(e){return Uint8Array.of(e?2:3)}function la(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function pu(e,t={}){Jt(e);let{Fn:r}=e,n=t.randomBytes===void 0?le:t.randomBytes,o=Object.assign(la(e.Fp,r),{seed:Math.max(Hr(r.ORDER),16)});function s(p){try{let _=r.fromBytes(p);return r.isValidNot0(_)}catch{return!1}}function i(p,_){let{publicKey:S,publicKeyUncompressed:L}=o;try{let x=p.length;return _===!0&&x!==S||_===!1&&x!==L?!1:!!e.fromBytes(p)}catch{return!1}}function a(p){return p=p===void 0?n(o.seed):p,zr(V(p,o.seed,"seed"),r.ORDER)}function c(p,_=!0){return e.BASE.multiply(r.fromBytes(p)).toBytes(_)}function f(p){let{secretKey:_,publicKey:S,publicKeyUncompressed:L}=o,x=r._lengths;if(!Gt(p))return;let w=V(p,void 0,"key").length,m=w===S||w===L,B=w===_||!!x?.includes(w);if(!(m&&B))return m}function u(p,_,S=!0){if(f(p)===!0)throw new Error("first arg must be private key");if(f(_)===!1)throw new Error("second arg must be public key");let L=r.fromBytes(p);return e.fromBytes(_).multiply(L).toBytes(S)}let l={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a},y=Yr(a,c);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:y,Point:e,utils:l,lengths:o})}function ha(e,t,r={}){Jt(e);let n=t;Te(n),pt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},r),s=o.randomBytes===void 0?le:o.randomBytes,i=o.hmac===void 0?(g,d)=>hn(n,g,d):o.hmac,{Fp:a,Fn:c}=e,{ORDER:f,BITS:u}=c,l=Hr(f),y=mo(s,l),{keygen:p,getPublicKey:_,getSharedSecret:S,utils:L,lengths:x}=pu(e,o),w={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},m=f*ca+ye<a.ORDER;function B(g){let d=f>>ye;return g>d}function v(g,d){if(!c.isValidNot0(d))throw new Error(`invalid signature ${g}: out of range 1..Point.Fn.ORDER`);return d}function k(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function P(g,d,A){return k(),(g===A?0:2)|Number(a.isOdd(d))}function U(){if(m)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function K(g,d){Zo(d);let A=x.signature,I=d==="compact"?A:d==="recovered"?A+1:void 0;return V(g,I)}class O{r;s;recovery;constructor(d,A,I){if(this.r=v("r",d),this.s=v("s",A),I!=null){if(U(),![0,1,2,3].includes(I))throw new Error("invalid recovery id");this.recovery=I}Object.freeze(this)}static fromBytes(d,A=w.format){K(d,A);let I;if(A==="der"){let{r:z,s:Q}=zo.toSig(V(d));return new O(z,Q)}A==="recovered"&&(I=d[0],A="compact",d=d.subarray(1));let F=x.signature/2,N=d.subarray(0,F),j=d.subarray(F,F*2);return new O(c.fromBytes(N),c.fromBytes(j),I)}static fromHex(d,A){return this.fromBytes(Le(d),A)}assertRecovery(){let{recovery:d}=this;if(d==null)throw new Error("invalid recovery id: must be present");return d}addRecoveryBit(d){return new O(this.r,this.s,d)}recoverPublicKey(d){let{r:A,s:I}=this,F=this.assertRecovery(),N=F===2||F===3?A+f:A;if(!a.isValid(N))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let j=a.toBytes(N),z=e.fromBytes(Bt(ua((F&1)===0),j)),Q=c.inv(N),ft=D(V(d,void 0,"msgHash")),tt=c.create(-ft*Q),st=c.create(I*Q),Rt=e.BASE.mulAddUnsafe(tt,z,st);if(Rt.is0())throw new Error("invalid recovery: point at infinify");return Rt.assertValidity(),Rt}hasHighS(){return B(this.s)}toBytes(d=w.format){if(Zo(d),d==="der")return Le(zo.hexFromSig(this));let{r:A,s:I}=this,F=c.toBytes(A),N=c.toBytes(I);return d==="recovered"?(U(),Bt(Uint8Array.of(this.assertRecovery()),F,N)):Bt(F,N)}toHex(d){return or(this.toBytes(d))}}Object.freeze(O.prototype),Object.freeze(O);let q=o.bits2int===void 0?function(d){if(d.length>8192)throw new Error("input is too large");let A=Ot(d),I=d.length*8-u;return I>0?A>>BigInt(I):A}:o.bits2int,D=o.bits2int_modN===void 0?function(d){return c.create(q(d))}:o.bits2int_modN,G=ir(u);function R(g){return De("num < 2^"+u,g,Pt,G),c.toBytes(g)}function T(g,d){return V(g,void 0,"message"),d?V(n(g),void 0,"prehashed message"):g}function h(g,d,A){let{lowS:I,prehash:F,extraEntropy:N}=jo(A,w);g=T(g,F);let j=D(g),z=c.fromBytes(d);if(!c.isValidNot0(z))throw new Error("invalid private key");let Q=[R(z),R(j)];if(N!=null&&N!==!1){let Rt=N===!0?s(x.secretKey):N;Q.push(V(Rt,void 0,"extraEntropy"))}let ft=Bt(...Q),tt=j;function st(Rt){let be=q(Rt);if(!c.isValidNot0(be))return;let qe=e.BASE.multiply(be).toAffine(),Mt=c.create(qe.x);if(Mt===Pt)return;let Lt;if(y!==void 0){let He=Ot(zr(y(l),f)),Ra=c.inv(c.mul(He,be)),La=c.mul(He,tt),Da=c.mul(He,z);Lt=c.create(Ra*c.create(La+Da*Mt))}else{let He=pi(be,f);Lt=c.create(He*c.create(tt+Mt*z))}if(Lt===Pt)return;let mn=P(qe.x,qe.y,Mt),ts=Lt;return I&&B(Lt)&&(ts=c.neg(Lt),mn^=1),new O(Mt,ts,m?void 0:mn)}return{seed:ft,k2sig:st}}function b(g,d,A={}){let{seed:I,k2sig:F}=h(g,d,A);return ii(n.outputLen,c.BYTES,i)(I,F).toBytes(A.format)}function E(g,d,A,I={}){let{lowS:F,prehash:N,format:j}=jo(I,w);if(A=V(A,void 0,"publicKey"),d=T(d,N),!Gt(g)){let z=g instanceof O?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+z)}K(g,j);try{let z=O.fromBytes(g,j),Q=e.fromBytes(A);if(F&&z.hasHighS())return!1;let{r:ft,s:tt}=z,st=D(d),Rt=c.inv(tt),be=c.create(st*Rt),qe=c.create(ft*Rt),Mt=e.BASE.mulAddUnsafe(be,Q,qe);if(Mt.is0())return!1;let Lt=Mt.toAffine();return!(c.create(Lt.x)!==ft||j==="recovered"&&z.recovery!==P(Lt.x,Lt.y,ft))}catch{return!1}}function C(g,d,A={}){let{prehash:I}=jo(A,w);return d=T(d,I),O.fromBytes(g,"recovered").recoverPublicKey(d).toBytes()}return Object.freeze({keygen:p,getPublicKey:_,getSharedSecret:S,utils:L,lengths:x,Point:e,sign:b,verify:E,recoverPublicKey:C,Signature:O,hash:n})}var $o={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},mu={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var da=BigInt(2);function yu(e){let t=$o.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),f=e*e*e%t,u=f*f*e%t,l=X(u,r,t)*u%t,y=X(l,r,t)*u%t,p=X(y,da,t)*f%t,_=X(p,o,t)*p%t,S=X(_,s,t)*_%t,L=X(S,a,t)*S%t,x=X(L,c,t)*L%t,w=X(x,a,t)*S%t,m=X(w,r,t)*u%t,B=X(m,i,t)*_%t,v=X(B,n,t)*f%t,k=X(v,da,t);if(!Yo.eql(Yo.sqr(k),e))throw new Error("Cannot find square root");return k}var Yo=Oe($o.p,{sqrt:yu}),bu=fa($o,{Fp:Yo,endo:mu}),_t=ha(bu,Zt);var pa=33,ma=32;function ya(e,t,r){let n=Br.digest(t instanceof Uint8Array?t:t.subarray());if(ke(n))return n.then(({digest:o})=>(r?.signal?.throwIfAborted(),_t.sign(o,e,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new ze(String(o))});try{return _t.sign(n.digest,e,{prehash:!1,format:"der"})}catch(o){throw new ze(String(o))}}function ba(e,t,r,n){let o=Br.digest(r instanceof Uint8Array?r:r.subarray());if(ke(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),_t.verify(t,s,e,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new je(String(s))});try{return n?.signal?.throwIfAborted(),_t.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(s){throw new je(String(s))}}var br=class{type="secp256k1";raw;_key;constructor(t){this._key=xa(t),this.raw=ga(this._key)}toMultihash(){return oe.digest(ie(this))}toCID(){return St.createV1(114,this.toMultihash())}toString(){return nt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}verify(t,r,n){return ba(this._key,r,t,n)}},gr=class{type="secp256k1";raw;publicKey;constructor(t,r){this.raw=wa(t),this.publicKey=new br(r??Ea(t))}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:at(this.raw,t.raw)}sign(t,r){return ya(this.raw,t,r)}};function Go(e){return new gr(e)}function dn(e){return new br(e)}async function Sa(){let e=gu();return new gr(e)}function ga(e){return _t.Point.fromBytes(e).toBytes()}function wa(e){try{return _t.getPublicKey(e,!0),e}catch(t){throw new Ve(String(t))}}function xa(e){try{return _t.Point.fromBytes(e),e}catch(t){throw new ge(String(t))}}function Ea(e){try{return _t.getPublicKey(e,!0)}catch(t){throw new Ve(String(t))}}function gu(){return _t.utils.randomSecretKey()}var pn={"P-256":32,"P-384":48,"P-521":66},wu=Object.keys(pn),Xo=wu.join(" / ");async function Aa(e){if(e!=="P-256"&&e!=="P-384"&&e!=="P-521")throw new M(`Unknown curve: ${e}. Must be ${Xo}`);let t=await W.get().subtle.generateKey({name:"ECDH",namedCurve:e},!0,["deriveBits"]),r=async(s,i)=>{let a;i!=null?a=await W.get().subtle.importKey("jwk",Eu(e,i),{name:"ECDH",namedCurve:e},!1,["deriveBits"]):a=t.privateKey;let c=await W.get().subtle.importKey("jwk",Ba(e,s),{name:"ECDH",namedCurve:e},!1,[]),f=await W.get().subtle.deriveBits({name:"ECDH",public:c},a,pn[e]*8);return new Uint8Array(f,0,f.byteLength)},n=await W.get().subtle.exportKey("jwk",t.publicKey);return{key:xu(n),genSharedKey:r}}function xu(e){if(e.crv==null||e.x==null||e.y==null)throw new M("JWK was missing components");if(e.crv!=="P-256"&&e.crv!=="P-384"&&e.crv!=="P-521")throw new M(`Unknown curve: ${e.crv}. Must be ${Xo}`);let t=pn[e.crv];return Ct([Uint8Array.from([4]),wo(e.x,t),wo(e.y,t)],1+t*2)}function Ba(e,t){if(e!=="P-256"&&e!=="P-384"&&e!=="P-521")throw new M(`Unknown curve: ${e}. Must be ${Xo}`);let r=pn[e];if(!at(t.subarray(0,1),Uint8Array.from([4])))throw new M("Cannot unmarshal public key - invalid key format");return{kty:"EC",crv:e,x:H(t.subarray(1,r+1),"base64url"),y:H(t.subarray(1+r),"base64url"),ext:!0}}var Eu=(e,t)=>({...Ba(e,t.public),d:H(t.private,"base64url")});var Su={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,keySize:32}};async function va(e,t,r){if(e!=="AES-128"&&e!=="AES-256"&&e!=="Blowfish")throw new M("Cipher type was missing or unsupported");if(t!=="SHA1"&&t!=="SHA256"&&t!=="SHA512")throw new M("Hash type was missing or unsupported");if(r==null||!(r instanceof Uint8Array))throw new M("Secret was missing or an incorrect type");let n=Su[e],o=n.keySize,s=n.ivSize,i=20,a=$("key expansion"),c=2*(s+o+i),f=await bn(t,r),u=await f.digest(a),l=[],y=0;for(;y<c;){let w=await f.digest(Ct([u,a])),m=w.length;y+m>c&&(m=c-y),l.push(w),y+=m,u=await f.digest(u)}let p=c/2,_=Ct(l),S=_.subarray(0,p),L=_.subarray(p,c),x=w=>({iv:w.subarray(0,s),cipherKey:w.subarray(s,s+o),macKey:w.subarray(s+o)});return{k1:x(S),k2:x(L)}}async function Au(e,t){if(e==="Ed25519")return ki();if(e==="secp256k1")return Sa();if(e==="RSA")return qo(Du(t));if(e==="ECDSA")return Ms(Cu(t));throw new qt}async function Bu(e,t){if(e!=="Ed25519")throw new qt("Seed key derivation only supported for Ed25519 keys");return Pi(t)}function vu(e,t){let{Type:r,Data:n}=Ut.decode(e),o=n??new Uint8Array;switch(r){case Y.RSA:return Mo(o,t);case Y.Ed25519:return Jr(o);case Y.secp256k1:return dn(o);case Y.ECDSA:return Zn(o);default:throw new qt}}function Iu(e){if(e.byteLength===Qt)return Jr(e);if(e.byteLength===pa)return dn(e);let t=yt(e),r=t[1]?.[0];if(r===_n||r===Rn||r===Ln)return Yn(t);if(t[0]?.[0]===ia)return fn(t,e);throw new M("Could not extract public key from raw bytes")}function Tu(e){let{Type:t,Data:r}=Ut.decode(e.digest),n=r??new Uint8Array;switch(t){case Y.Ed25519:return Jr(n);case Y.secp256k1:return dn(n);case Y.ECDSA:return Zn(n);default:throw new qt}}function ie(e){return Ut.encode({Type:Y[e.type],Data:e.raw})}function _u(e){let t=pr.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case Y.RSA:return Po(r);case Y.Ed25519:return xo(r);case Y.secp256k1:return Go(r);case Y.ECDSA:return Fs(r);default:throw new qt}}function Ru(e){if(e.byteLength===wt)return xo(e);if(e.byteLength===ma)return Go(e);let t=yt(e),r=t[2]?.[0];if(r===_n||r===Rn||r===Ln)return Vn(t);if(t.length>8)return cn(t);throw new M("Could not extract private key from raw bytes")}function Lu(e){return pr.encode({Type:Y[e.type],Data:e.raw})}function Du(e){return e==null?2048:parseInt(e,10)}function Cu(e){if(e==="P-256"||e==null)return"P-256";if(e==="P-384")return"P-384";if(e==="P-521")return"P-521";throw new M("Unsupported curve, should be P-256, P-384 or P-521")}async function Ku(e){if(e.type==="RSA")return{privateKey:await crypto.subtle.importKey("jwk",e.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",e.publicKey.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])};if(e.type==="ECDSA")return{privateKey:await crypto.subtle.importKey("jwk",e.jwk,{name:"ECDSA",namedCurve:e.jwk.crv??"P-256"},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",e.publicKey.jwk,{name:"ECDSA",namedCurve:e.publicKey.jwk.crv??"P-256"},!0,["verify"])};throw new M("Only RSA and ECDSA keys are supported")}async function Ou(e){if(e.privateKey.algorithm.name==="RSASSA-PKCS1-v1_5"){let t=await crypto.subtle.exportKey("jwk",e.privateKey);return un(t)}if(e.privateKey.algorithm.name==="ECDSA"){let t=await crypto.subtle.exportKey("jwk",e.privateKey);return new Nt(t)}throw new M("Only RSA and ECDSA keys are supported")}var wr=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),re=new Uint32Array(80),Jo=class extends fe{A=wr[0]|0;B=wr[1]|0;C=wr[2]|0;D=wr[3]|0;E=wr[4]|0;constructor(){super(64,20,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:s}=this;return[t,r,n,o,s]}set(t,r,n,o,s){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let c=0;c<16;c++,r+=4)re[c]=t.getUint32(r,!1);for(let c=16;c<80;c++)re[c]=Lr(re[c-3]^re[c-8]^re[c-14]^re[c-16],1);let{A:n,B:o,C:s,D:i,E:a}=this;for(let c=0;c<80;c++){let f,u;c<20?(f=Kr(o,s,i),u=1518500249):c<40?(f=o^s^i,u=1859775393):c<60?(f=Or(o,s,i),u=2400959708):(f=o^s^i,u=3395469782);let l=Lr(n,5)+f+a+u+re[c]|0;a=i,i=s,s=Lr(o,30),o=n,n=l}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,this.set(n,o,s,i,a)}roundClean(){At(re)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),At(this.buffer)}},Ia=rr(()=>new Jo);function Uu(e,t,r,n){Te(e);let o=Qn({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:a}=o;if(bt(s,"c"),bt(i,"dkLen"),bt(a,"asyncTick"),s<1)throw new Error('"c" (iterations) must be >= 1');if(i<1)throw new Error('"dkLen" must be >= 1');if(i>(2**32-1)*e.outputLen)throw new Error("derived key too long");let c=Wn(t,"password"),f=Wn(r,"salt"),u=new Uint8Array(i),{iHash:l,oHash:y,outputLen:p}=hn.create(e,c),_=new Uint8Array(p),S=Fu(l,y,f,_);return{c:s,dkLen:i,asyncTick:a,DK:u,outputLen:p,eng:S}}function Fu(e,t,r,n){let o=new Uint8Array(4),s=Re(o),i=e._cloneInto().update(r),a=t._cloneInto(),c=e._cloneInto,f=t._cloneInto;return{u1:(u,l)=>{s.setInt32(0,u,!1),i._cloneInto(a).update(o).digestInto(n),t._cloneInto(a).update(n).digestInto(n),l.set(n.subarray(0,l.length))},rounds:(u,l)=>{for(let y=1;y<u;y++){c.call(e,a).update(n).digestInto(n),f.call(t,a).update(n).digestInto(n);for(let p=0;p<l.length;p++)l[p]^=n[p]}},output:u=>(e.destroy(),t.destroy(),i.destroy(),a.destroy(),At(n),u)}}function Ta(e,t,r,n){let{c:o,dkLen:s,DK:i,outputLen:a,eng:c}=Uu(e,t,r,n);for(let f=1,u=0;u<s;f++,u+=a){let l=i.subarray(u,u+a);c.u1(f,l),c.rounds(o,l)}return c.output(i)}var _a={sha1:Ia,"sha2-256":Zt,"sha2-512":nr};function Qo(e,t,r,n,o){if(o!=="sha1"&&o!=="sha2-256"&&o!=="sha2-512"){let a=Object.keys(_a).join(" / ");throw new M(`Hash '${o}' is unknown or not supported. Must be ${a}`)}let s=_a[o],i=Ta(s,e,t,{c:r,dkLen:n});return Un.encode(i).substring(1)}return Fa(Nu);})();
|
|
2
|
+
"use strict";var Libp2PCrypto=(()=>{var bn=Object.defineProperty;var Ca=Object.getOwnPropertyDescriptor;var Oa=Object.getOwnPropertyNames;var Ka=Object.prototype.hasOwnProperty;var lt=(e,t)=>{for(var r in t)bn(e,r,{get:t[r],enumerable:!0})},Ua=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Oa(t))!Ka.call(e,o)&&o!==r&&bn(e,o,{get:()=>t[o],enumerable:!(n=Ca(t,o))||n.enumerable});return e};var Fa=e=>Ua(bn({},"__esModule",{value:!0}),e);var Nu={};lt(Nu,{hmac:()=>Sr,keys:()=>Wo,pbkdf2:()=>Qo,randomBytes:()=>Ko});var Sr={};lt(Sr,{create:()=>gn});function ka(e){return e.buffer instanceof ArrayBuffer}function ut(e){return ka(e)?e:e.slice()}var je=class extends Error{constructor(t="An error occurred while signing a message"){super(t),this.name="SigningError"}},ze=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Er=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var rt={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Er("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 es={SHA1:20,SHA256:32,SHA512:64};var Na={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},Pa=async(e,t)=>{let r=await rt.get().subtle.sign({name:"HMAC"},e,ut(t));return new Uint8Array(r,0,r.byteLength)};async function gn(e,t){let r=Na[e],n=await rt.get().subtle.importKey("raw",ut(t),{name:"HMAC",hash:{name:r}},!1,["sign"]);return{async digest(o){return Pa(n,o)},length:es[e]}}var Wo={};lt(Wo,{generateEphemeralKeyPair:()=>Aa,generateKeyPair:()=>Bu,generateKeyPairFromSeed:()=>vu,keyStretcher:()=>va,privateKeyFromCryptoKeyPair:()=>Uu,privateKeyFromProtobuf:()=>Ru,privateKeyFromRaw:()=>Lu,privateKeyToCryptoKeyPair:()=>Ku,privateKeyToProtobuf:()=>Du,publicKeyFromMultihash:()=>_u,publicKeyFromProtobuf:()=>Iu,publicKeyFromRaw:()=>Tu,publicKeyToProtobuf:()=>ce});var P=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},we=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}},Ve=class extends Error{static name="InvalidPrivateKeyError";constructor(t="Invalid private key"){super(t),this.name="InvalidPrivateKeyError"}};var zt=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var An={};lt(An,{base58btc:()=>ft,base58flickr:()=>Ya});var Gu=new Uint8Array(0);function ns(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Tt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return se(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return se(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function os(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}var rs=4096;function ss(e){let t=e.length;if(t<=rs)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.subarray(n,n+=rs));return r}function Ma(e){return e?.buffer instanceof ArrayBuffer}function se(e){return Ma(e)?e:e.slice()}function qa(e,t,r){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var s=0;s<e.length;s++){var i=e.charAt(s),a=i.charCodeAt(0);if(n[a]!==255)throw new TypeError(i+" is ambiguous");if(n[a]=s,r){var c=i.toLowerCase().charCodeAt(0),f=i.toUpperCase().charCodeAt(0);c!==a&&(n[c]=s),f!==a&&(n[f]=s)}}var u=e.length,h=e.charAt(0),y=Math.log(u)/Math.log(256),d=Math.log(256)/Math.log(u);function B(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var x=0,m=0,S=0,A=w.length;S!==A&&w[S]===0;)S++,x++;for(var K=(A-S)*d+1>>>0,k=new Uint8Array(K);S!==A;){for(var U=w[S],L=0,C=K-1;(U!==0||L<m)&&C!==-1;C--,L++)U+=256*k[C]>>>0,k[C]=U%u>>>0,U=U/u>>>0;if(U!==0)throw new Error("Non-zero carry");m=L,S++}for(var H=K-m;H!==K&&k[H]===0;)H++;for(var q=h.repeat(x);H<K;++H)q+=e.charAt(k[H]);return q}function g(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var x=0;if(w[x]!==" "){for(var m=0,S=0;w[x]===h;)m++,x++;for(var A=(w.length-x)*y+1>>>0,K=new Uint8Array(A);w[x];){var k=n[w.charCodeAt(x)];if(k===255)return;for(var U=0,L=A-1;(k!==0||U<S)&&L!==-1;L--,U++)k+=u*K[L]>>>0,K[L]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");S=U,x++}if(w[x]!==" "){for(var C=A-S;C!==A&&K[C]===0;)C++;for(var H=new Uint8Array(m+(A-C)),q=m;C!==A;)H[q++]=K[C++];return H}}}function I(w){var x=g(w);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:B,decodeUnsafe:g,decode:I}}var Ha=qa,ja=Ha,as=ja;var wn=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},xn=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return cs(this,t)}},En=class{decoders;constructor(t){this.decoders=t}or(t){return cs(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function cs(e,t){return new En({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Sn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new wn(t,r,n),this.decoder=new xn(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function xe({name:e,prefix:t,encode:r,decode:n}){return new Sn(e,t,r,n)}function Vt({name:e,prefix:t,alphabet:r,caseInsensitive:n=!1}){let{encode:o,decode:s}=as(r,e,n);return xe({prefix:t,name:e,encode:o,decode:i=>Tt(s(i))})}function za(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,c=0;for(let f=0;f<o;++f){let u=t[e[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|u,i+=r,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function Va(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>r;)i-=r,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Za(e,t){let r={};for(let n=0;n<e.length;++n)if(r[e[n]]=n,t){let o=e[n].toLowerCase(),s=e[n].toUpperCase();o!==e[n]&&(r[o]=n),s!==e[n]&&(r[s]=n)}return r}function ot({name:e,prefix:t,bitsPerChar:r,alphabet:n,caseInsensitive:o=!1}){let s=Za(n,o);return xe({prefix:t,name:e,encode(i){return Va(i,n,r)},decode(i){return za(i,s,r,e)}})}var ft=Vt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ya=Vt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bn={};lt(Bn,{base32:()=>Ee,base32hex:()=>Wa,base32hexpad:()=>Qa,base32hexpadupper:()=>tc,base32hexupper:()=>Ja,base32pad:()=>Ga,base32padupper:()=>Xa,base32upper:()=>$a,base32z:()=>ec});var Ee=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),$a=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),Ga=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Xa=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Wa=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),Ja=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),Qa=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),tc=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),ec=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vn={};lt(vn,{base36:()=>Ze,base36upper:()=>rc});var Ze=Vt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),rc=Vt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var nc=ls,fs=128,oc=127,sc=~oc,ic=Math.pow(2,31);function ls(e,t,r){t=t||[],r=r||0;for(var n=r;e>=ic;)t[r++]=e&255|fs,e/=128;for(;e≻)t[r++]=e&255|fs,e>>>=7;return t[r]=e|0,ls.bytes=r-n+1,t}var ac=In,cc=128,us=127;function In(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw In.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&us)<<o:(i&us)*Math.pow(2,o),o+=7}while(i>=cc);return In.bytes=s-n,r}var fc=Math.pow(2,7),uc=Math.pow(2,14),lc=Math.pow(2,21),hc=Math.pow(2,28),dc=Math.pow(2,35),pc=Math.pow(2,42),mc=Math.pow(2,49),yc=Math.pow(2,56),bc=Math.pow(2,63),gc=function(e){return e<fc?1:e<uc?2:e<lc?3:e<hc?4:e<dc?5:e<pc?6:e<mc?7:e<yc?8:e<bc?9:10},wc={encode:nc,decode:ac,encodingLength:gc},xc=wc,Ye=xc;function $e(e,t=0){let r=Ye.decode(e,t),n=Ye.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&e[t+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[r,n]}function Se(e,t,r=0){return Ye.encode(e,t,r),t}function Ae(e){return Ye.encodingLength(e)}function Kt(e,t){let r=t.byteLength,n=Ae(e),o=n+Ae(r),s=new Uint8Array(o+r);return Se(e,s,0),Se(r,s,n),s.set(t,o),new Be(e,r,t,s)}function hs(e){let t=Tt(e),[r,n]=$e(t),[o,s]=$e(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Be(r,o,i,t)}function ds(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&ns(e.bytes,r.bytes)}}var Be=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=se(n),this.bytes=se(o)}};function ps(e,t){let{bytes:r,version:n}=e;return n===0?Sc(r,Tn(e),t??ft.encoder):Ac(r,Tn(e),t??Ee.encoder)}var ms=new WeakMap;function Tn(e){let t=ms.get(e);if(t==null){let r=new Map;return ms.set(e,r),r}return t}var _t=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=se(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Bc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Kt(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&ds(t.multihash,n.multihash)}toString(t){return ps(this,t)}toJSON(){return{"/":ps(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??ys(n,o,s.bytes))}else if(r[vc]===!0){let{version:n,multihash:o,code:s}=r,i=hs(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Xe)throw new Error(`Version 0 CID must use dag-pb (code: ${Xe}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ys(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Xe,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Tt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new Be(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[h,y]=$e(t.subarray(r));return r+=y,h},o=n(),s=Xe;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),c=n(),f=r+c,u=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,r){let[n,o]=Ec(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Tn(s).set(n,t),s}};function Ec(e,t){switch(e[0]){case"Q":{let r=t??ft;return[ft.prefix,r.decode(`${ft.prefix}${e}`)]}case ft.prefix:{let r=t??ft;return[ft.prefix,r.decode(e)]}case Ee.prefix:{let r=t??Ee;return[Ee.prefix,r.decode(e)]}case Ze.prefix:{let r=t??Ze;return[Ze.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Sc(e,t,r){let{prefix:n}=r;if(n!==ft.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Ac(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var Xe=112,Bc=18;function ys(e,t,r){let n=Ae(e),o=n+Ae(t),s=new Uint8Array(o+r.byteLength);return Se(e,s,0),Se(t,s,n),s.set(r,o),s}var vc=Symbol.for("@ipld/js-cid/CID");var _n={};lt(_n,{identity:()=>ie});var bs=0,Ic="identity",gs=Tt;function Tc(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return Kt(bs,gs(e))}var ie={code:bs,name:Ic,encode:gs,digest:Tc};function ht(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}var Rn="1.2.840.10045.3.1.7",Ln="1.3.132.0.34",Dn="1.3.132.0.35";async function ws(e="P-256"){let t=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:e},!0,["sign","verify"]);return{publicKey:await crypto.subtle.exportKey("jwk",t.publicKey),privateKey:await crypto.subtle.exportKey("jwk",t.privateKey)}}async function xs(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["sign"]);r?.signal?.throwIfAborted();let o=await crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},n,ut(t.subarray()));return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function Es(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,ut(t),ut(r.subarray()));return n?.signal?.throwIfAborted(),s}function Pt(e=0){return new Uint8Array(e)}function xt(e=0){return new Uint8Array(e)}function _c(e){return e?.buffer instanceof ArrayBuffer}function Ss(e){if(_c(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function Ut(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=xt(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return Ss(r)}var Bs=Symbol.for("@achingbrain/uint8arraylist");function As(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function Br(e){return!!e?.[Bs]}var pt=class e{bufs;length;[Bs]=!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 r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Br(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Br(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=As(this.bufs,t);return r.buf[r.index]}set(t,r){let n=As(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(Br(t))for(let n=0;n<t.length;n++)this.set(r+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,r){let{bufs:n,length:o}=this._subList(t,r);return Ut(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:Ut(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=n,s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===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 f=t>=a&&t<c,u=r>a&&r<=c;if(f&&u){if(t===a&&r===c){n.push(i);break}let h=t-a;n.push(i.subarray(h,h+(r-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(u){if(r===c){n.push(i);break}n.push(i.subarray(0,r-a));break}n.push(i)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!Br(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(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;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 h=0;h<s;h++)i[h]=-1;for(let h=0;h<o;h++)i[n[h]]=h;let a=i,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let h=r;h<=c;h+=u){u=0;for(let y=f;y>=0;y--){let d=this.get(h+y);if(n[y]!==d){u=Math.max(1,y-a[d]);break}}if(u===0)return h}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=xt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Pt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Pt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Pt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=xt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Pt(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Pt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Pt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Pt(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Pt(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ht(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};var Cn={};lt(Cn,{base10:()=>Rc});var Rc=Vt({prefix:"9",name:"base10",alphabet:"0123456789"});var On={};lt(On,{base16:()=>Lc,base16upper:()=>Dc});var Lc=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),Dc=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var Kn={};lt(Kn,{base2:()=>Cc});var Cc=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Un={};lt(Un,{base256emoji:()=>kc});var vs=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}"),Oc=vs.reduce((e,t,r)=>(e[r]=t,e),[]),Kc=vs.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Uc(e){return e.reduce((t,r)=>(t+=Oc[r],t),"")}function Fc(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Kc[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var kc=xe({prefix:"\u{1F680}",name:"base256emoji",encode:Uc,decode:Fc});var kn={};lt(kn,{base64:()=>Fn,base64pad:()=>Nc,base64url:()=>Pc,base64urlpad:()=>Mc});var Fn=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Nc=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pc=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mc=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Nn={};lt(Nn,{base8:()=>qc});var qc=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Pn={};lt(Pn,{identity:()=>Hc});var Hc=xe({prefix:"\0",name:"identity",encode:e=>ss(Tt(e)),decode:e=>Tt(os(e))});var Ol=new TextEncoder,Kl=new TextDecoder;var Hn={};lt(Hn,{sha256:()=>vr,sha512:()=>Zc});var Vc=20;function qn({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Mn(e,t,r,n,o)}var Mn=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Vc,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Is(n,this.code,r?.truncate):n.then(o=>Is(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Is(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Kt(t,e)}function _s(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var vr=qn({name:"sha2-256",code:18,encode:_s("SHA-256")}),Zc=qn({name:"sha2-512",code:19,encode:_s("SHA-512")});var jn={...Pn,...Kn,...Nn,...Cn,...On,...Bn,...vn,...An,...kn,...Un},Zl={...Hn,..._n};function Ls(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Rs=Ls("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),zn=Ls("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=xt(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Yc={utf8:Rs,"utf-8":Rs,hex:jn.base16,latin1:zn,ascii:zn,binary:zn,...jn},Ir=Yc;function X(e,t="utf8"){let r=Ir[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function z(e,t="utf8"){let r=Ir[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var $c=parseInt("11111",2),Vn=parseInt("10000000",2),Gc=parseInt("01111111",2),Ds={0:We,1:We,2:Xc,3:Qc,4:tf,5:Jc,6:Wc,16:We,22:We,48:We};function Et(e,t={offset:0}){let r=e[t.offset]&$c;if(t.offset++,Ds[r]!=null)return Ds[r](e,t);throw new Error("No decoder for tag "+r)}function Je(e,t){let r=0;if((e[t.offset]&Vn)===Vn){let n=e[t.offset]&Gc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++){if(t.offset>=e.byteLength)throw new Error("invalid DER element length");o+=e[t.offset].toString(16).padStart(2,"0")}r=parseInt(o,16)}else r=e[t.offset],t.offset++;if(!Number.isInteger(r)||r<0||r>e.byteLength-t.offset)throw new Error("invalid DER element length");return r}function We(e,t){Je(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=Et(e,t);if(n===null)break;r.push(n)}return r}function Xc(e,t){let r=Je(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function Wc(e,t){let r=Je(e,t),n=t.offset+r,o=e[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 f=e[t.offset];if(t.offset++,c.push(f&127),f<128){c.reverse();let u=0;for(let h=0;h<c.length;h++)u+=c[h]<<h*7;a+=`.${u}`,c=[]}}return a}function Jc(e,t){return t.offset++,null}function Qc(e,t){let r=Je(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function tf(e,t){let r=Je(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function ef(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new pt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Tr(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=ef(e.byteLength);return new pt(Uint8Array.from([t.byteLength|Vn]),t)}function mt(e){let t=new pt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new pt(Uint8Array.from([2]),Tr(t),t)}function Qe(e){let t=Uint8Array.from([0]),r=new pt(t,e);return new pt(Uint8Array.from([3]),Tr(r),r)}function Cs(e){return new pt(Uint8Array.from([4]),Tr(e),e)}function Lt(e,t=48){let r=new pt;for(let n of e)r.append(n);return new pt(Uint8Array.from([t]),Tr(r),r)}var rf=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),nf=Uint8Array.from([6,5,43,129,4,0,34]),of=Uint8Array.from([6,5,43,129,4,0,35]),Os={ext:!0,kty:"EC",crv:"P-256"},Ks={ext:!0,kty:"EC",crv:"P-384"},Us={ext:!0,kty:"EC",crv:"P-521"},ve=32,Ie=48,Te=66;function Fs(e){let t=Et(e);return Zn(t)}function Zn(e){let t=e[1],r=z(t,"base64url"),n=e[2][1][0],o=1,s,i;if(t.byteLength===ve)return s=z(n.subarray(o,o+ve),"base64url"),i=z(n.subarray(o+ve),"base64url"),new Mt({...Os,key_ops:["sign"],d:r,x:s,y:i});if(t.byteLength===Ie)return s=z(n.subarray(o,o+Ie),"base64url"),i=z(n.subarray(o+Ie),"base64url"),new Mt({...Ks,key_ops:["sign"],d:r,x:s,y:i});if(t.byteLength===Te)return s=z(n.subarray(o,o+Te),"base64url"),i=z(n.subarray(o+Te),"base64url"),new Mt({...Us,key_ops:["sign"],d:r,x:s,y:i});throw new P(`Private key length was wrong length, got ${t.byteLength}, expected 32, 48 or 66`)}function Yn(e){let t=Et(e);return $n(t)}function $n(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===ve*2+1)return n=z(t.subarray(r,r+ve),"base64url"),o=z(t.subarray(r+ve),"base64url"),new ae({...Os,key_ops:["verify"],x:n,y:o});if(t.byteLength===Ie*2+1)return n=z(t.subarray(r,r+Ie),"base64url"),o=z(t.subarray(r+Ie),"base64url"),new ae({...Ks,key_ops:["verify"],x:n,y:o});if(t.byteLength===Te*2+1)return n=z(t.subarray(r,r+Te),"base64url"),o=z(t.subarray(r+Te),"base64url"),new ae({...Us,key_ops:["verify"],x:n,y:o});throw new P(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ks(e){return Lt([mt(Uint8Array.from([1])),Cs(X(e.d??"","base64url")),Lt([Ps(e.crv)],160),Lt([Qe(new pt(Uint8Array.from([4]),X(e.x??"","base64url"),X(e.y??"","base64url")))],161)]).subarray()}function Ns(e){return Lt([mt(Uint8Array.from([1])),Lt([Ps(e.crv)],160),Lt([Qe(new pt(Uint8Array.from([4]),X(e.x??"","base64url"),X(e.y??"","base64url")))],161)]).subarray()}function Ps(e){if(e==="P-256")return rf;if(e==="P-384")return nf;if(e==="P-521")return of;throw new P(`Invalid curve ${e}`)}async function Ms(e="P-256"){let t=await ws(e);return new Mt(t.privateKey)}var ae=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=Ns(this.jwk)),this._raw}toMultihash(){return ie.digest(ce(this))}toCID(){return _t.createV1(114,this.toMultihash())}toString(){return ft.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}async verify(t,r,n){return Es(this.jwk,r,t,n)}},Mt=class{type="ECDSA";jwk;publicKey;_raw;constructor(t){this.jwk=t,this.publicKey=new ae({crv:t.crv,ext:t.ext,key_ops:["verify"],kty:"EC",x:t.x,y:t.y})}get raw(){return this._raw==null&&(this._raw=ks(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}async sign(t,r){return xs(this.jwk,t,r)}};var _r=BigInt(4294967295),qs=BigInt(32);function sf(e,t=!1){return t?{h:Number(e&_r),l:Number(e>>qs&_r)}:{h:Number(e>>qs&_r)|0,l:Number(e&_r)|0}}function Hs(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=sf(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var af=e=>e/2**32|0,cf=e=>e>>>0;function js(e,t,r,n){let o=af(r),s=cf(r);e.setUint32(t,n?s:o,n),e.setUint32(t+4,n?o:s,n)}var Gn=(e,t,r)=>e>>>r,Xn=(e,t,r)=>e<<32-r|t>>>r,fe=(e,t,r)=>e>>>r|t<<32-r,ue=(e,t,r)=>e<<32-r|t>>>r,tr=(e,t,r)=>e<<64-r|t>>>r-32,er=(e,t,r)=>e>>>r-32|t<<64-r;function Ft(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var zs=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Vs=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Zs=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Ys=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,$s=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Gs=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;function Rr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var Wn=e=>e?`"${e}" `:"";function St(e,t=""){if(typeof e!="number")throw new TypeError(Wn(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(Wn(t)+"expected integer >= 0, got "+e);return e}function At(e,t,r=""){if(Rr(e)&&(t===void 0||e.length===t))return e;t!==void 0&&St(t,"length");let n=Rr(e),o=t!==void 0?` of length ${t}`:"",s=n?`length=${e.length}`:`type=${typeof e}`,i=Wn(r)+"expected Uint8Array"+o+", got "+s;throw n?new RangeError(i):new TypeError(i)}function _e(e){if(typeof e!="function"||typeof e.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(St(e.outputLen),St(e.blockLen),e.outputLen<1||e.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var uf=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},Xs=(e,t)=>{uf(e,t);let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function Re(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function Lr(e,t){At(e,void 0,"output");let r=t.outputLen;if(!(e.length>=r))throw new RangeError('"output" expected length >= '+r)}function yt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Le(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Dt(e,t){return e<<32-t|e>>>t}function Dr(e,t){return e<<t|e>>>32-t>>>0}var Js=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",lf=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Cr(e){if(At(e),Js)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=lf[e[r]];return t}function Ws(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function Or(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);if(Js)try{return Uint8Array.fromHex(e)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let t=e.length,r=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Ws(e.charCodeAt(s)),a=Ws(e.charCodeAt(s+1));if(i===void 0||a===void 0){let c=e[s]+e[s+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function hf(e){if(typeof e!="string")throw new TypeError("string expected");let t=new TextEncoder().encode(e);try{return new Uint8Array(t)}finally{yt(t)}}function Jn(e,t=""){return typeof e=="string"?hf(e):At(e,void 0,t)}function Qn(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];At(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function to(e,t,r="opts"){return Xs(e,"defaults"),t!==void 0&&Xs(t,r),Object.assign(Object.create(null),e,t)}function rr(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=to({},t,"info");let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function Qs(e=32){St(e,"bytesLength");let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(e>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${e}`);return t.getRandomValues(new Uint8Array(e))}var eo=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Kr(e,t,r){return e&t^~e&r}function Ur(e,t,r){return e&t^e&r^t&r}var le=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Le(this.buffer)}update(t){Re(this),At(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length,i=!1;for(let a=0;a<s;){let c=Math.min(o-this.pos,s-a);if(c===o){let f=Le(t);for(;o<=s-a;a+=o)this.process(f,a);i=!0;continue}n.set(a===0&&c===s?t:t.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(r,0),this.pos=0,i=!0)}return this.length+=t.length,i&&this.roundClean(),this}digestInto(t){Re(this),Lr(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,r.fill(0,i),this.padOffset>o-i&&(this.process(n,0),r.fill(0)),js(n,o-8,this.length*8,s),this.process(n,0),this.roundClean();let a=t===r?n:Le(t),c=this.outputLen,f=c/4,u=this.get();if(c%4||f>u.length)throw new Error("invalid outputLen");for(let h=0;h<f;h++)a.setUint32(4*h,u[h],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneIntoMeta(t){let{buffer:r,length:n,finished:o,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=o,t.length=n,t.pos=i,i&&t.buffer.set(r),t}clone(){return this._cloneInto()}},ti=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var ei=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var df=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]),Zt=new Uint32Array(64),ro=class extends le{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,r){super(64,t,8,!1),this.A=r[0]|0,this.B=r[1]|0,this.C=r[2]|0,this.D=r[3]|0,this.E=r[4]|0,this.F=r[5]|0,this.G=r[6]|0,this.H=r[7]|0}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,r,n,o,s,i,a,c]}set(t,r,n,o,s,i,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let h=0;h<16;h++,r+=4)Zt[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){let y=Zt[h-15],d=Zt[h-2],B=Dt(y,7)^Dt(y,18)^y>>>3,g=Dt(d,17)^Dt(d,19)^d>>>10;Zt[h]=g+Zt[h-7]+B+Zt[h-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:f,H:u}=this;for(let h=0;h<64;h++){let y=Dt(a,6)^Dt(a,11)^Dt(a,25),d=u+y+Kr(a,c,f)+df[h]+Zt[h]|0,g=(Dt(n,2)^Dt(n,13)^Dt(n,22))+Ur(n,o,s)|0;u=f,f=c,c=a,a=i+d|0,i=s,s=o,o=n,n=d+g|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,f=f+this.G|0,u=u+this.H|0,this.set(n,o,s,i,a,c,f,u)}roundClean(){yt(Zt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),yt(this.buffer)}},no=class extends ro{constructor(){super(32,ti)}};var ri=Hs(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),pf=ri[0],mf=ri[1],Yt=new Uint32Array(80),$t=new Uint32Array(80),oo=class extends le{Ah=0;Al=0;Bh=0;Bl=0;Ch=0;Cl=0;Dh=0;Dl=0;Eh=0;El=0;Fh=0;Fl=0;Gh=0;Gl=0;Hh=0;Hl=0;constructor(t,r){super(128,t,16,!1),this.Ah=r[0]|0,this.Al=r[1]|0,this.Bh=r[2]|0,this.Bl=r[3]|0,this.Ch=r[4]|0,this.Cl=r[5]|0,this.Dh=r[6]|0,this.Dl=r[7]|0,this.Eh=r[8]|0,this.El=r[9]|0,this.Fh=r[10]|0,this.Fl=r[11]|0,this.Gh=r[12]|0,this.Gl=r[13]|0,this.Hh=r[14]|0,this.Hl=r[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:f,El:u,Fh:h,Fl:y,Gh:d,Gl:B,Hh:g,Hl:I}=this;return[t,r,n,o,s,i,a,c,f,u,h,y,d,B,g,I]}set(t,r,n,o,s,i,a,c,f,u,h,y,d,B,g,I){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=h|0,this.Fl=y|0,this.Gh=d|0,this.Gl=B|0,this.Hh=g|0,this.Hl=I|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let m=0;m<16;m++,r+=4)Yt[m]=t.getUint32(r),$t[m]=t.getUint32(r+=4);for(let m=16;m<80;m++){let S=Yt[m-15]|0,A=$t[m-15]|0,K=fe(S,A,1)^fe(S,A,8)^Gn(S,A,7),k=ue(S,A,1)^ue(S,A,8)^Xn(S,A,7),U=Yt[m-2]|0,L=$t[m-2]|0,C=fe(U,L,19)^tr(U,L,61)^Gn(U,L,6),H=ue(U,L,19)^er(U,L,61)^Xn(U,L,6),q=Zs(k,H,$t[m-7],$t[m-16]),G=Ys(q,K,C,Yt[m-7],Yt[m-16]);Yt[m]=G|0,$t[m]=q|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:f,Dl:u,Eh:h,El:y,Fh:d,Fl:B,Gh:g,Gl:I,Hh:w,Hl:x}=this;for(let m=0;m<80;m++){let S=fe(h,y,14)^fe(h,y,18)^tr(h,y,41),A=ue(h,y,14)^ue(h,y,18)^er(h,y,41),K=h&d^~h&g,k=y&B^~y&I,U=$s(x,A,k,mf[m],$t[m]),L=Gs(U,w,S,K,pf[m],Yt[m]),C=U|0,H=fe(n,o,28)^tr(n,o,34)^tr(n,o,39),q=ue(n,o,28)^er(n,o,34)^er(n,o,39),G=n&s^n&a^s&a,T=o&i^o&c^i&c;w=g|0,x=I|0,g=d|0,I=B|0,d=h|0,B=y|0,{h,l:y}=Ft(f|0,u|0,L|0,C|0),f=a|0,u=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let N=zs(C,q,T);n=Vs(N,L,H,G),o=N|0}({h:n,l:o}=Ft(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=Ft(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=Ft(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=Ft(this.Dh|0,this.Dl|0,f|0,u|0),{h,l:y}=Ft(this.Eh|0,this.El|0,h|0,y|0),{h:d,l:B}=Ft(this.Fh|0,this.Fl|0,d|0,B|0),{h:g,l:I}=Ft(this.Gh|0,this.Gl|0,g|0,I|0),{h:w,l:x}=Ft(this.Hh|0,this.Hl|0,w|0,x|0),this.set(n,o,s,i,a,c,f,u,h,y,d,B,g,I,w,x)}roundClean(){yt(Yt,$t)}destroy(){this.destroyed=!0,yt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},so=class extends oo{constructor(){super(64,ei)}};var Gt=rr(()=>new no,eo(1));var nr=rr(()=>new so,eo(3));function kr(e,t,r=()=>{}){if(!Array.isArray(e))throw new TypeError(`"${t}" expected array, got type=${typeof e}`);for(let n=0;n<e.length;n++)r(e[n],`${t}[${n}]`);return e}var Z=(e,t,r)=>At(e,t,r),io=St;function oi(e,t=""){if(typeof e!="string"){let r=t&&`"${t}" `;throw new TypeError(r+"expected string, got type="+typeof e)}return e}function Xt(e,t="object"){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(t==="object"?"expected valid options object":`"${t}" expected object, got type=${typeof e}`);return e}function he(e,t){if(typeof e!="function")throw new TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}var or=Cr,Rt=(...e)=>Qn(...e),De=e=>Or(e),Jt=Rr,de=e=>Qs(e),Fr=BigInt(0),ni=BigInt(1),yf=e=>e?`"${e}" `:"";function gt(e,t=""){if(typeof e!="boolean")throw new TypeError(yf(t)+"expected boolean, got type="+typeof e);return e}function Nr(e){if(typeof e=="bigint"){if(!Wt(e))throw new RangeError("positive bigint expected, got "+e)}else io(e);return e}function qt(e,t=""){if(typeof e!="number"){let r=t&&`"${t}" `;throw new TypeError(r+"expected number, got type="+typeof e)}if(!Number.isSafeInteger(e)){let r=t&&`"${t}" `;throw new RangeError(r+"expected safe integer, got "+e)}}function sr(e){let t=Nr(e).toString(16);return t.length&1?"0"+t:t}function si(e){if(typeof e!="string")throw new TypeError("hex string expected, got "+typeof e);return e===""?Fr:BigInt("0x"+e)}function kt(e){return si(Cr(e))}function pe(e){return si(Cr(ir(At(e)).reverse()))}function Pr(e,t){if(St(t),t===0)throw new Error("zero output length is invalid");e=Nr(e);let r=t*2,n=e.toString(16);if(n.length>r)throw new RangeError("number is too large");return Or(n.padStart(r,"0"))}function ao(e,t){return Pr(e,t).reverse()}function ir(e){return Uint8Array.from(Z(e))}function Wt(e){return typeof e=="bigint"&&Fr<=e}function co(e,t,r){return Wt(e)&&Wt(t)&&Wt(r)&&t<=e&&e<r}function Ce(e,t,r,n){if(!co(t,r,n))throw new RangeError("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Oe(e){if(e<Fr)throw new Error("expected non-negative bigint, got "+e);return e===Fr?0:e.toString(2).length}var ar=e=>(qt(e,"n"),(ni<<BigInt(e))-ni);function ii(e,t,r){if(St(e,"hashLen"),St(t,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=I=>new Uint8Array(I),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),a=1e3,c=n(e),f=n(e),u=0,h=()=>{c.fill(1),f.fill(0),u=0},y=(...I)=>r(f,Rt(c,...I)),d=(I=o)=>{f=y(s,I),c=y(),I.length!==0&&(f=y(i,I),c=y())},B=()=>{if(u++>=a)throw new Error("drbg: tried max amount of iterations");let I=0,w=[];for(;I<t;){c=y();let x=c.slice();w.push(x),I+=c.length}return Rt(...w)};return(I,w)=>{h(),d(I);let x;for(;(x=w(B()))===void 0;)d();return h(),x}}function wt(e,t={},r={},n="object"){Xt(e,n),Xt(t,"fields"),Xt(r,"optFields");function o(i,a,c){let f=n==="object"?`param "${String(i)}"`:`"${n}.${String(i)}"`,u=e[i];if(!Object.hasOwn(e,i)&&(c?u!==void 0:a!=="function"))throw new TypeError(`${f} is invalid: expected own property`);if(c&&u===void 0)return;let h=typeof u;if(h!==a||u===null)throw new TypeError(`${f} is invalid: expected ${a}, got ${h}`)}let s=(i,a)=>Object.entries(i).forEach(([c,f])=>o(c,f,a));s(t,!1),s(r,!0)}var at=BigInt(0),Y=BigInt(1),Qt=BigInt(2),fi=BigInt(3),fo=BigInt(4),ui=BigInt(5),bf=BigInt(7),li=BigInt(8),gf=BigInt(9),wf=BigInt(15),hi=BigInt(16),xf=BigInt("0x10000000000000000");function nt(e,t){if(t<=at)throw new Error("mod: expected positive modulus, got "+t);let r=e%t;return r>=at?r:t+r}function di(e,t,r){if(r<=Y)throw new Error("pow: expected modulus > 1, got "+r);if(typeof t!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof t);if(t<at)throw new Error("invalid exponent, negatives unsupported");if(t===at)return Y;if(t===Y)return e;let n=e%r;if(n<at&&(n+=r),t<xf){let a=Y;for(;t>at;)t&Y&&(a=a*n%r),n=n*n%r,t>>=Y;return a}let o=[];for(;t>at;)o.push(Number(t&wf)),t>>=fo;let s=new Array(16);s[0]=Y,s[1]=n;for(let a=2;a<16;a++)s[a]=s[a-1]*n%r;let i=s[o[o.length-1]];for(let a=o.length-2;a>=0;a--){i=i*i%r,i=i*i%r,i=i*i%r,i=i*i%r;let c=o[a];c!==0&&(i=i*s[c]%r)}return i}function tt(e,t,r){if(r<=Y)throw new Error("pow2: expected modulus > 1, got "+r);if(t<at)throw new Error("pow2: expected non-negative exponent, got "+t);let n=e;for(;t-- >at;)n*=n,n%=r;return n}function ai(e,t){if(e===at)throw new Error("invert: expected non-zero number");if(t<=Y)throw new Error("invert: expected modulus > 1, got "+t);let r=nt(e,t),n=t,o=at,s=Y;for(;r!==at;){let a=n/r,c=n-r*a,f=o-s*a;n=r,r=c,o=s,s=f}if(n!==Y)throw new Error("invert: does not exist");return nt(o,t)}function pi(e,t){if(t<=Y)throw new Error("invertCt: expected prime modulus > 1, got "+t);let r=nt(e,t);if(r===at)throw new Error("invertCt: expected non-zero number");let n=di(r,t-Qt,t);if(nt(r*n,t)!==Y)throw new Error("invertCt: does not exist");return n}function uo(e,t,r){let n=e;if(!n.eql(n.sqr(t),r))throw new Error("Cannot find square root")}function lo(e,t){if((e&Y)===at)throw new Error(t+": expected odd modulus, got "+e)}function mi(e,t){let r=e,n=(r.ORDER+Y)/fo,o=r.pow(t,n);return uo(r,o,t),o}function Ef(e,t){let r=e,n=(r.ORDER-ui)/li,o=r.mul(t,Qt),s=r.pow(o,n),i=r.mul(t,s),a=r.mul(r.mul(i,Qt),s),c=r.mul(i,r.sub(a,r.ONE));return uo(r,c,t),c}function Sf(e){let t=Ue(e),r=yi(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+bf)/hi;return((a,c)=>{let f=a,u=f.pow(c,i),h=f.mul(u,n),y=f.mul(u,o),d=f.mul(u,s),B=f.eql(f.sqr(h),c),g=f.eql(f.sqr(y),c);u=f.cmov(u,h,B),h=f.cmov(d,y,g);let I=f.eql(f.sqr(h),c),w=f.cmov(u,h,I);return uo(f,w,c),w})}function yi(e){if(e<fi)throw new Error("sqrt is not defined for small field");lo(e,"tonelliShanks");let t=e-Y,r=0;for(;t%Qt===at;)t/=Qt,r++;let n=Qt,o=Ue(e);for(;cr(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return mi;let s=o.pow(n,t),i=(t+Y)/Qt;return function(c,f){let u=c;if(u.is0(f))return f;if(cr(u,f)!==1)throw new Error("Cannot find square root");let h=r,y=u.mul(u.ONE,s),d=u.pow(f,t),B=u.pow(f,i);for(;!u.eql(d,u.ONE);){if(u.is0(d))throw new Error("Cannot find square root: probably non-prime P");let g=1,I=u.sqr(d);for(;!u.eql(I,u.ONE);)if(g++,I=u.sqr(I),g===h)throw new Error("Cannot find square root");let w=Y<<BigInt(h-g-1),x=u.pow(y,w);h=g,y=u.sqr(x),d=u.mul(d,y),B=u.mul(B,x)}return B}}function Af(e){return lo(e,"Fp.sqrt"),e%fo===fi?mi:e%li===ui?Ef:e%hi===gf?Sf(e):yi(e)}var bi=(e,t)=>(nt(e,t)&Y)===Y,Bf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ke(e){if(Xt(e,"field"),typeof e.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof e.ORDER);qt(e.BYTES,"BYTES"),qt(e.BITS,"BITS");for(let t of Bf)he(e[t],"field."+t);if(e.BYTES<1||e.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(e.ORDER<=Y)throw new Error("invalid field: expected ORDER > 1, got "+e.ORDER);return e}function qr(e,t,r=!1){Ke(e),kr(t,"nums"),gt(r,"passZero");let n=e,o=new Array(t.length).fill(r?n.ZERO:void 0),s=t.reduce((a,c,f)=>n.is0(c)?a:(o[f]=a,n.mul(a,c)),n.ONE),i=n.inv(s);return t.reduceRight((a,c,f)=>n.is0(c)?a:(o[f]=n.mul(a,o[f]),n.mul(a,c)),i),o}function cr(e,t){Ke(e);let r=e;lo(r.ORDER,"FpLegendre");let n=(r.ORDER-Y)/Qt,o=r.pow(t,n),s=r.eql(o,r.ONE),i=r.eql(o,r.ZERO),a=r.eql(o,r.neg(r.ONE));if(!s&&!i&&!a)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function vf(e,t){if(t!==void 0&&io(t),e<=at)throw new Error("invalid n length: expected positive n, got "+e);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);let r=Oe(e);if(t!==void 0&&t<r)throw new Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${r})`);let n=t!==void 0?t:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var ci=new WeakMap,Mr=class{ORDER;BITS;BYTES;isLE;ZERO=at;ONE=Y;_lengths;_mod;constructor(t,r={}){if(t<=Y)throw new Error("invalid field: expected ORDER > 1, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=vf(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,Object.freeze(this)}create(t){return nt(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return at<=t&&t<this.ORDER}is0(t){return t===at}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Y)===Y}neg(t){return nt(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return nt(t*t,this.ORDER)}add(t,r){return nt(t+r,this.ORDER)}sub(t,r){return nt(t-r,this.ORDER)}mul(t,r){return nt(t*r,this.ORDER)}pow(t,r){return di(t,r,this.ORDER)}div(t,r){return nt(t*ai(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return ai(t,this.ORDER)}sqrt(t){let r=ci.get(this);return r||ci.set(this,r=Af(this.ORDER)),r(this,t)}toBytes(t){return this.isLE?ao(t,this.BYTES):Pr(t,this.BYTES)}fromBytes(t,r=!1){Z(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:a}=this;if(n){if(t.length<1||!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,s?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=s?pe(t):kt(t);if(a&&(c=nt(c,i)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return qr(this,t,!0)}cmov(t,r,n){return gt(n,"condition"),n?r:t}};function Ue(e,t={}){return Object.freeze(Mr.prototype),new Mr(e,t)}function gi(e){if(typeof e!="bigint")throw new Error("field order must be bigint");if(e<=Y)throw new Error("field order must be greater than 1");let t=Oe(e-Y);return Math.ceil(t/8)}function Hr(e){let t=gi(e);return t+Math.ceil(t/2)}function jr(e,t,r=!1){Z(e);let n=e.length,o=gi(t),s=Math.max(Hr(t),16);if(n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?pe(e):kt(e),a=nt(i,t-Y)+Y;return r?ao(a,o):Pr(a,o)}var mo=BigInt(0),fr=BigInt(1),If=BigInt(4),ho=16,wi=128,Tf=5,xi=2**31;function te(e){let t=e;if(typeof t!="function")throw new TypeError('"Point" expected constructor, got type='+typeof e);he(t.fromAffine,"Point.fromAffine"),he(t.fromBytes,"Point.fromBytes"),he(t.fromHex,"Point.fromHex"),Xt(t.BASE,"Point.BASE"),Xt(t.ZERO,"Point.ZERO"),Ke(t.Fp),Ke(t.Fn)}function zr(e,t){te(e),Si(t,e);let r=qr(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function _f(e,t,r=1){if(!Number.isSafeInteger(e)||e<r||e>t)throw new Error("invalid window size, expected ["+r+".."+t+"], got W="+e)}function Rf(e,t){let r=e*(4*t+128);if(r>xi)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+xi/2**20+" MiB")}function yo(e,t){if(e!==void 0){he(e,"randomBytes");try{let r=e(t);if(!Jt(r)||r.length!==t)return}catch{return}return e}}function Si(e,t){kr(e,"points"),e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function Lf(e,t,r){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,o)=>{if(!(r===void 0?t.isValid(n):Wt(n)&&n<r))throw new Error("invalid scalar at index "+o)})}var Ai=new WeakMap;function po(e){return Ai.get(e)||1}function Df(e,t){let r=e.double(),n=[e];for(let o=1;o<t;o++)n.push(n[o-1].add(r));return n}function Cf(e,t){let r=2**t,n=r/2,o=BigInt(r-1),s=[];for(;e>mo;){let i=0;e&fr&&(i=Number(e&o),i>=n&&(i-=r),e-=BigInt(i)),s.push(i),e>>=fr}return s}function Of(e,t,r){let n=2**t,o=n/2,s=BigInt(n-1),i=BigInt(t),a=[];for(let c=0;c<r;c++){let f=Number(e&s);e>>=i,f>o&&(f-=n,e+=fr),a.push(f)}if(e!==mo)throw new Error("invalid wnaf");return a}function Kf(e,t,r){let n=0;for(let s of r)n=Math.max(n,s.length);let o=e;for(let s=n-1;s>=0;s--){s!==n-1&&(o=o.double());for(let i=0;i<r.length;i++){let a=r[i][s];if(a){let c=t[i][Math.abs(a)-1>>1];o=o.add(a<0?c.negate():c)}}}return o}var Fe=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(t,r){te(t),this.randomBytes=yo(r,ho),this.Point=t,this.BASE=t.BASE,this.ZERO=t.ZERO,this.bits=t.Fn.BITS}buildWnafTable(t,r,n){let o=Math.ceil(n/r)+1,s=2**(r-1),i=[],a=t;for(let c=0;c<o;c++){let f=a;for(let u=0;u<s;u++)i.push(f),f=f.add(a);a=i[i.length-1].double()}return{W:r,bits:n,windows:o,comp:i}}wnafCachedCT(t,r){let{W:n,windows:o,comp:s}=t,i=2**(n-1),a=Of(r,n,o),c=this.ZERO,f=this.BASE;for(let u=0;u<o;u++){let h=a[u],y=u*i,d=Math.abs(h)-1,B=s[y];for(let I=1;I<i;I++)B=I===d?s[y+I]:B;let g=B.negate();h===0?f=f.add(s[y]):c=c.add(h<0?g:B)}return{p:c,f}}getWnafPrecomputes(t,r,n,o){let s=this.wnafPrecomputes.get(r),i=s?.find(a=>a.W===t&&a.bits===n);return i||(i=this.buildWnafTable(r,t,n),typeof o=="function"&&(i={...i,comp:o(i.comp)}),s||(s=[],this.wnafPrecomputes.set(r,s)),s.push(i)),i}assertPoint(t){if(!(t instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof t)}validateMulInput(t,r){if(this.assertPoint(t),!co(r,fr,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(t,r,n,o){let s=po(t);return s===1?this.fixedWindowCT(t,r,n):this.wnafCachedCT(this.getWnafPrecomputes(s,t,n,o),r)}mulCT(t,r,n){return this.validateMulInput(t,r),this.runCT(t,r,this.bits,n)}mulCTBlinded(t,r,n){if(this.validateMulInput(t,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+wi,s=this.randomBytes(ho);if(!Jt(s)||s.length!==ho)throw new Error("randomBytes returned invalid byte array");s[0]=s[0]&63|128;let i=r+kt(s)*this.Point.Fn.ORDER;return this.runCT(t,i,o,n)}fixedWindowCT(t,r,n){let o=Tf,s=1<<o,i=ar(o),a=new Array(s);a[0]=this.ZERO;for(let u=1;u<s;u++)a[u]=a[u-1].add(t);let c=Math.ceil(n/o),f=this.ZERO;for(let u=c-1;u>=0;u--){if(u!==c-1)for(let d=0;d<o;d++)f=f.double();let h=Number(r>>BigInt(u*o)&i),y=a[0];for(let d=1;d<s;d++)y=d===h?a[d]:y;f=f.add(y)}return{p:f,f}}shouldBlind(t,r){return this.randomBytes===void 0?!1:r===fr?!0:t!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(t,r,n,o){return this.shouldBlind(t,n)?this.mulCTBlinded(t,r,o):this.mulCT(t,r,o)}mulUnsafe(t,r,n){if(this.assertPoint(t),!Wt(r))throw new Error("invalid scalar");let o=po(t);if(o===1||r>=this.Point.Fn.ORDER)return Vr(this.Point,[t],[r],!0);let s=this.getWnafPrecomputes(o,t,this.bits,n);return this.wnafCachedCT(s,r).p}setWindowSize(t,r){this.assertPoint(t),_f(r,this.bits);let n=Math.ceil((this.bits+wi)/r)+1;Rf(n*2**(r-1),this.Point.Fp.BYTES),Ai.set(t,r),this.wnafPrecomputes.delete(t)}hasWindowSize(t){return po(t)!==1}};function Vr(e,t,r,n=!1){if(te(e),Si(t,e),gt(n,"allowOversized"),Lf(r,e.Fn,n?e.Fn.ORDER**If:void 0),t.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let o=t.map(i=>Df(i,4)),s=r.map(i=>Cf(i,4));return Kf(e.ZERO,o,s)}function Ei(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Ke(t),t}else return Ue(e,{isLE:r})}function Zr(e,t,r={},n){if(e!=="weierstrass"&&e!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);wt(r);for(let c of["p","n","h"]){let f=t[c];if(!(Wt(f)&&f!==mo))throw new Error(`CURVE.${c} must be positive bigint`)}let o=Ei(t.p,r.Fp,n),s=Ei(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function Yr(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var $r=BigInt(0),Gr=BigInt(1),Xr=BigInt(2),Uf=BigInt(4),Bi=BigInt(8);function Ff(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}function vi(e,t={}){wt(t,{},{},"extraOpts");let r=t,n=Zr("edwards",e,r,r.FpFnLE),{Fp:o,Fn:s}=n,i=n.CURVE,{h:a}=i;if(cr(o,i.a)!==1)throw new Error("edwards: CURVE.a must be a square in Fp for complete addition formulas");if(cr(o,i.d)!==-1)throw new Error("edwards: CURVE.d must be a non-square in Fp for complete addition formulas");wt(r,{},{uvRatio:"function",randomBytes:"function"});let c=r.randomBytes===void 0?de:r.randomBytes,f=Xr<<BigInt(o.BYTES*8)-Gr;function u(x){if(!o.isOdd)throw new Error("Field does not have .isOdd()");return o.isOdd(x)}let h=r.uvRatio===void 0?(x,m)=>{try{return{isValid:!0,value:o.sqrt(o.div(x,m))}}catch{return{isValid:!1,value:$r}}}:r.uvRatio;if(!Ff(o,i,i.Gx,i.Gy))throw new Error("bad curve params: generator point");let y=o.eql(i.a,o.neg(o.ONE))?x=>o.neg(x):o.eql(i.a,o.ONE)?x=>x:x=>o.mul(i.a,x);function d(x,m,S=!1){let A=S?Gr:$r;return Ce("coordinate "+x,m,A,f),m}function B(x){if(!(x instanceof g))throw new Error("EdwardsPoint expected")}class g{static BASE=new g(i.Gx,i.Gy,o.ONE,o.mul(i.Gx,i.Gy));static ZERO=new g(o.ZERO,o.ONE,o.ONE,o.ZERO);static Fp=o;static Fn=s;X;Y;Z;T;constructor(m,S,A,K){this.X=d("x",m),this.Y=d("y",S),this.Z=d("z",A,!0),this.T=d("t",K),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){if(m instanceof g)throw new Error("extended point not allowed");let{x:S,y:A}=m||{};return d("x",S),d("y",A),new g(S,A,o.ONE,o.mul(S,A))}static fromBytes(m,S=!1){let A=o.BYTES,{a:K,d:k}=i;m=ir(Z(m,A,"point")),gt(S,"zip215");let U=ir(m),L=m[A-1];U[A-1]=L&-129;let C=pe(U),H=S?f:o.ORDER;Ce("point.y",C,$r,H);let q=o.sqr(C),G=o.sub(q,o.ONE),T=o.sub(o.mulN(k,q),K),{isValid:N,value:M}=h(G,T);if(!N)throw new Error("bad point: invalid y coordinate");let D=u(M),W=(L&128)!==0;if(!S&&o.is0(M)&&W)throw new Error("bad point: x=0 and x_0=1");return W!==D&&(M=o.neg(M)),g.fromAffine({x:M,y:C})}static fromHex(m,S=!1){return g.fromBytes(De(m),S)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=6,S=!0){return w.setWindowSize(this,m),S||this.multiply(Xr),this}assertValidity(){let m=this,{a:S,d:A}=i;if(m.is0())throw new Error("bad point: ZERO");let{X:K,Y:k,Z:U,T:L}=m,C=o.sqr(K),H=o.sqr(k),q=o.sqr(U),G=o.sqr(q),T=o.mul(C,S),N=o.mul(o.add(T,H),q),M=o.add(G,o.mul(A,o.mul(C,H)));if(!o.eql(N,M))throw new Error("bad point: equation left != right (1)");let D=o.mul(K,k),W=o.mul(U,L);if(!o.eql(D,W))throw new Error("bad point: equation left != right (2)")}equals(m){B(m);let{X:S,Y:A,Z:K}=this,{X:k,Y:U,Z:L}=m,C=o.mul(S,L),H=o.mul(k,K),q=o.mul(A,L),G=o.mul(U,K);return o.eql(C,H)&&o.eql(q,G)}is0(){return this.equals(g.ZERO)}negate(){return new g(o.neg(this.X),this.Y,this.Z,o.neg(this.T))}double(){let{X:m,Y:S,Z:A}=this,K=o.sqr(m),k=o.sqr(S),U=o.mul(o.sqr(A),Xr),L=y(K),C=o.addN(m,S),H=o.sub(o.subN(o.sqr(C),K),k),q=o.addN(L,k),G=o.subN(q,U),T=o.subN(L,k),N=o.mul(H,G),M=o.mul(q,T),D=o.mul(H,T),W=o.mul(G,q);return new g(N,M,W,D)}add(m){B(m);let{d:S}=i,{X:A,Y:K,Z:k,T:U}=this,{X:L,Y:C,Z:H,T:q}=m,G=o.mul(A,L),T=o.mul(K,C),N=o.mul(o.mulN(U,S),q),M=o.mul(k,H),D=o.sub(o.subN(o.mulN(o.addN(A,K),o.addN(L,C)),G),T),W=o.subN(M,N),et=o.addN(M,N),E=o.sub(T,y(G)),l=o.mul(D,W),p=o.mul(et,E),b=o.mul(D,E),v=o.mul(W,et);return new g(l,p,v,b)}subtract(m){return B(m),this.add(m.negate())}multiply(m){if(!s.isValidNot0(m))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");let{p:S,f:A}=w.mulSecret(this,m,a,I);return I([S,A])[0]}multiplyUnsafe(m){if(!s.isValid(m))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return m===$r?g.ZERO:this.is0()||m===Gr?this:w.mulUnsafe(this,m,I)}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return w.mulUnsafe(this,i.n).is0()}toAffine(m){let S=this,A=m;if(A!=null&&typeof A!="bigint")throw new TypeError('"invertedZ" expected bigint, got type='+typeof A);let{X:K,Y:k,Z:U}=S,L=S.is0();A==null&&(A=L?o.create(Bi):o.inv(U));let C=o.mul(K,A),H=o.mul(k,A),q=o.mul(U,A);if(L)return{x:o.ZERO,y:o.ONE};if(!o.eql(q,o.ONE))throw new Error("invZ was invalid");return{x:C,y:H}}clearCofactor(){return a===Gr?this:a===Xr?this.double():a===Uf?this.double().double():a===Bi?this.double().double().double():this.multiplyUnsafe(a)}toBytes(){let{x:m,y:S}=this.toAffine(),A=o.toBytes(S);return A[A.length-1]|=u(m)?128:0,A}toHex(){return or(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let I=x=>zr(g,x),w=new Fe(g,c);return w.bits>=6&&g.BASE.precompute(6),Object.freeze(g.prototype),Object.freeze(g),g}function Ii(e,t,r={}){if(te(e),typeof t!="function")throw new Error('"hash" function param is required');let n=t,o=r;wt(o,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function",toMontgomery:"function",toMontgomerySecret:"function"});let{prehash:s}=o,{BASE:i,Fp:a,Fn:c}=e,f=n.outputLen,u=2*a.BYTES;if(f!==void 0&&(qt(f,"hash.outputLen"),f!==u))throw new Error(`hash.outputLen must be ${u}, got ${f}`);let h=o.randomBytes===void 0?de:o.randomBytes,y=o.toMontgomery,d=o.toMontgomerySecret,B=o.adjustScalarBytes===void 0?T=>T:o.adjustScalarBytes,g=o.domain===void 0?(T,N,M)=>{if(gt(M,"phflag"),N.length||M)throw new Error("Contexts/pre-hash are not supported");return T}:o.domain;function I(T){return c.create(pe(T))}function w(T){let N=L.secretKey;Z(T,L.secretKey,"secretKey");let M=Z(n(T),2*N,"hashedSecretKey"),D=B(M.slice(0,N)),W=M.slice(N,2*N),et=I(D);return{head:D,prefix:W,scalar:et}}function x(T){let{head:N,prefix:M,scalar:D}=w(T),W=i.multiply(D),et=W.toBytes();return{head:N,prefix:M,scalar:D,point:W,pointBytes:et}}function m(T){return x(T).pointBytes}function S(T=Uint8Array.of(),...N){let M=Rt(...N);return I(n(g(M,Z(T,void 0,"context"),!!s)))}function A(T,N,M={}){wt(M,{},{},"options"),T=ir(Z(T,void 0,"message")),s&&(T=s(T));let{prefix:D,scalar:W,pointBytes:et}=x(N),E=S(M.context,D,T),l=i.multiply(E).toBytes(),p=S(M.context,l,et,T),b=c.create(E+p*W);if(!c.isValid(b))throw new Error("sign failed: invalid s");let v=Rt(l,c.toBytes(b));return Z(v,L.signature,"result")}let K={zip215:o.zip215};function k(T,N,M,D=K){wt(D);let{context:W}=D,et=D.zip215===void 0?!!K.zip215:D.zip215,E=L.signature;T=Z(T,E,"signature"),N=Z(N,void 0,"message"),M=Z(M,L.publicKey,"publicKey"),et!==void 0&>(et,"zip215"),s&&(N=s(N));let l=E/2,p=T.subarray(0,l),b=pe(T.subarray(l,E)),v,_,R;try{v=e.fromBytes(M,et),_=e.fromBytes(p,et),R=i.multiplyUnsafe(b)}catch{return!1}if(!et&&v.isSmallOrder())return!1;let O=S(W,p,M,N);return _.add(v.multiplyUnsafe(O)).subtract(R).clearCofactor().is0()}let U=a.BYTES,L={secretKey:U,publicKey:U,signature:2*U,seed:U};function C(T){return T=T===void 0?h(L.seed):T,Z(T,L.seed,"seed")}function H(T){return Jt(T)&&T.length===L.secretKey}function q(T,N){try{return!!e.fromBytes(T,N===void 0?K.zip215:N)}catch{return!1}}let G={getExtendedPublicKey:x,randomSecretKey:C,isValidSecretKey:H,isValidPublicKey:q,toMontgomery(T){if(y===void 0)throw new Error("Montgomery conversion is not supported for this curve");return y(e.fromBytes(T))},toMontgomerySecret(T){if(d===void 0)throw new Error("Montgomery conversion is not supported for this curve");return d(T)}};return Object.freeze(L),Object.freeze(G),Object.freeze({keygen:Yr(C,m),getPublicKey:m,sign:A,verify:k,utils:G,Point:e,lengths:L})}var bo=BigInt(1),Ti=BigInt(2);var kf=BigInt(5),Nf=BigInt(8),go=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Pf={p:go,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Nf,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Mf(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=go,a=e*e%s*e%s,c=tt(a,Ti,s)*a%s,f=tt(c,bo,s)*e%s,u=tt(f,kf,s)*f%s,h=tt(u,t,s)*u%s,y=tt(h,r,s)*h%s,d=tt(y,n,s)*y%s,B=tt(d,o,s)*d%s,g=tt(B,o,s)*d%s,I=tt(g,t,s)*u%s;return{pow_p_5_8:tt(I,Ti,s)*e%s,b2:a}}function Li(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var _i=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function qf(e,t){let r=go,n=nt(t*t*t,r),o=nt(n*n*t,r),s=Mf(e*o).pow_p_5_8,i=nt(e*n*s,r),a=nt(t*i*i,r),c=i,f=nt(i*_i,r),u=a===e,h=a===nt(-e,r),y=a===nt(-e*_i,r);return u&&(i=c),(h||y)&&(i=f),bi(i,r)&&(i=nt(-i,r)),{isValid:u||h,value:i}}var wo=vi(Pf,{uvRatio:qf}),Ri=wo.Fp;function Hf(e){let{y:t}=e;return Ri.toBytes(Ri.div(bo+t,bo-t))}function jf(e){let t=wo.Fp.BYTES;return At(e,t),Li(nr(e.subarray(0,t))).subarray(0,t)}function zf(e){return Ii(wo,nr,Object.assign({adjustScalarBytes:Li,toMontgomery:Hf,toMontgomerySecret:jf,zip215:!0},e))}var ke=zf({});var ee=32,Bt=64,Wr=32;var Ne,Di=(async()=>{try{return await rt.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();function Ci(){let e=ke.utils.randomSecretKey(),t=ke.getPublicKey(e);return{privateKey:Fi(e,t),publicKey:t}}function Oi(e){if(e.length!==Wr)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let t=e,r=ke.getPublicKey(t);return{privateKey:Fi(t,r),publicKey:r}}async function Vf(e,t){let r;e.length===Bt?r=e.subarray(0,32):r=e;let n={crv:"Ed25519",kty:"OKP",x:z(e.subarray(32),"base64url"),d:z(r,"base64url"),ext:!0,key_ops:["sign"]},o=await rt.get().subtle.importKey("jwk",n,{name:"Ed25519"},!0,["sign"]),s=await rt.get().subtle.sign({name:"Ed25519"},o,ut(t instanceof Uint8Array?t:t.subarray()));return new Uint8Array(s,0,s.byteLength)}function Zf(e,t){let r=e.subarray(0,Wr);return ke.sign(t instanceof Uint8Array?t:t.subarray(),r)}async function Ki(e,t){return Ne==null&&(Ne=await Di),Ne?Vf(e,t):Zf(e,t)}async function Yf(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await rt.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await rt.get().subtle.verify({name:"Ed25519"},n,ut(t),ut(r instanceof Uint8Array?r:r.subarray()))}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function $f(e,t,r){return ke.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function Ui(e,t,r){return Ne==null&&(Ne=await Di),Ne?Yf(e,t,r):$f(e,t,r)}function Fi(e,t){let r=new Uint8Array(Bt);for(let n=0;n<Wr;n++)r[n]=e[n],r[Wr+n]=t[n];return r}function xo(e,t){let r=X(e,"base64urlpad");if(t!=null){if(r.length>t)throw new Error("byte array longer than desired length");r=Ut([new Uint8Array(t-r.length),r])}return r}function Pe(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var ur=class{type="Ed25519";raw;constructor(t){this.raw=Me(t,ee)}toMultihash(){return ie.digest(ce(this))}toCID(){return _t.createV1(114,this.toMultihash())}toString(){return ft.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=Ui(this.raw,r,t);return Pe(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}},me=class{type="Ed25519";raw;publicKey;constructor(t,r){this.raw=Me(t,Bt),this.publicKey=new ur(r)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}sign(t,r){r?.signal?.throwIfAborted();let n=Ki(this.raw,t);return Pe(n)?n.then(o=>(r?.signal?.throwIfAborted(),o)):(r?.signal?.throwIfAborted(),n)}};function Eo(e){if(e.length>Bt){e=Me(e,Bt+ee);let n=e.subarray(0,Bt),o=e.subarray(Bt,e.length);return new me(n,o)}e=Me(e,Bt);let t=e.subarray(0,Bt),r=e.subarray(ee);return new me(t,r)}function Jr(e){return e=Me(e,ee),new ur(e)}async function Ni(){let{privateKey:e,publicKey:t}=Ci();return new me(e,t)}async function Pi(e){let{privateKey:t,publicKey:r}=Oi(e);return new me(t,r)}function Me(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new P(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var Gf=Math.pow(2,7),Xf=Math.pow(2,14),Wf=Math.pow(2,21),Mi=Math.pow(2,28),qi=Math.pow(2,35),Hi=Math.pow(2,42),ji=Math.pow(2,49),bt=128,re=127;function lr(e){if(e<Gf)return 1;if(e<Xf)return 2;if(e<Wf)return 3;if(e<Mi)return 4;if(e<qi)return 5;if(e<Hi)return 6;if(e<ji)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function zi(e,t,r=0){switch(lr(e)){case 8:t[r++]=e&255|bt,e/=128;case 7:t[r++]=e&255|bt,e/=128;case 6:t[r++]=e&255|bt,e/=128;case 5:t[r++]=e&255|bt,e/=128;case 4:t[r++]=e&255|bt,e>>>=7;case 3:t[r++]=e&255|bt,e>>>=7;case 2:t[r++]=e&255|bt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Vi(e,t){let r=e[t],n=0;if(n+=r&re,r<bt||(r=e[t+1],n+=(r&re)<<7,r<bt)||(r=e[t+2],n+=(r&re)<<14,r<bt)||(r=e[t+3],n+=(r&re)<<21,r<bt)||(r=e[t+4],n+=(r&re)*Mi,r<bt)||(r=e[t+5],n+=(r&re)*qi,r<bt)||(r=e[t+6],n+=(r&re)*Hi,r<bt)||(r=e[t+7],n+=(r&re)*ji,r<bt))return n;throw new RangeError("Could not decode varint")}var So=new Float32Array([-0]),ne=new Uint8Array(So.buffer);function Zi(e,t,r){So[0]=e,t[r]=ne[0],t[r+1]=ne[1],t[r+2]=ne[2],t[r+3]=ne[3]}function Yi(e,t){return ne[0]=e[t],ne[1]=e[t+1],ne[2]=e[t+2],ne[3]=e[t+3],So[0]}var Ao=new Float64Array([-0]),dt=new Uint8Array(Ao.buffer);function $i(e,t,r){Ao[0]=e,t[r]=dt[0],t[r+1]=dt[1],t[r+2]=dt[2],t[r+3]=dt[3],t[r+4]=dt[4],t[r+5]=dt[5],t[r+6]=dt[6],t[r+7]=dt[7]}function Gi(e,t){return dt[0]=e[t],dt[1]=e[t+1],dt[2]=e[t+2],dt[3]=e[t+3],dt[4]=e[t+4],dt[5]=e[t+5],dt[6]=e[t+6],dt[7]=e[t+7],Ao[0]}var Jf=BigInt(Number.MAX_SAFE_INTEGER),Qf=BigInt(Number.MIN_SAFE_INTEGER),vt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return ye;if(t<Jf&&t>Qf)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Xi&&(o=0n,++n>Xi&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return ye;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):ye}},ye=new vt(0,0);ye.toBigInt=function(){return 0n};ye.zzEncode=ye.zzDecode=function(){return this};ye.length=function(){return 1};var Xi=4294967296n;function Wi(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ji(e,t,r){if(r-t<1)return"";let o,s=[],i=0,a;for(;t<r;)a=e[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Bo(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function Ct(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Qr(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var vo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=ut(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,Ct(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 Ct(this,4);return Qr(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ct(this,4);return Qr(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ct(this,4);let t=Yi(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Ct(this,4);let t=Gi(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw Ct(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ji(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Ct(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Ct(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 vt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Ct(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw Ct(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ct(this,8);let t=Qr(this.buf,this.pos+=4),r=Qr(this.buf,this.pos+=4);return new vt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Vi(this.buf,this.pos);return this.pos+=lr(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 hr(e){return new vo(e instanceof Uint8Array?e:e.subarray())}function tn(e,t,r){let n=hr(e);return t.decode(n,void 0,r)}function Io(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return xt(i);o+i>t&&(n=xt(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var be=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function To(){}var Ro=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},tu=Io();function eu(e){return globalThis.Buffer!=null?xt(e):tu(e)}var pr=class{len;head;tail;states;constructor(){this.len=0,this.head=new be(To,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new be(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Lo((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(en,10,vt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=vt.fromBigInt(t);return this._push(en,r.length(),r)}uint64Number(t){return this._push(zi,lr(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=vt.fromBigInt(t).zzEncode();return this._push(en,r.length(),r)}sint64Number(t){let r=vt.fromNumber(t).zzEncode();return this._push(en,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(_o,1,t?1:0)}fixed32(t){return this._push(dr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=vt.fromBigInt(t);return this._push(dr,4,r.lo)._push(dr,4,r.hi)}fixed64Number(t){let r=vt.fromNumber(t);return this._push(dr,4,r.lo)._push(dr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Zi,4,t)}double(t){return this._push($i,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(_o,1,0):this.uint32(r)._push(nu,r,t)}string(t){let r=Wi(t);return r!==0?this.uint32(r)._push(Bo,r,t):this._push(_o,1,0)}fork(){return this.states=new Ro(this),this.head=this.tail=new be(To,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 be(To,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=eu(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function _o(e,t,r){t[r]=e&255}function ru(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Lo=class extends be{next;constructor(t,r){super(ru,t,r),this.next=void 0}};function en(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function dr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function nu(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(pr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ou,t,e),this},pr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(su,t,e),this});function ou(e,t,r){t.set(e,r)}function su(e,t,r){e.length<40?Bo(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(X(e),r)}function Do(){return new pr}function rn(e,t){let r=Do();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}function*nn(e,t,r){let n=hr(e);yield*t.stream(n,void 0,"$",r)}var on={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function sn(e,t,r,n,o){return{name:e,type:t,encode:r,decode:n,stream:o}}function Co(e){function t(s){if(e[s.toString()]==null)throw new Error("Invalid enum value");return e[s]}let r=function(i,a){let c=t(i);a.int32(c)},n=function(i){let a=i.int32();return t(a)},o=function*(i){let a=i.int32();yield t(a)};return sn("enum",on.VARINT,r,n,o)}function an(e,t,r){return sn("message",on.LENGTH_DELIMITED,e,t,r)}var $;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})($||($={}));var Oo;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Oo||(Oo={}));(function(e){e.codec=()=>Co(Oo)})($||($={}));var Nt;(function(e){let t;e.codec=()=>(t==null&&(t=an((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),$.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let c={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{c.Type=$.codec().decode(s);break}case 2:{c.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return c},function*(s,i,a,c={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:$.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return rn(s,e.codec())}e.encode=r;function n(s,i){return tn(s,e.codec(),i)}e.decode=n;function o(s,i){return nn(s,e.codec(),i)}e.stream=o})(Nt||(Nt={}));var mr;(function(e){let t;e.codec=()=>(t==null&&(t=an((s,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),s.Type!=null&&(i.uint32(8),$.codec().encode(s.Type,i)),s.Data!=null&&(i.uint32(18),i.bytes(s.Data)),a.lengthDelimited!==!1&&i.ldelim()},(s,i,a={})=>{let c={},f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{c.Type=$.codec().decode(s);break}case 2:{c.Data=s.bytes();break}default:{s.skipType(u&7);break}}}return c},function*(s,i,a,c={}){let f=i==null?s.len:s.pos+i;for(;s.pos<f;){let u=s.uint32();switch(u>>>3){case 1:{yield{field:`${a}.Type`,value:$.codec().decode(s)};break}case 2:{yield{field:`${a}.Data`,value:s.bytes()};break}default:{s.skipType(u&7);break}}}})),t);function r(s){return rn(s,e.codec())}e.encode=r;function n(s,i){return tn(s,e.codec(),i)}e.decode=n;function o(s,i){return nn(s,e.codec(),i)}e.stream=o})(mr||(mr={}));function Ko(e){if(isNaN(e)||e<=0)throw new P("random bytes length must be a Number bigger than 0");return crypto.getRandomValues(new Uint8Array(e))}var br={};lt(br,{MAX_RSA_KEY_SIZE:()=>Uo,generateRSAKeyPair:()=>Ho,jwkToJWKKeyPair:()=>na,jwkToPkcs1:()=>fu,jwkToPkix:()=>Po,jwkToRSAPrivateKey:()=>un,pkcs1MessageToJwk:()=>ko,pkcs1MessageToRSAPrivateKey:()=>cn,pkcs1ToJwk:()=>cu,pkcs1ToRSAPrivateKey:()=>Mo,pkixMessageToJwk:()=>No,pkixMessageToRSAPublicKey:()=>fn,pkixToJwk:()=>uu,pkixToRSAPublicKey:()=>qo});var qe=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=br.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return _t.createV1(114,this._multihash)}toString(){return ft.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,r,n){return ra(this.jwk,r,t,n)}},yr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=br.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}sign(t,r){return ea(this.jwk,t,r)}};var Uo=8192,Fo=18,iu=1062,au=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function cu(e){let t=Et(e);return ko(t)}function ko(e){return{n:z(e[1],"base64url"),e:z(e[2],"base64url"),d:z(e[3],"base64url"),p:z(e[4],"base64url"),q:z(e[5],"base64url"),dp:z(e[6],"base64url"),dq:z(e[7],"base64url"),qi:z(e[8],"base64url"),kty:"RSA"}}function fu(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new P("JWK was missing components");return Lt([mt(Uint8Array.from([0])),mt(X(e.n,"base64url")),mt(X(e.e,"base64url")),mt(X(e.d,"base64url")),mt(X(e.p,"base64url")),mt(X(e.q,"base64url")),mt(X(e.dp,"base64url")),mt(X(e.dq,"base64url")),mt(X(e.qi,"base64url"))]).subarray()}function uu(e){let t=Et(e,{offset:0});return No(t)}function No(e){let t=Et(e[1],{offset:0});return{kty:"RSA",n:z(t[0],"base64url"),e:z(t[1],"base64url")}}function Po(e){if(e.n==null||e.e==null)throw new P("JWK was missing components");return Lt([au,Qe(Lt([mt(X(e.n,"base64url")),mt(X(e.e,"base64url"))]))]).subarray()}function Mo(e){let t=Et(e);return cn(t)}function cn(e){let t=ko(e);return un(t)}function qo(e,t){if(e.byteLength>=iu)throw new we("Key size is too large");let r=Et(e,{offset:0});return fn(r,e,t)}function fn(e,t,r){let n=No(e);if(r==null){let o=Gt(Nt.encode({Type:$.RSA,Data:t}));r=Kt(Fo,o)}return new qe(n,r)}function un(e){if(sa(e)>Uo)throw new P("Key size is too large");let t=na(e),r=Gt(Nt.encode({Type:$.RSA,Data:Po(t.publicKey)})),n=Kt(Fo,r);return new yr(t.privateKey,new qe(t.publicKey,n))}async function Ho(e){if(e>Uo)throw new P("Key size is too large");let t=await oa(e),r=Gt(Nt.encode({Type:$.RSA,Data:Po(t.publicKey)})),n=Kt(Fo,r);return new yr(t.privateKey,new qe(t.publicKey,n))}function na(e){if(e==null)throw new P("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}var ia="1.2.840.113549.1.1.1";async function oa(e,t){let r=await rt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]);t?.signal?.throwIfAborted();let n=await lu(r,t);return{privateKey:n[0],publicKey:n[1]}}async function ea(e,t,r){let n=await rt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]);r?.signal?.throwIfAborted();let o=await rt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,ut(t instanceof Uint8Array?t:t.subarray()));return r?.signal?.throwIfAborted(),new Uint8Array(o,0,o.byteLength)}async function ra(e,t,r,n){let o=await rt.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);n?.signal?.throwIfAborted();let s=await rt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},o,ut(t),ut(r instanceof Uint8Array?r:r.subarray()));return n?.signal?.throwIfAborted(),s}async function lu(e,t){if(e.privateKey==null||e.publicKey==null)throw new P("Private and public key are required");let r=await Promise.all([rt.get().subtle.exportKey("jwk",e.privateKey),rt.get().subtle.exportKey("jwk",e.publicKey)]);return t?.signal?.throwIfAborted(),r}function sa(e){if(e.kty!=="RSA")throw new P("invalid key type");if(e.n==null)throw new P("invalid key modulus");return X(e.n,"base64url").length*8}var ln=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(t,r){if(_e(t),At(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),yt(o)}update(t){return Re(this),this.iHash.update(t),this}digestInto(t){Re(this),Lr(t,this),this.finished=!0;let r=t.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a,canXOF:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.canXOF=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},hn=(()=>{let e=((t,r,n)=>new ln(t,r).update(n).digest());return e.create=(t,r)=>new ln(t,r),e})();var hu=BigInt(0),jo=class extends Error{constructor(t=""){super(t)}},Ht={Err:jo,_tlv:{encode:(e,t)=>{let{Err:r}=Ht;if(qt(e,"tag"),e<0||e>255)throw new r("tlv.encode: wrong tag");if(oi(t,"data"),t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=sr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?sr(o.length/2|128):"";return sr(e)+s+o+t},decode(e,t){let{Err:r}=Ht;t=Z(t,void 0,"DER data");let n=0;if(e<0||e>255)throw new r("tlv.decode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of f)i=i<<8|u;if(n+=c,i<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=Ht;if(Nr(e),e<hu)throw new t("integer: negative integers are not allowed");let r=sr(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Ht;if(e.length<1)throw new t("invalid signature integer: empty");if(e[0]&128)throw new t("invalid signature integer: negative");if(e.length>1&&e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return kt(e)}},toSig(e,t){let{Err:r,_int:n,_tlv:o}=Ht;if(t!==void 0&&(qt(t,"maxScalarBytes"),t<1))throw new r("invalid signature: maxScalarBytes must be positive");let s=Z(e,void 0,"signature"),{v:i,l:a}=o.decode(48,s);if(a.length)throw new r("invalid signature: left bytes after parsing");let{v:c,l:f}=o.decode(2,i),{v:u,l:h}=o.decode(2,f);if(h.length)throw new r("invalid signature: left bytes after parsing");if(t!==void 0&&(c.length>t||u.length>t))throw new r("invalid signature: integer too large");return{r:n.decode(c),s:n.decode(u)}},hexFromSig(e){let{_tlv:t,_int:r}=Ht;wt(e,{r:"bigint",s:"bigint"},{},"sig");let n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}},dn=(Object.freeze(Ht._tlv),Object.freeze(Ht._int),Object.freeze(Ht));var aa=(e,t)=>(e+(e>=0?t:-t)/ca)/t;function du(e,t,r){Ce("scalar",e,jt,r);let[[n,o],[s,i]]=t,a=aa(i*e,r),c=aa(-o*e,r),f=e-a*n-c*s,u=-a*o-c*i,h=f<jt,y=u<jt;h&&(f=-f),y&&(u=-u);let d=ar(Math.ceil(Oe(r)/2))+ge;if(f<jt||f>=d||u<jt||u>=d)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:h,k1:f,k2neg:y,k2:u}}function Zo(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function zo(e,t){wt(e);let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return gt(r.lowS,"lowS"),gt(r.prehash,"prehash"),r.format!==void 0&&Zo(r.format),r}var jt=BigInt(0),ge=BigInt(1),ca=BigInt(2),Vo=BigInt(3),pu=BigInt(4);function fa(e,t={}){let r=Zr("weierstrass",e,t),n=r.Fp,o=r.Fn,s=r.CURVE,{h:i,n:a}=s;wt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:f,clearCofactor:u,isTorsionFree:h,fromBytes:y,toBytes:d}=t,B=t.randomBytes===void 0?de:t.randomBytes;if(c&&(!n.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let g=c?{beta:c.beta,basises:c.basises.map(E=>[...E])}:void 0,I=la(n,o);function w(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function x(E,l,p){if(l.is0()){if(!f)throw new Error("bad point: ZERO");return Uint8Array.of(0)}let{x:b,y:v}=l.toAffine(),_=n.toBytes(b);if(gt(p,"isCompressed"),p){w();let R=!n.isOdd(v);return Rt(ua(R),_)}else return Rt(Uint8Array.of(4),_,n.toBytes(v))}function m(E){Z(E,void 0,"Point");let{publicKey:l,publicKeyUncompressed:p}=I,b=E.length,v=E[0],_=E.subarray(1);if(f&&b===1&&v===0)return{x:n.ZERO,y:n.ZERO};if(b===l&&(v===2||v===3)){let R=n.fromBytes(_);if(!n.isValid(R))throw new Error("bad point: is not on curve, wrong x");let O=U(R),F;try{F=n.sqrt(O)}catch(st){let J=st instanceof Error?": "+st.message:"";throw new Error("bad point: is not on curve, sqrt error"+J)}w();let V=n.isOdd(F);return(v&1)===1!==V&&(F=n.neg(F)),{x:R,y:F}}else if(b===p&&v===4){let R=n.BYTES,O=n.fromBytes(_.subarray(0,R)),F=n.fromBytes(_.subarray(R,R*2));if(!L(O,F))throw new Error("bad point: is not on curve");return{x:O,y:F}}else throw new Error(`bad point: got length ${b}, expected compressed=${l} or uncompressed=${p}`)}let S=d===void 0?x:d,A=y===void 0?m:y,K=n.mul(s.b,Vo),k=n.is0(s.a)?E=>n.ZERO:E=>n.mul(s.a,E);function U(E){let l=n.sqr(E),p=n.mul(l,E);return n.add(n.add(p,n.mul(E,s.a)),s.b)}function L(E,l){let p=n.sqr(l),b=U(E);return n.eql(p,b)}if(!L(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let C=n.mul(n.pow(s.a,Vo),pu),H=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(C,H)))throw new Error("bad curve params: a or b");function q(E,l,p=!1){if(!n.isValid(l)||p&&n.is0(l))throw new Error(`bad point coordinate ${E}`);return typeof l=="object"&&l!==null?n.create(l):l}function G(E){if(!(E instanceof D))throw new Error("Weierstrass Point expected")}function T(E){if(!g||!g.basises)throw new Error("no endo");return du(E,g.basises,o.ORDER)}function N(E,l,p,b){if(!o.isValid(b))throw new RangeError("invalid scalar: out of range");if(g){let{k1neg:v,k1:_,k2neg:R,k2:O}=T(b),F=new D(n.mul(p.X,g.beta),p.Y,p.Z);E.push(v?p.negate():p,R?F.negate():F),l.push(_,O)}else E.push(p),l.push(b)}let M=new WeakSet;class D{static BASE=new D(s.Gx,s.Gy,n.ONE);static ZERO=new D(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(l,p,b){this.X=q("x",l),this.Y=q("y",p,!0),this.Z=q("z",b),Object.freeze(this)}static CURVE(){return s}static fromAffine(l){let{x:p,y:b}=l||{};if(!l||!n.isValid(p)||!n.isValid(b))throw new Error("invalid affine point");if(l instanceof D)throw new Error("projective point not allowed");return n.is0(p)&&n.is0(b)?D.ZERO:new D(p,b,n.ONE)}static fromBytes(l){let p=D.fromAffine(A(Z(l,void 0,"point")));return p.assertValidity(),p}static fromHex(l){return D.fromBytes(De(l))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(l=6,p=!0){return et.setWindowSize(this,l),p||this.multiply(Vo),this}assertValidity(){let l=this;if(l.is0()){if(f&&n.is0(l.X)&&n.eql(l.Y,n.ONE)&&n.is0(l.Z))return;throw new Error("bad point: ZERO")}if(M.has(l))return;let{x:p,y:b}=l.toAffine();if(!n.isValid(p)||!n.isValid(b))throw new Error("bad point: x or y not field elements");if(!L(p,b))throw new Error("bad point: equation left != right");if(!l.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");M.add(l)}hasEvenY(){let{y:l}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(l)}equals(l){G(l);let{X:p,Y:b,Z:v}=this,{X:_,Y:R,Z:O}=l,F=n.eql(n.mul(p,O),n.mul(_,v)),V=n.eql(n.mul(b,O),n.mul(R,v));return F&&V}negate(){return new D(this.X,n.neg(this.Y),this.Z)}double(){let{X:l,Y:p,Z:b}=this,v=n.ZERO,_=n.ZERO,R=n.ZERO,O=n.mul(l,l),F=n.mul(p,p),V=n.mul(b,b),j=n.mul(l,p);return j=n.add(j,j),R=n.mul(l,b),R=n.add(R,R),v=k(R),_=n.mul(K,V),_=n.add(v,_),v=n.sub(F,_),_=n.add(F,_),_=n.mul(v,_),v=n.mul(j,v),R=n.mul(K,R),V=k(V),j=n.sub(O,V),j=k(j),j=n.add(j,R),R=n.add(O,O),O=n.add(R,O),O=n.add(O,V),O=n.mul(O,j),_=n.add(_,O),V=n.mul(p,b),V=n.add(V,V),O=n.mul(V,j),v=n.sub(v,O),R=n.mul(V,F),R=n.add(R,R),R=n.add(R,R),new D(v,_,R)}add(l){G(l);let{X:p,Y:b,Z:v}=this,{X:_,Y:R,Z:O}=l,F=n.ZERO,V=n.ZERO,j=n.ZERO,st=n.mul(p,_),J=n.mul(b,R),ct=n.mul(v,O),It=n.add(p,b),Q=n.add(_,R);It=n.mul(It,Q),Q=n.add(st,J),It=n.sub(It,Q),Q=n.add(p,v);let it=n.add(_,O);return Q=n.mul(Q,it),it=n.add(st,ct),Q=n.sub(Q,it),it=n.add(b,v),F=n.add(R,O),it=n.mul(it,F),F=n.add(J,ct),it=n.sub(it,F),j=k(Q),F=n.mul(K,ct),j=n.add(F,j),F=n.sub(J,j),j=n.add(J,j),V=n.mul(F,j),J=n.add(st,st),J=n.add(J,st),ct=k(ct),Q=n.mul(K,Q),J=n.add(J,ct),ct=n.sub(st,ct),ct=k(ct),Q=n.add(Q,ct),st=n.mul(J,Q),V=n.add(V,st),st=n.mul(it,Q),F=n.mul(It,F),F=n.sub(F,st),st=n.mul(It,J),j=n.mul(it,j),j=n.add(j,st),new D(F,V,j)}subtract(l){return G(l),this.add(l.negate())}is0(){return this.equals(D.ZERO)}multiply(l){if(!o.isValidNot0(l))throw new RangeError("invalid scalar: out of range");let{p,f:b}=et.mulSecret(this,l,i,W);return W([p,b])[0]}multiplyUnsafe(l){let p=this,b=l;if(!o.isValid(b))throw new RangeError("invalid scalar: out of range");if(b===jt||p.is0())return D.ZERO;if(b===ge)return p;if(et.hasWindowSize(this))return et.mulUnsafe(p,b,W);let v=[],_=[];return N(v,_,p,b),Vr(D,v,_)}mulAddUnsafe(l,p,b){G(p);let v=[],_=[];return N(v,_,this,l),N(v,_,p,b),Vr(D,v,_)}toAffine(l){let p=this,b=l;if(b!=null&&!n.isValid(b))throw new RangeError('"invertedZ" expected valid field element');let{X:v,Y:_,Z:R}=p;if(n.eql(R,n.ONE))return{x:v,y:_};let O=p.is0();b==null&&(b=O?n.ONE:n.inv(R));let F=n.mul(v,b),V=n.mul(_,b),j=n.mul(R,b);if(O)return{x:n.ZERO,y:n.ZERO};if(!n.eql(j,n.ONE))throw new Error("invZ was invalid");return{x:F,y:V}}isTorsionFree(){return i===ge?!0:h?h(D,this):et.mulUnsafe(this,a).is0()}clearCofactor(){return i===ge?this:u?u(D,this):this.multiplyUnsafe(i)}isSmallOrder(){return i===ge?this.is0():this.clearCofactor().is0()}toBytes(l=!0){return gt(l,"isCompressed"),this.assertValidity(),S(D,this,l)}toHex(l=!0){return or(this.toBytes(l))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let W=E=>zr(D,E),et=new Fe(D,B);return et.bits>=6&&D.BASE.precompute(6),Object.freeze(D.prototype),Object.freeze(D),D}function ua(e){return Uint8Array.of(e?2:3)}function la(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function mu(e,t={}){te(e);let{Fn:r}=e,n=t.randomBytes===void 0?de:t.randomBytes,o=Object.assign(la(e.Fp,r),{seed:Math.max(Hr(r.ORDER),16)});function s(d){try{let B=r.fromBytes(d);return r.isValidNot0(B)}catch{return!1}}function i(d,B){let{publicKey:g,publicKeyUncompressed:I}=o;try{let w=d.length;return B===!0&&w!==g||B===!1&&w!==I?!1:!e.fromBytes(d).is0()}catch{return!1}}function a(d){return d=d===void 0?n(o.seed):d,jr(Z(d,o.seed,"seed"),r.ORDER)}function c(d,B=!0){return e.BASE.multiply(r.fromBytes(d)).toBytes(B)}function f(d){let{secretKey:B,publicKey:g,publicKeyUncompressed:I}=o,w=r._lengths;if(!Jt(d))return;let x=Z(d,void 0,"key").length,m=x===g||x===I,S=x===B||!!w?.includes(x);if(!(m&&S))return m}function u(d,B,g=!0){if(f(d)===!0)throw new Error("first arg must be private key");if(f(B)===!1)throw new Error("second arg must be public key");let I=r.fromBytes(d),w=e.fromBytes(B);if(w.is0())throw new Error("invalid public key: point at infinity");return w.multiply(I).toBytes(g)}let h={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a},y=Yr(a,c);return Object.freeze(h),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:y,Point:e,utils:h,lengths:o})}function ha(e,t,r={}){te(e);let n=t;_e(n),wt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},r),s=o.randomBytes===void 0?de:o.randomBytes,i=o.hmac===void 0?(E,l)=>hn(n,E,l):o.hmac,{Fp:a,Fn:c}=e,{ORDER:f,BITS:u}=c,h=Hr(f),y=yo(s,h),{keygen:d,getPublicKey:B,getSharedSecret:g,utils:I,lengths:w}=mu(e,o),x={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},m=f*ca+ge<a.ORDER;function S(E){let l=f>>ge;return E>l}function A(E,l){if(!c.isValidNot0(l))throw new Error(`invalid signature ${E}: out of range 1..Point.Fn.ORDER`);return l}function K(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function k(E,l,p){return K(),(E===p?0:2)|Number(a.isOdd(l))}function U(){if(m)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function L(E,l){Zo(l);let p=w.signature,b=l==="compact"?p:l==="recovered"?p+1:void 0;return Z(E,b)}class C{r;s;recovery;constructor(l,p,b){if(this.r=A("r",l),this.s=A("s",p),b!=null){if(U(),![0,1,2,3].includes(b))throw new Error("invalid recovery id");this.recovery=b}Object.freeze(this)}static fromBytes(l,p=x.format){L(l,p);let b;if(p==="der"){if(l.length>2*c.BYTES+16)throw new dn.Err("invalid signature: DER signature too long");let{r:O,s:F}=dn.toSig(Z(l),c.BYTES+1);return new C(O,F)}p==="recovered"&&(b=l[0],p="compact",l=l.subarray(1));let v=w.signature/2,_=l.subarray(0,v),R=l.subarray(v,v*2);return new C(c.fromBytes(_),c.fromBytes(R),b)}static fromHex(l,p){return this.fromBytes(De(l),p)}assertRecovery(){let{recovery:l}=this;if(l==null)throw new Error("invalid recovery id: must be present");return l}addRecoveryBit(l){return new C(this.r,this.s,l)}recoverPublicKey(l){let{r:p,s:b}=this,v=this.assertRecovery(),_=v===2||v===3?p+f:p;if(!a.isValid(_))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let R=a.toBytes(_),O=e.fromBytes(Rt(ua((v&1)===0),R)),F=c.inv(_),V=q(Z(l,void 0,"msgHash")),j=c.create(-V*F),st=c.create(b*F),J=e.BASE.mulAddUnsafe(j,O,st);if(J.is0())throw new Error("invalid recovery: point at infinify");return J.assertValidity(),J}hasHighS(){return S(this.s)}toBytes(l=x.format){if(Zo(l),l==="der")return De(dn.hexFromSig(this));let{r:p,s:b}=this,v=c.toBytes(p),_=c.toBytes(b);return l==="recovered"?(U(),Rt(Uint8Array.of(this.assertRecovery()),v,_)):Rt(v,_)}toHex(l){return or(this.toBytes(l))}}Object.freeze(C.prototype),Object.freeze(C);let H=o.bits2int===void 0?function(l){if(l.length>8192)throw new Error("input is too large");let p=kt(l),b=l.length*8-u;return b>0?p>>BigInt(b):p}:o.bits2int,q=o.bits2int_modN===void 0?function(l){return c.create(H(l))}:o.bits2int_modN,G=ar(u);function T(E){return Ce("num < 2^"+u,E,jt,G),c.toBytes(E)}function N(E,l){return Z(E,void 0,"message"),l?Z(n(E),void 0,"prehashed message"):E}function M(E,l,p){let{lowS:b,prehash:v,extraEntropy:_}=zo(p,x);E=N(E,v);let R=q(E),O=c.fromBytes(l);if(!c.isValidNot0(O))throw new Error("invalid private key");let F=[T(O),T(R)];if(_!=null&&_!==!1){let J=_===!0?s(w.secretKey):_;F.push(Z(J,void 0,"extraEntropy"))}let V=Rt(...F),j=R;function st(J){let ct=H(J);if(!c.isValidNot0(ct))return;let It=e.BASE.multiply(ct).toAffine(),Q=c.create(It.x);if(Q===jt)return;let it;if(y!==void 0){let He=kt(jr(y(h),f)),Ra=c.inv(c.mul(He,ct)),La=c.mul(He,j),Da=c.mul(He,O);it=c.create(Ra*c.create(La+Da*Q))}else{let He=pi(ct,f);it=c.create(He*c.create(j+Q*O))}if(it===jt)return;let yn=k(It.x,It.y,Q),ts=it;return b&&S(it)&&(ts=c.neg(it),yn^=1),new C(Q,ts,m?void 0:yn)}return{seed:V,k2sig:st}}function D(E,l,p={}){let{seed:b,k2sig:v}=M(E,l,p);return ii(n.outputLen,c.BYTES,i)(b,v).toBytes(p.format)}function W(E,l,p,b={}){let{lowS:v,prehash:_,format:R}=zo(b,x);if(p=Z(p,void 0,"publicKey"),l=N(l,_),!Jt(E)){let O=E instanceof C?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+O)}L(E,R);try{let O=C.fromBytes(E,R),F=e.fromBytes(p);if(F.is0()||v&&O.hasHighS())return!1;let{r:V,s:j}=O,st=q(l),J=c.inv(j),ct=c.create(st*J),It=c.create(V*J),Q=e.BASE.mulAddUnsafe(ct,F,It);if(Q.is0())return!1;let it=Q.toAffine();return!(c.create(it.x)!==V||R==="recovered"&&O.recovery!==k(it.x,it.y,V))}catch{return!1}}function et(E,l,p={}){let{prehash:b}=zo(p,x);return l=N(l,b),C.fromBytes(E,"recovered").recoverPublicKey(l).toBytes()}return Object.freeze({keygen:d,getPublicKey:B,getSharedSecret:g,utils:I,lengths:w,Point:e,sign:D,verify:W,recoverPublicKey:et,Signature:C,hash:n})}var $o={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},yu={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var da=BigInt(2);function bu(e){let t=$o.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),f=e*e*e%t,u=f*f*e%t,h=tt(u,r,t)*u%t,y=tt(h,r,t)*u%t,d=tt(y,da,t)*f%t,B=tt(d,o,t)*d%t,g=tt(B,s,t)*B%t,I=tt(g,a,t)*g%t,w=tt(I,c,t)*I%t,x=tt(w,a,t)*g%t,m=tt(x,r,t)*u%t,S=tt(m,i,t)*B%t,A=tt(S,n,t)*f%t,K=tt(A,da,t);if(!Yo.eql(Yo.sqr(K),e))throw new Error("Cannot find square root");return K}var Yo=Ue($o.p,{sqrt:bu}),gu=fa($o,{Fp:Yo,endo:yu}),Ot=ha(gu,Gt);var pa=33,ma=32;function ya(e,t,r){let n=vr.digest(t instanceof Uint8Array?t:t.subarray());if(Pe(n))return n.then(({digest:o})=>(r?.signal?.throwIfAborted(),Ot.sign(o,e,{prehash:!1,format:"der"}))).catch(o=>{throw o.name==="AbortError"?o:new je(String(o))});try{return Ot.sign(n.digest,e,{prehash:!1,format:"der"})}catch(o){throw new je(String(o))}}function ba(e,t,r,n){let o=vr.digest(r instanceof Uint8Array?r:r.subarray());if(Pe(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),Ot.verify(t,s,e,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new ze(String(s))});try{return n?.signal?.throwIfAborted(),Ot.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(s){throw new ze(String(s))}}var gr=class{type="secp256k1";raw;_key;constructor(t){this._key=xa(t),this.raw=ga(this._key)}toMultihash(){return ie.digest(ce(this))}toCID(){return _t.createV1(114,this.toMultihash())}toString(){return ft.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,r,n){return ba(this._key,r,t,n)}},wr=class{type="secp256k1";raw;publicKey;constructor(t,r){this.raw=wa(t),this.publicKey=new gr(r??Ea(t))}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}sign(t,r){return ya(this.raw,t,r)}};function Go(e){return new wr(e)}function pn(e){return new gr(e)}async function Sa(){let e=wu();return new wr(e)}function ga(e){return Ot.Point.fromBytes(e).toBytes()}function wa(e){try{return Ot.getPublicKey(e,!0),e}catch(t){throw new Ve(String(t))}}function xa(e){try{return Ot.Point.fromBytes(e),e}catch(t){throw new we(String(t))}}function Ea(e){try{return Ot.getPublicKey(e,!0)}catch(t){throw new Ve(String(t))}}function wu(){return Ot.utils.randomSecretKey()}var mn={"P-256":32,"P-384":48,"P-521":66},xu=Object.keys(mn),Xo=xu.join(" / ");async function Aa(e){if(e!=="P-256"&&e!=="P-384"&&e!=="P-521")throw new P(`Unknown curve: ${e}. Must be ${Xo}`);let t=await rt.get().subtle.generateKey({name:"ECDH",namedCurve:e},!0,["deriveBits"]),r=async(s,i)=>{let a;i!=null?a=await rt.get().subtle.importKey("jwk",Su(e,i),{name:"ECDH",namedCurve:e},!1,["deriveBits"]):a=t.privateKey;let c=await rt.get().subtle.importKey("jwk",Ba(e,s),{name:"ECDH",namedCurve:e},!1,[]),f=await rt.get().subtle.deriveBits({name:"ECDH",public:c},a,mn[e]*8);return new Uint8Array(f,0,f.byteLength)},n=await rt.get().subtle.exportKey("jwk",t.publicKey);return{key:Eu(n),genSharedKey:r}}function Eu(e){if(e.crv==null||e.x==null||e.y==null)throw new P("JWK was missing components");if(e.crv!=="P-256"&&e.crv!=="P-384"&&e.crv!=="P-521")throw new P(`Unknown curve: ${e.crv}. Must be ${Xo}`);let t=mn[e.crv];return Ut([Uint8Array.from([4]),xo(e.x,t),xo(e.y,t)],1+t*2)}function Ba(e,t){if(e!=="P-256"&&e!=="P-384"&&e!=="P-521")throw new P(`Unknown curve: ${e}. Must be ${Xo}`);let r=mn[e];if(!ht(t.subarray(0,1),Uint8Array.from([4])))throw new P("Cannot unmarshal public key - invalid key format");return{kty:"EC",crv:e,x:z(t.subarray(1,r+1),"base64url"),y:z(t.subarray(1+r),"base64url"),ext:!0}}var Su=(e,t)=>({...Ba(e,t.public),d:z(t.private,"base64url")});var Au={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,keySize:32}};async function va(e,t,r){if(e!=="AES-128"&&e!=="AES-256"&&e!=="Blowfish")throw new P("Cipher type was missing or unsupported");if(t!=="SHA1"&&t!=="SHA256"&&t!=="SHA512")throw new P("Hash type was missing or unsupported");if(r==null||!(r instanceof Uint8Array))throw new P("Secret was missing or an incorrect type");let n=Au[e],o=n.keySize,s=n.ivSize,i=20,a=X("key expansion"),c=2*(s+o+i),f=await gn(t,r),u=await f.digest(a),h=[],y=0;for(;y<c;){let x=await f.digest(Ut([u,a])),m=x.length;y+m>c&&(m=c-y),h.push(x),y+=m,u=await f.digest(u)}let d=c/2,B=Ut(h),g=B.subarray(0,d),I=B.subarray(d,c),w=x=>({iv:x.subarray(0,s),cipherKey:x.subarray(s,s+o),macKey:x.subarray(s+o)});return{k1:w(g),k2:w(I)}}async function Bu(e,t){if(e==="Ed25519")return Ni();if(e==="secp256k1")return Sa();if(e==="RSA")return Ho(Cu(t));if(e==="ECDSA")return Ms(Ou(t));throw new zt}async function vu(e,t){if(e!=="Ed25519")throw new zt("Seed key derivation only supported for Ed25519 keys");return Pi(t)}function Iu(e,t){let{Type:r,Data:n}=Nt.decode(e),o=n??new Uint8Array;switch(r){case $.RSA:return qo(o,t);case $.Ed25519:return Jr(o);case $.secp256k1:return pn(o);case $.ECDSA:return Yn(o);default:throw new zt}}function Tu(e){if(e.byteLength===ee)return Jr(e);if(e.byteLength===pa)return pn(e);let t=Et(e),r=t[1]?.[0];if(r===Rn||r===Ln||r===Dn)return $n(t);if(t[0]?.[0]===ia)return fn(t,e);throw new P("Could not extract public key from raw bytes")}function _u(e){let{Type:t,Data:r}=Nt.decode(e.digest),n=r??new Uint8Array;switch(t){case $.Ed25519:return Jr(n);case $.secp256k1:return pn(n);case $.ECDSA:return Yn(n);default:throw new zt}}function ce(e){return Nt.encode({Type:$[e.type],Data:e.raw})}function Ru(e){let t=mr.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case $.RSA:return Mo(r);case $.Ed25519:return Eo(r);case $.secp256k1:return Go(r);case $.ECDSA:return Fs(r);default:throw new zt}}function Lu(e){if(e.byteLength===Bt)return Eo(e);if(e.byteLength===ma)return Go(e);let t=Et(e),r=t[2]?.[0];if(r===Rn||r===Ln||r===Dn)return Zn(t);if(t.length>8)return cn(t);throw new P("Could not extract private key from raw bytes")}function Du(e){return mr.encode({Type:$[e.type],Data:e.raw})}function Cu(e){return e==null?2048:parseInt(e,10)}function Ou(e){if(e==="P-256"||e==null)return"P-256";if(e==="P-384")return"P-384";if(e==="P-521")return"P-521";throw new P("Unsupported curve, should be P-256, P-384 or P-521")}async function Ku(e){if(e.type==="RSA")return{privateKey:await crypto.subtle.importKey("jwk",e.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",e.publicKey.jwk,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])};if(e.type==="ECDSA")return{privateKey:await crypto.subtle.importKey("jwk",e.jwk,{name:"ECDSA",namedCurve:e.jwk.crv??"P-256"},!0,["sign"]),publicKey:await crypto.subtle.importKey("jwk",e.publicKey.jwk,{name:"ECDSA",namedCurve:e.publicKey.jwk.crv??"P-256"},!0,["verify"])};throw new P("Only RSA and ECDSA keys are supported")}async function Uu(e){if(e.privateKey.algorithm.name==="RSASSA-PKCS1-v1_5"){let t=await crypto.subtle.exportKey("jwk",e.privateKey);return un(t)}if(e.privateKey.algorithm.name==="ECDSA"){let t=await crypto.subtle.exportKey("jwk",e.privateKey);return new Mt(t)}throw new P("Only RSA and ECDSA keys are supported")}var xr=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),oe=new Uint32Array(80),Jo=class extends le{A=xr[0]|0;B=xr[1]|0;C=xr[2]|0;D=xr[3]|0;E=xr[4]|0;constructor(){super(64,20,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:s}=this;return[t,r,n,o,s]}set(t,r,n,o,s){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,r){for(let c=0;c<16;c++,r+=4)oe[c]=t.getUint32(r,!1);for(let c=16;c<80;c++)oe[c]=Dr(oe[c-3]^oe[c-8]^oe[c-14]^oe[c-16],1);let{A:n,B:o,C:s,D:i,E:a}=this;for(let c=0;c<80;c++){let f,u;c<20?(f=Kr(o,s,i),u=1518500249):c<40?(f=o^s^i,u=1859775393):c<60?(f=Ur(o,s,i),u=2400959708):(f=o^s^i,u=3395469782);let h=Dr(n,5)+f+a+u+oe[c]|0;a=i,i=s,s=Dr(o,30),o=n,n=h}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,this.set(n,o,s,i,a)}roundClean(){yt(oe)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),yt(this.buffer)}},Ia=rr(()=>new Jo);function Fu(e,t,r,n){_e(e);let o=to({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:a}=o;if(St(s,"c"),St(i,"dkLen"),St(a,"asyncTick"),s<1)throw new Error('"c" (iterations) must be >= 1');if(i<1)throw new Error('"dkLen" must be >= 1');if(i>(2**32-1)*e.outputLen)throw new Error("derived key too long");let c=Jn(t,"password");try{let f=Jn(r,"salt");try{let u=new Uint8Array(i),{iHash:h,oHash:y,outputLen:d}=hn.create(e,c),B=new Uint8Array(d),g=ku(h,y,f,B);return{c:s,dkLen:i,asyncTick:a,DK:u,outputLen:d,eng:g}}finally{typeof r=="string"&&yt(f)}}finally{typeof t=="string"&&yt(c)}}function ku(e,t,r,n){let o=new Uint8Array(4),s=Le(o),i=e._cloneInto().update(r),a=t._cloneInto(),c=e._cloneInto,f=t._cloneInto;return{u1:(u,h)=>{s.setInt32(0,u,!1),i._cloneInto(a).update(o).digestInto(n),t._cloneInto(a).update(n).digestInto(n),h.set(n.subarray(0,h.length))},rounds:(u,h)=>{for(let y=1;y<u;y++){c.call(e,a).update(n).digestInto(n),f.call(t,a).update(n).digestInto(n);for(let d=0;d<h.length;d++)h[d]^=n[d]}},output:u=>(e.destroy(),t.destroy(),i.destroy(),a.destroy(),yt(n),u)}}function Ta(e,t,r,n){let{c:o,dkLen:s,DK:i,outputLen:a,eng:c}=Fu(e,t,r,n);for(let f=1,u=0;u<s;f++,u+=a){let h=i.subarray(u,u+a);c.u1(f,h),c.rounds(o,h)}return c.output(i)}var _a={sha1:Ia,"sha2-256":Gt,"sha2-512":nr};function Qo(e,t,r,n,o){if(o!=="sha1"&&o!=="sha2-256"&&o!=="sha2-512"){let a=Object.keys(_a).join(" / ");throw new P(`Hash '${o}' is unknown or not supported. Must be ${a}`)}let s=_a[o],i=Ta(s,e,t,{c:r,dkLen:n});return Fn.encode(i).substring(1)}return Fa(Nu);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/curves/utils.js:
|