>3,r-=c,a-=c<<3,n&=(1<=1&&0===P[g];g--);if(m>g&&(m=g),0===g)return n[a++]=20971520,n[a++]=20971520,o.bits=1,0;for(b=1;b =0;i--){for(var u=t.words[i],h=c-1;h>=0;h--){var d=u>>h&1;a!==r[0]&&(a=this.sqr(a)),0!==d||0!==s?(s<<=1,s|=d,(4===++o||0===i&&0===h)&&(a=this.mul(a,r[s]),o=0,s=0)):o=0}c=26}return a},_.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},_.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},n.mont=function(e){return new k(e)},i(k,_),k.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},k.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},k.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(i).iushrn(this.shift),a=n;return n.cmp(this.m)>=0?a=n.isub(this.m):n.cmpn(0)<0&&(a=n.iadd(this.m)),a._forceRed(this)},k.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new n(0)._forceRed(this);var r=e.mul(t),i=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(i).iushrn(this.shift),s=a;return a.cmp(this.m)>=0?s=a.isub(this.m):a.cmpn(0)<0&&(s=a.iadd(this.m)),s._forceRed(this)},k.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,it)})),qp=/*#__PURE__*/Object.freeze({__proto__:null,default:zp,__moduleExports:zp});class Fp{constructor(e){if(void 0===e)throw Error("Invalid BigInteger input");this.value=new zp(e)}clone(){const e=new Fp(null);return this.value.copy(e.value),e}iinc(){return this.value.iadd(new zp(1)),this}inc(){return this.clone().iinc()}idec(){return this.value.isub(new zp(1)),this}dec(){return this.clone().idec()}iadd(e){return this.value.iadd(e.value),this}add(e){return this.clone().iadd(e)}isub(e){return this.value.isub(e.value),this}sub(e){return this.clone().isub(e)}imul(e){return this.value.imul(e.value),this}mul(e){return this.clone().imul(e)}imod(e){return this.value=this.value.umod(e.value),this}mod(e){return this.clone().imod(e)}modExp(e,t){const r=t.isEven()?zp.red(t.value):zp.mont(t.value),i=this.clone();return i.value=i.value.toRed(r).redPow(e.value).fromRed(),i}modInv(e){if(!this.gcd(e).isOne())throw Error("Inverse does not exist");return new Fp(this.value.invm(e.value))}gcd(e){return new Fp(this.value.gcd(e.value))}ileftShift(e){return this.value.ishln(e.value.toNumber()),this}leftShift(e){return this.clone().ileftShift(e)}irightShift(e){return this.value.ishrn(e.value.toNumber()),this}rightShift(e){return this.clone().irightShift(e)}equal(e){return this.value.eq(e.value)}lt(e){return this.value.lt(e.value)}lte(e){return this.value.lte(e.value)}gt(e){return this.value.gt(e.value)}gte(e){return this.value.gte(e.value)}isZero(){return this.value.isZero()}isOne(){return this.value.eq(new zp(1))}isNegative(){return this.value.isNeg()}isEven(){return this.value.isEven()}abs(){const e=this.clone();return e.value=e.value.abs(),e}toString(){return this.value.toString()}toNumber(){return this.value.toNumber()}getBit(e){return this.value.testn(e)?1:0}bitLength(){return this.value.bitLength()}byteLength(){return this.value.byteLength()}toUint8Array(e="be",t){return this.value.toArrayLike(Uint8Array,e,t)}}var Op,Lp=/*#__PURE__*/Object.freeze({__proto__:null,default:Fp}),Np=nt((function(e,t){var r=t;function i(e){return 1===e.length?"0"+e:e}function n(e){for(var t="",r=0;rn.bindingSignatures[t].created&&(n.bindingSignatures[t]=e),!1;try{return await e.verify(i,Z.signature.subkeyBinding,a,t,void 0,r),!0}catch(e){return!1}})),await Qu(e,this,"revocationSignatures",t,(function(e){return Ju(i,Z.signature.subkeyRevocation,a,[e],void 0,void 0,t,r)}))}async revoke(e,{flag:t=Z.reasonForRevocation.noReason,string:r=""}={},i=new Date,n=ae){const a={key:e,bind:this.keyPacket},s=new oh(this.keyPacket,this.mainKey);return s.revocationSignatures.push(await Yu(a,null,e,{signatureType:Z.signature.subkeyRevocation,reasonForRevocationFlag:Z.write(Z.reasonForRevocation,t),reasonForRevocationString:r},i,void 0,void 0,!1,n)),await s.update(this),s}hasSameFingerprintAs(e){return this.keyPacket.hasSameFingerprintAs(e.keyPacket||e)}}["getKeyID","getFingerprint","getAlgorithmInfo","getCreationTime","isDecrypted"].forEach((e=>{oh.prototype[e]=function(){return this.keyPacket[e]()}}));const ch=/*#__PURE__*/Y.constructAllowedPackets([hu]),uh=new Set([Z.packet.publicKey,Z.packet.privateKey]),hh=new Set([Z.packet.publicKey,Z.packet.privateKey,Z.packet.publicSubkey,Z.packet.privateSubkey]);class dh{packetListToStructure(e,t=new Set){let r,i,n,a;for(const s of e){if(s instanceof mn){hh.has(s.tag)&&!a&&(a=uh.has(s.tag)?uh:hh);continue}const e=s.constructor.tag;if(a){if(!a.has(e))continue;a=null}if(t.has(e))throw Error("Unexpected packet type: "+e);switch(e){case Z.packet.publicKey:case Z.packet.secretKey:if(this.keyPacket)throw Error("Key block contains multiple keys");if(this.keyPacket=s,i=this.getKeyID(),!i)throw Error("Missing Key ID");break;case Z.packet.userID:case Z.packet.userAttribute:r=new sh(s,this),this.users.push(r);break;case Z.packet.publicSubkey:case Z.packet.secretSubkey:r=null,n=new oh(s,this),this.subkeys.push(n);break;case Z.packet.signature:switch(s.signatureType){case Z.signature.certGeneric:case Z.signature.certPersona:case Z.signature.certCasual:case Z.signature.certPositive:if(!r){Y.printDebug("Dropping certification signatures without preceding user packet");continue}s.issuerKeyID.equals(i)?r.selfCertifications.push(s):r.otherCertifications.push(s);break;case Z.signature.certRevocation:r?r.revocationSignatures.push(s):this.directSignatures.push(s);break;case Z.signature.key:this.directSignatures.push(s);break;case Z.signature.subkeyBinding:if(!n){Y.printDebug("Dropping subkey binding signature without preceding subkey packet");continue}n.bindingSignatures.push(s);break;case Z.signature.keyRevocation:this.revocationSignatures.push(s);break;case Z.signature.subkeyRevocation:if(!n){Y.printDebug("Dropping subkey revocation signature without preceding subkey packet");continue}n.revocationSignatures.push(s)}}}}toPacketList(){const e=new pu;return e.push(this.keyPacket),e.push(...this.revocationSignatures),e.push(...this.directSignatures),this.users.map((t=>e.push(...t.toPacketList()))),this.subkeys.map((t=>e.push(...t.toPacketList()))),e}clone(e=!1){const t=new this.constructor(this.toPacketList());return e&&t.getKeys().forEach((e=>{if(e.keyPacket=Object.create(Object.getPrototypeOf(e.keyPacket),Object.getOwnPropertyDescriptors(e.keyPacket)),!e.keyPacket.isDecrypted())return;const t={};Object.keys(e.keyPacket.privateParams).forEach((r=>{t[r]=new Uint8Array(e.keyPacket.privateParams[r])})),e.keyPacket.privateParams=t})),t}getSubkeys(e=null){return this.subkeys.filter((t=>!e||t.getKeyID().equals(e,!0)))}getKeys(e=null){const t=[];return e&&!this.getKeyID().equals(e,!0)||t.push(this),t.concat(this.getSubkeys(e))}getKeyIDs(){return this.getKeys().map((e=>e.getKeyID()))}getUserIDs(){return this.users.map((e=>e.userID?e.userID.userID:null)).filter((e=>null!==e))}write(){return this.toPacketList().write()}async getSigningKey(e=null,t=new Date,r={},i=ae){await this.verifyPrimaryKey(t,r,i);const n=this.keyPacket,a=this.subkeys.slice().sort(((e,t)=>t.keyPacket.created-e.keyPacket.created));let s;for(const r of a)if(!e||r.getKeyID().equals(e))try{await r.verify(t,i);const e={key:n,bind:r.keyPacket},a=await Gu(r.bindingSignatures,n,Z.signature.subkeyBinding,e,t,i);if(!rh(r.keyPacket,a))continue;if(!a.embeddedSignature)throw Error("Missing embedded signature");return await Gu([a.embeddedSignature],r.keyPacket,Z.signature.keyBinding,e,t,i),ah(r.keyPacket,i),r}catch(e){s=e}try{const a=await this.getPrimaryUser(t,r,i);if((!e||n.getKeyID().equals(e))&&rh(n,a.selfCertification))return ah(n,i),this}catch(e){s=e}throw Y.wrapError("Could not find valid signing key packet in key "+this.getKeyID().toHex(),s)}async getEncryptionKey(e,t=new Date,r={},i=ae){await this.verifyPrimaryKey(t,r,i);const n=this.keyPacket,a=this.subkeys.slice().sort(((e,t)=>t.keyPacket.created-e.keyPacket.created));let s;for(const r of a)if(!e||r.getKeyID().equals(e))try{await r.verify(t,i);const e={key:n,bind:r.keyPacket},a=await Gu(r.bindingSignatures,n,Z.signature.subkeyBinding,e,t,i);if(ih(r.keyPacket,a))return ah(r.keyPacket,i),r}catch(e){s=e}try{const a=await this.getPrimaryUser(t,r,i);if((!e||n.getKeyID().equals(e))&&ih(n,a.selfCertification))return ah(n,i),this}catch(e){s=e}throw Y.wrapError("Could not find valid encryption key packet in key "+this.getKeyID().toHex(),s)}async isRevoked(e,t,r=new Date,i=ae){return Ju(this.keyPacket,Z.signature.keyRevocation,{key:this.keyPacket},this.revocationSignatures,e,t,r,i)}async verifyPrimaryKey(e=new Date,t={},r=ae){const i=this.keyPacket;if(await this.isRevoked(null,null,e,r))throw Error("Primary key is revoked");const{selfCertification:n}=await this.getPrimaryUser(e,t,r);if(Vu(i,n,e))throw Error("Primary key is expired");const a=await Gu(this.directSignatures,i,Z.signature.key,{key:i},e,r).catch((()=>{}));if(a&&Vu(i,a,e))throw Error("Primary key is expired")}async getExpirationTime(e,t=ae){let r;try{const{selfCertification:i}=await this.getPrimaryUser(null,e,t),n=eh(this.keyPacket,i),a=i.getExpirationTime(),s=await Gu(this.directSignatures,this.keyPacket,Z.signature.key,{key:this.keyPacket},null,t).catch((()=>{}));if(s){const e=eh(this.keyPacket,s);r=Math.min(n,a,e)}else r=ne.subkeys.some((e=>t.hasSameFingerprintAs(e)))))))throw Error("Cannot update public key with private key if subkeys mismatch");return e.update(this,r)}const i=this.clone();return await Qu(e,i,"revocationSignatures",t,(n=>Ju(i.keyPacket,Z.signature.keyRevocation,i,[n],null,e.keyPacket,t,r))),await Qu(e,i,"directSignatures",t),await Promise.all(e.users.map((async e=>{const n=i.users.filter((t=>e.userID&&e.userID.equals(t.userID)||e.userAttribute&&e.userAttribute.equals(t.userAttribute)));if(n.length>0)await Promise.all(n.map((i=>i.update(e,t,r))));else{const t=e.clone();t.mainKey=i,i.users.push(t)}}))),await Promise.all(e.subkeys.map((async e=>{const n=i.subkeys.filter((t=>t.hasSameFingerprintAs(e)));if(n.length>0)await Promise.all(n.map((i=>i.update(e,t,r))));else{const t=e.clone();t.mainKey=i,i.subkeys.push(t)}}))),i}async getRevocationCertificate(e=new Date,t=ae){const r={key:this.keyPacket},i=await Gu(this.revocationSignatures,this.keyPacket,Z.signature.keyRevocation,r,e,t),n=new pu;return n.push(i),pe(Z.armor.publicKey,n.write(),null,null,"This is a revocation certificate")}async applyRevocationCertificate(e,t=new Date,r=ae){const i=await le(e,r),n=(await pu.fromBinary(i.data,ch,r)).findPacket(Z.packet.signature);if(!n||n.signatureType!==Z.signature.keyRevocation)throw Error("Could not find revocation signature packet");if(!n.issuerKeyID.equals(this.getKeyID()))throw Error("Revocation signature does not match key");try{await n.verify(this.keyPacket,Z.signature.keyRevocation,{key:this.keyPacket},t,void 0,r)}catch(e){throw Y.wrapError("Could not verify revocation signature",e)}const a=this.clone();return a.revocationSignatures.push(n),a}async signPrimaryUser(e,t,r,i=ae){const{index:n,user:a}=await this.getPrimaryUser(t,r,i),s=await a.certify(e,t,i),o=this.clone();return o.users[n]=s,o}async signAllUsers(e,t=new Date,r=ae){const i=this.clone();return i.users=await Promise.all(this.users.map((function(i){return i.certify(e,t,r)}))),i}async verifyPrimaryUser(e,t=new Date,r,i=ae){const n=this.keyPacket,{user:a}=await this.getPrimaryUser(t,r,i);return e?await a.verifyAllCertifications(e,t,i):[{keyID:n.getKeyID(),valid:await a.verify(t,i).catch((()=>!1))}]}async verifyAllUsers(e,t=new Date,r=ae){const i=this.keyPacket,n=[];return await Promise.all(this.users.map((async a=>{const s=e?await a.verifyAllCertifications(e,t,r):[{keyID:i.getKeyID(),valid:await a.verify(t,r).catch((()=>!1))}];n.push(...s.map((e=>({userID:a.userID?a.userID.userID:null,userAttribute:a.userAttribute,keyID:e.keyID,valid:e.valid}))))}))),n}}["getKeyID","getFingerprint","getAlgorithmInfo","getCreationTime","hasSameFingerprintAs"].forEach((e=>{dh.prototype[e]=oh.prototype[e]}));class fh extends dh{constructor(e){if(super(),this.keyPacket=null,this.revocationSignatures=[],this.directSignatures=[],this.users=[],this.subkeys=[],e&&(this.packetListToStructure(e,new Set([Z.packet.secretKey,Z.packet.secretSubkey])),!this.keyPacket))throw Error("Invalid key: missing public-key packet")}isPrivate(){return!1}toPublic(){return this}armor(e=ae){return pe(Z.armor.publicKey,this.toPacketList().write(),void 0,void 0,void 0,e)}}class lh extends fh{constructor(e){if(super(),this.packetListToStructure(e,new Set([Z.packet.publicKey,Z.packet.publicSubkey])),!this.keyPacket)throw Error("Invalid key: missing private-key packet")}isPrivate(){return!0}toPublic(){const e=new pu,t=this.toPacketList();for(const r of t)switch(r.constructor.tag){case Z.packet.secretKey:{const t=Uu.fromSecretKeyPacket(r);e.push(t);break}case Z.packet.secretSubkey:{const t=Bu.fromSecretSubkeyPacket(r);e.push(t);break}default:e.push(r)}return new fh(e)}armor(e=ae){return pe(Z.armor.privateKey,this.toPacketList().write(),void 0,void 0,void 0,e)}async getDecryptionKeys(e,t=new Date,r={},i=ae){const n=this.keyPacket,a=[];for(let r=0;r