require(`../_virtual/_rolldown/runtime.cjs`);const e=require(`../functions/utils/bytes32.utils.cjs`);let t=require(`ethers`),n=require(`@noble/curves/secp256k1.js`),r=require(`@noble/hashes/hkdf.js`),i=require(`@noble/hashes/sha2.js`),a=require(`@noble/hashes/utils.js`);var o=(e,t)=>(0,r.hkdf)(i.sha256,n.secp256k1.getSharedSecret(e,t).slice(1,33),void 0,void 0,32),s=(e,t)=>{if(e.length!==t.length)throw Error(`xor: length mismatch`);let n=new Uint8Array(e.length);for(let r=0;r<e.length;r+=1)n[r]=e[r]^t[r];return n},c=async(e,t,n)=>{let r=new Uint8Array(e),i=new Uint8Array(t),a=new Uint8Array(n),o=await crypto.subtle.importKey(`raw`,r,{name:`AES-GCM`},!1,[`encrypt`]);return new Uint8Array(await crypto.subtle.encrypt({name:`AES-GCM`,iv:i},o,a))},l=async(e,t,n)=>{let r=new Uint8Array(e),i=new Uint8Array(t),a=new Uint8Array(n),o=await crypto.subtle.importKey(`raw`,r,{name:`AES-GCM`},!1,[`decrypt`]);return new Uint8Array(await crypto.subtle.decrypt({name:`AES-GCM`,iv:i},o,a))},u=async(r,i,l,u)=>{let d=n.secp256k1.utils.randomSecretKey(),f=BigInt(t.ethers.hexlify(d)),p=t.ethers.hexlify(i.publicKey),m=n.secp256k1.Point.fromHex(p.startsWith(`0x`)?p.slice(2):p).multiply(f),h=t.ethers.getBytes(`0x${m.toHex(!1)}`),g=n.secp256k1.Point.Fn.ORDER,_=BigInt(t.ethers.hexlify(i.privateKey))*f%g,v=new Uint8Array(e.convertBigIntToBytes32(_)),y=o(v,l),b=o(v,u),x=(0,a.randomBytes)(32),S=(0,a.randomBytes)(12),C=await c(x,S,r);return{blindedSenderKey:h,wrapKeyReceiver1:s(x,y),wrapKeyReceiver2:s(x,b),ciphertext:C,nonce:S}},d=async(e,t,n,r,i)=>{let a=await l(s(r,o(t,n)),i,e);return new TextDecoder().decode(a)};exports.decryptDualPath=d,exports.encryptDualPath=u;