@ckb-ccc/core 1.21.0 → 1.22.1
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/CHANGELOG.md +50 -0
- package/README.md +3 -3
- package/dist/advanced.d.mts +1 -1
- package/dist/advanced.mjs +1 -1
- package/dist/{advancedBarrel-B_9PyL2D.d.mts → advancedBarrel-Daj_LJkz.d.mts} +139 -19
- package/dist/advancedBarrel-Daj_LJkz.d.mts.map +1 -0
- package/dist/advancedBarrel.d.mts +1 -1
- package/dist/advancedBarrel.mjs +1 -1
- package/dist/barrel-pRBtHOAW.mjs +7 -0
- package/dist/barrel-pRBtHOAW.mjs.map +1 -0
- package/dist/barrel.d.mts +2 -2
- package/dist/barrel.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/transformers-lavDTtAW.mjs +2 -0
- package/dist/transformers-lavDTtAW.mjs.map +1 -0
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +1 -1
- package/dist.commonjs/{advancedBarrel-Cll2j9KP.d.ts → advancedBarrel-CJL3rfuW.d.ts} +139 -19
- package/dist.commonjs/advancedBarrel-CJL3rfuW.d.ts.map +1 -0
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +1 -1
- package/dist.commonjs/barrel--PaV2IZx.js +23 -0
- package/dist.commonjs/barrel--PaV2IZx.js.map +1 -0
- package/dist.commonjs/barrel.d.ts +2 -2
- package/dist.commonjs/barrel.js +1 -1
- package/dist.commonjs/index.d.ts +2 -2
- package/dist.commonjs/index.js +1 -1
- package/dist.commonjs/transformers-VBXQGQKe.js +2 -0
- package/dist.commonjs/transformers-VBXQGQKe.js.map +1 -0
- package/package.json +1 -1
- package/src/ckb/transaction.ts +20 -4
- package/src/client/client.ts +8 -2
- package/src/client/clientPublicMainnet.advanced.ts +9 -0
- package/src/client/clientPublicTestnet.advanced.ts +9 -0
- package/src/client/jsonRpc/client.ts +1 -1
- package/src/fixedPoint/index.ts +17 -8
- package/src/jsonRpc/requestor.ts +32 -8
- package/src/jsonRpc/transports/fallback.ts +6 -2
- package/src/jsonRpc/transports/http.ts +20 -17
- package/src/jsonRpc/transports/transport.ts +11 -1
- package/src/jsonRpc/transports/webSocket.ts +87 -27
- package/src/signer/btc/psbt.ts +4 -2
- package/src/signer/jsonRpc/handler.ts +394 -133
- package/src/signer/jsonRpc/signer.ts +178 -34
- package/src/signer/jsonRpc/transformers.ts +4 -0
- package/src/utils/abortSignal.ts +14 -0
- package/src/utils/index.ts +150 -0
- package/dist/advancedBarrel-B_9PyL2D.d.mts.map +0 -1
- package/dist/barrel-CrN8Ibc4.mjs +0 -7
- package/dist/barrel-CrN8Ibc4.mjs.map +0 -1
- package/dist/transformers-7aume1sD.mjs +0 -2
- package/dist/transformers-7aume1sD.mjs.map +0 -1
- package/dist.commonjs/advancedBarrel-Cll2j9KP.d.ts.map +0 -1
- package/dist.commonjs/barrel-BL6-tNI3.js +0 -23
- package/dist.commonjs/barrel-BL6-tNI3.js.map +0 -1
- package/dist.commonjs/transformers-1XBitiyh.js +0 -2
- package/dist.commonjs/transformers-1XBitiyh.js.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-Chgba0Kb.js"),t=require("./transformers-VBXQGQKe.js");let n=require("bech32"),r=require("isomorphic-ws");r=e.n(r);let i=require("@joyid/ckb"),a=require("ethers");function o(e,t,n){return e&t^~e&n}function s(e,t,n){return e&t^e&n^t&n}var c=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,n,r,i){this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=t.Vr(this.buffer)}update(e){t.jr(this),t.Ar(e);let{view:n,buffer:r,blockLen:i}=this,a=e.length,o=!1;for(let s=0;s<a;){let c=Math.min(i-this.pos,a-s);if(c===i){let n=t.Vr(e);for(;i<=a-s;s+=i)this.process(n,s);o=!0;continue}r.set(s===0&&c===a?e:e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===i&&(this.process(n,0),this.pos=0,o=!0)}return this.length+=e.length,o&&this.roundClean(),this}digestInto(e){t.jr(this),t.Pr(e,this),this.finished=!0;let{buffer:n,view:r,blockLen:i,isLE:a}=this,{pos:o}=this;n[o++]=128,n.fill(0,o),this.padOffset>i-o&&(this.process(r,0),n.fill(0)),t.Dr(r,i-8,this.length*8,a),this.process(r,0),this.roundClean();let s=e===n?r:t.Vr(e),c=this.outputLen,l=c/4,u=this.get();if(c%4||l>u.length)throw Error(`invalid outputLen`);for(let e=0;e<l;e++)s.setUint32(4*e,u[e],a)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}};const l=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u=BigInt(0),d=BigInt(1),f=BigInt(2),p=BigInt(7),m=BigInt(256),h=BigInt(113),g=[],_=[],v=[];for(let e=0,t=d,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],g.push(2*(5*r+n)),_.push((e+1)*(e+2)/2%64);let i=u;for(let e=0;e<7;e++)t=(t<<d^(t>>p)*h)%m,t&f&&(i^=d<<(d<<BigInt(e))-d);v.push(i)}const y=t.Or(v,!0),ee=y[0],te=y[1],b=(e,t,n)=>e<<n|t>>>32-n,x=(e,t,n)=>t<<n|e>>>32-n,S=(e,t,n)=>t<<n-32|e>>>64-n,C=(e,t,n)=>e<<n-32|t>>>64-n,w=(e,t,n)=>n>32?S(e,t,n):b(e,t,n),T=(e,t,n)=>n>32?C(e,t,n):x(e,t,n),E=new Uint32Array(10);function D(e,n=24){if(!(e instanceof Uint32Array))throw TypeError(`"s" expected Uint32Array(50), got type=`+typeof e);if(e.length!==50)throw RangeError(`"s" expected Uint32Array(50), got length=`+e.length);if(t.Nr(n,`rounds`),n<1||n>24)throw Error(`"rounds" expected integer 1..24`);for(let t=24-n;t<24;t++){for(let t=0;t<10;t++)E[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,r=(t+2)%10,i=E[r],a=E[r+1],o=w(i,a,1)^E[n],s=T(i,a,1)^E[n+1];for(let n=0;n<50;n+=10)e[t+n]^=o,e[t+n+1]^=s}let n=e[2],r=e[3];for(let t=0;t<24;t++){let i=_[t],a=w(n,r,i),o=T(n,r,i),s=g[t];n=e[s],r=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3];e[t]^=~e[t+2]&e[t+4],e[t+1]^=~e[t+3]&e[t+5],e[t+2]^=~e[t+4]&e[t+6],e[t+3]^=~e[t+5]&e[t+7],e[t+4]^=~e[t+6]&e[t+8],e[t+5]^=~e[t+7]&e[t+9],e[t+6]^=~e[t+8]&n,e[t+7]^=~e[t+9]&r,e[t+8]^=~n&i,e[t+9]^=~r&a}e[0]^=ee[t],e[1]^=te[t]}t.Rr(E)}var O=class e{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(e,n,r,i=!1,a=24){if(t.Nr(e,`blockLen`),t.Nr(n,`suffix`),t.Nr(a,`rounds`),t.kr(i,`enableXOF`),this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.canXOF=i,this.rounds=a,t.Nr(r,`outputLen`),!(0<e&&e<200))throw Error(`"blockLen" must be 1..199`);this.state=new Uint8Array(200),this.state32=t.Xr(this.state)}clone(){return this._cloneInto()}keccak(){t.Yr(this.state32),D(this.state32,this.rounds),t.Yr(this.state32),this.posOut=0,this.pos=0}update(e){t.jr(this),t.Ar(e);let{blockLen:n,state:r,state32:i}=this,a=e.length,o=n%4==0&&e.byteOffset%4==0,s=n/4,c=o&&a>=n?t.Xr(e):void 0;for(let t=0;t<a;){if(c!==void 0&&this.pos===0&&t%4==0&&a-t>=n){for(let e=0,n=t/4;e<s;e++)i[e]^=c[n+e];t+=n,this.pos=n,this.keccak();continue}let o=Math.min(n-this.pos,a-t);for(let n=0;n<o;n++)r[this.pos++]^=e[t++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){t.jr(this,!1),t.Ar(e),this.finish();let n=this.state,{blockLen:r}=this;for(let t=0,i=e.length;t<i;){this.posOut>=r&&this.keccak();let a=Math.min(r-this.posOut,i-t);e.set(n.subarray(this.posOut,this.posOut+a),t),this.posOut+=a,t+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not enabled`);return this.writeInto(e)}xof(e){return t.Nr(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(t.Pr(e,this),this.finished)throw Error(`digest() was already called`);this.writeInto(e.length===this.outputLen?e:e.subarray(0,this.outputLen)),this.destroy()}digest(){let e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,t.Rr(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.blockLen=n,t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.canXOF=this.canXOF,t.destroyed=this.destroyed,t}};const k=((e,n,r,i={})=>t.Br(()=>new O(n,e,r),i))(1,136,32);var A=class{constructor(){this.hasher=k.create()}update(e){return this.hasher.update(t.ni(e)),this}digest(){return t.Er(this.hasher.digest())}},j=e.t({Bool:()=>t.En,BoolOpt:()=>t.zt,BoolVec:()=>t.Bt,Byte:()=>t.Dn,Byte16:()=>t.On,Byte16Opt:()=>t.Vt,Byte16Vec:()=>t.Ht,Byte32:()=>t.kn,Byte32Opt:()=>t.Ut,Byte32Vec:()=>t.Wt,Byte4:()=>t.An,Byte4Opt:()=>t.Gt,Byte4Vec:()=>t.Kt,Byte8:()=>t.jn,Byte8Opt:()=>t.qt,Byte8Vec:()=>t.Jt,ByteOpt:()=>t.Yt,ByteVec:()=>t.Xt,Bytes:()=>t.Zt,BytesOpt:()=>t.Qt,BytesVec:()=>t.$t,Codec:()=>t.Zr,Entity:()=>t.gr,String:()=>t.en,StringOpt:()=>t.tn,StringVec:()=>t.nn,Uint128:()=>t.Pn,Uint128BE:()=>t.Fn,Uint128LE:()=>t.In,Uint128Opt:()=>t.rn,Uint128Vec:()=>t.in,Uint16:()=>t.Ln,Uint16BE:()=>t.Rn,Uint16LE:()=>t.zn,Uint16Opt:()=>t.an,Uint16Vec:()=>t.on,Uint256:()=>t.Bn,Uint256BE:()=>t.Vn,Uint256LE:()=>t.Hn,Uint256Opt:()=>t.sn,Uint256Vec:()=>t.cn,Uint32:()=>t.Un,Uint32BE:()=>t.Wn,Uint32LE:()=>t.Gn,Uint32Opt:()=>t.ln,Uint32Vec:()=>t.un,Uint512:()=>t.Kn,Uint512BE:()=>t.qn,Uint512LE:()=>t.Jn,Uint512Opt:()=>t.dn,Uint512Vec:()=>t.fn,Uint64:()=>t.Yn,Uint64BE:()=>t.Xn,Uint64LE:()=>t.Zn,Uint64Opt:()=>t.pn,Uint64Vec:()=>t.mn,Uint8:()=>t.Qn,Uint8Opt:()=>t.hn,Uint8Vec:()=>t.gn,array:()=>t._n,byteVec:()=>t.vn,codec:()=>t._r,dynItemVec:()=>t.yn,fixedItemVec:()=>t.bn,option:()=>t.xn,struct:()=>t.Sn,table:()=>t.Cn,uint:()=>t.er,uintNumber:()=>t.tr,union:()=>t.wn,vector:()=>t.Tn}),M=class e extends t.Ft{constructor(e,t){super(),this.value_=e,this.owners=t}static from(t){if(new Set(t).size!==t.length)throw Error(`Cannot aggregate the same Owner more than once`);let n=t.map(e=>e.value),r=t.map(e=>this.moveFrom(e));return new e(n,r)}async release(){let e=await Promise.allSettled(this.owners.map(e=>e.dispose())),t=[];for(let n of e)n.status===`rejected`&&t.push(n.reason);if(t.length!==0)throw AggregateError(t,`Failed to dispose aggregated Owners`)}},N=class e extends t.Ft{constructor(e){super(),this.state=e}get value_(){return this.state.owner.value}static new(n,r){return new e({owner:new t.It(n,r),referenceCount:1})}static from(t){return new e({owner:this.moveFrom(t),referenceCount:1})}clone(){return this.value,this.state.referenceCount+=1,new e(this.state)}release(){if(--this.state.referenceCount,this.state.referenceCount===0)return this.state.owner.dispose()}};let P;(function(e){let t=e.inner=`@ckb-ccc/core.Proxy.inner`,n=e.localKeys=Symbol.for(`@ckb-ccc/core.Proxy.localKeys`);function r(e){class r{constructor(e){this[t]=e;let i=new Set([t]),a=new Map;for(let e=new.target.prototype;e!==null&&e!==r.prototype;e=Reflect.getPrototypeOf(e)){for(let t of Reflect.ownKeys(e))i.add(t);let t=Object.getOwnPropertyDescriptor(e,`constructor`)?.value;try{let e=Object.getOwnPropertyDescriptor(t,n)?.value;for(let t of e??[])i.add(t)}catch{}}let o=(e,t)=>i.has(t)||Reflect.getOwnPropertyDescriptor(e,t)!==void 0;return new globalThis.Proxy(this,{deleteProperty:(t,n)=>Reflect.deleteProperty(o(t,n)?t:e,n),get:(t,n,r)=>{let i=o(t,n),s=Reflect.get(i?t:e,n,i?r:e);if(i||typeof s!=`function`)return s;let c=a.get(n);return c?.value!==s&&(c={value:s,wrapper:(...t)=>Reflect.apply(s,e,t)},a.set(n,c)),c.wrapper},has:(t,n)=>Reflect.has(o(t,n)?t:e,n),set:(t,n,r,i)=>{let a=o(t,n);return Reflect.set(a?t:e,n,r,a?i:e)}})}}let i=e.prototype;return Object.setPrototypeOf(r.prototype,i),Object.setPrototypeOf(r,e),r}e.Base=r})(P||={});function F(e,n){return t.xr(t.C.from(e).toBytes(),t.sr(n,8))}var I=class{async markUsable(...e){return await this.recordCells(...e),this.markUsableNoCache(...e)}async markTransactions(...e){await Promise.all([this.recordTransactionResponses(e.flat().map(e=>({transaction:e,status:`sent`}))),...e.flat().map(e=>{let n=t.j.from(e),r=n.hash();return Promise.all([...n.inputs.map(e=>this.markUnusable(e.previousOutput)),...n.outputs.map((e,t)=>this.markUsable({cellOutput:e,outputData:n.outputsData[t],outPoint:{txHash:r,index:t}}))])})])}async recordCells(...e){}async getCell(e){}async recordTransactionResponses(...e){}async getTransactionResponse(e){}async recordTransactions(...e){return this.recordTransactionResponses(e.flat().map(e=>({transaction:e,status:`unknown`})))}async getTransaction(e){return(await this.getTransactionResponse(e))?.transaction}async recordHeaders(...e){}async getHeaderByHash(e){}async getHeaderByNumber(e){}async recordBlocks(...e){}async getBlockByHash(e){}async getBlockByNumber(e){}hasHeaderConfirmed(e){return t.ir(Date.now())-e.timestamp>=t.f}},ne=class extends I{constructor(e=512,n=256,r=128,i=t.f){super(),this.maxCells=e,this.maxTxs=n,this.maxBlocks=r,this.cells=new t.p(this.maxCells),this.knownTransactions=new t.p(this.maxTxs),this.knownBlockHashes=new t.p(this.maxBlocks),this.knownBlocks=new t.p(this.maxBlocks),this.confirmedBlockTime=t.ir(i)}async markUsableNoCache(...e){e.flat().forEach(e=>{let n=t.y.from(e).clone(),r=t.Er(n.outPoint.toBytes());this.cells.set(r,[!0,n])})}async markUnusable(...e){e.flat().forEach(e=>{let n=t.O.from(e),r=t.Er(n.toBytes()),i=this.cells.get(r);if(i){i[0]=!1;return}this.cells.set(r,[!1,{outPoint:n}])})}async clear(){this.cells.clear(),this.knownTransactions.clear()}async*findCells(e){for(let[n,[r,i]]of this.cells.entries())r&&t.m(e,i)&&(this.cells.get(n),yield i.clone())}async isUnusable(e){let n=t.O.from(e);return!(this.cells.get(t.Er(n.toBytes()))?.[0]??!0)}async recordCells(...e){e.flat().map(e=>{let n=t.y.from(e),r=t.Er(n.outPoint.toBytes());this.cells.get(r)||this.cells.set(r,[void 0,n])})}async getCell(e){let n=t.O.from(e),r=this.cells.get(t.Er(n.toBytes()))?.[1];if(r&&r.cellOutput&&r.outputData)return t.y.from(r.clone())}async recordTransactionResponses(...e){e.flat().map(e=>{let n=t.lt.from(e);this.knownTransactions.set(n.transaction.hash(),n)})}async getTransactionResponse(e){let n=t.Er(e);return this.knownTransactions.get(n)?.clone()}async recordHeaders(...e){e.flat().map(e=>{let n=t.it.from(e);this.knownBlockHashes.set(n.number,n.hash),!this.knownBlocks.get(n.hash)&&this.knownBlocks.set(n.hash,{header:n})})}async getHeaderByHash(e){let n=t.Er(e),r=this.knownBlocks.get(n);return r&&this.knownBlockHashes.get(r.header.number),r?.header}async getHeaderByNumber(e){let n=t.ir(e),r=this.knownBlockHashes.get(n);if(r)return this.getHeaderByHash(r)}async recordBlocks(...e){e.flat().map(e=>{let n=t.rt.from(e);this.knownBlockHashes.set(n.header.number,n.header.hash),this.knownBlocks.set(n.header.hash,n)})}async getBlockByHash(e){let n=t.Er(e),r=this.knownBlocks.get(n);if(r&&(this.knownBlockHashes.get(r.header.number),`transactions`in r))return r}async getBlockByNumber(e){let n=t.ir(e),r=this.knownBlockHashes.get(n);if(r)return this.getBlockByHash(r)}hasHeaderConfirmed(e){return t.ir(Date.now())-e.timestamp>=this.confirmedBlockTime}},re=class{constructor(e){this.cache=e?.cache??new ne,this.scripts=e?.scripts??{}}async getKnownScript(e){let n=this.scripts[e];if(!n)throw Error(`No script information was found for ${e} on ${this.addressPrefix}`);return t._t.from(n)}async getFeeRate(e,n){let r=t.cr((await this.getFeeRateStatistics(e)).median,t.yt),i=t.ir(n?.maxFeeRate??t.vt);return i===0n?r:t.lr(r,i)}async getBlockByNumber(e,t,n){let r=await this.cache.getBlockByNumber(e);if(r)return r;let i=await this.getBlockByNumberNoCache(e,t,n);return i&&this.cache.hasHeaderConfirmed(i.header)&&await this.cache.recordBlocks(i),i}async getBlockByHash(e,t,n){let r=await this.cache.getBlockByHash(e);if(r)return r;let i=await this.getBlockByHashNoCache(e,t,n);return i&&this.cache.hasHeaderConfirmed(i.header)&&await this.cache.recordBlocks(i),i}async getHeaderByNumber(e,t){let n=await this.cache.getHeaderByNumber(e);if(n)return n;let r=await this.getHeaderByNumberNoCache(e,t);return r&&this.cache.hasHeaderConfirmed(r)&&await this.cache.recordHeaders(r),r}async getHeaderByHash(e,t){let n=await this.cache.getHeaderByHash(e);if(n)return n;let r=await this.getHeaderByHashNoCache(e,t);return r&&this.cache.hasHeaderConfirmed(r)&&await this.cache.recordHeaders(r),r}async getCell(e){let n=t.O.from(e),r=await this.cache.getCell(n);if(r)return r;let i=await this.getTransaction(n.txHash);if(!i)return;let a=i.transaction.getOutput(n.index);if(!a)return;let o=t.y.from({...a,outPoint:n});return await this.cache.recordCells(o),o}async getCellWithHeader(e){let n=t.O.from(e),r=await this.getTransactionWithHeader(n.txHash);if(!r)return;let{transaction:i,header:a}=r,o=i.transaction.getOutput(n.index);if(!o)return;let s=t.y.from({...o,outPoint:n});return await this.cache.recordCells(s),{cell:s,header:a}}async getCellLive(e,t,n){let r=await this.getCellLiveNoCache(e,t,n);return t&&r&&await this.cache.recordCells(r),r}async findCellsPaged(e,t,n,r){let i=await this.findCellsPagedNoCache(e,t,n,r);return e.withData!==!1&&await this.cache.recordCells(i.cells),i}async*findCellsOnChain(e,t,n=10){let r;for(;;){let{cells:i,lastCursor:a}=await this.findCellsPaged(e,t,n,r);for(let e of i)yield e;if(i.length===0||i.length<n)return;r=a}}async*findCells(e,n,r=10){let i=t.ot.from(e),a=[];for await(let e of this.cache.findCells(i))a.push(e.outPoint),yield e;for await(let e of this.findCellsOnChain(i,n,r))await this.cache.isUnusable(e.outPoint)||a.some(t=>t.eq(e.outPoint))||(yield e)}findCellsByLock(e,t,n=!0,r,i=10){return this.findCells({script:e,scriptType:`lock`,scriptSearchMode:`exact`,filter:{script:t},withData:n},r,i)}findCellsByType(e,t=!0,n,r=10){return this.findCells({script:e,scriptType:`type`,scriptSearchMode:`exact`,withData:t},n,r)}async findSingletonCellByType(e,t=!0){for await(let n of this.findCellsByType(e,t,void 0,1))return n}async getCellDeps(...e){return Promise.all(e.flat().map(async e=>{let{cellDep:n,type:r}=t.nt.from(e);if(r===void 0)return n;let i=await this.findSingletonCellByType(r);return i?t.x.from({outPoint:i.outPoint,depType:n.depType}):n}))}async*findTransactions(e,t,n=10){let r;for(;;){let{transactions:i,lastCursor:a}=await this.findTransactionsPaged(e,t,n,r);for(let e of i)yield e;if(i.length===0||i.length<n)return;r=a}}findTransactionsByLock(e,t,n,r,i=10){return this.findTransactions({script:e,scriptType:`lock`,scriptSearchMode:`exact`,filter:{script:t},groupByTransaction:n},r,i)}findTransactionsByType(e,t,n,r=10){return this.findTransactions({script:e,scriptType:`type`,scriptSearchMode:`exact`,groupByTransaction:t},n,r)}async getBalanceSingle(e){return this.getCellsCapacity({script:e,scriptType:`lock`,scriptSearchMode:`exact`,filter:{scriptLenRange:[0,1],outputDataLenRange:[0,1]}})}async getBalance(e){return t.kt(e,async(e,t)=>e+await this.getBalanceSingle(t),t.pr)}async sendTransaction(e,n,r){let i=t.j.from(e),a=t.ir(r?.maxFeeRate??t.vt),o=await i.getFeeRate(this);if(a>0n&&o>a)throw new t.ft(a,o);let s=await this.sendTransactionNoCache(i,n);return await this.cache.markTransactions(i),s}async getTransaction(e){let n=t.Er(e),r=await this.getTransactionNoCache(n);return r?(await this.cache.recordTransactionResponses(r),r):this.cache.getTransactionResponse(n)}async getTransactionWithHeader(e){let n=t.Er(e),r=await this.cache.getTransactionResponse(n);if(r?.blockHash){let e=await this.getHeaderByHash(r.blockHash);if(e&&this.cache.hasHeaderConfirmed(e))return{transaction:r,header:e}}let i=await this.getTransactionNoCache(n);if(i)return await this.cache.recordTransactionResponses(i),{transaction:i,header:i.blockHash?await this.getHeaderByHash(i.blockHash):void 0}}async waitTransaction(e,n=0,r=6e4,i=2e3){let a=Date.now(),o,s=async()=>{let t=await this.getTransaction(e);if(t&&t.blockNumber!=null&&![`sent`,`pending`,`proposed`].includes(t.status))return o=t,t};for(;;){if(!o){if(await s())continue}else if(n===0)return o;else if((await this.getTipHeader()).number-o.blockNumber>=n)return o;if(Date.now()-a+i>=r)throw new t.gt(r);await t.jt(i)}}},ie=class{constructor(e){this.transports=e,this.i=0}async request(e,t){let n=this.i,r=Error(`JsonRpcTransportFallback requires at least one transport`);for(let i=0;i<this.transports.length;i+=1){let a=(n+i)%this.transports.length;try{let n=await this.transports[a].request(e,t);return this.i=a,n}catch(e){r=e}}throw r}},L=class extends Error{constructor(e){super(e.message),this.name=`JsonRpcError`,this.code=e.code,this.data=e.data}};function ae(e,n){let r=Array.from(new Set(e),e=>t.c(e,n));return M.from(r).map(e=>new ie([...e]))}function oe(e,t){return t?t(e):e}var se=class e{constructor(e,t,n){this.url_=e,this.onError=n,this.concurrent=0,this.pending=[],this.id=0,this.maxConcurrent=t?.maxConcurrent,this.transport=t?.transport?t.transport:ae([e,...t?.fallbacks??[]],t).value}static new({transport:t,maxConcurrent:n,onError:r}){return new e(``,{transport:t,maxConcurrent:n},r)}static open({urls:[t,...n],onError:r,...i}){return ae([t,...n],i).map(t=>e.new({transport:t,...i,onError:r}))}get url(){return this.url_}async request(e,t,n,r,i){let a=this.buildPayload(e,n?await Promise.all(t.concat(Array.from(Array(Math.max(n.length-t.length,0)))).map((e,t)=>oe(e,n[t]))):t);try{return await oe(await this.requestPayload(a,i),r)}catch(e){if(!this.onError)throw e;await this.onError(e)}}async requestPayload(e,n){if(this.maxConcurrent!==void 0&&this.concurrent>=this.maxConcurrent){n?.signal?.throwIfAborted();let e,r=new Promise(t=>{e=t,this.pending.push(t)});try{await(n?.signal?Promise.race([r,t.Rt(n.signal)]):r)}catch(t){let n=e?this.pending.indexOf(e):-1;throw n===-1?this.pending.shift()?.():this.pending.splice(n,1),t}}let r=await(async()=>{this.concurrent+=1;try{return await this.transport.request(e,n)}finally{--this.concurrent,this.pending.shift()?.()}})();if(r.id!==e.id)throw Error(`Id mismatched, got ${r.id}, expected ${e.id}`);if(r.error!=null)throw new L(r.error);return r.result}buildPayload(e,t){return{id:this.id++,method:e,params:t,jsonrpc:`2.0`}}};const ce=[[`Resolve\\(Unknown\\(OutPoint\\((0x.*)\\)\\)\\)`,(e,n)=>new t.mt(e,t.O.fromBytes(n[1]))],[`Verification\\(Error { kind: Script, inner: TransactionScriptError { source: (Inputs|Outputs)\\[([0-9]*)\\].(Lock|Type), cause: ValidationFailure: see error code (-?[0-9]+) on page https://nervosnetwork\\.github\\.io/ckb-script-error-codes/by-(type|data)-hash/(.*)\\.html`,(e,n)=>new t.ht(e,n[3]===`Lock`?`lock`:n[1]===`Inputs`?`inputType`:`outputType`,n[2],Number(n[4]),n[5]===`data`?`data`:`type`,n[6])],[`Duplicated\\(Byte32\\((0x.*)\\)\\)`,(e,n)=>new t.dt(e,n[1])],[`RBFRejected\\("Tx's current fee is ([0-9]*), expect it to >= ([0-9]*) to replace old txs"\\)`,(e,n)=>new t.pt(e,n[1],n[2])]];function le(e){if(typeof e!=`object`||!e||!(`data`in e)||typeof e.data!=`string`)throw e;let n=e;for(let[e,t]of ce){let r=n.data.match(e);if(r)throw t(n,r)}throw new t.ut(n)}var ue=class extends re{constructor(e,n){super(n),this.url_=e,this.getFeeRateStatistics=this.buildSender(`get_fee_rate_statistics`,[e=>t.Et(t.dr,e)],e=>({mean:t.ir(e?.mean??t.yt),median:t.ir(e?.median??t.yt)})),this.getTip=this.buildSender(`get_tip_block_number`,[],t.ir),this.getTipHeader=this.buildSender(`get_tip_header`,[],e=>t.Et(t.s.blockHeaderTo,e)),this.getBlockByNumberNoCache=this.buildSender(`get_block_by_number`,[e=>t.dr(t.ir(e))],e=>t.Et(t.s.blockTo,e)),this.getBlockByHashNoCache=this.buildSender(`get_block`,[t.Er],e=>t.Et(t.s.blockTo,e)),this.getHeaderByNumberNoCache=this.buildSender(`get_header_by_number`,[e=>t.dr(t.ir(e))],e=>t.Et(t.s.blockHeaderTo,e)),this.getHeaderByHashNoCache=this.buildSender(`get_header`,[t.Er],e=>t.Et(t.s.blockHeaderTo,e)),this.estimateCycles=this.buildSender(`estimate_cycles`,[t.s.transactionFrom],({cycles:e})=>t.ir(e)),this.sendTransactionDry=this.buildSender(`test_tx_pool_accept`,[t.s.transactionFrom],({cycles:e})=>t.ir(e)),this.sendTransactionNoCache=this.buildSender(`send_transaction`,[t.s.transactionFrom,e=>e??void 0],t.Er),this.getTransactionNoCache=this.buildSender(`get_transaction`,[t.Er],t.s.transactionResponseTo),this.findCellsPagedNoCache=this.buildSender(`get_cells`,[t.s.indexerSearchKeyFrom,e=>e??`asc`,e=>t.dr(e??10)],t.s.findCellsResponseTo),this.findTransactionsPaged=this.buildSender(`get_transactions`,[t.s.indexerSearchKeyTransactionFrom,e=>e??`asc`,e=>t.dr(e??10)],t.s.findTransactionsResponseTo),this.getCellsCapacity=this.buildSender(`get_cells_capacity`,[t.s.indexerSearchKeyFrom],({capacity:e})=>t.ir(e));let r=n?.requestor;this.requestor=r||(n?.transport?se.new({transport:n.transport,maxConcurrent:n.maxConcurrent,onError:le}):se.open({urls:[e,...n?.fallbacks??[]],timeout:n?.timeout,maxConcurrent:n?.maxConcurrent,onError:le}).value)}static newRequestor(e){return se.new({...e,onError:le})}static openRequestor(e){return se.open({...e,onError:le})}get url(){return this.url_}getCellLiveNoCache(e,n,r){return this.buildSender(`get_live_cell`,[t.s.outPointFrom],({cell:n})=>t.Et(({output:n,data:r})=>t.y.from({cellOutput:t.s.cellOutputTo(n),outputData:r?.content??`0x`,outPoint:e}),n))(e,n??!0,r)}buildSender(e,t,n){return async(...r)=>this.requestor.request(e,r,t,n)}},de=class e extends ue{static defaultUrls(){return r.default===void 0?[`https://mainnet.ckb.dev/`,`https://mainnet.ckbapp.dev/`]:[`wss://mainnet.ckb.dev/ws`,`https://mainnet.ckb.dev/`,`https://mainnet.ckbapp.dev/`]}static resolveConfig(e){let n=this.defaultUrls();return{...e,url:e?.url??n[0],fallbacks:e?.fallbacks??[...n],scripts:e?.scripts??t.d}}constructor(t){let n=e.resolveConfig(t);super(n.url,n)}static new(t){let{cache:n,scripts:r,...i}=t,a=this.newRequestor(i);return new e({cache:n,scripts:r,requestor:a})}static open(t){let{cache:n,scripts:r,urls:i=this.defaultUrls(),...a}=t??{};return this.openRequestor({...a,urls:i}).map(t=>new e({cache:n,scripts:r,requestor:t,url:i[0],fallbacks:[...i.slice(1)]}))}get addressPrefix(){return`ckb`}},fe=class e extends ue{static defaultUrls(){return r.default===void 0?[`https://testnet.ckb.dev/`,`https://testnet.ckbapp.dev/`]:[`wss://testnet.ckb.dev/ws`,`https://testnet.ckb.dev/`,`https://testnet.ckbapp.dev/`]}static resolveConfig(e){let n=this.defaultUrls();return{...e,url:e?.url??n[0],fallbacks:e?.fallbacks??[...n],scripts:e?.scripts??t.o}}constructor(t){let n=e.resolveConfig(t);super(n.url,n)}static new(t){let{cache:n,scripts:r,...i}=t,a=this.newRequestor(i);return new e({cache:n,scripts:r,requestor:a})}static open(t){let{cache:n,scripts:r,urls:i=this.defaultUrls(),...a}=t??{};return this.openRequestor({...a,urls:i}).map(t=>new e({cache:n,scripts:r,requestor:t,url:i[0],fallbacks:[...i.slice(1)]}))}get addressPrefix(){return`ckt`}},R=class e{constructor(e,t){this.script=e,this.prefix=t}static from(n){return n instanceof e?n:new e(t.K.from(n.script),n.prefix)}static async fromString(n,r){let{prefix:i,format:a,payload:o}=t.a(n),s=r[i]??r;if(!s)throw Error(`Unknown address prefix ${i}`);let c=s.addressPrefix;if(c!==i)throw Error(`Unknown address prefix ${i}, expected ${c}`);return e.from(await t.i(i,a,o,s))}static fromScript(t,n){return e.from({script:t,prefix:n.addressPrefix})}static async fromKnownScript(n,r,i){return e.from({script:await t.K.fromKnownScript(n,r,i),prefix:n.addressPrefix})}toString(){let e=t.$r([0],t.ni(this.script.codeHash),t.Z(this.script.hashType),t.ni(this.script.args));return n.bech32m.encode(this.prefix,n.bech32m.toWords(e),t.n)}};
|
|
2
|
+
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
|
3
|
+
function pe(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}const me=e=>e?`"${e}" `:``;function he(e,t=``){if(typeof e!=`number`)throw TypeError(me(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(me(t)+`expected integer >= 0, got `+e);return e}function z(e,t,n=``){if(pe(e)&&(t===void 0||e.length===t))return e;t!==void 0&&he(t,`length`);let r=pe(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=me(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}function ge(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function _e(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ve(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const ye=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function be(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const B=ye?e=>e:e=>be(e)>>>0;function xe(e){for(let t=0;t<e.length;t++)e[t]=be(e[t]);return e}const Se=ye?e=>e:xe;function Ce(e,t){return!e.byteLength||!t.byteLength?!1:e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function we(e,t){if(Ce(e,t)&&e.byteOffset<t.byteOffset)throw Error(`complex overlap of input and output is not supported`)}const Te=(e,t)=>{function n(n,...r){if(z(n,void 0,`key`),e.nonceLength!==void 0){let t=r[0];z(t,e.varSizeNonce?void 0:e.nonceLength,`nonce`)}let i=e.tagLength,a=e.nonceLength===void 0?0:1;if(!e.withAAD){for(let e=a;e<r.length;e++)if(pe(r[e]))throw Error(`AAD not supported`)}e.withAAD&&r[a]!==void 0&&z(r[a],void 0,`AAD`);let o=t(n,...r),s=(e,t)=>{if(t!==void 0){if(e!==2)throw Error(`cipher output not supported`);z(t,void 0,`output`)}},c=!1;return{encrypt(e,t){if(c)throw Error(`cannot encrypt() twice with same key + nonce`);return c=!0,z(e,void 0,`data`),s(o.encrypt.length,t),o.encrypt(e,t)},decrypt(e,t){if(z(e,void 0,`data`),i&&e.length<i)throw Error(`"ciphertext" expected length >= tagLength=`+i);return s(o.decrypt.length,t),o.decrypt(e,t)}}}return Object.assign(n,e),n};function Ee(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(z(t,e,`output`),n&&!De(t))throw Error(`invalid output, must be aligned`);return t}function De(e){return e.byteOffset%4==0}function Oe(e){return Uint8Array.from(z(e))}function ke(e){if(![16,24,32].includes(e.length))throw Error(`"aes key" expected Uint8Array of length 16/24/32, got length=`+e.length)}function Ae(e){return e<<1^283&-(e>>7)}function je(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=Ae(e);return n}const Me=(()=>{let e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=Ae(n))e[t]=n;let t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return ve(e),t})(),Ne=e=>e<<24|e>>>8,Pe=e=>e<<8|e>>>24;function Fe(e,t){if(e.length!==256)throw Error(`wrong sbox length`);let n=new Uint32Array(256).map((n,r)=>t(e[r])),r=n.map(Pe),i=r.map(Pe),a=i.map(Pe),o=new Uint32Array(65536),s=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){let u=t*256+l;o[u]=n[t]^r[l],s[u]=i[t]^a[l],c[u]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:a,T01:o,T23:s}}const Ie=Fe(Me,e=>je(e,3)<<24|e<<16|e<<8|je(e,2)),Le=(()=>{let e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Ae(n))e[t]=n;return e})();function Re(e){z(e);let t=e.length;ke(e);let{sbox2:n}=Ie,r=[];(!ye||!De(e))&&r.push(e=Oe(e));let i=Se(_e(e)),a=i.length,o=e=>Be(n,e,e,e,e),s=new Uint32Array(t+28);s.set(i);for(let e=a;e<s.length;e++){let t=s[e-1];e%a===0?t=o(Ne(t))^Le[e/a-1]:a>6&&e%a===4&&(t=o(t)),s[e]=s[e-a]^t}return ve(...r),s}function ze(e,t,n,r,i,a){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|a>>>24&255]}function Be(e,t,n,r,i){return e[t&255|n&65280]|e[r>>>16&255|i>>>16&65280]<<16}function Ve(e,t,n,r,i){let{sbox2:a,T01:o,T23:s}=Ie,c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];let l=e.length/4-2;for(let a=0;a<l;a++){let a=e[c++]^ze(o,s,t,n,r,i),l=e[c++]^ze(o,s,n,r,i,t),u=e[c++]^ze(o,s,r,i,t,n),d=e[c++]^ze(o,s,i,t,n,r);t=a,n=l,r=u,i=d}return{s0:e[c++]^Be(a,t,n,r,i),s1:e[c++]^Be(a,n,r,i,t),s2:e[c++]^Be(a,r,i,t,n),s3:e[c++]^Be(a,i,t,n,r)}}function He(e,t,n,r){z(t,16,`nonce`),z(n);let i=n.length;r=Ee(i,r),we(n,r);let a=t,o=_e(a),s=_e(n),c=_e(r);for(let t=0;t+4<=s.length;t+=4){let{s0:n,s1:r,s2:i,s3:l}=Ve(e,B(o[0]),B(o[1]),B(o[2]),B(o[3]));c[t+0]=s[t+0]^B(n),c[t+1]=s[t+1]^B(r),c[t+2]=s[t+2]^B(i),c[t+3]=s[t+3]^B(l);for(let e=15,t=1;e>=0;e--)t=t+a[e]|0,a[e]=t&255,t>>>=8}let l=16*Math.floor(s.length/4);if(l<i){let{s0:t,s1:a,s2:s,s3:c}=Ve(e,B(o[0]),B(o[1]),B(o[2]),B(o[3])),u=new Uint32Array([t,a,s,c]);Se(u);let d=ge(u);for(let e=l,t=0;e<i;e++,t++)r[e]=n[e]^d[t];ve(u)}return r}const Ue=Te({blockSize:16,nonceLength:16},function(e,t){function n(n,r){if(z(n),r!==void 0&&(z(r),!De(r)))throw Error(`unaligned destination`);let i=Re(e),a=Oe(t),o=[i,a];De(n)||o.push(n=Oe(n));let s=He(i,a,n,r);return ve(...o),s}return{encrypt:(e,t)=>n(e,t),decrypt:(e,t)=>n(e,t)}});var We=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,n){if(t.Mr(e),t.Ar(n,void 0,`key`),this.iHash=e.create(),typeof this.iHash.update!=`function`)throw Error(`expected Hash instance`);this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),t.Rr(i)}update(e){return t.jr(this),this.iHash.update(e),this}digestInto(e){t.jr(this),t.Pr(e,this),this.finished=!0;let n=e.subarray(0,this.outputLen);this.iHash.digestInto(n),this.oHash.update(n),this.oHash.digestInto(n),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:t,iHash:n,finished:r,destroyed:i,blockLen:a,outputLen:o,canXOF:s}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=a,e.outputLen=o,e.canXOF=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Ge=(()=>{let e=((e,t,n)=>new We(e,t).update(n).digest());return e.create=(e,t)=>new We(e,t),e})();function Ke(e,n,r,i){t.Mr(e);let{c:a,dkLen:o,asyncTick:s}=t.Lr({dkLen:32,asyncTick:10},i);if(t.Nr(a,`c`),t.Nr(o,`dkLen`),t.Nr(s,`asyncTick`),a<1)throw Error(`"c" (iterations) must be >= 1`);if(o<1)throw Error(`"dkLen" must be >= 1`);if(o>(2**32-1)*e.outputLen)throw Error(`derived key too long`);let c=t.Wr(n,`password`);try{let n=t.Wr(r,`salt`);try{let t=new Uint8Array(o),{iHash:r,oHash:i,outputLen:l}=Ge.create(e,c);return{c:a,dkLen:o,asyncTick:s,DK:t,outputLen:l,eng:qe(r,i,n,new Uint8Array(l))}}finally{typeof r==`string`&&t.Rr(n)}}finally{typeof n==`string`&&t.Rr(c)}}function qe(e,n,r,i){let a=new Uint8Array(4),o=t.Vr(a),s=e._cloneInto().update(r),c=n._cloneInto(),l=e._cloneInto,u=n._cloneInto;return{u1:(e,t)=>{o.setInt32(0,e,!1),s._cloneInto(c).update(a).digestInto(i),n._cloneInto(c).update(i).digestInto(i),t.set(i.subarray(0,t.length))},rounds:(t,r)=>{for(let a=1;a<t;a++){l.call(e,c).update(i).digestInto(i),u.call(n,c).update(i).digestInto(i);for(let e=0;e<r.length;e++)r[e]^=i[e]}},output:r=>(e.destroy(),n.destroy(),s.destroy(),c.destroy(),t.Rr(i),r)}}function Je(e,t,n,r){let{c:i,dkLen:a,DK:o,outputLen:s,eng:c}=Ke(e,t,n,r);for(let e=1,t=0;t<a;e++,t+=s){let n=o.subarray(t,t+s);c.u1(e,n),c.rounds(i,n)}return c.output(o)}const Ye=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]),Xe=new Uint32Array(64);var Ze=class extends c{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,n){for(let t=0;t<16;t++,n+=4)Xe[t]=e.getUint32(n,!1);for(let e=16;e<64;e++){let n=Xe[e-15],r=Xe[e-2],i=t.Jr(n,7)^t.Jr(n,18)^n>>>3,a=t.Jr(r,17)^t.Jr(r,19)^r>>>10;Xe[e]=a+Xe[e-7]+i+Xe[e-16]|0}let{A:r,B:i,C:a,D:c,E:l,F:u,G:d,H:f}=this;for(let e=0;e<64;e++){let n=t.Jr(l,6)^t.Jr(l,11)^t.Jr(l,25),p=f+n+o(l,u,d)+Ye[e]+Xe[e]|0,m=(t.Jr(r,2)^t.Jr(r,13)^t.Jr(r,22))+s(r,i,a)|0;f=d,d=u,u=l,l=c+p|0,c=a,a=i,i=r,r=p+m|0}r=r+this.A|0,i=i+this.B|0,a=a+this.C|0,c=c+this.D|0,l=l+this.E|0,u=u+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(r,i,a,c,l,u,d,f)}roundClean(){t.Rr(Xe)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),t.Rr(this.buffer)}},Qe=class extends Ze{constructor(){super(32,l)}};const V=t.Br(()=>new Qe,t.Gr(1));function $e(e,n,r,i,a,o){let s=e[n++]^r[i++],c=e[n++]^r[i++],l=e[n++]^r[i++],u=e[n++]^r[i++],d=e[n++]^r[i++],f=e[n++]^r[i++],p=e[n++]^r[i++],m=e[n++]^r[i++],h=e[n++]^r[i++],g=e[n++]^r[i++],_=e[n++]^r[i++],v=e[n++]^r[i++],y=e[n++]^r[i++],ee=e[n++]^r[i++],te=e[n++]^r[i++],b=e[n++]^r[i++],x=s,S=c,C=l,w=u,T=d,E=f,D=p,O=m,k=h,A=g,j=_,M=v,N=y,P=ee,F=te,I=b;for(let e=0;e<8;e+=2)T^=t.qr(x+N|0,7),k^=t.qr(T+x|0,9),N^=t.qr(k+T|0,13),x^=t.qr(N+k|0,18),A^=t.qr(E+S|0,7),P^=t.qr(A+E|0,9),S^=t.qr(P+A|0,13),E^=t.qr(S+P|0,18),F^=t.qr(j+D|0,7),C^=t.qr(F+j|0,9),D^=t.qr(C+F|0,13),j^=t.qr(D+C|0,18),w^=t.qr(I+M|0,7),O^=t.qr(w+I|0,9),M^=t.qr(O+w|0,13),I^=t.qr(M+O|0,18),S^=t.qr(x+w|0,7),C^=t.qr(S+x|0,9),w^=t.qr(C+S|0,13),x^=t.qr(w+C|0,18),D^=t.qr(E+T|0,7),O^=t.qr(D+E|0,9),T^=t.qr(O+D|0,13),E^=t.qr(T+O|0,18),M^=t.qr(j+A|0,7),k^=t.qr(M+j|0,9),A^=t.qr(k+M|0,13),j^=t.qr(A+k|0,18),N^=t.qr(I+F|0,7),P^=t.qr(N+I|0,9),F^=t.qr(P+N|0,13),I^=t.qr(F+P|0,18);a[o++]=s+x|0,a[o++]=c+S|0,a[o++]=l+C|0,a[o++]=u+w|0,a[o++]=d+T|0,a[o++]=f+E|0,a[o++]=p+D|0,a[o++]=m+O|0,a[o++]=h+k|0,a[o++]=g+A|0,a[o++]=_+j|0,a[o++]=v+M|0,a[o++]=y+N|0,a[o++]=ee+P|0,a[o++]=te+F|0,a[o++]=b+I|0}function et(e,t,n,r,i){let a=r+0,o=r+16*i;for(let r=0;r<16;r++)n[o+r]=e[t+(2*i-1)*16+r];for(let r=0;r<i;r++,a+=16,t+=16)$e(n,o,e,t,n,a),r>0&&(o+=16),$e(n,a,e,t+=16,n,o)}const tt=1024*(2**20+1+1);function nt(e,n,r){let{N:i,r:a,p:o,dkLen:s,asyncTick:c,maxmem:l,onProgress:u}=t.Lr({dkLen:32,asyncTick:10,maxmem:tt},r);if(t.Nr(i,`N`),t.Nr(a,`r`),t.Nr(o,`p`),t.Nr(s,`dkLen`),t.Nr(c,`asyncTick`),t.Nr(l,`maxmem`),u!==void 0&&typeof u!=`function`)throw Error(`"onProgress" must be a function`);if(a<1)throw Error(`"r" expected integer >= 1`);let d=128*a,f=d/4,p=2**32;if(i<=1||i&i-1||i>p)throw Error(`"N" expected a power of 2, and 2^1 <= N <= 2^32`);if(o<1||o>(p-1)*32/d)throw Error(`"p" expected integer 1..((2^32 - 1) * 32) / (128 * r)`);if(s<1||s>(p-1)*32)throw Error(`"dkLen" expected integer 1..(2^32 - 1) * 32`);let m=d*(i+o+1);if(m>l)throw Error(`"maxmem" limit was hit: memUsed(128*r*(N+p+1))=`+m+`, maxmem=`+l);let h=Je(V,e,n,{c:1,dkLen:d*o}),g=t.Xr(h),_=t.Xr(new Uint8Array(d*i)),v=t.Xr(new Uint8Array(d)),y=()=>{};if(u){let e=2*i*o,n=Math.max(Math.floor(e/1e4),1),r=0;y=()=>{if(r++,u&&(!(r%n)||r===e))try{u(r/e)}catch(e){throw t.Rr(h,_,v),e}}}return{N:i,r:a,p:o,dkLen:s,blockSize32:f,V:_,B32:g,B:h,tmp:v,blockMixCb:y,asyncTick:c}}function rt(e,n,r,i,a){let o=Je(V,e,r,{c:1,dkLen:n});return t.Rr(r,i,a),o}async function it(e,n,r){let{N:i,r:a,p:o,dkLen:s,blockSize32:c,V:l,B32:u,B:d,tmp:f,blockMixCb:p,asyncTick:m}=nt(e,n,r),h=()=>t.Rr(d,l,f);t.Yr(u);for(let e=0;e<o;e++){let n=c*e;for(let e=0;e<c;e++)l[e]=u[n+e];let r=0;await t.Fr(i-1,m,()=>{et(l,r,l,r+=c,a),p()},h),et(l,(i-1)*c,u,n,a),p(),await t.Fr(i,m,()=>{let e=(u[n+c-16]&i-1)>>>0;for(let t=0;t<c;t++)f[t]=u[n+t]^l[e*c+t];et(f,0,u,n,a),p()},h)}return t.Yr(u),rt(e,s,d,l,f)}function at(e,n){return t.Er(k(t.$r(e.subarray(16,32),n))).slice(2)}async function ot(e,n,r){let i=t.Kr(32),a=t.Kr(16),o={dklen:32,salt:t.Er(i).slice(2),n:262144,r:8,p:1},s=await it(t.ni(r,`utf8`),i,{N:o.n,r:o.r,p:o.p,dkLen:o.dklen}),c=Ue(s.subarray(0,16),a.map(e=>e)).encrypt(t.$r(t.ni(e),t.ni(n)));return{id:t.Er(t.Kr(16)).slice(2),crypto:{ciphertext:t.Er(c).slice(2),cipherparams:{iv:t.Er(a).slice(2)},cipher:`aes-128-ctr`,kdf:`scrypt`,kdfparams:o,mac:at(s,c)}}}async function st(e,n){if(typeof e!=`object`||!e||!(`crypto`in e))throw Error(`Invalid keystore`);let r=e.crypto;if(typeof r!=`object`||!r||!(`kdfparams`in r)||!(`ciphertext`in r)||typeof r.ciphertext!=`string`||!(`mac`in r)||typeof r.mac!=`string`||!(`cipherparams`in r)||typeof r.cipherparams!=`object`||r.cipherparams===null||!(`iv`in r.cipherparams)||typeof r.cipherparams.iv!=`string`)throw Error(`Invalid crypto`);let i=r.kdfparams;if(typeof i!=`object`||!i||!(`n`in i)||typeof i.n!=`number`||!(`r`in i)||typeof i.r!=`number`||!(`p`in i)||typeof i.p!=`number`||!(`dklen`in i)||typeof i.dklen!=`number`||!(`salt`in i)||typeof i.salt!=`string`)throw Error(`Invalid kdfparams`);let a=await it(t.ni(n,`utf8`),t.ni(i.salt),{N:i.n,r:i.r,p:i.p,dkLen:i.dklen}),o=t.ni(r.ciphertext);if(at(a,o)!==r.mac)throw Error(`Invalid password`);let s=Ue(a.subarray(0,16),t.ni(r.cipherparams.iv)).decrypt(o);return{privateKey:s.slice(0,32),chainCode:s.slice(32)}}var ct=class e{constructor(e,t){this.autoFinalized=e,this.inputsToSign=t}static from(t){return t instanceof e?t:new e(t?.autoFinalized??!0,t?.inputsToSign?.map(e=>lt.from(e))??[])}},lt=class e{constructor(e,t,n,r,i){this.index=e,this.sighashTypes=t,this.disableTweakSigner=n,this.address=r,this.publicKey=i}static from(n){return n instanceof e?n:new e(n.index,n.sighashTypes,n.disableTweakSigner,n.address,n.publicKey?t.Er(n.publicKey):void 0)}};
|
|
4
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
|
+
function ut(e,t,n=()=>{}){if(!Array.isArray(e))throw TypeError(`"${t}" expected array, got type=${typeof e}`);for(let r=0;r<e.length;r++)n(e[r],`${t}[${r}]`);return e}const H=(e,n,r)=>t.Ar(e,n,r),dt=t.Nr;function ft(e,t=``){if(typeof e!=`string`){let n=t&&`"${t}" `;throw TypeError(n+`expected string, got type=`+typeof e)}return e}function pt(e,t=`object`){if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(t===`object`?`expected valid options object`:`"${t}" expected object, got type=${typeof e}`);return e}function mt(e,t){if(typeof e!=`function`)throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);return e}const ht=t.Ir,U=(...e)=>t.zr(...e),gt=e=>t.Hr(e),_t=t.Ur,vt=e=>t.Kr(e),yt=BigInt(0),bt=BigInt(1),xt=e=>e?`"${e}" `:``;function St(e,t=``){if(typeof e!=`boolean`)throw TypeError(xt(t)+`expected boolean, got type=`+typeof e);return e}function Ct(e){if(typeof e==`bigint`){if(!Nt(e))throw RangeError(`positive bigint expected, got `+e)}else dt(e);return e}function wt(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(n+`expected number, got type=`+typeof e)}if(!Number.isSafeInteger(e)){let n=t&&`"${t}" `;throw RangeError(n+`expected safe integer, got `+e)}}function Tt(e){let t=Ct(e).toString(16);return t.length&1?`0`+t:t}function Et(e){if(typeof e!=`string`)throw TypeError(`hex string expected, got `+typeof e);return e===``?yt:BigInt(`0x`+e)}function Dt(e){return Et(t.Ir(e))}function Ot(e){return Et(t.Ir(jt(t.Ar(e)).reverse()))}function kt(e,n){if(t.Nr(n),n===0)throw Error(`zero output length is invalid`);e=Ct(e);let r=n*2,i=e.toString(16);if(i.length>r)throw RangeError(`number is too large`);return t.Hr(i.padStart(r,`0`))}function At(e,t){return kt(e,t).reverse()}function jt(e){return Uint8Array.from(H(e))}function Mt(e){if(typeof e!=`string`)throw TypeError(`ascii string expected, got `+typeof e);return Uint8Array.from(e,(t,n)=>{let r=t.charCodeAt(0);if(t.length!==1||r>127)throw RangeError(`string contains non-ASCII character "${e[n]}" with code ${r} at position ${n}`);return r})}function Nt(e){return typeof e==`bigint`&&yt<=e}function Pt(e,t,n){return Nt(e)&&Nt(t)&&Nt(n)&&t<=e&&e<n}function Ft(e,t,n,r){if(!Pt(t,n,r))throw RangeError(`expected valid `+e+`: `+n+` <= n < `+r+`, got `+t)}function It(e){if(e<yt)throw Error(`expected non-negative bigint, got `+e);return e===yt?0:e.toString(2).length}const Lt=e=>(wt(e,`n`),(bt<<BigInt(e))-bt);function Rt(e,n,r){if(t.Nr(e,`hashLen`),t.Nr(n,`qByteLen`),typeof r!=`function`)throw TypeError(`hmacFn must be a function`);let i=e=>new Uint8Array(e),a=Uint8Array.of(),o=Uint8Array.of(0),s=Uint8Array.of(1),c=i(e),l=i(e),u=0,d=()=>{c.fill(1),l.fill(0),u=0},f=(...e)=>r(l,U(c,...e)),p=(e=a)=>{l=f(o,e),c=f(),e.length!==0&&(l=f(s,e),c=f())},m=()=>{if(u++>=1e3)throw Error(`drbg: tried max amount of iterations`);let e=0,t=[];for(;e<n;){c=f();let n=c.slice();t.push(n),e+=c.length}return U(...t)};return(e,t)=>{d(),p(e);let n;for(;(n=t(m()))===void 0;)p();return d(),n}}function zt(e,t={},n={},r=`object`){pt(e,r),pt(t,`fields`),pt(n,`optFields`);function i(t,n,i){let a=r===`object`?`param "${String(t)}"`:`"${r}.${String(t)}"`,o=e[t];if(!Object.hasOwn(e,t)&&(i?o!==void 0:n!==`function`))throw TypeError(`${a} is invalid: expected own property`);if(i&&o===void 0)return;let s=typeof o;if(s!==n||o===null)throw TypeError(`${a} is invalid: expected ${n}, got ${s}`)}let a=(e,t)=>Object.entries(e).forEach(([e,n])=>i(e,n,t));a(t,!1),a(n,!0)}
|
|
6
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
7
|
+
const W=BigInt(0),G=BigInt(1),Bt=BigInt(2),Vt=BigInt(3),Ht=BigInt(4),Ut=BigInt(5),Wt=BigInt(7),Gt=BigInt(8),Kt=BigInt(9),qt=BigInt(15),Jt=BigInt(16),Yt=BigInt(`0x10000000000000000`);function K(e,t){if(t<=W)throw Error(`mod: expected positive modulus, got `+t);let n=e%t;return n>=W?n:t+n}function Xt(e,t,n){if(n<=G)throw Error(`pow: expected modulus > 1, got `+n);if(typeof t!=`bigint`)throw TypeError(`invalid exponent: expected bigint, got `+typeof t);if(t<W)throw Error(`invalid exponent, negatives unsupported`);if(t===W)return G;if(t===G)return e;let r=e%n;if(r<W&&(r+=n),t<Yt){let e=G;for(;t>W;)t&G&&(e=e*r%n),r=r*r%n,t>>=G;return e}let i=[];for(;t>W;)i.push(Number(t&qt)),t>>=Ht;let a=Array(16);a[0]=G,a[1]=r;for(let e=2;e<16;e++)a[e]=a[e-1]*r%n;let o=a[i[i.length-1]];for(let e=i.length-2;e>=0;e--){o=o*o%n,o=o*o%n,o=o*o%n,o=o*o%n;let t=i[e];t!==0&&(o=o*a[t]%n)}return o}function q(e,t,n){if(n<=G)throw Error(`pow2: expected modulus > 1, got `+n);if(t<W)throw Error(`pow2: expected non-negative exponent, got `+t);let r=e;for(;t-->W;)r*=r,r%=n;return r}function Zt(e,t){if(e===W)throw Error(`invert: expected non-zero number`);if(t<=G)throw Error(`invert: expected modulus > 1, got `+t);let n=K(e,t),r=t,i=W,a=G;for(;n!==W;){let e=r/n,t=r-n*e,o=i-a*e;r=n,n=t,i=a,a=o}if(r!==G)throw Error(`invert: does not exist`);return K(i,t)}function Qt(e,t){if(t<=G)throw Error(`invertCt: expected prime modulus > 1, got `+t);let n=K(e,t);if(n===W)throw Error(`invertCt: expected non-zero number`);let r=Xt(n,t-Bt,t);if(K(n*r,t)!==G)throw Error(`invertCt: does not exist`);return r}function $t(e,t,n){let r=e;if(!r.eql(r.sqr(t),n))throw Error(`Cannot find square root`)}function en(e,t){if((e&G)===W)throw Error(t+`: expected odd modulus, got `+e)}function tn(e,t){let n=e,r=(n.ORDER+G)/Ht,i=n.pow(t,r);return $t(n,i,t),i}function nn(e,t){let n=e,r=(n.ORDER-Ut)/Gt,i=n.mul(t,Bt),a=n.pow(i,r),o=n.mul(t,a),s=n.mul(n.mul(o,Bt),a),c=n.mul(o,n.sub(s,n.ONE));return $t(n,c,t),c}function rn(e){let t=mn(e),n=an(e),r=n(t,t.neg(t.ONE)),i=n(t,r),a=n(t,t.neg(r)),o=(e+Wt)/Jt;return((e,t)=>{let n=e,s=n.pow(t,o),c=n.mul(s,r),l=n.mul(s,i),u=n.mul(s,a),d=n.eql(n.sqr(c),t),f=n.eql(n.sqr(l),t);s=n.cmov(s,c,d),c=n.cmov(u,l,f);let p=n.eql(n.sqr(c),t),m=n.cmov(s,c,p);return $t(n,m,t),m})}function an(e){if(e<Vt)throw Error(`sqrt is not defined for small field`);en(e,`tonelliShanks`);let t=e-G,n=0;for(;t%Bt===W;)t/=Bt,n++;let r=Bt,i=mn(e);for(;un(i,r)===1;)if(r++>1e3)throw Error(`Cannot find square root: probably non-prime P`);if(n===1)return tn;let a=i.pow(r,t),o=(t+G)/Bt;return function(e,r){let i=e;if(i.is0(r))return r;if(un(i,r)!==1)throw Error(`Cannot find square root`);let s=n,c=i.mul(i.ONE,a),l=i.pow(r,t),u=i.pow(r,o);for(;!i.eql(l,i.ONE);){if(i.is0(l))throw Error(`Cannot find square root: probably non-prime P`);let e=1,t=i.sqr(l);for(;!i.eql(t,i.ONE);)if(e++,t=i.sqr(t),e===s)throw Error(`Cannot find square root`);let n=G<<BigInt(s-e-1),r=i.pow(c,n);s=e,c=i.sqr(r),l=i.mul(l,c),u=i.mul(u,r)}return u}}function on(e){return en(e,`Fp.sqrt`),e%Ht===Vt?tn:e%Gt===Ut?nn:e%Jt===Kt?rn(e):an(e)}const sn=[`create`,`isValid`,`is0`,`neg`,`inv`,`sqrt`,`sqr`,`eql`,`add`,`sub`,`mul`,`pow`,`div`,`addN`,`subN`,`mulN`,`sqrN`];function cn(e){if(pt(e,`field`),typeof e.ORDER!=`bigint`)throw TypeError(`param "ORDER" is invalid: expected bigint, got `+typeof e.ORDER);wt(e.BYTES,`BYTES`),wt(e.BITS,`BITS`);for(let t of sn)mt(e[t],`field.`+t);if(e.BYTES<1||e.BITS<1)throw Error(`invalid field: expected BYTES/BITS > 0`);if(e.ORDER<=G)throw Error(`invalid field: expected ORDER > 1, got `+e.ORDER);return e}function ln(e,t,n=!1){cn(e),ut(t,`nums`),St(n,`passZero`);let r=e,i=Array(t.length).fill(n?r.ZERO:void 0),a=t.reduce((e,t,n)=>r.is0(t)?e:(i[n]=e,r.mul(e,t)),r.ONE),o=r.inv(a);return t.reduceRight((e,t,n)=>r.is0(t)?e:(i[n]=r.mul(e,i[n]),r.mul(e,t)),o),i}function un(e,t){cn(e);let n=e;en(n.ORDER,`FpLegendre`);let r=(n.ORDER-G)/Bt,i=n.pow(t,r),a=n.eql(i,n.ONE),o=n.eql(i,n.ZERO),s=n.eql(i,n.neg(n.ONE));if(!a&&!o&&!s)throw Error(`invalid Legendre symbol result`);return a?1:o?0:-1}function dn(e,t){if(t!==void 0&&dt(t),e<=W)throw Error(`invalid n length: expected positive n, got `+e);if(t!==void 0&&t<1)throw Error(`invalid n length: expected positive bit length, got `+t);let n=It(e);if(t!==void 0&&t<n)throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);let r=t===void 0?n:t;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}const fn=new WeakMap;var pn=class{ORDER;BITS;BYTES;isLE;ZERO=W;ONE=G;_lengths;_mod;constructor(e,t={}){if(e<=G)throw Error(`invalid field: expected ORDER > 1, got `+e);let n;this.isLE=!1,typeof t==`object`&&t&&(typeof t.BITS==`number`&&(n=t.BITS),typeof t.sqrt==`function`&&Object.defineProperty(this,"sqrt",{value:t.sqrt,enumerable:!0}),typeof t.isLE==`boolean`&&(this.isLE=t.isLE),t.allowedLengths&&(this._lengths=Object.freeze(t.allowedLengths.slice())),typeof t.modFromBytes==`boolean`&&(this._mod=t.modFromBytes));let{nBitLength:r,nByteLength:i}=dn(e,n);if(i>2048)throw Error(`invalid field: expected ORDER of <= 2048 bytes`);this.ORDER=e,this.BITS=r,this.BYTES=i,Object.freeze(this)}create(e){return K(e,this.ORDER)}isValid(e){if(typeof e!=`bigint`)throw TypeError(`invalid field element: expected bigint, got `+typeof e);return W<=e&&e<this.ORDER}is0(e){return e===W}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&G)===G}neg(e){return K(-e,this.ORDER)}eql(e,t){return e===t}sqr(e){return K(e*e,this.ORDER)}add(e,t){return K(e+t,this.ORDER)}sub(e,t){return K(e-t,this.ORDER)}mul(e,t){return K(e*t,this.ORDER)}pow(e,t){return Xt(e,t,this.ORDER)}div(e,t){return K(e*Zt(t,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,t){return e+t}subN(e,t){return e-t}mulN(e,t){return e*t}inv(e){return Zt(e,this.ORDER)}sqrt(e){let t=fn.get(this);return t||fn.set(this,t=on(this.ORDER)),t(this,e)}toBytes(e){return this.isLE?At(e,this.BYTES):kt(e,this.BYTES)}fromBytes(e,t=!1){H(e);let{_lengths:n,BYTES:r,isLE:i,ORDER:a,_mod:o}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>r)throw Error(`Field.fromBytes: expected `+n+` bytes, got `+e.length);let t=new Uint8Array(r);t.set(e,i?0:t.length-e.length),e=t}if(e.length!==r)throw Error(`Field.fromBytes: expected `+r+` bytes, got `+e.length);let s=i?Ot(e):Dt(e);if(o&&(s=K(s,a)),!t&&!this.isValid(s))throw Error(`invalid field element: outside of range 0..ORDER`);return s}invertBatch(e){return ln(this,e,!0)}cmov(e,t,n){return St(n,`condition`),n?t:e}};function mn(e,t={}){return Object.freeze(pn.prototype),new pn(e,t)}function hn(e){if(typeof e!=`bigint`)throw Error(`field order must be bigint`);if(e<=G)throw Error(`field order must be greater than 1`);let t=It(e-G);return Math.ceil(t/8)}function gn(e){let t=hn(e);return t+Math.ceil(t/2)}function _n(e,t,n=!1){H(e);let r=e.length,i=hn(t),a=Math.max(gn(t),16);if(r<a||r>1024)throw Error(`expected `+a+`-1024 bytes of input, got `+r);let o=K(n?Ot(e):Dt(e),t-G)+G;return n?At(o,i):kt(o,i)}
|
|
8
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
9
|
+
const vn=BigInt(0),yn=BigInt(1),bn=BigInt(4),xn=2**31;function Sn(e){let t=e;if(typeof t!=`function`)throw TypeError(`"Point" expected constructor, got type=`+typeof e);mt(t.fromAffine,`Point.fromAffine`),mt(t.fromBytes,`Point.fromBytes`),mt(t.fromHex,`Point.fromHex`),pt(t.BASE,`Point.BASE`),pt(t.ZERO,`Point.ZERO`),cn(t.Fp),cn(t.Fn)}function Cn(e,t){Sn(e),Dn(t,e);let n=ln(e.Fp,t.map(e=>e.Z));return t.map((t,r)=>e.fromAffine(t.toAffine(n[r])))}function wn(e,t,n=1){if(!Number.isSafeInteger(e)||e<n||e>t)throw Error(`invalid window size, expected [`+n+`..`+t+`], got W=`+e)}function Tn(e,t){let n=e*(4*t+128);if(n>xn)throw Error(`invalid window size: table would need ~`+Math.ceil(n/2**20)+` MiB, max `+xn/2**20+` MiB`)}function En(e,t){if(e!==void 0){mt(e,`randomBytes`);try{let n=e(t);if(!_t(n)||n.length!==t)return}catch{return}return e}}function Dn(e,t){ut(e,`points`),e.forEach((e,n)=>{if(!(e instanceof t))throw Error(`invalid point at index `+n)})}function On(e,t,n){if(!Array.isArray(e))throw Error(`array of scalars expected`);e.forEach((e,r)=>{if(!(n===void 0?t.isValid(e):Nt(e)&&e<n))throw Error(`invalid scalar at index `+r)})}const kn=new WeakMap;function An(e){return kn.get(e)||1}function jn(e,t){let n=e.double(),r=[e];for(let e=1;e<t;e++)r.push(r[e-1].add(n));return r}function Mn(e,t){let n=2**t,r=n/2,i=BigInt(n-1),a=[];for(;e>vn;){let t=0;e&yn&&(t=Number(e&i),t>=r&&(t-=n),e-=BigInt(t)),a.push(t),e>>=yn}return a}function Nn(e,t,n){let r=2**t,i=r/2,a=BigInt(r-1),o=BigInt(t),s=[];for(let t=0;t<n;t++){let t=Number(e&a);e>>=o,t>i&&(t-=r,e+=yn),s.push(t)}if(e!==vn)throw Error(`invalid wnaf`);return s}function Pn(e,t,n){let r=0;for(let e of n)r=Math.max(r,e.length);let i=e;for(let e=r-1;e>=0;e--){e!==r-1&&(i=i.double());for(let r=0;r<n.length;r++){let a=n[r][e];if(a){let e=t[r][Math.abs(a)-1>>1];i=i.add(a<0?e.negate():e)}}}return i}var Fn=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,t){Sn(e),this.randomBytes=En(t,16),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,t,n){let r=Math.ceil(n/t)+1,i=2**(t-1),a=[],o=e;for(let e=0;e<r;e++){let e=o;for(let t=0;t<i;t++)a.push(e),e=e.add(o);o=a[a.length-1].double()}return{W:t,bits:n,windows:r,comp:a}}wnafCachedCT(e,t){let{W:n,windows:r,comp:i}=e,a=2**(n-1),o=Nn(t,n,r),s=this.ZERO,c=this.BASE;for(let e=0;e<r;e++){let t=o[e],n=e*a,r=Math.abs(t)-1,l=i[n];for(let e=1;e<a;e++)l=e===r?i[n+e]:l;let u=l.negate();t===0?c=c.add(i[n]):s=s.add(t<0?u:l)}return{p:s,f:c}}getWnafPrecomputes(e,t,n,r){let i=this.wnafPrecomputes.get(t),a=i?.find(t=>t.W===e&&t.bits===n);return a||(a=this.buildWnafTable(t,e,n),typeof r==`function`&&(a={...a,comp:r(a.comp)}),i||(i=[],this.wnafPrecomputes.set(t,i)),i.push(a)),a}assertPoint(e){if(!(e instanceof this.Point))throw TypeError(`"point" expected Point instance, got type=`+typeof e)}validateMulInput(e,t){if(this.assertPoint(e),!Pt(t,yn,this.Point.Fn.ORDER))throw Error(`invalid scalar`)}runCT(e,t,n,r){let i=An(e);return i===1?this.fixedWindowCT(e,t,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,r),t)}mulCT(e,t,n){return this.validateMulInput(e,t),this.runCT(e,t,this.bits,n)}mulCTBlinded(e,t,n){if(this.validateMulInput(e,t),this.randomBytes===void 0)throw Error(`randomBytes is required for scalar blinding`);let r=this.Point.Fn.BITS+128,i=this.randomBytes(16);if(!_t(i)||i.length!==16)throw Error(`randomBytes returned invalid byte array`);i[0]=i[0]&63|128;let a=t+Dt(i)*this.Point.Fn.ORDER;return this.runCT(e,a,r,n)}fixedWindowCT(e,t,n){let r=Lt(5),i=Array(32);i[0]=this.ZERO;for(let t=1;t<32;t++)i[t]=i[t-1].add(e);let a=Math.ceil(n/5),o=this.ZERO;for(let e=a-1;e>=0;e--){if(e!==a-1)for(let e=0;e<5;e++)o=o.double();let n=Number(t>>BigInt(e*5)&r),s=i[0];for(let e=1;e<32;e++)s=e===n?i[e]:s;o=o.add(s)}return{p:o,f:o}}shouldBlind(e,t){return this.randomBytes===void 0?!1:t===yn||e===this.BASE&&(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,t,n,r){return this.shouldBlind(e,n)?this.mulCTBlinded(e,t,r):this.mulCT(e,t,r)}mulUnsafe(e,t,n){if(this.assertPoint(e),!Nt(t))throw Error(`invalid scalar`);let r=An(e);if(r===1||t>=this.Point.Fn.ORDER)return In(this.Point,[e],[t],!0);let i=this.getWnafPrecomputes(r,e,this.bits,n);return this.wnafCachedCT(i,t).p}setWindowSize(e,t){this.assertPoint(e),wn(t,this.bits),Tn((Math.ceil((this.bits+128)/t)+1)*2**(t-1),this.Point.Fp.BYTES),kn.set(e,t),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return An(e)!==1}};function In(e,t,n,r=!1){if(Sn(e),Dn(t,e),St(r,`allowOversized`),On(n,e.Fn,r?e.Fn.ORDER**bn:void 0),t.length!==n.length)throw Error(`arrays of points and scalars must have equal length`);let i=t.map(e=>jn(e,4)),a=n.map(e=>Mn(e,4));return Pn(e.ZERO,i,a)}function Ln(e,t,n){if(t){if(t.ORDER!==e)throw Error(`Field.ORDER must match order: Fp == p, Fn == n`);return cn(t),t}return mn(e,{isLE:n})}function Rn(e,t,n={},r){if(e!==`weierstrass`&&e!==`edwards`)throw Error(`expected curve type "weierstrass" or "edwards"`);if(r===void 0&&(r=e===`edwards`),!t||typeof t!=`object`)throw Error(`expected valid ${e} CURVE object`);zt(n);for(let e of[`p`,`n`,`h`]){let n=t[e];if(!(Nt(n)&&n!==vn))throw Error(`CURVE.${e} must be positive bigint`)}let i=Ln(t.p,n.Fp,r),a=Ln(t.n,n.Fn,r),o=[`Gx`,`Gy`,`a`,e===`weierstrass`?`b`:`d`];for(let e of o)if(!i.isValid(t[e]))throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:i,Fn:a}}function zn(e,t){return function(n){let r=e(n);return{secretKey:r,publicKey:t(r)}}}
|
|
10
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
11
|
+
const Bn=BigInt(0),J={Err:class extends Error{constructor(e=``){super(e)}},_tlv:{encode:(e,t)=>{let{Err:n}=J;if(wt(e,`tag`),e<0||e>255)throw new n(`tlv.encode: wrong tag`);if(ft(t,`data`),t.length&1)throw new n(`tlv.encode: unpadded data`);let r=t.length/2,i=Tt(r);if(i.length/2&128)throw new n(`tlv.encode: long form length too big`);let a=r>127?Tt(i.length/2|128):``;return Tt(e)+a+i+t},decode(e,t){let{Err:n}=J;t=H(t,void 0,`DER data`);let r=0;if(e<0||e>255)throw new n(`tlv.decode: wrong tag`);if(t.length<2||t[r++]!==e)throw new n(`tlv.decode: wrong tlv`);let i=t[r++],a=!!(i&128),o=0;if(!a)o=i;else{let e=i&127;if(!e)throw new n(`tlv.decode(long): indefinite length not supported`);if(e>4)throw new n(`tlv.decode(long): byte length is too big`);let a=t.subarray(r,r+e);if(a.length!==e)throw new n(`tlv.decode: length bytes not complete`);if(a[0]===0)throw new n(`tlv.decode(long): zero leftmost byte`);for(let e of a)o=o<<8|e;if(r+=e,o<128)throw new n(`tlv.decode(long): not minimal encoding`)}let s=t.subarray(r,r+o);if(s.length!==o)throw new n(`tlv.decode: wrong value length`);return{v:s,l:t.subarray(r+o)}}},_int:{encode(e){let{Err:t}=J;if(Ct(e),e<Bn)throw new t(`integer: negative integers are not allowed`);let n=Tt(e);if(Number.parseInt(n[0],16)&8&&(n=`00`+n),n.length&1)throw new t(`unexpected DER parsing assertion: unpadded hex`);return n},decode(e){let{Err:t}=J;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 Dt(e)}},toSig(e,t){let{Err:n,_int:r,_tlv:i}=J;if(t!==void 0&&(wt(t,`maxScalarBytes`),t<1))throw new n(`invalid signature: maxScalarBytes must be positive`);let a=H(e,void 0,`signature`),{v:o,l:s}=i.decode(48,a);if(s.length)throw new n(`invalid signature: left bytes after parsing`);let{v:c,l}=i.decode(2,o),{v:u,l:d}=i.decode(2,l);if(d.length)throw new n(`invalid signature: left bytes after parsing`);if(t!==void 0&&(c.length>t||u.length>t))throw new n(`invalid signature: integer too large`);return{r:r.decode(c),s:r.decode(u)}},hexFromSig(e){let{_tlv:t,_int:n}=J;zt(e,{r:`bigint`,s:`bigint`},{},`sig`);let r=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,r)}},Vn=(Object.freeze(J._tlv),Object.freeze(J._int),Object.freeze(J)),Hn=(e,t)=>(e+(e>=0?t:-t)/qn)/t
|
|
12
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
13
|
+
;function Un(e,t,n){Ft(`scalar`,e,Y,n);let[[r,i],[a,o]]=t,s=Hn(o*e,n),c=Hn(-i*e,n),l=e-s*r-c*a,u=-s*i-c*o,d=l<Y,f=u<Y;d&&(l=-l),f&&(u=-u);let p=Lt(Math.ceil(It(n)/2))+Kn;if(l<Y||l>=p||u<Y||u>=p)throw Error(`splitScalar (endomorphism): failed for k`);return{k1neg:d,k1:l,k2neg:f,k2:u}}function Wn(e){if(![`compact`,`recovered`,`der`].includes(e))throw Error(`Signature format must be "compact", "recovered", or "der"`);return e}function Gn(e,t){zt(e);let n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return St(n.lowS,`lowS`),St(n.prehash,`prehash`),n.format!==void 0&&Wn(n.format),n}const Y=BigInt(0),Kn=BigInt(1),qn=BigInt(2),Jn=BigInt(3),Yn=BigInt(4);function Xn(e,t={}){let n=Rn(`weierstrass`,e,t),r=n.Fp,i=n.Fn,a=n.CURVE,{h:o,n:s}=a;zt(t,{},{allowInfinityPoint:`boolean`,clearCofactor:`function`,isTorsionFree:`function`,fromBytes:`function`,toBytes:`function`,endo:`object`,randomBytes:`function`});let{endo:c,allowInfinityPoint:l,clearCofactor:u,isTorsionFree:d,fromBytes:f,toBytes:p}=t,m=t.randomBytes===void 0?vt:t.randomBytes;if(c&&(!r.is0(a.a)||typeof c.beta!=`bigint`||!Array.isArray(c.basises)))throw Error(`invalid endo: expected "beta": bigint and "basises": array`);let h=c?{beta:c.beta,basises:c.basises.map(e=>[...e])}:void 0,g=Qn(r,i);function _(){if(!r.isOdd)throw Error(`compression is not supported: Field does not have .isOdd()`)}function v(e,t,n){if(t.is0()){if(!l)throw Error(`bad point: ZERO`);return Uint8Array.of(0)}let{x:i,y:a}=t.toAffine(),o=r.toBytes(i);if(St(n,`isCompressed`),n){_();let e=!r.isOdd(a);return U(Zn(e),o)}return U(Uint8Array.of(4),o,r.toBytes(a))}function y(e){H(e,void 0,`Point`);let{publicKey:t,publicKeyUncompressed:n}=g,i=e.length,a=e[0],o=e.subarray(1);if(l&&i===1&&a===0)return{x:r.ZERO,y:r.ZERO};if(i===t&&(a===2||a===3)){let e=r.fromBytes(o);if(!r.isValid(e))throw Error(`bad point: is not on curve, wrong x`);let t=S(e),n;try{n=r.sqrt(t)}catch(e){let t=e instanceof Error?`: `+e.message:``;throw Error(`bad point: is not on curve, sqrt error`+t)}_();let i=r.isOdd(n);return(a&1)==1!==i&&(n=r.neg(n)),{x:e,y:n}}if(i===n&&a===4){let e=r.BYTES,t=r.fromBytes(o.subarray(0,e)),n=r.fromBytes(o.subarray(e,e*2));if(!C(t,n))throw Error(`bad point: is not on curve`);return{x:t,y:n}}throw Error(`bad point: got length ${i}, expected compressed=${t} or uncompressed=${n}`)}let ee=p===void 0?v:p,te=f===void 0?y:f,b=r.mul(a.b,Jn),x=r.is0(a.a)?e=>r.ZERO:e=>r.mul(a.a,e);function S(e){let t=r.sqr(e),n=r.mul(t,e);return r.add(r.add(n,r.mul(e,a.a)),a.b)}function C(e,t){let n=r.sqr(t),i=S(e);return r.eql(n,i)}if(!C(a.Gx,a.Gy))throw Error(`bad curve params: generator point`);let w=r.mul(r.pow(a.a,Jn),Yn),T=r.mul(r.sqr(a.b),BigInt(27));if(r.is0(r.add(w,T)))throw Error(`bad curve params: a or b`);function E(e,t,n=!1){if(!r.isValid(t)||n&&r.is0(t))throw Error(`bad point coordinate ${e}`);return typeof t==`object`&&t?r.create(t):t}function D(e){if(!(e instanceof j))throw Error(`Weierstrass Point expected`)}function O(e){if(!h||!h.basises)throw Error(`no endo`);return Un(e,h.basises,i.ORDER)}function k(e,t,n,a){if(!i.isValid(a))throw RangeError(`invalid scalar: out of range`);if(h){let{k1neg:i,k1:o,k2neg:s,k2:c}=O(a),l=new j(r.mul(n.X,h.beta),n.Y,n.Z);e.push(i?n.negate():n,s?l.negate():l),t.push(o,c)}else e.push(n),t.push(a)}let A=new WeakSet;class j{static BASE=new j(a.Gx,a.Gy,r.ONE);static ZERO=new j(r.ZERO,r.ONE,r.ZERO);static Fp=r;static Fn=i;X;Y;Z;constructor(e,t,n){this.X=E(`x`,e),this.Y=E(`y`,t,!0),this.Z=E(`z`,n),Object.freeze(this)}static CURVE(){return a}static fromAffine(e){let{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw Error(`invalid affine point`);if(e instanceof j)throw Error(`projective point not allowed`);return r.is0(t)&&r.is0(n)?j.ZERO:new j(t,n,r.ONE)}static fromBytes(e){let t=j.fromAffine(te(H(e,void 0,`point`)));return t.assertValidity(),t}static fromHex(e){return j.fromBytes(gt(e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(e=6,t=!0){return N.setWindowSize(this,e),t||this.multiply(Jn),this}assertValidity(){let e=this;if(e.is0()){if(l&&r.is0(e.X)&&r.eql(e.Y,r.ONE)&&r.is0(e.Z))return;throw Error(`bad point: ZERO`)}if(A.has(e))return;let{x:t,y:n}=e.toAffine();if(!r.isValid(t)||!r.isValid(n))throw Error(`bad point: x or y not field elements`);if(!C(t,n))throw Error(`bad point: equation left != right`);if(!e.isTorsionFree())throw Error(`bad point: not in prime-order subgroup`);A.add(e)}hasEvenY(){let{y:e}=this.toAffine();if(!r.isOdd)throw Error(`Field doesn't support isOdd`);return!r.isOdd(e)}equals(e){D(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.eql(r.mul(t,s),r.mul(a,i)),l=r.eql(r.mul(n,s),r.mul(o,i));return c&&l}negate(){return new j(this.X,r.neg(this.Y),this.Z)}double(){let{X:e,Y:t,Z:n}=this,i=r.ZERO,a=r.ZERO,o=r.ZERO,s=r.mul(e,e),c=r.mul(t,t),l=r.mul(n,n),u=r.mul(e,t);return u=r.add(u,u),o=r.mul(e,n),o=r.add(o,o),i=x(o),a=r.mul(b,l),a=r.add(i,a),i=r.sub(c,a),a=r.add(c,a),a=r.mul(i,a),i=r.mul(u,i),o=r.mul(b,o),l=x(l),u=r.sub(s,l),u=x(u),u=r.add(u,o),o=r.add(s,s),s=r.add(o,s),s=r.add(s,l),s=r.mul(s,u),a=r.add(a,s),l=r.mul(t,n),l=r.add(l,l),s=r.mul(l,u),i=r.sub(i,s),o=r.mul(l,c),o=r.add(o,o),o=r.add(o,o),new j(i,a,o)}add(e){D(e);let{X:t,Y:n,Z:i}=this,{X:a,Y:o,Z:s}=e,c=r.ZERO,l=r.ZERO,u=r.ZERO,d=r.mul(t,a),f=r.mul(n,o),p=r.mul(i,s),m=r.add(t,n),h=r.add(a,o);m=r.mul(m,h),h=r.add(d,f),m=r.sub(m,h),h=r.add(t,i);let g=r.add(a,s);return h=r.mul(h,g),g=r.add(d,p),h=r.sub(h,g),g=r.add(n,i),c=r.add(o,s),g=r.mul(g,c),c=r.add(f,p),g=r.sub(g,c),u=x(h),c=r.mul(b,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),l=r.mul(c,u),f=r.add(d,d),f=r.add(f,d),p=x(p),h=r.mul(b,h),f=r.add(f,p),p=r.sub(d,p),p=x(p),h=r.add(h,p),d=r.mul(f,h),l=r.add(l,d),d=r.mul(g,h),c=r.mul(m,c),c=r.sub(c,d),d=r.mul(m,f),u=r.mul(g,u),u=r.add(u,d),new j(c,l,u)}subtract(e){return D(e),this.add(e.negate())}is0(){return this.equals(j.ZERO)}multiply(e){if(!i.isValidNot0(e))throw RangeError(`invalid scalar: out of range`);let{p:t,f:n}=N.mulSecret(this,e,o,M);return M([t,n])[0]}multiplyUnsafe(e){let t=this,n=e;if(!i.isValid(n))throw RangeError(`invalid scalar: out of range`);if(n===Y||t.is0())return j.ZERO;if(n===Kn)return t;if(N.hasWindowSize(this))return N.mulUnsafe(t,n,M);let r=[],a=[];return k(r,a,t,n),In(j,r,a)}mulAddUnsafe(e,t,n){D(t);let r=[],i=[];return k(r,i,this,e),k(r,i,t,n),In(j,r,i)}toAffine(e){let t=this,n=e;if(n!=null&&!r.isValid(n))throw RangeError(`"invertedZ" expected valid field element`);let{X:i,Y:a,Z:o}=t;if(r.eql(o,r.ONE))return{x:i,y:a};let s=t.is0();n??=s?r.ONE:r.inv(o);let c=r.mul(i,n),l=r.mul(a,n),u=r.mul(o,n);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw Error(`invZ was invalid`);return{x:c,y:l}}isTorsionFree(){return o===Kn?!0:d?d(j,this):N.mulUnsafe(this,s).is0()}clearCofactor(){return o===Kn?this:u?u(j,this):this.multiplyUnsafe(o)}isSmallOrder(){return o===Kn?this.is0():this.clearCofactor().is0()}toBytes(e=!0){return St(e,`isCompressed`),this.assertValidity(),ee(j,this,e)}toHex(e=!0){return ht(this.toBytes(e))}toString(){return`<Point ${this.is0()?`ZERO`:this.toHex()}>`}}let M=e=>Cn(j,e),N=new Fn(j,m);return N.bits>=6&&j.BASE.precompute(6),Object.freeze(j.prototype),Object.freeze(j),j}function Zn(e){return Uint8Array.of(e?2:3)}function Qn(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function $n(e,t={}){Sn(e);let{Fn:n}=e,r=t.randomBytes===void 0?vt:t.randomBytes,i=Object.assign(Qn(e.Fp,n),{seed:Math.max(gn(n.ORDER),16)});function a(e){try{let t=n.fromBytes(e);return n.isValidNot0(t)}catch{return!1}}function o(t,n){let{publicKey:r,publicKeyUncompressed:a}=i;try{let i=t.length;return n===!0&&i!==r||n===!1&&i!==a?!1:!e.fromBytes(t).is0()}catch{return!1}}function s(e){return e=e===void 0?r(i.seed):e,_n(H(e,i.seed,`seed`),n.ORDER)}function c(t,r=!0){return e.BASE.multiply(n.fromBytes(t)).toBytes(r)}function l(e){let{secretKey:t,publicKey:r,publicKeyUncompressed:a}=i,o=n._lengths;if(!_t(e))return;let s=H(e,void 0,`key`).length,c=s===r||s===a,l=s===t||!!o?.includes(s);if(!(c&&l))return c}function u(t,r,i=!0){if(l(t)===!0)throw Error(`first arg must be private key`);if(l(r)===!1)throw Error(`second arg must be public key`);let a=n.fromBytes(t),o=e.fromBytes(r);if(o.is0())throw Error(`invalid public key: point at infinity`);return o.multiply(a).toBytes(i)}let d={isValidSecretKey:a,isValidPublicKey:o,randomSecretKey:s},f=zn(s,c);return Object.freeze(d),Object.freeze(i),Object.freeze({getPublicKey:c,getSharedSecret:u,keygen:f,Point:e,utils:d,lengths:i})}function er(e,n,r={}){Sn(e);let i=n;t.Mr(i),zt(r,{},{hmac:`function`,lowS:`boolean`,randomBytes:`function`,bits2int:`function`,bits2int_modN:`function`});let a=Object.assign({},r),o=a.randomBytes===void 0?vt:a.randomBytes,s=a.hmac===void 0?(e,t)=>Ge(i,e,t):a.hmac,{Fp:c,Fn:l}=e,{ORDER:u,BITS:d}=l,f=gn(u),p=En(o,f),{keygen:m,getPublicKey:h,getSharedSecret:g,utils:_,lengths:v}=$n(e,a),y={prehash:!0,lowS:typeof a.lowS!=`boolean`||a.lowS,format:`compact`,extraEntropy:!1},ee=u*qn+Kn<c.ORDER;function te(e){return e>u>>Kn}function b(e,t){if(!l.isValidNot0(t))throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);return t}function x(){if(!c.isOdd)throw Error(`Field doesn't support isOdd`)}function S(e,t,n){return x(),(e===n?0:2)|Number(c.isOdd(t))}function C(){if(ee)throw Error(`"recovered" sig type is not supported for cofactor >2 curves`)}function w(e,t){Wn(t);let n=v.signature,r=t===`compact`?n:t===`recovered`?n+1:void 0;return H(e,r)}class T{r;s;recovery;constructor(e,t,n){if(this.r=b(`r`,e),this.s=b(`s`,t),n!=null){if(C(),![0,1,2,3].includes(n))throw Error(`invalid recovery id`);this.recovery=n}Object.freeze(this)}static fromBytes(e,t=y.format){w(e,t);let n;if(t===`der`){if(e.length>2*l.BYTES+16)throw new Vn.Err(`invalid signature: DER signature too long`);let{r:t,s:n}=Vn.toSig(H(e),l.BYTES+1);return new T(t,n)}t===`recovered`&&(n=e[0],t=`compact`,e=e.subarray(1));let r=v.signature/2,i=e.subarray(0,r),a=e.subarray(r,r*2);return new T(l.fromBytes(i),l.fromBytes(a),n)}static fromHex(e,t){return this.fromBytes(gt(e),t)}assertRecovery(){let{recovery:e}=this;if(e==null)throw Error(`invalid recovery id: must be present`);return e}addRecoveryBit(e){return new T(this.r,this.s,e)}recoverPublicKey(t){let{r:n,s:r}=this,i=this.assertRecovery(),a=i===2||i===3?n+u:n;if(!c.isValid(a))throw Error(`invalid recovery id: sig.r+curve.n != R.x`);let o=c.toBytes(a),s=e.fromBytes(U(Zn(!(i&1)),o)),d=l.inv(a),f=D(H(t,void 0,`msgHash`)),p=l.create(-f*d),m=l.create(r*d),h=e.BASE.mulAddUnsafe(p,s,m);if(h.is0())throw Error(`invalid recovery: point at infinify`);return h.assertValidity(),h}hasHighS(){return te(this.s)}toBytes(e=y.format){if(Wn(e),e===`der`)return gt(Vn.hexFromSig(this));let{r:t,s:n}=this,r=l.toBytes(t),i=l.toBytes(n);return e===`recovered`?(C(),U(Uint8Array.of(this.assertRecovery()),r,i)):U(r,i)}toHex(e){return ht(this.toBytes(e))}}Object.freeze(T.prototype),Object.freeze(T);let E=a.bits2int===void 0?function(e){if(e.length>8192)throw Error(`input is too large`);let t=Dt(e),n=e.length*8-d;return n>0?t>>BigInt(n):t}:a.bits2int,D=a.bits2int_modN===void 0?function(e){return l.create(E(e))}:a.bits2int_modN,O=Lt(d);function k(e){return Ft(`num < 2^`+d,e,Y,O),l.toBytes(e)}function A(e,t){return H(e,void 0,`message`),t?H(i(e),void 0,`prehashed message`):e}function j(t,n,r){let{lowS:i,prehash:a,extraEntropy:s}=Gn(r,y);t=A(t,a);let c=D(t),d=l.fromBytes(n);if(!l.isValidNot0(d))throw Error(`invalid private key`);let m=[k(d),k(c)];if(s!=null&&s!==!1){let e=s===!0?o(v.secretKey):s;m.push(H(e,void 0,`extraEntropy`))}let h=U(...m),g=c;function _(t){let n=E(t);if(!l.isValidNot0(n))return;let r=e.BASE.multiply(n).toAffine(),a=l.create(r.x);if(a===Y)return;let o;if(p!==void 0){let e=Dt(_n(p(f),u)),t=l.inv(l.mul(e,n)),r=l.mul(e,g),i=l.mul(e,d);o=l.create(t*l.create(r+i*a))}else{let e=Qt(n,u);o=l.create(e*l.create(g+a*d))}if(o===Y)return;let s=S(r.x,r.y,a),c=o;return i&&te(o)&&(c=l.neg(o),s^=1),new T(a,c,ee?void 0:s)}return{seed:h,k2sig:_}}function M(e,t,n={}){let{seed:r,k2sig:a}=j(e,t,n);return Rt(i.outputLen,l.BYTES,s)(r,a).toBytes(n.format)}function N(t,n,r,i={}){let{lowS:a,prehash:o,format:s}=Gn(i,y);if(r=H(r,void 0,`publicKey`),n=A(n,o),!_t(t)){let e=t instanceof T?`, use sig.toBytes()`:``;throw Error(`verify expects Uint8Array signature`+e)}w(t,s);try{let i=T.fromBytes(t,s),o=e.fromBytes(r);if(o.is0()||a&&i.hasHighS())return!1;let{r:c,s:u}=i,d=D(n),f=l.inv(u),p=l.create(d*f),m=l.create(c*f),h=e.BASE.mulAddUnsafe(p,o,m);if(h.is0())return!1;let g=h.toAffine();return!(l.create(g.x)!==c||s===`recovered`&&i.recovery!==S(g.x,g.y,c))}catch{return!1}}function P(e,t,n={}){let{prehash:r}=Gn(n,y);return t=A(t,r),T.fromBytes(e,`recovered`).recoverPublicKey(t).toBytes()}return Object.freeze({keygen:m,getPublicKey:h,getSharedSecret:g,utils:_,lengths:v,Point:e,sign:M,verify:N,recoverPublicKey:P,Signature:T,hash:i})}
|
|
14
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
15
|
+
const tr={p:BigInt(`0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f`),n:BigInt(`0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141`),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt(`0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798`),Gy:BigInt(`0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8`)},nr={beta:BigInt(`0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee`),basises:[[BigInt(`0x3086d221a7d46bcde86c90e49284eb15`),-BigInt(`0xe4437ed6010e88286f547fa90abfe4c3`)],[BigInt(`0x114ca50f7a8e2f3f657c1108d9d44cfd8`),BigInt(`0x3086d221a7d46bcde86c90e49284eb15`)]]},rr=BigInt(0),ir=BigInt(2);function ar(e){let t=tr.p,n=BigInt(3),r=BigInt(6),i=BigInt(11),a=BigInt(22),o=BigInt(23),s=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,d=q(q(q(u,n,t)*u%t,n,t)*u%t,ir,t)*l%t,f=q(d,i,t)*d%t,p=q(f,a,t)*f%t,m=q(p,s,t)*p%t,h=q(q(q(q(q(q(m,c,t)*m%t,s,t)*p%t,n,t)*u%t,o,t)*f%t,r,t)*l%t,ir,t);if(!or.eql(or.sqr(h),e))throw Error(`Cannot find square root`);return h}const or=mn(tr.p,{sqrt:ar}),sr=Xn(tr,{Fp:or,endo:nr}),cr=er(sr,V),lr=Object.create(null);function ur(e,...t){let n=lr[e];if(n===void 0){let t=V(Mt(e));n=U(t,t),lr[e]=n}return V(U(n,...t))}const dr=e=>e.toBytes(!0).slice(1),fr=({x:e})=>or.toBytes(e),pr=e=>!or.isOdd(e);function mr(e){let{Fn:t,BASE:n}=sr,r=t.fromBytes(H(e,32,`secretKey`)),i=n.multiply(r).toAffine();return{scalar:pr(i.y)?r:t.neg(r),bytes:fr(i)}}function hr(e){let t=or;if(!t.isValidNot0(e))throw Error(`invalid x: Fail if x ≥ p`);let n=t.sqr(e),r=t.add(t.mulN(n,e),BigInt(7)),i=t.sqrt(r);pr(i)||(i=t.neg(i));let a=sr.fromAffine({x:e,y:i});return a.assertValidity(),a}const gr=Dt;function _r(...e){return sr.Fn.create(gr(ur(`BIP0340/challenge`,...e)))}function vr(e){return mr(e).bytes}function yr(e,n,r=t.Kr(32)){let{Fn:i,BASE:a}=sr,o=jt(H(e,void 0,`message`)),{bytes:s,scalar:c}=mr(n),l=H(r,32,`auxRand`),u=ur(`BIP0340/nonce`,i.toBytes(c^gr(ur(`BIP0340/aux`,l))),s,o),d=i.create(gr(u));if(d===rr)throw Error(`sign failed: k is zero`);let f=a.multiply(d).toAffine(),p=pr(f.y)?d:i.neg(d),m=fr(f),h=_r(m,s,o),g=new Uint8Array(64);if(g.set(m,0),g.set(i.toBytes(i.create(p+h*c)),32),!br(g,o,s))throw Error(`sign: Invalid signature produced`);return g}function br(e,t,n){let{Fp:r,Fn:i,BASE:a}=sr,o=H(e,64,`signature`),s=H(t,void 0,`message`),c=H(n,32,`publicKey`);try{let e=hr(gr(c)),t=o.subarray(0,32),n=gr(t);if(!r.isValidNot0(n))return!1;let l=gr(o.subarray(32,64));if(!i.isValidNot0(l))return!1;let u=_r(t,dr(e),s),d=a.mulAddUnsafe(l,e,i.neg(u)),{x:f,y:p}=d.toAffine();return!(d.is0()||!pr(p)||!r.eql(f,n))}catch{return!1}}const xr=(()=>{let e=e=>(e=e===void 0?t.Kr(48):e,_n(H(e,48,`seed`),tr.n));return Object.freeze({keygen:zn(e,vr),getPublicKey:vr,sign:yr,verify:br,Point:sr,utils:Object.freeze({randomSecretKey:e,taggedHash:ur,lift_x:hr,pointToBytes:dr}),lengths:Object.freeze({secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48})})})(),Sr=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Cr=Uint8Array.from(Array(16).fill(0).map((e,t)=>t)),wr=Cr.map(e=>(9*e+5)%16),Tr=(()=>{let e=[[Cr],[wr]];for(let t=0;t<4;t++)for(let n of e)n.push(n[t].map(e=>Sr[e]));return e})(),Er=Tr[0],Dr=Tr[1],Or=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),kr=Er.map((e,t)=>e.map(e=>Or[t][e])),Ar=Dr.map((e,t)=>e.map(e=>Or[t][e])),jr=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),Mr=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function Nr(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}const Pr=new Uint32Array(16);var Fr=class extends c{h0=1732584193;h1=-271733879;h2=-1732584194;h3=271733878;h4=-1009589776;constructor(){super(64,20,8,!0)}get(){let{h0:e,h1:t,h2:n,h3:r,h4:i}=this;return[e,t,n,r,i]}set(e,t,n,r,i){this.h0=e|0,this.h1=t|0,this.h2=n|0,this.h3=r|0,this.h4=i|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,n){for(let t=0;t<16;t++,n+=4)Pr[t]=e.getUint32(n,!0);let r=this.h0|0,i=r,a=this.h1|0,o=a,s=this.h2|0,c=s,l=this.h3|0,u=l,d=this.h4|0,f=d;for(let e=0;e<5;e++){let n=4-e,p=jr[e],m=Mr[e],h=Er[e],g=Dr[e],_=kr[e],v=Ar[e];for(let n=0;n<16;n++){let i=t.qr(r+Nr(e,a,s,l)+Pr[h[n]]+p,_[n])+d|0;r=d,d=l,l=t.qr(s,10)|0,s=a,a=i}for(let e=0;e<16;e++){let r=t.qr(i+Nr(n,o,c,u)+Pr[g[e]]+m,v[e])+f|0;i=f,f=u,u=t.qr(c,10)|0,c=o,o=r}}this.set(this.h1+s+u|0,this.h2+l+f|0,this.h3+d+i|0,this.h4+r+o|0,this.h0+a+c|0)}roundClean(){t.Rr(Pr)}destroy(){this.destroyed=!0,t.Rr(this.buffer),this.set(0,0,0,0,0)}};const Ir=t.Br(()=>new Fr);
|
|
16
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
17
|
+
function Lr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function Rr(e,...t){if(!Lr(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function zr(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Br(e,t){Rr(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function Vr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Hr(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function X(e,t){return e<<32-t|e>>>t}function Ur(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function Wr(e){return typeof e==`string`&&(e=Ur(e)),Rr(e),e}var Gr=class{};function Kr(e){let t=t=>e().update(Wr(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function qr(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function Jr(e,t,n){return e&t^~e&n}function Yr(e,t,n){return e&t^e&n^t&n}var Xr=class extends Gr{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Hr(this.buffer)}update(e){zr(this),e=Wr(e),Rr(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Hr(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){zr(this),Br(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,Vr(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;qr(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=Hr(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}};const Z=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Zr=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]),Qr=new Uint32Array(64);var $r=class extends Xr{constructor(e=32){super(64,e,8,!1),this.A=Z[0]|0,this.B=Z[1]|0,this.C=Z[2]|0,this.D=Z[3]|0,this.E=Z[4]|0,this.F=Z[5]|0,this.G=Z[6]|0,this.H=Z[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Qr[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Qr[e-15],n=Qr[e-2],r=X(t,7)^X(t,18)^t>>>3,i=X(n,17)^X(n,19)^n>>>10;Qr[e]=i+Qr[e-7]+r+Qr[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=X(o,6)^X(o,11)^X(o,25),u=l+t+Jr(o,s,c)+Zr[e]+Qr[e]|0,d=(X(n,2)^X(n,13)^X(n,22))+Yr(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){Vr(Qr)}destroy(){this.set(0,0,0,0,0,0,0,0),Vr(this.buffer)}};const ei=Kr(()=>new $r);function ti(e){if(e.length>=255)throw TypeError(`Alphabet too long`);let t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let n=0;n<e.length;n++){let r=e.charAt(n),i=r.charCodeAt(0);if(t[i]!==255)throw TypeError(r+` is ambiguous`);t[i]=n}let n=e.length,r=e.charAt(0),i=Math.log(n)/Math.log(256),a=Math.log(256)/Math.log(n);function o(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError(`Expected Uint8Array`);if(t.length===0)return``;let i=0,o=0,s=0,c=t.length;for(;s!==c&&t[s]===0;)s++,i++;let l=(c-s)*a+1>>>0,u=new Uint8Array(l);for(;s!==c;){let e=t[s],r=0;for(let t=l-1;(e!==0||r<o)&&t!==-1;t--,r++)e+=256*u[t]>>>0,u[t]=e%n>>>0,e=e/n>>>0;if(e!==0)throw Error(`Non-zero carry`);o=r,s++}let d=l-o;for(;d!==l&&u[d]===0;)d++;let f=r.repeat(i);for(;d<l;++d)f+=e.charAt(u[d]);return f}function s(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return new Uint8Array;let a=0,o=0,s=0;for(;e[a]===r;)o++,a++;let c=(e.length-a)*i+1>>>0,l=new Uint8Array(c);for(;a<e.length;){let r=e.charCodeAt(a);if(r>255)return;let i=t[r];if(i===255)return;let o=0;for(let e=c-1;(i!==0||o<s)&&e!==-1;e--,o++)i+=n*l[e]>>>0,l[e]=i%256>>>0,i=i/256>>>0;if(i!==0)throw Error(`Non-zero carry`);s=o,a++}let u=c-s;for(;u!==c&&l[u]===0;)u++;let d=new Uint8Array(o+(c-u)),f=o;for(;u!==c;)d[f++]=l[u++];return d}function c(e){let t=s(e);if(t)return t;throw Error(`Non-base`+n+` character`)}return{encode:o,decodeUnsafe:s,decode:c}}var ni=ti(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`);function ri(e){function t(t){var n=Uint8Array.from(t),r=e(n),i=n.length+4,a=new Uint8Array(i);return a.set(n,0),a.set(r.subarray(0,4),n.length),ni.encode(a)}function n(t){var n=t.slice(0,-4),r=t.slice(-4),i=e(n);if(!(r[0]^i[0]|r[1]^i[1]|r[2]^i[2]|r[3]^i[3]))return n}function r(e){var t=ni.decodeUnsafe(e);if(t!=null)return n(t)}function i(e){var t=n(ni.decode(e));if(t==null)throw Error(`Invalid checksum`);return t}return{encode:t,decode:i,decodeUnsafe:r}}function ii(e){return ei(ei(e))}var ai=ri(ii);function oi(e){let n=t.ir(e);return n<253?t.sr(n,1):n<=65535?t.$r([253],t.sr(n,2)):n<=4294967295?t.$r([254],t.sr(n,4)):t.$r([255],t.sr(n,8))}function si(e,n){let r=n??`Bitcoin Signed Message:
|
|
18
|
+
`,i=typeof r==`string`?t.ni(r,`utf8`):t.ni(r),a=typeof e==`string`?t.ni(e,`utf8`):t.ni(e);return V(V(t.$r(i,oi(a.length),a)))}function ci(e){return Ir(V(t.ni(e)))}function li(e,n){return ai.encode(t.$r([n],ci(e)))}function ui(e){return t.Er(ai.decode(e).subarray(1))}function di(e,n,r){let i=typeof e==`string`?e:t.Er(e).slice(2),a=t.ni(n,`base64`).subarray(1);return cr.verify(t.ni(a),si(i),t.ni(r),{prehash:!1})}function fi(e,n){let r=cr.sign(t.ni(e),t.ni(n),{format:`recovered`,prehash:!1});return t.Er(t.$r(r.subarray(1),r.subarray(0,1)))}function pi(e,n,r){let i=t.ni(n);return cr.verify(t.$r(i.subarray(64),i.subarray(0,64)),t.ni(e),t.ni(r),{format:`recovered`,prehash:!1})}function mi(e,n){let r=t.ni(n);return t.Er(cr.recoverPublicKey(t.$r(r.subarray(64),r.subarray(0,64)),t.ni(e),{prehash:!1}))}function hi(e){let n=typeof e==`string`?e:t.Er(e),r=t.ni(`Nervos Message:${n}`,`utf8`);return t.xr(r)}function gi(e,t,n){return pi(hi(e),t,n)}function _i(e,n,r){let a=typeof e==`string`?e:t.Er(e).slice(2),{publicKey:o,keyType:s}=JSON.parse(r);return(0,i.verifySignature)({challenge:a,pubkey:o,keyType:s,...JSON.parse(n)})}function vi(e,t){return si(e,t??`Dogecoin Signed Message:
|
|
19
|
+
`)}function yi(e,n,r){let i=typeof e==`string`?e:t.Er(e).slice(2),a=t.ni(n,`base64`);return a[0]-=31,ui(r)===t.Er(ci(cr.recoverPublicKey(a,vi(i),{prehash:!1})))}function bi(e,n,r){return r.toLowerCase()===(0,a.verifyMessage)(typeof e==`string`?e:t.ni(e),n).toLowerCase()}function xi(e){if(typeof e==`string`)try{let t=JSON.parse(e);if(typeof t==`object`&&typeof t.created_at==`number`&&typeof t.kind==`number`&&typeof t.content==`string`&&Array.isArray(t.tags)&&t.tags.every(e=>Array.isArray(e)&&e.every(e=>typeof e==`string`)))return t}catch{}return{kind:23335,created_at:0,content:typeof e==`string`?e:t.Er(e),tags:[]}}function Si(e){let n=JSON.stringify([0,e.pubkey,e.created_at,e.kind,e.tags,e.content]);return V(t.ni(n,`utf8`))}function Ci(e,r,i){let{words:a}=n.bech32.decode(i),o=t.Er(n.bech32.fromWords(a)).slice(2),s=Si({...xi(e),pubkey:o});try{return xr.verify(t.ni(r),s,t.ni(o))}catch{return!1}}let wi=function(e){return e.Unknown=`Unknown`,e.BtcEcdsa=`BtcEcdsa`,e.EvmPersonal=`EvmPersonal`,e.JoyId=`JoyId`,e.NostrEvent=`NostrEvent`,e.CkbSecp256k1=`CkbSecp256k1`,e.DogeEcdsa=`DogeEcdsa`,e}({}),Ti=function(e){return e.EVM=`EVM`,e.BTC=`BTC`,e.CKB=`CKB`,e.Nostr=`Nostr`,e.Doge=`Doge`,e}({});var Ei=class{constructor(e,t,n){this.signature=e,this.identity=t,this.signType=n}},Q=class e{constructor(e){this.client_=e}get client(){return this.client_}matchNetworkPreference(e,t){if(!(t!==void 0&&e.some(({signerType:e,addressPrefix:n,network:r})=>e===this.type&&n===this.client.addressPrefix&&r===t)))return e.find(({signerType:e,addressPrefix:t})=>e===this.type&&t===this.client.addressPrefix)}static async verifyMessage(e,t){switch(t.signType){case`EvmPersonal`:return bi(e,t.signature,t.identity);case`BtcEcdsa`:return di(e,t.signature,t.identity);case`JoyId`:return _i(e,t.signature,t.identity);case`NostrEvent`:return Ci(e,t.signature,t.identity);case`CkbSecp256k1`:return gi(e,t.signature,t.identity);case`DogeEcdsa`:return yi(e,t.signature,t.identity);case`Unknown`:throw Error(`Unknown signer sign type`)}}onReplaced(e){return()=>{}}async disconnect(){}async getIdentity(){return this.getInternalAddress()}async getRecommendedAddressObj(e){return(await this.getAddressObjs())[0]}async getRecommendedAddress(e){return(await this.getRecommendedAddressObj(e)).toString()}async getAddresses(){return this.getAddressObjs().then(e=>e.map(e=>e.toString()))}async*findCellsOnChain(e,t,n,r){let i=await this.getAddressObjs();for(let{script:a}of i)for await(let i of this.client.findCellsOnChain({script:a,scriptType:`lock`,filter:e,scriptSearchMode:`exact`,withData:t},n,r))yield i}async*findCells(e,t,n,r){let i=await this.getAddressObjs();for(let{script:a}of i)for await(let i of this.client.findCells({script:a,scriptType:`lock`,filter:e,scriptSearchMode:`exact`,withData:t},n,r))yield i}async*findTransactions(e,t,n,r){let i=await this.getAddressObjs();for(let{script:a}of i)for await(let i of this.client.findTransactions({script:a,scriptType:`lock`,filter:e,scriptSearchMode:`exact`,groupByTransaction:t},n,r))yield i}async getBalance(){return this.client.getBalance((await this.getAddressObjs()).map(({script:e})=>e))}async signMessage(e){return{signature:await this.signMessageRaw(e),identity:await this.getIdentity(),signType:this.signType}}signMessageRaw(e){throw Error(`Signer.signMessageRaw not implemented`)}async verifyMessage(t,n){return typeof n==`string`?e.verifyMessage(t,{signType:this.signType,signature:n,identity:await this.getIdentity()}):n.identity!==await this.getIdentity()||![`Unknown`,this.signType].includes(n.signType)?!1:e.verifyMessage(t,n)}async sendTransaction(e){return this.client.sendTransaction(await this.signTransaction(e))}async signTransaction(e){let t=await this.prepareTransaction(e);return this.signOnlyTransaction(t)}async prepareTransaction(e){return t.j.from(e)}signOnlyTransaction(e){throw Error(`Signer.signOnlyTransaction not implemented`)}},Di=class extends Q{async sendTransaction(e){let t=await this.signTransaction(e);if(await this.needMoreSignatures(t))throw new Oi(await this.getSignaturesCount(t)??0,await this.getMemberThreshold());return this.client.sendTransaction(t)}},Oi=class extends Error{constructor(e,t){let n=`Not enough signatures: got ${e}, need ${t}`;super(n),this.name=`SignerMultisigNotEnoughSignaturesError`,this.signaturesCount=e,this.threshold=t}},ki=class{constructor(e,t){this.name=e,this.signer=t}},Ai=class extends Q{get type(){return`BTC`}get signType(){return`BtcEcdsa`}async signAndBroadcastPsbt(e,t){let n=await this.signPsbt(e,t);return this.broadcastPsbt(n,t)}async getInternalAddress(){return this.getBtcAccount()}async getIdentity(){return t.Er(await this.getBtcPublicKey()).slice(2)}async getAddressObjs(){let e=ci(await this.getBtcPublicKey());return[await R.fromKnownScript(this.client,`OmniLock`,t.Er([4,...e,0]))]}async prepareTransaction(e){let n=t.j.from(e),{script:r}=await this.getRecommendedAddressObj();return await n.addCellDepsOfKnownScripts(this.client,`OmniLock`),await n.prepareSighashAllWitness(r,85,this.client),n}async signOnlyTransaction(e){let n=t.j.from(e),{script:r}=await this.getRecommendedAddressObj(),i=await n.getSignHashInfo(r,this.client);if(!i)return n;let a=t.ni(await this.signMessageRaw(`CKB (Bitcoin Layer) transaction: ${i.message}`),`base64`);a[0]=31+(a[0]-27)%4;let o=t.M.fromBytes(n.witnesses[i.position]);return o.lock=t.Er(t.$r(t.ur(20+a.length,4),t.ur(16,4),t.ur(20+a.length,4),t.ur(20+a.length,4),t.ur(a.length,4),a)),n.setWitnessArgs(i.position,o),n}},ji=class extends Ai{constructor(e,n,r){super(e),this.account=n,this.publicKey=t.Er(r)}async connect(){}async isConnected(){return!0}async getBtcAccount(){return this.account}async getBtcPublicKey(){return this.publicKey}async signPsbt(e,t){throw Error(`Read-only signer does not support signPsbt`)}async broadcastPsbt(e,t){throw Error(`Read-only signer does not support broadcastPsbt`)}},Mi=class extends Q{get type(){return`CKB`}get signType(){return`Unknown`}constructor(e){super(e)}async connect(){}async isConnected(){return!0}async getInternalAddress(){return this.getRecommendedAddress()}async getAddressObjs(){return[await R.fromKnownScript(this.client,`AlwaysSuccess`,`0x`)]}async prepareTransaction(e){let n=t.j.from(e);return await n.addCellDepsOfKnownScripts(this.client,`AlwaysSuccess`),n}async signOnlyTransaction(e){return t.j.from(e)}},Ni=class extends Q{get type(){return`CKB`}get signType(){return`CkbSecp256k1`}constructor(e,n){if(super(e),this.publicKey=t.Er(n),t.ni(this.publicKey).length!==33)throw Error(`Public key must be 33 bytes!`)}async connect(){}async isConnected(){return!0}async getInternalAddress(){return this.getRecommendedAddress()}async getIdentity(){return this.publicKey}async getAddressObjSecp256k1(){return R.fromKnownScript(this.client,`Secp256k1Blake160`,t.Sr(this.publicKey))}async getRecommendedAddressObj(e){return this.getAddressObjSecp256k1()}async getAddressObjs(){let e=await this.getAddressObjSecp256k1(),n=[],r=0;for await(let i of this.client.findCells({script:await t.K.fromKnownScript(this.client,`AnyoneCanPay`,e.script.args),scriptType:`lock`,scriptSearchMode:`prefix`,withData:!1})){if(r>=10)break;r+=1,!n.some(({script:e})=>e.eq(i.cellOutput.lock))&&n.push(R.from({prefix:this.client.addressPrefix,script:i.cellOutput.lock}))}return[e,...n]}async getRelatedScripts(e){let n=t.j.from(e),r=await this.getAddressObjSecp256k1(),i=await t.K.fromKnownScript(this.client,`AnyoneCanPay`,r.script.args),a=[];for(let e of n.inputs){let{cellOutput:{lock:t}}=await e.getCell(this.client);a.some(({script:e})=>e.eq(t))||(t.eq(r.script)?a.push({script:t,cellDeps:(await this.client.getKnownScript(`Secp256k1Blake160`)).cellDeps}):t.codeHash===i.codeHash&&t.hashType===i.hashType&&t.args.startsWith(i.args)&&a.push({script:t,cellDeps:(await this.client.getKnownScript(`AnyoneCanPay`)).cellDeps}))}return a}async prepareTransaction(e){let n=t.j.from(e);return await Promise.all((await this.getRelatedScripts(n)).map(async({script:e,cellDeps:t})=>{await n.prepareSighashAllWitness(e,65,this.client),await n.addCellDepInfos(this.client,t)})),n}},Pi=class extends Ni{constructor(e,n){let r=t.Er(n);if(t.ni(r).length!==32)throw Error(`Private key must be 32 bytes!`);super(e,cr.getPublicKey(t.ni(r),!0)),this.privateKey=r}async _signMessage(e){return fi(e,this.privateKey)}async signMessageRaw(e){return this._signMessage(hi(e))}async signOnlyTransaction(e){let n=t.j.from(e);for(let{script:e}of await this.getRelatedScripts(n)){let r=await n.getSignHashInfo(e,this.client);if(!r)return n;let i=await this._signMessage(r.message),a=n.getWitnessArgs(r.position)??t.M.from({});a.lock=i,n.setWitnessArgs(r.position,a)}return n}},Fi=class extends Q{get type(){return`CKB`}get signType(){return`Unknown`}constructor(e,...n){if(super(e),this.scripts=n.flat().map(t.K.from),this.scripts.length===0)throw Error(`SignerCkbScriptReadonly requires at least one script.`)}async connect(){}async isConnected(){return!0}async getInternalAddress(){return this.getRecommendedAddress()}async getAddressObjs(){return this.scripts.map(e=>R.fromScript(e,this.client))}},Ii;let $=Ii=class extends t.gr.Base(){constructor(e,t,n,r){super(),this.publicKeyHashes=e,this.threshold=t,this.mustMatch=n,this.signatures=r;let i=e.length;if(t<=0||t>i)throw Error(`threshold should be in range from 1 to public keys length`);if(n<0||n>Math.min(i,t))throw Error(`mustMatch should be in range from 0 to min(public keys length, threshold)`);if(i>255)throw Error(`public keys length should be less than 256`)}static from(e){let n=e.publicKeyHashes?e.publicKeyHashes:e.publicKeys.map(e=>t.Sr(e));return new Ii(n.map(t.Er),Number(t.ir(e.threshold)),Number(t.ir(e.mustMatch??0)),e.signatures?.map(t.Er)??[])}get flexibleThreshold(){return this.threshold-this.mustMatch}scriptArgs(e){let n=t.Sr(Ii.from({...this,signatures:[]}).toBytes());return e==null?t.ni(n):t.$r(n,t.A.from(e).toBytes())}eqInfo(e){let t=Ii.from(e);return this.publicKeyHashes.length===t.publicKeyHashes.length&&this.publicKeyHashes.every((e,n)=>e===t.publicKeyHashes[n])&&this.threshold===t.threshold&&this.mustMatch===t.mustMatch}*generatePublicKeyHashesFromSignatures(e){let n=new Set;for(let r of this.signatures.filter(e=>e!==Li.EmptySignature)){let i=(()=>{try{return mi(e,r)}catch{return}})();if(i===void 0)continue;let a=t.Sr(i);if(n.has(a))continue;let o=this.publicKeyHashes.indexOf(a);o!==-1&&(n.add(a),yield{pubkeyHash:a,signature:r,isRequired:o<this.mustMatch})}}calcMatchedSignaturesCount(e){let t=0,n=0;for(let{isRequired:r}of this.generatePublicKeyHashesFromSignatures(e))r?t+=1:n+=1;return{required:t,flexible:n}}};$=Ii=t.Tt([t._r({encode:e=>{let{publicKeyHashes:n,threshold:r,mustMatch:i,signatures:a}=$.from(e);if(a.some(e=>e.length!==132))throw Error(`MultisigCkbWitness: invalid signature length`);if(n.some(e=>e.length!==42))throw Error(`MultisigCkbWitness: invalid public key hash length`);return t.$r(`0x00`,t.ur(i??0),t.ur(r),t.ur(n.length),...n,...a)},decode:e=>{if(e.length<4)throw Error(`MultisigCkbWitness: data length too short`);let[n,r,i,a,...o]=e;if(o.length<a*20)throw Error(`MultisigCkbWitness: invalid public key hashes length`);let s=o.slice(a*20);return $.from({publicKeyHashes:Array.from(Array(a),(e,n)=>t.Er(o.slice(n*20,(n+1)*20))),threshold:t.ir(i),mustMatch:t.ir(r),signatures:Array.from(Array(Math.floor(s.length/65)),(e,n)=>t.Er(s.slice(n*65,(n+1)*65)))})}})],$);var Li=class e extends Di{static{this.EmptySignature=t.Er(`00`.repeat(65))}get type(){return`CKB`}get signType(){return`Unknown`}constructor(e,n,r){super(e),this.multisigInfo=$.from(n),this.since=t.Et(t.A.from,r?.since);let i=this.multisigInfo.scriptArgs(this.since);this.scriptInfos=Promise.all((r?.scriptInfos??[`Secp256k1MultisigV2`,`Secp256k1MultisigV2Beta`,`Secp256k1Multisig`]).map(async n=>{if(typeof n!=`string`)return t._t.from(n);try{return await e.getKnownScript(n)}catch{return}})).then(e=>e.filter(e=>e!==void 0).map(e=>({script:t.K.from({...e,args:i}),cellDeps:e.cellDeps})))}async getMemberCount(){return this.multisigInfo.publicKeyHashes.length}async getMemberThreshold(){return this.multisigInfo.threshold}async getMemberRequiredCount(){return this.multisigInfo.mustMatch}async connect(){}async isConnected(){return!0}async getInternalAddress(){return this.getRecommendedAddress()}async getAddressObjs(){return(await this.scriptInfos).map(({script:e})=>R.fromScript(e,this.client))}decodeWitnessArgsAt(e,n){let r=t.j.from(e);return this.decodeWitnessArgs(r.getWitnessArgs(n))}decodeWitnessArgs(e){if(!e)return;let n=t.M.from(e);if(n.lock!=null)try{let e=$.decode(n.lock);if(e.eqInfo(this.multisigInfo))return e}catch{}}async prepareWitnessArgsAt(n,r,i){let a=t.j.from(n),o=a.getWitnessArgs(r)??t.M.from({}),s=this.decodeWitnessArgs(o)??this.multisigInfo.clone(),c=$.from(await i?.(s,o)??s);return c.signatures=c.signatures.slice(0,this.multisigInfo.threshold),c.signatures.push(...Array.from(Array(this.multisigInfo.threshold-c.signatures.length),()=>e.EmptySignature)),o.lock=c.toHex(),a.setWitnessArgs(r,o),a}async prepareTransactionOneScript(e,n,r){let i=t.j.from(e),a=await i.findInputIndexByLock(n,this.client);return a===void 0?i:(await i.addCellDepInfos(this.client,r),this.prepareWitnessArgsAt(i,a))}async prepareTransaction(e){return await t.kt(await this.scriptInfos,(e,{script:t,cellDeps:n})=>this.prepareTransactionOneScript(e,t,n),t.j.from(e))}async getSignaturesCount(e){let n=t.j.from(e),r;for(let{script:e}of await this.scriptInfos){let t=await this.getSignInfo(n,e);if(t===void 0)continue;let i=this.decodeWitnessArgsAt(n,t.position);if(!i){r=0;continue}let{required:a,flexible:o}=i.calcMatchedSignaturesCount(t.message);r=Math.min(r??256,a+Math.min(o,this.multisigInfo.flexibleThreshold))}return r}async needMoreSignatures(e){let t=await this.getSignaturesCount(e);return t!=null&&t<await this.getMemberThreshold()}async getSignInfo(n,r){let i=t.j.from(n),a=await i.findInputIndexByLock(r,this.client);if(a==null)return;let o=i.getWitnessArgs(a)??t.M.from({});o.lock=$.from({...this.multisigInfo,signatures:Array.from(Array(this.multisigInfo.threshold),()=>e.EmptySignature)}).toHex();let s=i.clone();return s.setWitnessArgs(a,o),s.getSignHashInfo(r,this.client)}async aggregateTransactions(e){if(e.length===0)throw Error(`No transaction to aggregate`);let n=t.j.from(e[0]);for(let{script:r}of await this.scriptInfos){let i=await this.getSignInfo(n,r);if(i===void 0)continue;let a=new Map,o=0;for(let n of e){let e=t.j.from(n),r=this.decodeWitnessArgsAt(e,i.position);if(r){for(let{pubkeyHash:e,signature:t,isRequired:n}of r.generatePublicKeyHashesFromSignatures(i.message))if(!a.has(e)){if(n)o+=1;else if(a.size-o>=this.multisigInfo.flexibleThreshold)continue;if(a.set(e,t),a.size>=this.multisigInfo.threshold)break}if(a.size>=this.multisigInfo.threshold)break}}n=await this.prepareWitnessArgsAt(n,i.position,e=>{e.signatures=Array.from(a.values())})}return n}},Ri=class extends Li{constructor(e,n,r,i){super(e,r,i),this.privateKey=t.Er(n),this.signer=new Pi(e,this.privateKey)}async signOnlyTransaction(e){let n=t.j.from(e),r=t.Sr(this.signer.publicKey),i=this.multisigInfo.publicKeyHashes.indexOf(r);if(i===-1)return n;let a=i<this.multisigInfo.mustMatch;for(let{script:e}of await this.scriptInfos){let t=await this.getSignInfo(n,e);t&&(n=await this.prepareWitnessArgsAt(n,t.position,async e=>{let n=[],i=0,o=!0;for(let{pubkeyHash:a,signature:s,isRequired:c}of e.generatePublicKeyHashesFromSignatures(t.message)){if(a===r){if(!o)continue;o=!1}if(c)i+=1;else if(n.length-i>=this.multisigInfo.flexibleThreshold)continue;if(n.push(s),n.length>=this.multisigInfo.threshold){o=!1;break}}return o&&(a||n.length-i<this.multisigInfo.flexibleThreshold)&&n.push(fi(t.message,this.privateKey)),e.signatures=n,e}))}return n}},zi=class extends Q{get type(){return`Doge`}get signType(){return`DogeEcdsa`}async getInternalAddress(){return this.getDogeAddress()}async getIdentity(){return this.getDogeAddress()}async getAddressObjs(){let e=ai.decode(await this.getDogeAddress()).subarray(1);return[await R.fromKnownScript(this.client,`OmniLock`,t.Er([5,...e,0]))]}async prepareTransaction(e){let n=t.j.from(e),{script:r}=await this.getRecommendedAddressObj();return await n.addCellDepsOfKnownScripts(this.client,`OmniLock`),await n.prepareSighashAllWitness(r,85,this.client),n}async signOnlyTransaction(e){let n=t.j.from(e),{script:r}=await this.getRecommendedAddressObj(),i=await n.getSignHashInfo(r,this.client);if(!i)return n;let a=t.ni(await this.signMessageRaw(i.message.slice(2)),`base64`);a[0]=31+(a[0]-27)%4;let o=t.M.fromBytes(n.witnesses[i.position]);return o.lock=t.Er(t.$r(t.ur(20+a.length,4),t.ur(16,4),t.ur(20+a.length,4),t.ur(20+a.length,4),t.ur(a.length,4),a)),n.setWitnessArgs(i.position,o),n}},Bi=class extends zi{constructor(e,t){super(e),this.address=t}async connect(){}async isConnected(){return!0}async getDogeAddress(){return this.address}},Vi=class extends zi{constructor(e,n,r=30){if(super(e),this.dogeNetwork=r,this.privateKey=t.ni(n),this.privateKey.length!==32)throw Error(`Private key must be 32 bytes!`)}async connect(){}async isConnected(){return!0}async getDogePublicKey(){return t.Er(cr.getPublicKey(this.privateKey,!0))}async getDogeAddress(){return li(await this.getDogePublicKey(),this.dogeNetwork)}async signMessageRaw(e){let n=typeof e==`string`?e:t.Er(e).slice(2),r=cr.sign(vi(n),this.privateKey,{format:`recovered`,prehash:!1});return t.ri(t.$r([31+Number(r[0])],r.subarray(1)),`base64`)}},Hi=class extends Q{get signType(){return`Unknown`}constructor(e,t){super(e),this.type=t}async isConnected(){return!1}async getInternalAddress(){throw Error(`Can't get address from SignerDummy`)}async getAddressObjs(){throw Error(`Can't get addresses from SignerDummy`)}},Ui=class extends Hi{constructor(e,t,n){super(e,t),this.message=n}async connect(){throw Error(this.message)}},Wi=class extends Hi{constructor(e,t,n){super(e,t),this.link=n}async connect(){window.open(this.link,`_blank`)?.focus()}},Gi=class extends Q{get type(){return`EVM`}get signType(){return`EvmPersonal`}async getInternalAddress(){return this.getEvmAccount()}async getAddressObjs(){let e=await this.getEvmAccount();return(await Promise.all([this._getOmniLockAddresses(e),this._getPWLockAddresses(e)])).flat()}_getOmniLockAddresses(e){return Promise.all([this._getOmniLockEvmAddressObj(e),this._getOmniLockOldEvmAddressObj(e)])}async _getPWLockAddresses(e){let t=await this._getPWLockEvmAddressObj(e);return t?[t]:[]}async _getOmniLockEvmAddressObj(e){return R.fromKnownScript(this.client,`OmniLock`,t.Er([18,...t.ni(e),0]))}async _getOmniLockOldEvmAddressObj(e){return R.fromKnownScript(this.client,`OmniLock`,t.Er([1,...t.ni(e),0]))}async _getPWLockEvmAddressObj(e){try{return R.fromKnownScript(this.client,`PWLock`,t.Er(t.ni(e)))}catch{}}async prepareTransaction(e){let n=t.j.from(e);await n.findInputIndexByLockId(await this.client.getKnownScript(`OmniLock`),this.client)!==void 0&&await n.addCellDepsOfKnownScripts(this.client,`OmniLock`),await n.findInputIndexByLockId(await this.client.getKnownScript(`PWLock`),this.client)!==void 0&&await n.addCellDepsOfKnownScripts(this.client,`PWLock`);let r=await this.getEvmAccount(),i=await this._getOmniLockAddresses(r),a=await this._getPWLockAddresses(r),o=t.kt(i,(e,{script:t})=>e.prepareSighashAllWitness(t,85,this.client),n);return t.kt(a,(e,{script:t})=>e.prepareSighashAllWitness(t,65,this.client),o)}async signOnlyTransaction(e){let n=t.j.from(e),r=await this.getEvmAccount(),{script:i}=await this._getOmniLockEvmAddressObj(r),{script:a}=await this._getOmniLockOldEvmAddressObj(r);n=await this._signOmniLockScriptForTransaction(n,i,e=>`CKB transaction: ${e}`),n=await this._signOmniLockScriptForTransaction(n,a,e=>t.ni(e));let o=await this._getPWLockEvmAddressObj(r);return o&&(n=await this._signPWLockScriptForTransaction(n,o.script,e=>t.ni(e))),n}async _signOmniLockScriptForTransaction(e,n,r){let i=await this._signPersonalEvmForTransaction(e,n,r);if(!i)return e;let a=t.M.fromBytes(e.witnesses[i.position]);return a.lock=t.Er(t.$r(t.ur(20+i.signature.length,4),t.ur(16,4),t.ur(20+i.signature.length,4),t.ur(20+i.signature.length,4),t.ur(i.signature.length,4),i.signature)),e.setWitnessArgs(i.position,a),e}async _signPWLockScriptForTransaction(e,n,r){let i=await this._signPersonalEvmForTransaction(e,n,r,new A);if(!i)return e;let a=t.M.fromBytes(e.witnesses[i.position]);return a.lock=t.Er(i.signature),e.setWitnessArgs(i.position,a),e}async _signPersonalEvmForTransaction(e,n,r,i){let a=await e.getSignHashInfo(n,this.client,i);if(!a)return;let o=t.ni(await this.signMessageRaw(r(a.message)));return o[o.length-1]>=27&&(o[o.length-1]-=27),{signature:o,position:a.position}}},Ki=class extends Gi{constructor(e,n){super(e),this.address=t.Er(n)}async connect(){}async isConnected(){return!0}async getEvmAccount(){return this.address}};function qi(e){if(e===`ckb`)return`ckb-mainnet`;if(e===`ckt`)return`ckb-testnet`;throw Error(`Unsupported address prefix: ${e}`)}const Ji=Symbol(`pending`);let Yi=function(e){return e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.ServerError=-32e3]=`ServerError`,e[e.InvalidState=-32001]=`InvalidState`,e[e.NetworkMismatch=-32002]=`NetworkMismatch`,e[e.UserRejected=-32003]=`UserRejected`,e[e.InvalidSession=-32004]=`InvalidSession`,e[e.DuplicateRequestId=-32005]=`DuplicateRequestId`,e}({});var Xi=class e{constructor(e){this.config=e,this.abortController=new AbortController,this.id=t.Er(t.Kr(16)),this.resultRecords=new Map,this.resultHistory=new Map,this.connected=!1,this.handle=e=>{let t=this.abortController.signal;t.throwIfAborted();let[n,...r]=$i(e),{requestId:i,sessionId:a}=ea(n);if(e.method===`get_result`){let[n]=r;return $i(e,2),ta(n),this.getResult(this.resultRecords.get(n)??this.resultHistory.get(n),t)}if(ta(i),this.resultRecords.has(i)||this.resultHistory.has(i))throw new L({code:-32005,message:`Request ID already exists`});return this.executeRequest(i,async()=>{t.throwIfAborted();let n=e.method===`get_info`;if(n){if(a!==void 0)throw new L({code:-32602,message:`get_info does not accept a session ID`})}else this.requireSession(a);let i=this.handlers.get(e.method);if(!i)throw new L({code:-32601,message:`Unsupported method: ${e.method}`});let[o,s]=i;if($i(e,o+1),!n&&e.method!==`connect`&&!this.connected)throw new L({code:-32001,message:`Connect must be approved before this request`});let c=await s(r,{signal:t});return t.throwIfAborted(),c})},this.handlers=new Map([[`get_info`,[0,()=>this.info??=na(this.id,this.requireSigner(),this.config.getSignerMetadata?.()??{})]],[`connect`,[1,async([e],t)=>{if(this.connected=!1,typeof e!=`string`||!e)throw new L({code:-32602,message:`Invalid network ID`});await this.requireConfirmation({method:`connect`,networkId:e},t);let n=await this.config.connect(e,t);t?.signal?.throwIfAborted();let r=qi(n.client.addressPrefix);if(r!==e)throw new L({code:-32002,message:`Signer uses ${r}, expected ${e}`});return this.connected=!0,null}]],[`get_scripts`,[0,async()=>(await this.requireSigner().getAddressObjs()).map(({script:e})=>t.s.scriptFrom(e))]],[`get_native_address`,[0,()=>this.requireSigner().getInternalAddress()]],[`get_identity`,[0,()=>this.requireSigner().getIdentity()]],[`sign_message`,[1,async([e],n)=>{let r=Zi(e);return await this.requireConfirmation({method:`sign_message`,message:t.t.messageFrom(r)},n),this.requireSigner().signMessageRaw(r)}]],[`prepare_transaction`,[1,async([e])=>t.s.transactionFrom(await this.requireSigner().prepareTransaction(Qi(e)))]],[`sign_transaction`,[1,async([e],n)=>{let r=Qi(e);return await this.requireConfirmation({method:`sign_transaction`,transaction:r},n),t.s.transactionFrom(await this.requireSigner().signOnlyTransaction(r))}]]])}static open(n){let r=new e(n);return new t.Pt(r,e=>e.dispose())}get isConnected(){return this.connected}dispose(){this.connected=!1,this.resultRecords.clear(),this.resultHistory.clear(),this.abortController.abort(new L({code:-32004,message:`Invalid or expired session`}))}requireSession(e){if(e!==this.id)throw new L({code:-32004,message:`Invalid or expired session`})}requireSigner(){let e=this.config.getSigner();if(!e)throw new L({code:-32e3,message:`No signer is connected`});return e}async requireConfirmation(e,t){let n=await this.config.confirmRequest(e,t);if(t?.signal?.throwIfAborted(),!n)throw new L({code:-32003,message:`User rejected request`})}executeRequest(e,t){let n=Promise.resolve().then(t),r={completion:n,retrieved:!1};this.resultRecords.set(e,r);let i=()=>{setTimeout(()=>{this.resultRecords.get(e)===r&&(this.resultRecords.delete(e),this.resultHistory.set(e,r),this.trimResultHistory())},12e4)};return n.then(i,i),n}trimResultHistory(){for(;this.resultHistory.size>128;){let e;for(let[t,n]of this.resultHistory)if(n.retrieved){e=t;break}this.resultHistory.delete(e??this.resultHistory.keys().next().value)}}async getResult(e,n){if(!e)return{status:`not_found`};let r=new AbortController;try{let i=await Promise.race([e.completion.then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e})),t.jt(1e4,n?t.Lt([n,r.signal]):r.signal).then(()=>Ji)]);if(i===Ji)return{status:`pending`};if(e.retrieved=!0,i.status===`rejected`)throw i.reason;return{status:`completed`,result:i.value}}finally{r.abort()}}};function Zi(e){try{return t.t.messageTo(e)}catch(e){throw new L({code:-32602,message:e instanceof Error?e.message:`Invalid signer message`})}}function Qi(e){try{return t.s.transactionTo(e)}catch(e){throw new L({code:-32602,message:e instanceof Error?e.message:`Invalid signer transaction`})}}function $i(e,t){if(!Array.isArray(e.params))throw new L({code:-32602,message:`${e.method} expects positional parameters`});if(t!==void 0&&e.params.length!==t)throw new L({code:-32602,message:`${e.method} expects ${t} parameter${t===1?``:`s`}`});return e.params}function ea(e){if(typeof e!=`object`||!e||`request_id`in e&&typeof e.request_id!=`string`||`session_id`in e&&typeof e.session_id!=`string`)throw new L({code:-32602,message:`Invalid request metadata`});return{requestId:`request_id`in e?e.request_id:void 0,sessionId:`session_id`in e?e.session_id:void 0}}function ta(e){if(typeof e!=`string`||!e)throw new L({code:-32602,message:`Invalid request ID`})}function na(e,n,r){return t.t.infoFrom({sessionId:e,type:n.type,signType:n.signType,name:r.name,icon:r.icon})}const ra=[1e3,2e3,4e3,8e3],ia=[5e3,1e4,2e4];var aa=class e extends Q{constructor(e,n,r,i){super(e),this.requestor=n,this.info=r,this.disconnectHandler=i,this.requestsController=new AbortController,this.replacedListeners=new Set,this.requestConnect=this.buildSender(`connect`,[]),this.signMessageRaw=this.buildSender(`sign_message`,[t.t.messageFrom]),this.prepareTransaction=this.buildSender(`prepare_transaction`,[t.s.transactionFrom],t.s.transactionTo),this.signOnlyTransaction=this.buildSender(`sign_transaction`,[t.s.transactionFrom],t.s.transactionTo)}static async new(n,r){let{disconnectHandler:i,...a}=r,o=se.new(a),s=new e(n,o,{},i);return s.info=await s.request(`get_info`,[],[],t.t.infoTo),s}get type(){return this.info.type}get signType(){return this.info.signType}get name(){return this.info.name}get icon(){return this.info.icon}connect(){if(this.disconnecting)return this.disconnecting.then(()=>this.connect());if(this.connecting)return this.connecting;let e=this.requestConnect(qi(this.client.addressPrefix)).catch(t=>{throw this.connecting===e&&(this.connecting=void 0),t});return this.connecting=e,e}disconnect(){return this.clearReadCache(),this.disconnecting?this.disconnecting:this.connecting?(this.connecting=void 0,this.disconnecting=Promise.resolve().then(()=>this.disconnectHandler?.()).finally(()=>{this.replace(),this.disconnecting=void 0}),this.disconnecting):Promise.resolve()}onReplaced(e){return this.replacedListeners.add(e),()=>this.replacedListeners.delete(e)}replace(){let e=this.requestsController;this.requestsController=new AbortController,e.abort(Error(`Signer JSON-RPC was replaced`)),this.connecting=void 0,this.clearReadCache();let t=[...this.replacedListeners];this.replacedListeners.clear(),t.forEach(e=>e())}async isConnected(){return this.connecting?.then(()=>!0,()=>!1)??!1}getScripts(){if(this.scriptsPromise)return this.scriptsPromise.then(e=>[...e]);let e=this.request(`get_scripts`,[],[],e=>e.map(e=>t.s.scriptTo(e))).catch(t=>{throw this.scriptsPromise===e&&(this.scriptsPromise=void 0),t});return this.scriptsPromise=e,e.then(e=>[...e])}async getAddressObjs(){return(await this.getScripts()).map(e=>R.fromScript(e,this.client))}getInternalAddress(){if(this.internalAddressPromise)return this.internalAddressPromise;let e=this.request(`get_native_address`,[],[]).catch(t=>{throw this.internalAddressPromise===e&&(this.internalAddressPromise=void 0),t});return this.internalAddressPromise=e,e}getIdentity(){if(this.identityPromise)return this.identityPromise;let e=this.request(`get_identity`,[],[]).catch(t=>{throw this.identityPromise===e&&(this.identityPromise=void 0),t});return this.identityPromise=e,e}buildSender(e,t,n){return async(...r)=>this.request(e,r,t,n)}clearReadCache(){this.scriptsPromise=void 0,this.internalAddressPromise=void 0,this.identityPromise=void 0}async request(e,n,r,i){let a=t.Er(t.Kr(16)),o=e===`get_info`?void 0:this.info.sessionId,s=this.requestsController.signal,c=t.At(ia,async({resolve:t,reject:c})=>{try{return t(await this.requestor.request(e,[{request_id:a,...o?{session_id:o}:{}},...n],r?[void 0,...r]:void 0,i,{signal:s,timeout:1e4}))}catch(e){if(e instanceof L)return c(e);throw e}},{signal:s}).catch(e=>{if(s.throwIfAborted(),e instanceof L&&e.code!==-32005)throw e;return this.recoverResult(a,e,s,i)});try{let e=await c;return s.throwIfAborted(),e}catch(e){throw e instanceof L&&e.code===-32004&&this.replace(),e}}async recoverResult(e,n,r,i){return t.At([],async({resolve:a,reject:o,next:s})=>{try{let c=Date.now(),l=await t.At(ra,async({resolve:n,reject:i})=>{await t.Nt(r),c=Date.now();try{return n(await this.requestor.request(`get_result`,[{},e],void 0,void 0,{signal:r,timeout:2e4}))}catch(e){if(e instanceof L)return i(e);throw e}},{repeat:1e4,signal:r});if(r.throwIfAborted(),l.status===`not_found`)return o(n);if(l.status===`pending`){let e=5e3-(Date.now()-c);return e>0&&await t.jt(e,r),s()}return l.status!==`completed`||!(`result`in l)?o(Error(`Invalid signer request result`)):a(i?i(l.result):l.result)}catch(e){return o(e)}},{repeat:0,signal:r})}},oa=class e extends Q{static{this.CKB_SIG_HASH_ALL_TAG=`ckb_sighash_all`}static{this.CKB_UNLOCK_EVENT_KIND=23334}static{this.CKB_UNLOCK_EVENT_CONTENT=`Signing a CKB transaction
|
|
20
|
+
|
|
21
|
+
IMPORTANT: Please verify the integrity and authenticity of connected Nostr client before signing this message
|
|
22
|
+
`}get type(){return`Nostr`}get signType(){return`NostrEvent`}async signNostrEvent(e){throw Error(`SignerNostr.signNostrEvent not implemented`)}async signMessageRaw(e){return t.Er((await this.signNostrEvent(xi(e))).sig)}async getInternalAddress(){return n.bech32.encode(`npub`,n.bech32.toWords(t.ni(await this.getNostrPublicKey())))}async getAddressObjs(){let e=await this.getNostrPublicKey();return[await R.fromKnownScript(this.client,`NostrLock`,t.Er(t.$r([0],t.xr(e).slice(0,42))))]}async prepareTransaction(e){let n=t.j.from(e),{script:r}=await this.getRecommendedAddressObj();return await n.addCellDepsOfKnownScripts(this.client,`NostrLock`),await n.prepareSighashAllWitness(r,572,this.client),n}async signOnlyTransaction(n){let r=t.j.from(n),{script:i}=await this.getRecommendedAddressObj(),a=await r.getSignHashInfo(i,this.client);if(!a)return r;let o=t.ni(JSON.stringify(await this.signNostrEvent({pubkey:(await this.getNostrPublicKey()).slice(2),tags:[[e.CKB_SIG_HASH_ALL_TAG,a.message.slice(2)]],created_at:Math.floor(Date.now()/1e3),kind:e.CKB_UNLOCK_EVENT_KIND,content:e.CKB_UNLOCK_EVENT_CONTENT})),`utf8`),s=t.M.fromBytes(r.witnesses[a.position]);return s.lock=t.Er(o),r.setWitnessArgs(a.position,s),r}},sa=class extends oa{constructor(e,r){if(super(e),typeof r==`string`&&r.startsWith(`npub`)){let{words:e}=n.bech32.decode(r);this.publicKey=t.Er(n.bech32.fromWords(e))}else this.publicKey=t.Er(r)}async connect(){}async isConnected(){return!0}async getNostrPublicKey(){return this.publicKey}},ca=class extends sa{constructor(e,r){let i=(()=>{if(typeof r==`string`&&r.startsWith(`nsec`)){let{words:e}=n.bech32.decode(r);return t.ni(n.bech32.fromWords(e))}return t.ni(r)})();super(e,xr.getPublicKey(i)),this.privateKey=i}async signNostrEvent(e){let n=(await this.getNostrPublicKey()).slice(2),r=Si({...e,pubkey:n}),i=xr.sign(r,this.privateKey);return{...e,id:t.Er(r).slice(2),pubkey:n,sig:t.Er(i).slice(2)}}},la=e.t({Address:()=>R,Bytes:()=>t.Qr,Cell:()=>t.y,CellAny:()=>t.b,CellDep:()=>t.x,CellDepInfo:()=>t.nt,CellDepVec:()=>t.S,CellInput:()=>t.C,CellInputVec:()=>t.w,CellOutput:()=>t.T,CellOutputVec:()=>t.E,Client:()=>re,ClientBlock:()=>t.rt,ClientBlockHeader:()=>t.it,ClientBlockUncle:()=>t.at,ClientCache:()=>I,ClientCacheMemory:()=>ne,ClientIndexerSearchKey:()=>t.ot,ClientIndexerSearchKeyFilter:()=>t.st,ClientIndexerSearchKeyTransaction:()=>t.ct,ClientJsonRpc:()=>ue,ClientPublicMainnet:()=>de,ClientPublicTestnet:()=>fe,ClientTransactionResponse:()=>t.lt,Codec:()=>t.Zr,CodecBool:()=>t.En,CodecByte:()=>t.Dn,CodecByte16:()=>t.On,CodecByte32:()=>t.kn,CodecByte4:()=>t.An,CodecByte8:()=>t.jn,CodecBytes:()=>t.Mn,CodecRaw:()=>t.Nn,CodecUint128:()=>t.Pn,CodecUint128BE:()=>t.Fn,CodecUint128LE:()=>t.In,CodecUint16:()=>t.Ln,CodecUint16BE:()=>t.Rn,CodecUint16LE:()=>t.zn,CodecUint256:()=>t.Bn,CodecUint256BE:()=>t.Vn,CodecUint256LE:()=>t.Hn,CodecUint32:()=>t.Un,CodecUint32BE:()=>t.Wn,CodecUint32LE:()=>t.Gn,CodecUint512:()=>t.Kn,CodecUint512BE:()=>t.qn,CodecUint512LE:()=>t.Jn,CodecUint64:()=>t.Yn,CodecUint64BE:()=>t.Xn,CodecUint64LE:()=>t.Zn,CodecUint8:()=>t.Qn,DepTypeCodec:()=>t.D,Entity:()=>t.gr,Epoch:()=>t.xt,ErrorClientBase:()=>t.ut,ErrorClientDuplicatedTransaction:()=>t.dt,ErrorClientMaxFeeRateExceeded:()=>t.ft,ErrorClientRBFRejected:()=>t.pt,ErrorClientResolveUnknown:()=>t.mt,ErrorClientVerification:()=>t.ht,ErrorClientWaitTransactionTimeout:()=>t.gt,ErrorTransactionInsufficientCapacity:()=>t.B,ErrorTransactionInsufficientCoin:()=>t.V,HASH_CKB_LENGTH:()=>32,HASH_CKB_SHORT_LENGTH:()=>20,HashTypeCodec:()=>t.G,HasherCkb:()=>t.br,HasherKeecak256:()=>A,InputToSign:()=>lt,JsonRpcError:()=>L,JsonRpcTransportFallback:()=>ie,JsonRpcTransportHttp:()=>t.u,JsonRpcTransportWebSocket:()=>t.l,KnownScript:()=>t.tt,MultisigCkbWitness:()=>$,One:()=>t.fr,OutPoint:()=>t.O,Owner:()=>t.Ft,OwnerAggregated:()=>M,OwnerMoved:()=>t.It,OwnerRefCount:()=>N,OwnerUnique:()=>t.Pt,Proxy:()=>P,RawTransaction:()=>t.k,RequestorJsonRpc:()=>se,SECP256K1_SIGNATURE_LENGTH:()=>65,Script:()=>t.K,ScriptInfo:()=>t._t,ScriptOpt:()=>t.q,ScriptVec:()=>t.J,SignPsbtOptions:()=>ct,Signature:()=>Ei,Signer:()=>Q,SignerAlwaysError:()=>Ui,SignerBtc:()=>Ai,SignerBtcPublicKeyReadonly:()=>ji,SignerCkbAlwaysSuccess:()=>Mi,SignerCkbPrivateKey:()=>Pi,SignerCkbPublicKey:()=>Ni,SignerCkbScriptReadonly:()=>Fi,SignerDoge:()=>zi,SignerDogeAddressReadonly:()=>Bi,SignerDogePrivateKey:()=>Vi,SignerDummy:()=>Hi,SignerEvm:()=>Gi,SignerEvmAddressReadonly:()=>Ki,SignerInfo:()=>ki,SignerJsonRpc:()=>aa,SignerJsonRpcErrorCode:()=>Yi,SignerJsonRpcProviderSession:()=>Xi,SignerMultisig:()=>Di,SignerMultisigCkbPrivateKey:()=>Ri,SignerMultisigCkbReadonly:()=>Li,SignerMultisigNotEnoughSignaturesError:()=>Oi,SignerNostr:()=>oa,SignerNostrPrivateKey:()=>ca,SignerNostrPublicKeyReadonly:()=>sa,SignerOpenLink:()=>Wi,SignerSignType:()=>wi,SignerType:()=>Ti,Since:()=>t.A,Transaction:()=>t.j,WitnessArgs:()=>t.M,Zero:()=>t.pr,abortSignalAny:()=>t.Lt,abortSignalToPromise:()=>t.Rt,apply:()=>t.Et,btcEcdsaPublicKeyHash:()=>ci,btcP2pkhAddressFromPublicKey:()=>li,btcPublicKeyFromP2pkhAddress:()=>ui,btcVarLengthBytesFrom:()=>oi,buildNostrEventFromMessage:()=>xi,bytesConcat:()=>t.$r,bytesConcatTo:()=>t.ei,bytesEq:()=>t.ti,bytesFrom:()=>t.ni,bytesLen:()=>t.wr,bytesLenUnsafe:()=>t.Tr,bytesTo:()=>t.ri,calcDaoClaimEpoch:()=>t.N,calcDaoProfit:()=>t.P,codec:()=>t._r,codecPadding:()=>t.$n,codecUint:()=>t.er,codecUintNumber:()=>t.tr,depTypeFrom:()=>t.F,depTypeFromBytes:()=>t.I,depTypeToBytes:()=>t.L,epochFrom:()=>t.St,epochFromHex:()=>t.Ct,epochToHex:()=>t.wt,fixedPointFrom:()=>t.mr,fixedPointToString:()=>t.hr,gcd:()=>t.Dt,hashCkb:()=>t.xr,hashCkbShort:()=>t.Sr,hashTypeFrom:()=>t.Y,hashTypeFromBytes:()=>t.X,hashTypeId:()=>F,hashTypeToBytes:()=>t.Z,hexFrom:()=>t.Er,isDaoOutputLimitExceeded:()=>t.R,isWebview:()=>t.Ot,keystoreDecrypt:()=>st,keystoreEncrypt:()=>ot,messageHashBtcEcdsa:()=>si,messageHashCkbSecp256k1:()=>hi,messageHashDogeEcdsa:()=>vi,mol:()=>j,nostrEventHash:()=>Si,numBeFromBytes:()=>t.nr,numBeToBytes:()=>t.rr,numFrom:()=>t.ir,numFromBytes:()=>t.ar,numLeFromBytes:()=>t.or,numLeToBytes:()=>t.sr,numMax:()=>t.cr,numMin:()=>t.lr,numToBytes:()=>t.ur,numToHex:()=>t.dr,recoverMessageSecp256k1:()=>mi,reduceAsync:()=>t.kt,retry:()=>t.At,signMessageSecp256k1:()=>fi,sleep:()=>t.jt,stringify:()=>t.Mt,udtBalanceFrom:()=>t.z,verifyMessageBtcEcdsa:()=>di,verifyMessageCkbSecp256k1:()=>gi,verifyMessageDogeEcdsa:()=>yi,verifyMessageEvmPersonal:()=>bi,verifyMessageJoyId:()=>_i,verifyMessageNostrEvent:()=>Ci,verifyMessageSecp256k1:()=>pi,waitForAvailability:()=>t.Nt});Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return st}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return wi}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return hi}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return ji}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return ki}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return bi}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return ci}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return fi}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return vi}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return oi}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return li}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return yi}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return xi}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return Si}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Di}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return Ci}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return _i}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return Mi}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Ei}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return gi}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return mi}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return pi}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return di}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return si}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return aa}}),Object.defineProperty(exports,"at",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return Pi}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Ki}}),Object.defineProperty(exports,"ct",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Ui}}),Object.defineProperty(exports,"dt",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Hi}}),Object.defineProperty(exports,"ft",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return Ri}}),Object.defineProperty(exports,"gt",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return zi}}),Object.defineProperty(exports,"ht",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return oa}}),Object.defineProperty(exports,"it",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Ti}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return Oi}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Gi}}),Object.defineProperty(exports,"lt",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Bi}}),Object.defineProperty(exports,"mt",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return ca}}),Object.defineProperty(exports,"nt",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Yi}}),Object.defineProperty(exports,"ot",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Vi}}),Object.defineProperty(exports,"pt",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return ui}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return sa}}),Object.defineProperty(exports,"rt",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Xi}}),Object.defineProperty(exports,"st",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return la}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Wi}}),Object.defineProperty(exports,"ut",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return Li}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Ai}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return Ni}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return Fi}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return 65}});
|
|
23
|
+
//# sourceMappingURL=barrel--PaV2IZx.js.map
|