hsynchronous
Version:
Hybrid synchronous encryption protocol using NIST approved post-quantum algorithms.
4 lines • 40.6 kB
JavaScript
(function(exports,crypto){'use strict';var Ue=Object.create;var ce=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols,Ye=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable;var Se=r=>{throw TypeError(r)};var Ee=(r,e,t)=>e in r?ce(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,H=(r,e)=>{for(var t in e||(e={}))ge.call(e,t)&&Ee(r,t,e[t]);if(_e)for(var t of _e(e))Ze.call(e,t)&&Ee(r,t,e[t]);return r};var T=(r=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(r,{get:(e,t)=>(typeof require!="undefined"?require:e)[t]}):r)(function(r){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var U=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Xe=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ge(e))!ge.call(r,o)&&o!==t&&ce(r,o,{get:()=>e[o],enumerable:!(s=Ve(e,o))||s.enumerable});return r};var Je=(r,e,t)=>(t=r!=null?Ue(Ye(r)):{},Xe(!r||!r.__esModule?ce(t,"default",{value:r,enumerable:true}):t,r));var le=(r,e,t)=>e.has(r)||Se("Cannot "+t);var c=(r,e,t)=>(le(r,e,"read from private field"),t?t.call(r):e.get(r)),F=(r,e,t)=>e.has(r)?Se("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),K=(r,e,t,s)=>(le(r,e,"write to private field"),e.set(r,t),t);var x=(r,e,t,s)=>({set _(o){K(r,e,o);},get _(){return c(r,e,s)}});var $=(r,e,t)=>new Promise((s,o)=>{var p=a=>{try{f(t.next(a));}catch(u){o(u);}},y=a=>{try{f(t.throw(a));}catch(u){o(u);}},f=a=>a.done?s(a.value):Promise.resolve(a.value).then(p,y);f((t=t.apply(r,e)).next());});var Le=U((Cr,me)=>{me.exports.backend="prefer-native";});var Ce=U((hr,Ae)=>{var J=T("path").sep||"/";Ae.exports=er;function er(r){if(typeof r!="string"||r.length<=7||r.substring(0,7)!="file://")throw new TypeError("must pass in a file:// URI to convert to a file path");var e=decodeURI(r.substring(7)),t=e.indexOf("/"),s=e.substring(0,t),o=e.substring(t+1);return s=="localhost"&&(s=""),s&&(s=J+J+s),o=o.replace(/^(.+)\|/,"$1:"),J=="\\"&&(o=o.replace(/\//g,"\\")),/^.+\:/.test(o)||(o=J+o),s+o}});var de=U((G,Pe)=>{var ae=T("fs"),re=T("path"),rr=Ce(),ee=re.join,tr=re.dirname,he=ae.accessSync&&function(r){try{ae.accessSync(r);}catch(e){return false}return true}||ae.existsSync||re.existsSync,Ne={arrow:process.env.NODE_BINDINGS_ARROW||" \u2192 ",compiled:process.env.NODE_BINDINGS_COMPILED_DIR||"compiled",platform:process.platform,arch:process.arch,nodePreGyp:"node-v"+process.versions.modules+"-"+process.platform+"-"+process.arch,version:process.versions.node,bindings:"bindings.node",try:[["module_root","build","bindings"],["module_root","build","Debug","bindings"],["module_root","build","Release","bindings"],["module_root","out","Debug","bindings"],["module_root","Debug","bindings"],["module_root","out","Release","bindings"],["module_root","Release","bindings"],["module_root","build","default","bindings"],["module_root","compiled","version","platform","arch","bindings"],["module_root","addon-build","release","install-root","bindings"],["module_root","addon-build","debug","install-root","bindings"],["module_root","addon-build","default","install-root","bindings"],["module_root","lib","binding","nodePreGyp","bindings"]]};function ir(r){typeof r=="string"?r={bindings:r}:r||(r={}),Object.keys(Ne).map(function(a){a in r||(r[a]=Ne[a]);}),r.module_root||(r.module_root=G.getRoot(G.getFileName())),re.extname(r.bindings)!=".node"&&(r.bindings+=".node");for(var e=typeof __webpack_require__=="function"?__non_webpack_require__:T,t=[],s=0,o=r.try.length,p,y,f;s<o;s++){p=ee.apply(null,r.try[s].map(function(a){return r[a]||a})),t.push(p);try{return y=r.path?e.resolve(p):e(p),r.path||(y.path=p),y}catch(a){if(a.code!=="MODULE_NOT_FOUND"&&a.code!=="QUALIFIED_PATH_RESOLUTION_FAILED"&&!/not find/i.test(a.message))throw a}}throw f=new Error(`Could not locate the bindings file. Tried:
`+t.map(function(a){return r.arrow+a}).join(`
`)),f.tries=t,f}Pe.exports=G=ir;G.getFileName=function(e){var t=Error.prepareStackTrace,s=Error.stackTraceLimit,o={},p;Error.stackTraceLimit=10,Error.prepareStackTrace=function(f,a){for(var u=0,_=a.length;u<_;u++)if(p=a[u].getFileName(),p!==__filename)if(e){if(p!==e)return}else return},Error.captureStackTrace(o),o.stack,Error.prepareStackTrace=t,Error.stackTraceLimit=s;var y="file://";return p.indexOf(y)===0&&(p=rr(p)),p};G.getRoot=function(e){for(var t=tr(e),s;;){if(t==="."&&(t=process.cwd()),he(ee(t,"package.json"))||he(ee(t,"node_modules")))return t;if(s===t)throw new Error('Could not find module root given file: "'+e+'". Do you have a `package.json` file? ');s=t,t=ee(t,"..");}};});var be=U((Pr,nr)=>{nr.exports={kem:[{properties:{name:"hqc-128",description:"HQC-128",publicKeySize:2249,privateKeySize:2305,keySize:64,encryptedKeySize:4433},functions:{keypair:"PQCLEAN_HQC128_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_HQC128_CLEAN_crypto_kem_enc",dec:"PQCLEAN_HQC128_CLEAN_crypto_kem_dec"}},{properties:{name:"hqc-192",description:"HQC-192",publicKeySize:4522,privateKeySize:4586,keySize:64,encryptedKeySize:8978},functions:{keypair:"PQCLEAN_HQC192_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_HQC192_CLEAN_crypto_kem_enc",dec:"PQCLEAN_HQC192_CLEAN_crypto_kem_dec"}},{properties:{name:"hqc-256",description:"HQC-256",publicKeySize:7245,privateKeySize:7317,keySize:64,encryptedKeySize:14421},functions:{keypair:"PQCLEAN_HQC256_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_HQC256_CLEAN_crypto_kem_enc",dec:"PQCLEAN_HQC256_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece348864",description:"Classic McEliece 348864",publicKeySize:261120,privateKeySize:6492,keySize:32,encryptedKeySize:96},functions:{keypair:"PQCLEAN_MCELIECE348864_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE348864_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE348864_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece348864f",description:"Classic McEliece 348864",publicKeySize:261120,privateKeySize:6492,keySize:32,encryptedKeySize:96},functions:{keypair:"PQCLEAN_MCELIECE348864F_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE348864F_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE348864F_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece460896",description:"Classic McEliece 460896",publicKeySize:524160,privateKeySize:13608,keySize:32,encryptedKeySize:156},functions:{keypair:"PQCLEAN_MCELIECE460896_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE460896_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE460896_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece460896f",description:"Classic McEliece 460896",publicKeySize:524160,privateKeySize:13608,keySize:32,encryptedKeySize:156},functions:{keypair:"PQCLEAN_MCELIECE460896F_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE460896F_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE460896F_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece6688128",description:"Classic McEliece 6688128",publicKeySize:1044992,privateKeySize:13932,keySize:32,encryptedKeySize:208},functions:{keypair:"PQCLEAN_MCELIECE6688128_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE6688128_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE6688128_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece6688128f",description:"Classic McEliece 6688128",publicKeySize:1044992,privateKeySize:13932,keySize:32,encryptedKeySize:208},functions:{keypair:"PQCLEAN_MCELIECE6688128F_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE6688128F_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE6688128F_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece6960119",description:"Classic McEliece 6960119",publicKeySize:1047319,privateKeySize:13948,keySize:32,encryptedKeySize:194},functions:{keypair:"PQCLEAN_MCELIECE6960119_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE6960119_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE6960119_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece6960119f",description:"Classic McEliece 6960119",publicKeySize:1047319,privateKeySize:13948,keySize:32,encryptedKeySize:194},functions:{keypair:"PQCLEAN_MCELIECE6960119F_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE6960119F_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE6960119F_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece8192128",description:"Classic McEliece 8192128",publicKeySize:1357824,privateKeySize:14120,keySize:32,encryptedKeySize:208},functions:{keypair:"PQCLEAN_MCELIECE8192128_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE8192128_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE8192128_CLEAN_crypto_kem_dec"}},{properties:{name:"mceliece8192128f",description:"Classic McEliece 8192128",publicKeySize:1357824,privateKeySize:14120,keySize:32,encryptedKeySize:208},functions:{keypair:"PQCLEAN_MCELIECE8192128F_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MCELIECE8192128F_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MCELIECE8192128F_CLEAN_crypto_kem_dec"}},{properties:{name:"ml-kem-1024",description:"ML-KEM-1024",publicKeySize:1568,privateKeySize:3168,keySize:32,encryptedKeySize:1568},functions:{keypair:"PQCLEAN_MLKEM1024_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MLKEM1024_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MLKEM1024_CLEAN_crypto_kem_dec"}},{properties:{name:"ml-kem-512",description:"ML-KEM-512",publicKeySize:800,privateKeySize:1632,keySize:32,encryptedKeySize:768},functions:{keypair:"PQCLEAN_MLKEM512_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MLKEM512_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MLKEM512_CLEAN_crypto_kem_dec"}},{properties:{name:"ml-kem-768",description:"ML-KEM-768",publicKeySize:1184,privateKeySize:2400,keySize:32,encryptedKeySize:1088},functions:{keypair:"PQCLEAN_MLKEM768_CLEAN_crypto_kem_keypair",enc:"PQCLEAN_MLKEM768_CLEAN_crypto_kem_enc",dec:"PQCLEAN_MLKEM768_CLEAN_crypto_kem_dec"}}],sign:[{properties:{name:"falcon-1024",description:"Falcon-1024",publicKeySize:1793,privateKeySize:2305,signatureSize:1462},functions:{keypair:"PQCLEAN_FALCON1024_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_FALCON1024_CLEAN_crypto_sign_signature",sign:"PQCLEAN_FALCON1024_CLEAN_crypto_sign",verify:"PQCLEAN_FALCON1024_CLEAN_crypto_sign_verify",open:"PQCLEAN_FALCON1024_CLEAN_crypto_sign_open"}},{properties:{name:"falcon-512",description:"Falcon-512",publicKeySize:897,privateKeySize:1281,signatureSize:752},functions:{keypair:"PQCLEAN_FALCON512_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_FALCON512_CLEAN_crypto_sign_signature",sign:"PQCLEAN_FALCON512_CLEAN_crypto_sign",verify:"PQCLEAN_FALCON512_CLEAN_crypto_sign_verify",open:"PQCLEAN_FALCON512_CLEAN_crypto_sign_open"}},{properties:{name:"falcon-padded-1024",description:"Falcon-padded-1024",publicKeySize:1793,privateKeySize:2305,signatureSize:1280},functions:{keypair:"PQCLEAN_FALCONPADDED1024_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_FALCONPADDED1024_CLEAN_crypto_sign_signature",sign:"PQCLEAN_FALCONPADDED1024_CLEAN_crypto_sign",verify:"PQCLEAN_FALCONPADDED1024_CLEAN_crypto_sign_verify",open:"PQCLEAN_FALCONPADDED1024_CLEAN_crypto_sign_open"}},{properties:{name:"falcon-padded-512",description:"Falcon-padded-512",publicKeySize:897,privateKeySize:1281,signatureSize:666},functions:{keypair:"PQCLEAN_FALCONPADDED512_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_FALCONPADDED512_CLEAN_crypto_sign_signature",sign:"PQCLEAN_FALCONPADDED512_CLEAN_crypto_sign",verify:"PQCLEAN_FALCONPADDED512_CLEAN_crypto_sign_verify",open:"PQCLEAN_FALCONPADDED512_CLEAN_crypto_sign_open"}},{properties:{name:"ml-dsa-44",description:"ML-DSA-44",publicKeySize:1312,privateKeySize:2560,signatureSize:2420},functions:{keypair:"PQCLEAN_MLDSA44_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_MLDSA44_CLEAN_crypto_sign_signature",sign:"PQCLEAN_MLDSA44_CLEAN_crypto_sign",verify:"PQCLEAN_MLDSA44_CLEAN_crypto_sign_verify",open:"PQCLEAN_MLDSA44_CLEAN_crypto_sign_open"}},{properties:{name:"ml-dsa-65",description:"ML-DSA-65",publicKeySize:1952,privateKeySize:4032,signatureSize:3309},functions:{keypair:"PQCLEAN_MLDSA65_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_MLDSA65_CLEAN_crypto_sign_signature",sign:"PQCLEAN_MLDSA65_CLEAN_crypto_sign",verify:"PQCLEAN_MLDSA65_CLEAN_crypto_sign_verify",open:"PQCLEAN_MLDSA65_CLEAN_crypto_sign_open"}},{properties:{name:"ml-dsa-87",description:"ML-DSA-87",publicKeySize:2592,privateKeySize:4896,signatureSize:4627},functions:{keypair:"PQCLEAN_MLDSA87_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_MLDSA87_CLEAN_crypto_sign_signature",sign:"PQCLEAN_MLDSA87_CLEAN_crypto_sign",verify:"PQCLEAN_MLDSA87_CLEAN_crypto_sign_verify",open:"PQCLEAN_MLDSA87_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-sha2-128f-simple",description:"SPHINCS+-sha2-128f-simple",publicKeySize:32,privateKeySize:64,signatureSize:17088},functions:{keypair:"PQCLEAN_SPHINCSSHA2128FSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHA2128FSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHA2128FSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHA2128FSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHA2128FSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-sha2-128s-simple",description:"SPHINCS+-sha2-128s-simple",publicKeySize:32,privateKeySize:64,signatureSize:7856},functions:{keypair:"PQCLEAN_SPHINCSSHA2128SSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHA2128SSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHA2128SSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHA2128SSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHA2128SSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-sha2-192f-simple",description:"SPHINCS+-sha2-192f-simple",publicKeySize:48,privateKeySize:96,signatureSize:35664},functions:{keypair:"PQCLEAN_SPHINCSSHA2192FSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHA2192FSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHA2192FSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHA2192FSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHA2192FSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-sha2-192s-simple",description:"SPHINCS+-sha2-192s-simple",publicKeySize:48,privateKeySize:96,signatureSize:16224},functions:{keypair:"PQCLEAN_SPHINCSSHA2192SSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHA2192SSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHA2192SSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHA2192SSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHA2192SSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-sha2-256f-simple",description:"SPHINCS+-sha2-256f-simple",publicKeySize:64,privateKeySize:128,signatureSize:49856},functions:{keypair:"PQCLEAN_SPHINCSSHA2256FSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHA2256FSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHA2256FSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHA2256FSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHA2256FSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-sha2-256s-simple",description:"SPHINCS+-sha2-256s-simple",publicKeySize:64,privateKeySize:128,signatureSize:29792},functions:{keypair:"PQCLEAN_SPHINCSSHA2256SSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHA2256SSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHA2256SSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHA2256SSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHA2256SSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-shake-128f-simple",description:"SPHINCS+-shake-128f-simple",publicKeySize:32,privateKeySize:64,signatureSize:17088},functions:{keypair:"PQCLEAN_SPHINCSSHAKE128FSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHAKE128FSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHAKE128FSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHAKE128FSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHAKE128FSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-shake-128s-simple",description:"SPHINCS+-shake-128s-simple",publicKeySize:32,privateKeySize:64,signatureSize:7856},functions:{keypair:"PQCLEAN_SPHINCSSHAKE128SSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHAKE128SSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHAKE128SSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHAKE128SSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHAKE128SSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-shake-192f-simple",description:"SPHINCS+-shake-192f-simple",publicKeySize:48,privateKeySize:96,signatureSize:35664},functions:{keypair:"PQCLEAN_SPHINCSSHAKE192FSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHAKE192FSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHAKE192FSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHAKE192FSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHAKE192FSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-shake-192s-simple",description:"SPHINCS+-shake-192s-simple",publicKeySize:48,privateKeySize:96,signatureSize:16224},functions:{keypair:"PQCLEAN_SPHINCSSHAKE192SSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHAKE192SSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHAKE192SSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHAKE192SSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHAKE192SSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-shake-256f-simple",description:"SPHINCS+-shake-256f-simple",publicKeySize:64,privateKeySize:128,signatureSize:49856},functions:{keypair:"PQCLEAN_SPHINCSSHAKE256FSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHAKE256FSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHAKE256FSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHAKE256FSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHAKE256FSIMPLE_CLEAN_crypto_sign_open"}},{properties:{name:"sphincs-shake-256s-simple",description:"SPHINCS+-shake-256s-simple",publicKeySize:64,privateKeySize:128,signatureSize:29792},functions:{keypair:"PQCLEAN_SPHINCSSHAKE256SSIMPLE_CLEAN_crypto_sign_keypair",signature:"PQCLEAN_SPHINCSSHAKE256SSIMPLE_CLEAN_crypto_sign_signature",sign:"PQCLEAN_SPHINCSSHAKE256SSIMPLE_CLEAN_crypto_sign",verify:"PQCLEAN_SPHINCSSHAKE256SSIMPLE_CLEAN_crypto_sign_verify",open:"PQCLEAN_SPHINCSSHAKE256SSIMPLE_CLEAN_crypto_sign_open"}}]};});var we=U((dr,Ke)=>{Ke.exports.init=(r,e)=>{var d,h,w,k,N,M,b,I;let t=E=>({properties:{name:i}})=>i===E,s=(()=>{if(typeof navigator=="object"&&navigator.hardwareConcurrency)return navigator.hardwareConcurrency;if(typeof T=="function"){let E=T("os");return typeof E.availableParallelism=="function"?E.availableParallelism():E.cpus().length}else return 2})(),o=0,p=[],y=[];function f(E){let i=y.shift();i?a(E,i.task,i.resolve,i.reject):(p.push(E),typeof E.unref=="function"?E.unref():p.length===o&&setTimeout(()=>{if(p.length===o){o=0;for(let n of p.splice(0))n.terminate();}},0));}function a(E,i,n,g){typeof E.ref=="function"&&E.ref();let l=typeof E.addEventListener=="function";E[l?"addEventListener":"once"]("message",function L(C){l&&E.removeEventListener("message",L),f(E),C=C.data||C,C.memoryAllocationFailed?g(new Error("Memory allocation failed")):n(C);}),E.postMessage(i);}function u(E){return new Promise((i,n)=>{let g=p.shift();g!==void 0?a(g,E,i,n):y.push({task:E,resolve:i,reject:n})>o**2&&o<s&&(o++,e().then(L=>{f(L);},L=>{if(!--o)for(let{reject:C}of y.splice(0))C(L);}));})}let _=Symbol();class S{constructor(i,n){F(this,d);F(this,h);if(arguments.length===1&&typeof i=="object"&&_ in i){[x(this,d)._,x(this,h)._]=i[_];return}if(arguments.length!==2)throw new TypeError("Wrong number of arguments");if(typeof i!="string")throw new TypeError("First argument must be a string");if(n instanceof ArrayBuffer)K(this,h,n.slice(0));else if(ArrayBuffer.isView(n))K(this,h,n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));else throw new TypeError("Second argument must be a BufferSource");if(K(this,d,r.kem.find(t(i)))==null)throw new Error("No such implementation");if(c(this,h).byteLength!==c(this,d).properties.publicKeySize)throw new Error("Invalid public key size")}get algorithm(){return H({},c(this,d).properties)}export(){return c(this,h).slice(0)}generateKey(){if(arguments.length!==0)throw new TypeError("Wrong number of arguments");let{keySize:i,encryptedKeySize:n}=c(this,d).properties;return u({fn:c(this,d).functions.enc,inputs:[c(this,h)],outputs:[{type:"ArrayBuffer",byteLength:n},{type:"ArrayBuffer",byteLength:i}]}).then(({result:g,outputs:l})=>g!==0?Promise.reject(new Error("Encapsulation failed")):Promise.resolve({key:l[1],encryptedKey:l[0]}))}}d=new WeakMap,h=new WeakMap;class m{constructor(i,n){F(this,w);F(this,k);if(arguments.length===1&&typeof i=="object"&&_ in i){[x(this,w)._,x(this,k)._]=i[_];return}if(arguments.length!==2)throw new TypeError("Wrong number of arguments");if(typeof i!="string")throw new TypeError("First argument must be a string");if(n instanceof ArrayBuffer)K(this,k,n.slice(0));else if(ArrayBuffer.isView(n))K(this,k,n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));else throw new TypeError("Second argument must be a BufferSource");if(K(this,w,r.kem.find(t(i)))==null)throw new Error("No such implementation");if(c(this,k).byteLength!==c(this,w).properties.privateKeySize)throw new Error("Invalid private key size")}get algorithm(){return H({},c(this,w).properties)}export(){return c(this,k).slice(0)}decryptKey(i){if(arguments.length!==1)throw new TypeError("Wrong number of arguments");let n;if(i instanceof ArrayBuffer)n=i.slice();else if(ArrayBuffer.isView(i))n=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);else throw new TypeError("First argument must be a BufferSource");let{keySize:g,encryptedKeySize:l}=c(this,w).properties;if(n.byteLength!==l)throw new Error("Invalid ciphertext size");return u({fn:c(this,w).functions.dec,inputs:[n,c(this,k)],outputs:[{type:"ArrayBuffer",byteLength:g}]}).then(({result:L,outputs:C})=>L!==0?Promise.reject(new Error("Decryption failed")):Promise.resolve(C[0]))}}w=new WeakMap,k=new WeakMap;function A(E){if(arguments.length!==1)throw new TypeError("Wrong number of arguments");if(typeof E!="string")throw new TypeError("First argument must be a string");let i=r.kem.find(t(E));if(i==null)throw new Error("No such implementation");let{publicKeySize:n,privateKeySize:g}=i.properties;return u({fn:i.functions.keypair,inputs:[],outputs:[{type:"ArrayBuffer",byteLength:n},{type:"ArrayBuffer",byteLength:g}]}).then(({result:l,outputs:L})=>l!==0?Promise.reject(new Error("Failed to generate keypair")):Promise.resolve({publicKey:new S({[_]:[i,L[0]]}),privateKey:new m({[_]:[i,L[1]]})}))}class P{constructor(i,n){F(this,N);F(this,M);if(arguments.length===1&&typeof i=="object"&&_ in i){[x(this,N)._,x(this,M)._]=i[_];return}if(arguments.length!==2)throw new TypeError("Wrong number of arguments");if(typeof i!="string")throw new TypeError("First argument must be a string");if(n instanceof ArrayBuffer)K(this,M,n.slice(0));else if(ArrayBuffer.isView(n))K(this,M,n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));else throw new TypeError("Second argument must be a BufferSource");if(K(this,N,r.sign.find(t(i)))==null)throw new Error("No such implementation");if(c(this,M).byteLength!==c(this,N).properties.publicKeySize)throw new Error("Invalid public key size")}get algorithm(){return H({},c(this,N).properties)}export(){return c(this,M).slice(0)}verify(i,n){if(arguments.length!==2)throw new TypeError("Wrong number of arguments");let g;if(i instanceof ArrayBuffer)g=i.slice();else if(ArrayBuffer.isView(i))g=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);else throw new TypeError("First argument must be a BufferSource");let l;if(n instanceof ArrayBuffer)l=n.slice();else if(ArrayBuffer.isView(n))l=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength);else throw new TypeError("Second argument must be a BufferSource");let{signatureSize:L}=c(this,N).properties;if(l.byteLength>L)throw new Error("Invalid signature size");return u({fn:c(this,N).functions.verify,inputs:[l,l.byteLength,g,g.byteLength,c(this,M)],outputs:[]}).then(({result:C})=>Promise.resolve(C===0))}open(i){if(arguments.length!==1)throw new TypeError("Wrong number of arguments");let n;if(i instanceof ArrayBuffer)n=i.slice();else if(ArrayBuffer.isView(i))n=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);else throw new TypeError("First argument must be a BufferSource");let g=n.byteLength;return u({fn:c(this,N).functions.open,inputs:[n,g,c(this,M)],outputs:[{type:"ArrayBuffer",byteLength:g},{type:"u32",init:g}]}).then(({result:l,outputs:L})=>{if(l!==0)return Promise.reject(new Error("Open operation failed"));{let C=L[1];return Promise.resolve(L[0].slice(0,C))}})}}N=new WeakMap,M=new WeakMap;class z{constructor(i,n){F(this,b);F(this,I);if(arguments.length===1&&typeof i=="object"&&_ in i){[x(this,b)._,x(this,I)._]=i[_];return}if(arguments.length!==2)throw new TypeError("Wrong number of arguments");if(typeof i!="string")throw new TypeError("First argument must be a string");if(n instanceof ArrayBuffer)K(this,I,n.slice(0));else if(ArrayBuffer.isView(n))K(this,I,n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength));else throw new TypeError("Second argument must be a BufferSource");if(K(this,b,r.sign.find(t(i)))==null)throw new Error("No such implementation");if(c(this,I).byteLength!==c(this,b).properties.privateKeySize)throw new Error("Invalid private key size")}get algorithm(){return H({},c(this,b).properties)}export(){return c(this,I).slice(0)}sign(i){if(arguments.length!==1)throw new TypeError("Wrong number of arguments");let n;if(i instanceof ArrayBuffer)n=i.slice();else if(ArrayBuffer.isView(i))n=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);else throw new TypeError("First argument must be a BufferSource");let{signatureSize:g}=c(this,b).properties,l=n.byteLength;return u({fn:c(this,b).functions.signature,inputs:[n,l,c(this,I)],outputs:[{type:"ArrayBuffer",byteLength:g},{type:"u32",init:g}]}).then(({result:L,outputs:C})=>{if(L!==0)return Promise.reject(new Error("Sign operation failed"));{let V=C[1];return V>g?Promise.reject(new Error(`Actual signature size (${V}) exceeds maximum size (${g}).`)):Promise.resolve(C[0].slice(0,V))}})}signEmbed(i){if(arguments.length!==1)throw new TypeError("Wrong number of arguments");let n;if(i instanceof ArrayBuffer)n=i.slice();else if(ArrayBuffer.isView(i))n=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);else throw new TypeError("First argument must be a BufferSource");let{signatureSize:g}=c(this,b).properties,l=n.byteLength,L=l+g;return u({fn:c(this,b).functions.sign,inputs:[n,l,c(this,I)],outputs:[{type:"ArrayBuffer",byteLength:L},{type:"u32",init:L}]}).then(({result:C,outputs:V})=>{if(C!==0)return Promise.reject(new Error("Sign operation failed"));{let qe=V[1];return Promise.resolve(V[0].slice(0,qe))}})}}b=new WeakMap,I=new WeakMap;function O(E){if(arguments.length!==1)throw new TypeError("Wrong number of arguments");if(typeof E!="string")throw new TypeError("First argument must be a string");let i=r.sign.find(t(E));if(i==null)throw new Error("No such implementation");let{publicKeySize:n,privateKeySize:g}=i.properties;return u({fn:i.functions.keypair,inputs:[],outputs:[{type:"ArrayBuffer",byteLength:n},{type:"ArrayBuffer",byteLength:g}]}).then(({result:l,outputs:L})=>l!==0?Promise.reject(new Error("Failed to generate keypair")):Promise.resolve({publicKey:new P({[_]:[i,L[0]]}),privateKey:new z({[_]:[i,L[1]]})}))}return {kem:Object.defineProperties({},{PublicKey:{value:S},PrivateKey:{value:m},generateKeyPair:{value:A},supportedAlgorithms:{value:r.kem.map(({properties:E})=>H({},E))}}),sign:Object.defineProperties({},{PublicKey:{value:P},PrivateKey:{value:z},generateKeyPair:{value:O},supportedAlgorithms:{value:r.sign.map(({properties:E})=>H({},E))}})}};});var ke=U((ze,pe)=>{var{randomFillSync:sr}=T("crypto"),or=T("events"),{readFileSync:cr}=T("fs"),{Worker:ar}=T("worker_threads"),Z=be(),Ie=new WebAssembly.Module(cr(`${__dirname}/gen/pqclean.wasm`)),W=new WebAssembly.Instance(Ie,{env:{PQCLEAN_randombytes(r,e){sr(Y(),r,e);}},wasi_snapshot_preview1:{proc_exit(){throw new Error(`WebAssembly code requested exit through WASI (${[...arguments]})`)}}}),Y=()=>Buffer.from(W.exports.memory.buffer),j=(r,e)=>Y().set(e,r),R=(r,e)=>Uint8Array.prototype.slice.call(Y(),r,r+e),pr=(r,e)=>Y().writeUInt32LE(e,r),ur=r=>Y().readUInt32LE(r);function D(r,e){let t=W.exports.malloc(r);if(t===0)throw new Error("WebAssembly memory allocation failed");function s(o){let p=false;function y(){return p=true,s}try{return o(t,y)}finally{p||(Y().fill(0,t,t+r),W.exports.free(t));}}return s(e)}var ve=r=>({properties:{name:e}})=>e===r,v,te=class{constructor(e){F(this,v);if(arguments.length!==1)throw new TypeError("Wrong number of arguments");if(typeof e!="string")throw new TypeError("First argument must be a string");if(K(this,v,Z.kem.find(ve(e)))==null)throw new Error("No such implementation")}get algorithm(){return c(this,v).properties.name}get description(){return c(this,v).properties.description}get publicKeySize(){return c(this,v).properties.publicKeySize}get privateKeySize(){return c(this,v).properties.privateKeySize}get keySize(){return c(this,v).properties.keySize}get encryptedKeySize(){return c(this,v).properties.encryptedKeySize}keypair(e){if(arguments.length>1)throw new TypeError("Wrong number of arguments");if(arguments.length===1){if(typeof e!="function")throw new TypeError("First argument must be a function");setImmediate(()=>{let t;try{t=this.keypair();}catch(s){e(s);return}e(void 0,t);});}else {let{privateKeySize:t,publicKeySize:s}=c(this,v).properties;return D(t+s,o=>{let p=o,y=o+t;if(W.exports[c(this,v).functions.keypair](y,p)!==0)throw new Error("Failed to generate keypair");let a=R(y,s),u=R(p,t);return {publicKey:a,privateKey:u}})}}generateKey(e,t){let{publicKeySize:s,keySize:o,encryptedKeySize:p}=c(this,v).properties;if(arguments.length!==1&&arguments.length!==2)throw new TypeError("Wrong number of arguments");if(!ArrayBuffer.isView(e))throw new TypeError("First argument must be a TypedArray");if(e.byteLength!==s)throw new TypeError("Invalid public key size");return D(s,(y,f)=>{j(y,e);let a=()=>D(o+p,u=>{let _=u,S=u+o;if(W.exports[c(this,v).functions.enc](S,_,y)!==0)throw new Error("Encapsulation failed");let A=R(_,o),P=R(S,p);return {key:A,encryptedKey:P}});if(arguments.length===2){if(typeof t!="function")throw new TypeError("Second argument must be a function");let u=f();setImmediate(()=>{let _;try{_=u(()=>a());}catch(S){t(S);return}t(void 0,_);});}else return a()})}decryptKey(e,t,s){let{privateKeySize:o,keySize:p,encryptedKeySize:y}=c(this,v).properties;if(arguments.length!==2&&arguments.length!==3)throw new TypeError("Wrong number of arguments");if(!ArrayBuffer.isView(e))throw new TypeError("First argument must be a TypedArray");if(e.byteLength!==o)throw new TypeError("Invalid private key size");if(!ArrayBuffer.isView(t))throw new TypeError("Second argument must be a TypedArray");if(t.byteLength!==y)throw new TypeError("Invalid encrypted key size");return D(o+y,(f,a)=>{let u=f,_=f+o;j(u,e),j(_,t);let S=()=>D(p,m=>{if(W.exports[c(this,v).functions.dec](m,_,u)!==0)throw new Error("Decryption failed");return R(m,p)});if(arguments.length===3){if(typeof s!="function")throw new TypeError("Third argument must be a function");let m=a();setImmediate(()=>{let A;try{A=m(()=>S());}catch(P){s(P);return}s(void 0,A);});}else return S()})}};v=new WeakMap;Object.defineProperty(te,"supportedAlgorithms",{value:Z.kem.map(({properties:{name:r}})=>r)});var Q,ie=class{constructor(e){F(this,Q);if(arguments.length!==1)throw new TypeError("Wrong number of arguments");if(typeof e!="string")throw new TypeError("First argument must be a string");if(K(this,Q,Z.sign.find(ve(e)))==null)throw new Error("No such implementation")}get algorithm(){return c(this,Q).properties.name}get description(){return c(this,Q).properties.description}get publicKeySize(){return c(this,Q).properties.publicKeySize}get privateKeySize(){return c(this,Q).properties.privateKeySize}get signatureSize(){return c(this,Q).properties.signatureSize}keypair(e){if(arguments.length>1)throw new TypeError("Wrong number of arguments");if(arguments.length===1){if(typeof e!="function")throw new TypeError("First argument must be a function");setImmediate(()=>{let t;try{t=this.keypair();}catch(s){e(s);return}e(void 0,t);});}else {let{privateKeySize:t,publicKeySize:s}=c(this,Q).properties;return D(t+s,o=>{let p=o,y=o+t;if(W.exports[c(this,Q).functions.keypair](y,p)!==0)throw new Error("Failed to generate keypair");let a=R(y,s),u=R(p,t);return {publicKey:a,privateKey:u}})}}sign(e,t,s){let{privateKeySize:o,signatureSize:p}=c(this,Q).properties;if(arguments.length!==2&&arguments.length!==3)throw new TypeError("Wrong number of arguments");if(!ArrayBuffer.isView(e))throw new TypeError("First argument must be a TypedArray");if(e.byteLength!==o)throw new TypeError("Invalid private key size");if(!ArrayBuffer.isView(t))throw new TypeError("Second argument must be a TypedArray");return D(o+t.byteLength,(y,f)=>{let a=y,u=y+o;j(a,e),j(u,t);let _=()=>D(4+p,S=>{let m=S,A=S+4;if(pr(m,p),W.exports[c(this,Q).functions.signature](A,m,u,t.byteLength,a)!==0)throw new Error("Sign operation failed");let z=ur(m);if(z>p)throw new Error(`Actual signature size (${z}) exceeds maximum size (${p}).`);return R(A,z)});if(arguments.length===3){if(typeof s!="function")throw new TypeError("Third argument must be a function");let S=f();setImmediate(()=>{let m;try{m=S(()=>_());}catch(A){s(A);return}s(void 0,m);});}else return _()})}verify(e,t,s,o){let{publicKeySize:p,signatureSize:y}=c(this,Q).properties;if(arguments.length!==3&&arguments.length!==4)throw new TypeError("Wrong number of arguments");if(!ArrayBuffer.isView(e))throw new TypeError("First argument must be a TypedArray");if(e.byteLength!==p)throw new TypeError("Invalid public key size");if(!ArrayBuffer.isView(t))throw new TypeError("Second argument must be a TypedArray");if(!ArrayBuffer.isView(s))throw new TypeError("Third argument must be a TypedArray");if(s.byteLength>y)throw new TypeError("Invalid signature size");return D(p+y+t.byteLength,(f,a)=>{let u=f,_=f+p,S=f+p+y;j(u,e),j(_,s),j(S,t);let m=()=>W.exports[c(this,Q).functions.verify](_,s.byteLength,S,t.byteLength,u)===0;if(arguments.length===4){if(typeof o!="function")throw new TypeError("Fourth argument must be a function");let A=a();setImmediate(()=>{let P;try{P=A(()=>m());}catch(z){o(z);return}o(void 0,P);});}else return m()})}};Q=new WeakMap;Object.defineProperty(ie,"supportedAlgorithms",{value:Z.sign.map(({properties:{name:r}})=>r)});Object.assign(pe.exports,{KEM:te,Sign:ie});Object.assign(pe.exports,we().init(Z,()=>$(null,null,function*(){let r=new ar(`${__dirname}/worker.js`,{workerData:{wasmModule:Ie}});return yield or.once(r,"online"),r})));});var Be=U((wr,Fe)=>{var yr=Le(),{kem:Me,sign:Qe,KEM:He,Sign:Te}=function r(e){switch(e){case "prefer-native":try{return r("native")}catch(t){return process.emitWarning(`Using WebAssembly backend: ${t.message}`),r("wasm")}case "native":return de()("node_pqclean");case "wasm":return ke();default:throw new Error(`Unsupported backend: ${e}`)}}(yr.backend);Object.freeze(Me.supportedAlgorithms);Object.freeze(Qe.supportedAlgorithms);Object.freeze(He.supportedAlgorithms);Object.freeze(Te.supportedAlgorithms);Object.defineProperties(Fe.exports,{kem:{value:Me,enumerable:true},sign:{value:Qe,enumerable:true},KEM:{value:He,enumerable:true},Sign:{value:Te,enumerable:true}});});var B=Je(Be());function fr(r,e){let t=crypto.createHmac("sha256",r),s=Buffer.concat([e,Buffer.alloc(Math.max(0,256-e.length))]);return t.update(s),t.digest()}function ue(r,e,t,s){let o=fr(e,r),p=Math.ceil(s/32),y=[],f=Buffer.alloc(0);for(let a=0;a<p;a++){let u=crypto.createHmac("sha256",o);u.update(Buffer.concat([f,t,Buffer.from([a+1])])),f=u.digest(),y.push(f);}return Buffer.concat(y).subarray(0,s)}function X(r){for(let e=0;e<r.length;e++)r[e]=0;}function xe(r,e=1024){let t=e-r.length%e;return r+"\0".repeat(t)}var Sr=B.kem.supportedAlgorithms,lr=B.sign.supportedAlgorithms,We=Sr.map(r=>r.name),$e=lr.map(r=>r.name),se="1.0.1",oe="hsynchronous",ne="aes-256-gcm",je=32,Re=50,fe=25,q=128,mr={fixedRunTime:true},Lr={fixedRunTime:true,memoryNonceProtection:true},De=new Set,Mr=(r="ml-kem-1024",e="falcon-1024")=>$(null,null,function*(){let t=yield B.kem.generateKeyPair(r),s=yield B.sign.generateKeyPair(e);return {kemKeyPair:t,sigKeyPair:s}}),Qr=r=>$(null,null,function*(){let e=r.kemKeyPair.publicKey.algorithm.name,t=r.sigKeyPair.publicKey.algorithm.name,s=r.kemKeyPair.publicKey.export(),o=r.kemKeyPair.privateKey.export(),p=r.sigKeyPair.publicKey.export(),y=r.sigKeyPair.privateKey.export(),f=[e.length,t.length,s.byteLength,o.byteLength,p.byteLength],a=Buffer.from(f.join(","),"utf8"),u=Buffer.concat([Buffer.from(e,"utf8"),Buffer.from(t,"utf8"),Buffer.from(s),Buffer.from(o),Buffer.from(p),Buffer.from(y)]);return `${oe}:${se}:${a.toString("hex")}:${u.toString("hex")}`}),Hr=r=>$(null,null,function*(){let[e,t,s,o]=r.split(":");if(e!==oe||t!==se)throw new Error(`Unsupported protocol or version: ${e} ${t}`);let p=Buffer.from(s,"hex").toString("utf8").split(",").map(Number),[y,f,a,u,_]=p,S=Buffer.from(o,"hex"),m=S.subarray(0,y).toString("utf8"),A=S.subarray(y,y+f).toString("utf8");if(!We.includes(m))throw new Error(`Unsupported KEM algorithm: ${m}`);if(!$e.includes(A))throw new Error(`Unsupported signature algorithm: ${A}`);let P=S.subarray(y+f,y+f+a),z=S.subarray(y+f+a,y+f+a+u),O=S.subarray(y+f+a+u,y+f+a+u+_),d=S.subarray(y+f+a+u+_),h=new B.kem.PublicKey(m,P),w=new B.kem.PrivateKey(m,z),k=new B.sign.PublicKey(A,O),N=new B.sign.PrivateKey(A,d);return {kemKeyPair:{publicKey:h,privateKey:w},sigKeyPair:{publicKey:k,privateKey:N}}}),Tr=(r,e,t,s)=>$(null,null,function*(){let o=performance.now();if(!e||!e.kemKeyPair||!e.sigKeyPair)throw new Error("Call generateKeys() first");if(typeof r!="string")throw new Error("Message must be a string");if(s||(s=crypto.randomBytes(q/2).toString("hex")),typeof s!="string")throw new Error("Nonce must be a string");if(s.length>q)throw new Error(`Nonce must be less than ${q} characters`);if(t=H(H({},mr),t),!We.includes(e.kemKeyPair.publicKey.algorithm.name))throw new Error("Unsupported KEM algorithm");if(!$e.includes(e.sigKeyPair.publicKey.algorithm.name))throw new Error("Unsupported signature algorithm");let{key:p,encryptedKey:y}=yield e.kemKeyPair.publicKey.generateKey(),f=Buffer.from(p),a=Buffer.from(y),u=crypto.randomBytes(64),_=Buffer.from(`${e.kemKeyPair.publicKey.algorithm.name}-${e.sigKeyPair.publicKey.algorithm.name}-${ne}-${oe}-${se}`,"utf8"),S=ue(f,u,_,je);X(f);let A=Date.now().toString().padStart(fe,"0"),P=s.padStart(q," "),z=`${r}${A}${P}`,O=crypto.randomBytes(12),d=crypto.createCipheriv(ne,S,O),h=Buffer.concat([d.update(z,"utf8"),d.final()]),w=d.getAuthTag();X(S);let k=Buffer.concat([u,a,h,O,w]),N=yield e.sigKeyPair.privateKey.sign(k),M=h.byteLength,b=Buffer.from(N).byteLength,I=Buffer.from(`${M},${b}`,"utf8"),E=Buffer.concat([u,a,O,w,h,Buffer.from(N)]),i=`${I.toString("hex")}.${E.toString("hex")}`,n=xe(i,1024);return t.fixedRunTime?yield new Promise(g=>setTimeout(g,Re-(performance.now()-o))).then(()=>n):n}),Fr=(r,e,t)=>$(null,null,function*(){t=H(H({},Lr),t);let s=performance.now(),[o,p]=r.split("."),y=Buffer.from(o,"hex"),[f,a]=y.toString("utf8").split(",").map(Number),u=e.kemKeyPair.publicKey.algorithm.encryptedKeySize,_=Buffer.from(p,"hex"),S=_.subarray(0,64),m=_.subarray(64,64+u),A=_.subarray(64+u,64+u+12),P=_.subarray(64+u+12,64+u+12+16),z=_.subarray(64+u+12+16,64+u+12+16+f),O=_.subarray(64+u+12+16+f),d=Buffer.concat([S,m,z,A,P]),h=yield e.sigKeyPair.publicKey.verify(d,O),w=crypto.timingSafeEqual(Buffer.from(h?"":"\0"),Buffer.from(""));if(!h)throw new Error("Invalid signature");if(!w)throw new Error("Signature verification failed due to timing attack protection");let k=Buffer.from(`${e.kemKeyPair.publicKey.algorithm.name}-${e.sigKeyPair.publicKey.algorithm.name}-${ne}-${oe}-${se}`,"utf8"),N=Buffer.from(yield e.kemKeyPair.privateKey.decryptKey(m)),M=ue(N,S,k,je);X(N);let b=crypto.createDecipheriv(ne,M,A);X(M),b.setAuthTag(P);let I=Buffer.concat([b.update(z),b.final()]).toString("utf8"),E=I.slice(-q),i=I.slice(-153,-q),n=I.slice(0,-153),g=new Date(parseInt(i,10)),l=E.trimEnd();if(t.memoryNonceProtection){if(De.has(l))throw new Error("Nonce reuse detected");De.add(l);}let L={message:n,createdAt:g,decryptedAt:new Date,nonce:l};return t.fixedRunTime?yield new Promise(C=>setTimeout(C,Re-(performance.now()-s))).then(()=>L):L});
exports.VERSION=se;exports.decrypt=Fr;exports.encrypt=Tr;exports.exportKeys=Qr;exports.generateKeys=Mr;exports.importKeys=Hr;exports.supportedKemAlgorithms=Sr;exports.supportedSigAlgorithms=lr;return exports;})({},crypto);