UNPKG

mima-kit

Version:

mima-kit is a cryptographic suite implemented in TypeScript. The goal is to provide an easy-to-use cryptographic library. mima-kit 是一个使用 TypeScript 实现的密码学套件。目标是提供一个简单易用的密码学库。

1 lines 172 kB
"use strict";function rotateL32(e,r){return(e<<r|e>>>32-r)>>>0}function rotateR32(e,r){return e>>>r|e<<32-r>>>0}function rotateL(e,r,n1,f1){return e=BigInt(e),f1??=genBitMask(e),r=BigInt(r),n1=BigInt(n1),r&=f1,n1%=e,r=r<<n1|r>>e-n1,r&f1}function rotateR(e,r,n1,f1){return e=BigInt(e),f1??=genBitMask(e),r=BigInt(r),n1=BigInt(n1),r&=f1,n1%=e,r=r>>n1|r<<e-n1,r&f1}function genRandomBI(e,r,n1=1e3){if(e<=1n)throw new KitError("Max must be greater than 1");const f1=new U8(r);let e1=0n,t1=0;for(;t1<n1;){if(crypto.getRandomValues(f1),e1=f1.toBI(),e1<e)return{buffer:f1,result:e1};t1++}throw new KitError("Failed to generate random bigint within max attempts")}function getBIBits(e){return e===0n?0:e.toString(2).length}function genBitMask(e){e=BigInt(e);let r=0x0n;for(let n1=0;n1<e;n1++)r=r<<1n|1n;return r}function extendedEuclidean(e,r){let[n1,f1,e1,t1,r1,c1]=[1n,0n,0n,1n,e,r];if(r===0n)return{gcd:e,x:1n};for(;c1!==0n;){const a1=r1/c1;[r1,c1]=[c1,r1-a1*c1],[n1,f1]=[f1,n1-a1*f1],[e1,t1]=[t1,e1-a1*t1]}return{gcd:r1,x:n1}}function legendreSymbol(e,r){return modPow(e,r-1n>>1n,r)}function tonelliShanks(e,r){if(legendreSymbol(e,r)!==1n)throw new KitError("There is no square root");if(e===0n)return 0n;if(r===2n)return e;if(r%4n===3n)return modPow(e,r+1n>>2n,r);let n1=r-1n,f1=0n;for(;mod(n1,2n)===0n;)n1>>=1n,f1++;let e1=2n;for(;legendreSymbol(e1,r)!==r-1n;)e1++;let t1=f1,r1=modPow(e1,n1,r),c1=modPow(e,n1,r),a1=modPow(e,n1+1n>>1n,r);for(;c1!==0n&&c1!==1n;){let s1=c1,i1=1n;for(;i1<t1&&(s1=modPow(s1,2n,r),s1!==1n);i1++);const o1=modPow(r1,1n<<t1-i1-1n,r);t1=i1,r1=modPow(o1,2n,r),c1=c1*r1%r,a1=a1*o1%r}return a1}function gcd(e,r){return extendedEuclidean(e,r).gcd}function lcm(e,r){return e*r/gcd(e,r)}function mod(e,r){const n1=e%r;return n1<0n?n1+r:n1}function modPow(e,r,n1){e%=n1;let f1=1n;for(;r>0n;)r&1n&&(f1=f1*e%n1),e=e*e%n1,r>>=1n;return f1}function modInverse(e,r){const{gcd:n1,x:f1}=extendedEuclidean(e,r);if(n1!==1n)throw new KitError("Modular inverse does not exist");return mod(f1,r)}function modPrimeSquareRoot(e,r){if(e=mod(e,r),e===0n)return 0n;const n1=tonelliShanks(e,r),f1=mod(r-n1,r);return n1<=f1?n1:f1}class U8 extends Uint8Array{getWord(r,n1,f1=!1){const e1=n1*r,t1=this.subarray(e1,e1+r);return f1?t1.toBI(!0):t1.toBI()}setWord(r,n1,f1,e1=!1){const t1=n1*r,r1=typeof f1=="bigint"?U8.fromBI(f1,r):f1;this.set(e1?r1.toReversed():r1,t1)}view(r){const n1=Math.floor(this.length/r);return{get:(f1,e1=!1)=>this.getWord(r,f1,e1),set:(f1,e1,t1=!1)=>this.setWord(r,f1,e1,t1),length:n1}}to(r){return r(this)}toBI(r=!1){const n1=r?this.toReversed():this;let f1=0n;return n1.forEach(e1=>{f1=f1<<8n|BigInt(e1)}),f1}toUint8Array(){return new Uint8Array(this)}static fromString(r,n1){return n1(r)}static fromBI(r,n1,f1=!1){n1=n1||getBIBits(r)+7>>3;const e1=new U8(n1);if(f1)for(let t1=0;t1<e1.length;t1++)e1[t1]=Number(r&0xffn),r>>=8n;else for(let t1=e1.length-1;t1>=0;t1--)e1[t1]=Number(r&0xffn),r>>=8n;return e1}filter(r,n1){const f1=super.filter(r,n1);return new U8(f1.buffer,f1.byteOffset,f1.byteLength)}static of(...r){const n1=Uint8Array.of(...r);return new U8(n1.buffer,n1.byteOffset,n1.byteLength)}static from(r,n1,f1){const e1=Uint8Array.from(r,n1,f1);return new U8(e1.buffer,e1.byteOffset,e1.byteLength)}map(r,n1){const f1=super.map(r,n1);return new U8(f1.buffer,f1.byteOffset,f1.byteLength)}slice(r,n1){const f1=super.slice(r,n1);return new U8(f1.buffer,f1.byteOffset,f1.byteLength)}subarray(r,n1){const f1=super.subarray(r,n1);return new U8(f1.buffer,f1.byteOffset,f1.byteLength)}toReversed(){const r=super.toReversed();return new U8(r.buffer,r.byteOffset,r.byteLength)}toSorted(r){const n1=super.toSorted(r);return new U8(n1.buffer,n1.byteOffset,n1.byteLength)}with(r,n1){const f1=super.with(r,n1);return new U8(f1.buffer,f1.byteOffset,f1.byteLength)}}function u8(e){return new U8(e.buffer,e.byteOffset,e.byteLength)}function u32(e){return new Uint32Array(e.buffer,e.byteOffset,e.byteLength>>2)}function joinBuffer(...e){const r=e.reduce((e1,t1)=>e1+t1.byteLength,0),n1=new U8(r);let f1=0;for(const e1 of e)n1.set(new U8(e1),f1),f1+=e1.byteLength;return n1}function resizeBuffer(e,r){const n1=new U8(r);return n1.set(e),n1}class Counter extends U8{inc(r,n1,f1=!1){if(r=r||0,r<0||r>=this.length)throw new KitError("Invalid counter offset");if(n1=n1||this.length-r,n1<0||r+n1>this.length)throw new KitError("Invalid counter length");if(f1)for(let e1=r;e1<r+n1;e1++){if(this[e1]<255){this[e1]+=1;break}this[e1]=0}else for(let e1=r+n1-1;e1>=r;e1--){if(this[e1]<255){this[e1]+=1;break}this[e1]=0}}}function trying(e){try{return[null,e()]}catch(r){return r instanceof Error?[r,null]:[new KitError("Unknown error"),null]}}function wrap(...e){return Object.assign(...e)}class KitError extends Error{constructor(r){super(r),this.name="mima-kit Error"}}const f$3=40,i$2=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n,103n,107n,109n,113n,127n,131n,137n,139n,149n,151n,157n,163n,167n,173n,179n,181n,191n,193n,197n,199n,211n,223n,227n,229n,233n,239n,241n,251n,257n,263n,269n,271n,277n,281n,283n,293n,307n,311n,313n,317n,331n,337n,347n,349n,353n,359n,367n,373n,379n,383n,389n,397n,401n,409n,419n,421n,431n,433n,439n,443n,449n,457n,461n,463n,467n,479n,487n,491n,499n,503n,509n,521n,523n,541n,547n,557n,563n,569n,571n,577n,587n,593n,599n,601n,607n,613n,617n,619n,631n,641n,643n,647n,653n,659n,661n,673n,677n,683n,691n,701n,709n,719n,727n,733n,739n,743n,751n,757n,761n,769n,773n,787n,797n,809n,811n,821n,823n,827n,829n,839n,853n,857n,859n,863n,877n,881n,883n,887n,907n,911n,919n,929n,937n,941n,947n,953n,967n,971n,977n,983n,991n,997n],m$7=(1n<<26n)/i$2[i$2.length-1];function c(e,r){const n1=e-1n;let f1=0n,e1=n1;for(;(e1&1n)===0n;)e1>>=1n,f1++;r=r+1>>1,r>i$2.length&&(r=i$2.length);const t1=[2n];for(let r1=0;r1<r;++r1){let c1;do c1=i$2[Math.floor(Math.random()*i$2.length)];while(t1.includes(c1));if(t1.push(c1),d$3(e,n1,f1,e1,c1)===!1)return!1}return!0}function d$3(e,r,n1,f1,e1){let t1=modPow(e1,f1,e);if(t1===1n||t1===r)return!0;let r1=0n;for(let c1=1;c1<n1;c1++){if(r1=modPow(t1,2n,e),r1===1n&&t1!==1n&&t1!==r)return!1;t1=r1}return r1===1n}function s$2(e,r=f$3){for(let n1=1;n1<i$2.length;){let f1=i$2[n1],e1=n1+1;for(;e1<i$2.length&&f1<m$7;)f1*=i$2[e1++];for(f1=e%f1;n1<e1;)if(f1%i$2[n1++]===0n)return!1}return c(e,r)}function h$9(e){crypto.getRandomValues(e),e[0]|=128;let r=e.toBI()|1n;const n1=r%6n;return n1!==1n&&n1!==5n&&(r+=4n),r}const genPrime=e=>{const r=new U8(e>>3);let n1;do n1=h$9(r);while(!s$2(n1));return n1};function isProbablePrime(e,r=f$3){if(r<=0||(e&1n)===0n)return!1;const n1=e%6n;return n1!==1n&&n1!==5n?!1:e<=i$2[i$2.length-1]?i$2.includes(e):s$2(e,r)}function h$8(e,r,n1){function f1(e1){return typeof e1=="string"?e(e1):r(e1)}return wrap(f1,{FORMAT:n1})}function E$5(e){const[r,n1]=trying(()=>new TextEncoder().encode(e));if(!r)return u8(n1);const f1=[];for(let e1=0;e1<e.length;e1++){const t1=e.codePointAt(e1);t1===void 0||(t1<128?f1.push(t1):t1<2048?(f1.push(192|t1>>6),f1.push(128|t1&63)):t1<65536?(f1.push(224|t1>>12),f1.push(128|t1>>6&63),f1.push(128|t1&63)):t1<1114112&&(f1.push(240|t1>>18),f1.push(128|t1>>12&63),f1.push(128|t1>>6&63),f1.push(128|t1&63),e1++))}return U8.from(f1)}function O$3(e){const[r,n1]=trying(()=>new TextDecoder().decode(e));if(!r)return n1;const f1=[];for(let e1=0;e1<e.length;){const t1=e[e1++];if(t1<128)f1.push(String.fromCharCode(t1));else if(t1>=192&&t1<224){const r1=e[e1++],c1=(t1&31)<<6|r1&63;f1.push(String.fromCharCode(c1))}else if(t1>=224&&t1<240){const r1=e[e1++],c1=e[e1++],a1=(t1&15)<<12|(r1&63)<<6|c1&63;f1.push(String.fromCharCode(a1))}else if(t1>=240&&t1<248){const r1=e[e1++],c1=e[e1++],a1=e[e1++],s1=(t1&7)<<18|(r1&63)<<12|(c1&63)<<6|a1&63;f1.push(String.fromCodePoint(s1))}else console.warn("Included an invalid UTF-8 byte")}return f1.join("")}const UTF8=h$8(E$5,O$3,"utf-8");function w$6(e){e=e.replace(/^0x/,"");const[r,n1]=trying(()=>Buffer.from(e.replace(/[^0-9a-f]/gi,""),"hex"));if(!r)return u8(n1);const f1=e.match(/[\da-f]{2}/gi);return f1==null?new U8:new U8(f1.map(e1=>Number.parseInt(e1,16)))}function S$7(e){const[r,n1]=trying(()=>Buffer.from(e).toString("hex"));if(!r)return n1;let f1="";for(let e1=0;e1<e.length;e1++)f1+=e[e1].toString(16).padStart(2,"0");return f1}const HEX=h$8(w$6,S$7,"hex");function P$4(e){const[r,n1]=trying(()=>Buffer.from(e.replace(/[^A-Z0-9+/]/gi,""),"base64"));return r?C$8(e):u8(n1)}function F$2(e){const[r,n1]=trying(()=>Buffer.from(e).toString("base64"));return r?_$4(e):n1}const B64=h$8(P$4,F$2,"base64");function R$7(e){const[r,n1]=trying(()=>Buffer.from(e.replace(/[^\w-]/g,""),"base64url"));return r?C$8(e):u8(n1)}function M$5(e){const[r,n1]=trying(()=>Buffer.from(e).toString("base64url"));return r?B64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,""):n1}const B64URL=h$8(R$7,M$5,"base64url");function C$8(e){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/[^A-Z0-9+/]/gi,"");const n1=e.length*.75,f1=new U8(n1);let e1=0,t1=0;for(;e1<e.length;){const r1=r.indexOf(e.charAt(e1++)),c1=r.indexOf(e.charAt(e1++)),a1=r.indexOf(e.charAt(e1++)),s1=r.indexOf(e.charAt(e1++)),i1=r1<<18|c1<<12|a1<<6|s1;f1[t1++]=i1>>16&255,f1[t1++]=i1>>8&255,f1[t1++]=i1&255}return f1}function _$4(e,r){let n1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";n1+="+/";let f1="",e1;for(e1=0;e1<e.length-2;e1+=3)f1+=n1[e[e1]>>2],f1+=n1[(e[e1]&3)<<4|e[e1+1]>>4],f1+=n1[(e[e1+1]&15)<<2|e[e1+2]>>6],f1+=n1[e[e1+2]&63];return e1===e.length-2?(f1+=n1[e[e1]>>2],f1+=n1[(e[e1]&3)<<4|e[e1+1]>>4],f1+=n1[(e[e1+1]&15)<<2],f1+="="):e1===e.length-1&&(f1+=n1[e[e1]>>2],f1+=n1[(e[e1]&3)<<4],f1+="=="),f1}function H$5(e){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";if(typeof e=="string"){const e1=e.toUpperCase().replace(/[^A-Z2-7]/g,"");return b$6(e1,r)}else if(e instanceof Uint8Array)return u$5(e,r,!1);const{variant:n1="rfc4648",padding:f1=!1}=e;if(n1==="rfc4648")return h$8(function(e1){return e1=e1.toUpperCase().replace(/[^A-Z2-7]/g,""),b$6(e1,r)},function(e1){return u$5(e1,r,f1)},"base32");if(n1==="rfc4648-hex"){let e1=function(c1){return c1=c1.toUpperCase().replace(/[^0-9A-V]/g,""),b$6(c1,r1)},t1=function(c1){return u$5(c1,r1,f1)};const r1="0123456789ABCDEFGHIJKLMNOPQRSTUV";return h$8(e1,t1,"base32-hex")}else if(n1==="crockford"){let e1=function(c1){return c1=c1.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1").replace(/[^0-9A-HJKMNP-TV-Z]/g,""),b$6(c1,r1)},t1=function(c1){return u$5(c1,r1,f1)};const r1="0123456789ABCDEFGHJKMNPQRSTVWXYZ";return h$8(e1,t1,"base32-crockford")}}const B32=wrap(H$5,{FORMAT:"base32"});function b$6(e,r){const n1=e.length*.625,f1=new U8(n1);let e1=0,t1=0;for(;e1<e.length;){const r1=r.indexOf(e.charAt(e1++)),c1=r.indexOf(e.charAt(e1++)),a1=r.indexOf(e.charAt(e1++)),s1=r.indexOf(e.charAt(e1++)),i1=r.indexOf(e.charAt(e1++)),o1=r.indexOf(e.charAt(e1++)),u1=r.indexOf(e.charAt(e1++)),y1=r.indexOf(e.charAt(e1++));f1[t1++]=r1<<3|c1>>2,f1[t1++]=(c1&3)<<6|a1<<1|s1>>4,f1[t1++]=(s1&15)<<4|i1>>1,f1[t1++]=(i1&1)<<7|o1<<2|u1>>3,f1[t1++]=(u1&7)<<5|y1}return f1}function u$5(e,r,n1){let f1="",e1;for(e1=0;e1<e.length-4;e1+=5){const t1=e[e1],r1=e[e1+1],c1=e[e1+2],a1=e[e1+3],s1=e[e1+4];f1+=r[t1>>3],f1+=r[(t1&7)<<2|r1>>6],f1+=r[r1>>1&31],f1+=r[(r1&1)<<4|c1>>4],f1+=r[(c1&15)<<1|a1>>7],f1+=r[a1>>2&31],f1+=r[(a1&3)<<3|s1>>5],f1+=r[s1&31]}if(e1===e.length-4){const t1=e[e1],r1=e[e1+1],c1=e[e1+2],a1=e[e1+3];f1+=r[t1>>3],f1+=r[(t1&7)<<2|r1>>6],f1+=r[r1>>1&31],f1+=r[(r1&1)<<4|c1>>4],f1+=r[(c1&15)<<1|a1>>7],f1+=r[a1>>2&31],f1+=r[(a1&3)<<3],f1+=n1?"=":""}else if(e1===e.length-3){const t1=e[e1],r1=e[e1+1],c1=e[e1+2];f1+=r[t1>>3],f1+=r[(t1&7)<<2|r1>>6],f1+=r[r1>>1&31],f1+=r[(r1&1)<<4|c1>>4],f1+=r[(c1&15)<<1],f1+=n1?"===":""}else if(e1===e.length-2){const t1=e[e1],r1=e[e1+1];f1+=r[t1>>3],f1+=r[(t1&7)<<2|r1>>6],f1+=r[r1>>1&31],f1+=r[(r1&1)<<4],f1+=n1?"====":""}else if(e1===e.length-1){const t1=e[e1];f1+=r[t1>>3],f1+=r[(t1&7)<<2],f1+=n1?"======":""}return f1}function m$6(e){const r=new Map;r.set("\u5BCC\u5F3A",0),r.set("\u6C11\u4E3B",1),r.set("\u6587\u660E",2),r.set("\u548C\u8C10",3),r.set("\u81EA\u7531",4),r.set("\u5E73\u7B49",5),r.set("\u516C\u6B63",6),r.set("\u6CD5\u6CBB",7),r.set("\u7231\u56FD",8),r.set("\u656C\u4E1A",9),r.set("\u8BDA\u4FE1",10),r.set("\u53CB\u5584",11);const n1=a1=>{const s1=r.get(a1);if(s1===void 0)throw new KitError("\u4F60\u7ADF\u7136\u5728\u793E\u4F1A\u4E3B\u4E49\u6838\u5FC3\u4EF7\u503C\u89C2\u91CC\u5939\u5E26\u79C1\u8D27\uFF01");return s1},f1=e.match(/(\S){2}/g);if(f1==null)return new U8;let e1=0,t1=0,r1=0;const c1=[];for(let a1=0;a1<f1.length;a1++){const s1=r1%2===0;let i1=n1(f1[a1]);if(i1===10||i1===11){if(a1++,a1===f1.length)throw new KitError("\u4F60\u7684\u793E\u4F1A\u4E3B\u4E49\u6838\u5FC3\u4EF7\u503C\u89C2\u7834\u788E\u4E86\uFF01");i1=i1===10?10+n1(f1[a1]):6+n1(f1[a1])}s1?e1=i1:t1=i1,s1||c1.push((e1<<4|t1)&255),r1++}return new U8(c1)}function V$2(e){const r=()=>Math.random()>=.5,n1=["\u5BCC\u5F3A","\u6C11\u4E3B","\u6587\u660E","\u548C\u8C10","\u81EA\u7531","\u5E73\u7B49","\u516C\u6B63","\u6CD5\u6CBB","\u7231\u56FD","\u656C\u4E1A","\u8BDA\u4FE1","\u53CB\u5584"];let f1="";return e.forEach(e1=>{const t1=e1>>4&15,r1=e1&15;t1<10?f1+=n1[t1]:f1+=n1[11]+n1[t1-6],r1<10?f1+=n1[r1]:r()?f1+=n1[10]+n1[r1-10]:f1+=n1[11]+n1[r1-6]}),f1}const CSV=h$8(m$6,V$2,"core-socialist-values"),createHash=(e,r)=>wrap(e,r),createTupleHash=(e,r)=>wrap(e,r),createKeyHash=(e,r)=>wrap(e,r),C$7=(e,r,n1,f1)=>f1<16?e^r^n1:e&r|e&n1|r&n1,M$4=(e,r,n1,f1)=>f1<16?e^r^n1:e&r|~e&n1,P$3=e=>e^rotateL32(e,9)^rotateL32(e,17),W$3=e=>e^rotateL32(e,15)^rotateL32(e,23);function j$4(e){const r=new U8(32),n1=r.view(4);n1.set(0,0x7380166fn),n1.set(1,0x4914b2b9n),n1.set(2,0x172442d7n),n1.set(3,0xda8a0600n),n1.set(4,0xa96f30bcn),n1.set(5,0x163138aan),n1.set(6,0xe38dee4dn),n1.set(7,0xb0fb0e4en);const f1=e.length,e1=BigInt(f1)<<3n,t1=64,r1=f1+9+63>>6,c1=new U8(r1*t1);c1.set(e),c1[f1]=128;const a1=new DataView(c1.buffer,c1.byteOffset,c1.byteLength);a1.setBigUint64(c1.length-8,e1,!1);for(let s1=0;s1<c1.length;s1+=t1){const i1=Number(n1.get(0)),o1=Number(n1.get(1)),u1=Number(n1.get(2)),y1=Number(n1.get(3)),b1=Number(n1.get(4)),l1=Number(n1.get(5)),d1=Number(n1.get(6)),I1=Number(n1.get(7));let g1=i1,O1=o1,B1=u1,p1=y1,E1=b1,m1=l1,A1=d1,w1=I1;const h1=new Uint32Array(68),S1=new Uint32Array(64);for(let _1=0;_1<68;_1++)if(_1<16?h1[_1]=a1.getUint32(s1+(_1<<2),!1):h1[_1]=W$3(h1[_1-16]^h1[_1-9]^rotateL32(h1[_1-3],15))^rotateL32(h1[_1-13],7)^h1[_1-6],_1>3){const L1=_1-4;S1[L1]=h1[L1]^h1[_1];const v1=L1<16?2043430169:2055708042,D1=rotateL32(rotateL32(g1,12)+E1+rotateL32(v1,L1),7),C1=D1^rotateL32(g1,12),$1=C$7(g1,O1,B1,L1)+p1+C1+S1[L1],k1=M$4(E1,m1,A1,L1)+w1+D1+h1[L1];p1=B1,B1=rotateL32(O1,9),O1=g1,g1=$1,w1=A1,A1=rotateL32(m1,19),m1=E1,E1=P$3(k1)}n1.set(0,BigInt(i1^g1)),n1.set(1,BigInt(o1^O1)),n1.set(2,BigInt(u1^B1)),n1.set(3,BigInt(y1^p1)),n1.set(4,BigInt(b1^E1)),n1.set(5,BigInt(l1^m1)),n1.set(6,BigInt(d1^A1)),n1.set(7,BigInt(I1^w1))}return r}const sm3=createHash(j$4,{ALGORITHM:"SM3",BLOCK_SIZE:64,DIGEST_SIZE:32,OID:"1.2.156.10197.1.401"}),b$5=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]);function a$1(e,r,n1,f1,e1,t1,r1){const c1=e+(r&n1|~r&f1)+e1+r1;return rotateL32(c1,t1)+r}function u$4(e,r,n1,f1,e1,t1,r1){const c1=e+(r&f1|n1&~f1)+e1+r1;return rotateL32(c1,t1)+r}function d$2(e,r,n1,f1,e1,t1,r1){const c1=e+(r^n1^f1)+e1+r1;return rotateL32(c1,t1)+r}function o$2(e,r,n1,f1,e1,t1,r1){const c1=e+(n1^(r|~f1))+e1+r1;return rotateL32(c1,t1)+r}function B$3(e){const r=new Uint32Array([1732584193,4023233417,2562383102,271733878]),n1=e.length,f1=BigInt(n1)<<3n,e1=64,t1=n1+9+63>>6,r1=new U8(t1*e1);r1.set(e),r1[n1]=128,new DataView(r1.buffer,r1.byteOffset,r1.byteLength).setBigUint64(r1.length-8,f1,!0);for(let c1=0;c1<r1.length;){const a1=c1+e1,s1=new Uint32Array(r1.buffer,r1.byteOffset+c1,e1>>2);c1=a1;const i1=r[0],o1=r[1],u1=r[2],y1=r[3];let b1=i1,l1=o1,d1=u1,I1=y1;b1=a$1(b1,l1,d1,I1,s1[0],7,b$5[0]),I1=a$1(I1,b1,l1,d1,s1[1],12,b$5[1]),d1=a$1(d1,I1,b1,l1,s1[2],17,b$5[2]),l1=a$1(l1,d1,I1,b1,s1[3],22,b$5[3]),b1=a$1(b1,l1,d1,I1,s1[4],7,b$5[4]),I1=a$1(I1,b1,l1,d1,s1[5],12,b$5[5]),d1=a$1(d1,I1,b1,l1,s1[6],17,b$5[6]),l1=a$1(l1,d1,I1,b1,s1[7],22,b$5[7]),b1=a$1(b1,l1,d1,I1,s1[8],7,b$5[8]),I1=a$1(I1,b1,l1,d1,s1[9],12,b$5[9]),d1=a$1(d1,I1,b1,l1,s1[10],17,b$5[10]),l1=a$1(l1,d1,I1,b1,s1[11],22,b$5[11]),b1=a$1(b1,l1,d1,I1,s1[12],7,b$5[12]),I1=a$1(I1,b1,l1,d1,s1[13],12,b$5[13]),d1=a$1(d1,I1,b1,l1,s1[14],17,b$5[14]),l1=a$1(l1,d1,I1,b1,s1[15],22,b$5[15]),b1=u$4(b1,l1,d1,I1,s1[1],5,b$5[16]),I1=u$4(I1,b1,l1,d1,s1[6],9,b$5[17]),d1=u$4(d1,I1,b1,l1,s1[11],14,b$5[18]),l1=u$4(l1,d1,I1,b1,s1[0],20,b$5[19]),b1=u$4(b1,l1,d1,I1,s1[5],5,b$5[20]),I1=u$4(I1,b1,l1,d1,s1[10],9,b$5[21]),d1=u$4(d1,I1,b1,l1,s1[15],14,b$5[22]),l1=u$4(l1,d1,I1,b1,s1[4],20,b$5[23]),b1=u$4(b1,l1,d1,I1,s1[9],5,b$5[24]),I1=u$4(I1,b1,l1,d1,s1[14],9,b$5[25]),d1=u$4(d1,I1,b1,l1,s1[3],14,b$5[26]),l1=u$4(l1,d1,I1,b1,s1[8],20,b$5[27]),b1=u$4(b1,l1,d1,I1,s1[13],5,b$5[28]),I1=u$4(I1,b1,l1,d1,s1[2],9,b$5[29]),d1=u$4(d1,I1,b1,l1,s1[7],14,b$5[30]),l1=u$4(l1,d1,I1,b1,s1[12],20,b$5[31]),b1=d$2(b1,l1,d1,I1,s1[5],4,b$5[32]),I1=d$2(I1,b1,l1,d1,s1[8],11,b$5[33]),d1=d$2(d1,I1,b1,l1,s1[11],16,b$5[34]),l1=d$2(l1,d1,I1,b1,s1[14],23,b$5[35]),b1=d$2(b1,l1,d1,I1,s1[1],4,b$5[36]),I1=d$2(I1,b1,l1,d1,s1[4],11,b$5[37]),d1=d$2(d1,I1,b1,l1,s1[7],16,b$5[38]),l1=d$2(l1,d1,I1,b1,s1[10],23,b$5[39]),b1=d$2(b1,l1,d1,I1,s1[13],4,b$5[40]),I1=d$2(I1,b1,l1,d1,s1[0],11,b$5[41]),d1=d$2(d1,I1,b1,l1,s1[3],16,b$5[42]),l1=d$2(l1,d1,I1,b1,s1[6],23,b$5[43]),b1=d$2(b1,l1,d1,I1,s1[9],4,b$5[44]),I1=d$2(I1,b1,l1,d1,s1[12],11,b$5[45]),d1=d$2(d1,I1,b1,l1,s1[15],16,b$5[46]),l1=d$2(l1,d1,I1,b1,s1[2],23,b$5[47]),b1=o$2(b1,l1,d1,I1,s1[0],6,b$5[48]),I1=o$2(I1,b1,l1,d1,s1[7],10,b$5[49]),d1=o$2(d1,I1,b1,l1,s1[14],15,b$5[50]),l1=o$2(l1,d1,I1,b1,s1[5],21,b$5[51]),b1=o$2(b1,l1,d1,I1,s1[12],6,b$5[52]),I1=o$2(I1,b1,l1,d1,s1[3],10,b$5[53]),d1=o$2(d1,I1,b1,l1,s1[10],15,b$5[54]),l1=o$2(l1,d1,I1,b1,s1[1],21,b$5[55]),b1=o$2(b1,l1,d1,I1,s1[8],6,b$5[56]),I1=o$2(I1,b1,l1,d1,s1[15],10,b$5[57]),d1=o$2(d1,I1,b1,l1,s1[6],15,b$5[58]),l1=o$2(l1,d1,I1,b1,s1[13],21,b$5[59]),b1=o$2(b1,l1,d1,I1,s1[4],6,b$5[60]),I1=o$2(I1,b1,l1,d1,s1[11],10,b$5[61]),d1=o$2(d1,I1,b1,l1,s1[2],15,b$5[62]),l1=o$2(l1,d1,I1,b1,s1[9],21,b$5[63]),r[0]=i1+b1,r[1]=o1+l1,r[2]=u1+d1,r[3]=y1+I1}return new U8(r.buffer)}const md5=createHash(B$3,{ALGORITHM:"MD5",BLOCK_SIZE:64,DIGEST_SIZE:16,OID:"1.2.840.113549.2.5"});function L$7(e){return e<20?1518500249:e<40?1859775393:e<60?2400959708:3395469782}const O$2=(e,r,n1)=>e&r^~e&n1,x$2=(e,r,n1)=>e^r^n1,S$6=(e,r,n1)=>e&r^e&n1^r&n1;function v$3(e,r,n1,f1){return f1<20?O$2(e,r,n1):f1<40?x$2(e,r,n1):f1<60?S$6(e,r,n1):x$2(e,r,n1)}function D$2(e){const r=new U8(20),n1=r.view(4);n1.set(0,0x67452301n),n1.set(1,0xefcdab89n),n1.set(2,0x98badcfen),n1.set(3,0x10325476n),n1.set(4,0xc3d2e1f0n);const f1=e.length,e1=BigInt(f1)<<3n,t1=64,r1=f1+9+63>>6,c1=new U8(r1*t1);c1.set(e),c1[f1]=128;const a1=new DataView(c1.buffer,c1.byteOffset,c1.byteLength);a1.setBigUint64(c1.length-8,e1);for(let s1=0;s1<c1.length;s1+=t1){const i1=Number(n1.get(0)),o1=Number(n1.get(1)),u1=Number(n1.get(2)),y1=Number(n1.get(3)),b1=Number(n1.get(4));let l1=i1,d1=o1,I1=u1,g1=y1,O1=b1;const B1=new Uint32Array(80);for(let p1=0;p1<80;p1++){p1<16?B1[p1]=a1.getUint32(s1+(p1<<2)):B1[p1]=rotateL32(B1[p1-3]^B1[p1-8]^B1[p1-14]^B1[p1-16],1);const E1=rotateL32(l1,5)+v$3(d1,I1,g1,p1)+L$7(p1)+O1+B1[p1];O1=g1,g1=I1,I1=rotateL32(d1,30),d1=l1,l1=E1}n1.set(0,BigInt(i1+l1)),n1.set(1,BigInt(o1+d1)),n1.set(2,BigInt(u1+I1)),n1.set(3,BigInt(y1+g1)),n1.set(4,BigInt(b1+O1))}return r}const sha1=createHash(D$2,{ALGORITHM:"SHA-1",BLOCK_SIZE:64,DIGEST_SIZE:20,OID:"1.3.14.3.2.26"}),L$6=new Uint32Array([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]),G$2=(e,r,n1)=>e&r^~e&n1,Z$4=(e,r,n1)=>e&r^e&n1^r&n1,C$6=e=>rotateR32(e,2)^rotateR32(e,13)^rotateR32(e,22),K$6=e=>rotateR32(e,6)^rotateR32(e,11)^rotateR32(e,25),M$3=e=>rotateR32(e,7)^rotateR32(e,18)^e>>>3,R$6=e=>rotateR32(e,17)^rotateR32(e,19)^e>>>10;function p$6(e,r){e=e.slice(0);const n1=e.view(4),f1=r.length,e1=BigInt(f1)<<3n,t1=64,r1=f1+9+63>>6,c1=new U8(r1*t1);c1.set(r),c1[f1]=128;const a1=new DataView(c1.buffer,c1.byteOffset,c1.byteLength);a1.setBigUint64(c1.length-8,e1);for(let s1=0;s1<c1.length;s1+=t1){const i1=Number(n1.get(0)),o1=Number(n1.get(1)),u1=Number(n1.get(2)),y1=Number(n1.get(3)),b1=Number(n1.get(4)),l1=Number(n1.get(5)),d1=Number(n1.get(6)),I1=Number(n1.get(7));let g1=i1,O1=o1,B1=u1,p1=y1,E1=b1,m1=l1,A1=d1,w1=I1;const h1=new Uint32Array(64);for(let S1=0;S1<h1.length;S1++){S1<16?h1[S1]=a1.getUint32(s1+(S1<<2)):h1[S1]=R$6(h1[S1-2])+h1[S1-7]+M$3(h1[S1-15])+h1[S1-16];const _1=w1+K$6(E1)+G$2(E1,m1,A1)+L$6[S1]+h1[S1],L1=C$6(g1)+Z$4(g1,O1,B1);w1=A1,A1=m1,m1=E1,E1=p1+_1,p1=B1,B1=O1,O1=g1,g1=_1+L1}n1.set(0,BigInt(i1+g1)),n1.set(1,BigInt(o1+O1)),n1.set(2,BigInt(u1+B1)),n1.set(3,BigInt(y1+p1)),n1.set(4,BigInt(b1+E1)),n1.set(5,BigInt(l1+m1)),n1.set(6,BigInt(d1+A1)),n1.set(7,BigInt(I1+w1))}return e}function k$5(e){const r=new U8(32),n1=r.view(4);return n1.set(0,0xc1059ed8n),n1.set(1,0x367cd507n),n1.set(2,0x3070dd17n),n1.set(3,0xf70e5939n),n1.set(4,0xffc00b31n),n1.set(5,0x68581511n),n1.set(6,0x64f98fa7n),n1.set(7,0xbefa4fa4n),p$6(r,e).slice(0,28)}function j$3(e){const r=new U8(32),n1=r.view(4);return n1.set(0,0x6a09e667n),n1.set(1,0xbb67ae85n),n1.set(2,0x3c6ef372n),n1.set(3,0xa54ff53an),n1.set(4,0x510e527fn),n1.set(5,0x9b05688cn),n1.set(6,0x1f83d9abn),n1.set(7,0x5be0cd19n),p$6(r,e)}const sha224=createHash(k$5,{ALGORITHM:"SHA-224",BLOCK_SIZE:64,DIGEST_SIZE:28,OID:"2.16.840.1.101.3.4.2.4"}),sha256=createHash(j$3,{ALGORITHM:"SHA-256",BLOCK_SIZE:64,DIGEST_SIZE:32,OID:"2.16.840.1.101.3.4.2.1"}),R$5=new BigUint64Array([0x428a2f98d728ae22n,0x7137449123ef65cdn,0xb5c0fbcfec4d3b2fn,0xe9b5dba58189dbbcn,0x3956c25bf348b538n,0x59f111f1b605d019n,0x923f82a4af194f9bn,0xab1c5ed5da6d8118n,0xd807aa98a3030242n,0x12835b0145706fben,0x243185be4ee4b28cn,0x550c7dc3d5ffb4e2n,0x72be5d74f27b896fn,0x80deb1fe3b1696b1n,0x9bdc06a725c71235n,0xc19bf174cf692694n,0xe49b69c19ef14ad2n,0xefbe4786384f25e3n,0x0fc19dc68b8cd5b5n,0x240ca1cc77ac9c65n,0x2de92c6f592b0275n,0x4a7484aa6ea6e483n,0x5cb0a9dcbd41fbd4n,0x76f988da831153b5n,0x983e5152ee66dfabn,0xa831c66d2db43210n,0xb00327c898fb213fn,0xbf597fc7beef0ee4n,0xc6e00bf33da88fc2n,0xd5a79147930aa725n,0x06ca6351e003826fn,0x142929670a0e6e70n,0x27b70a8546d22ffcn,0x2e1b21385c26c926n,0x4d2c6dfc5ac42aedn,0x53380d139d95b3dfn,0x650a73548baf63den,0x766a0abb3c77b2a8n,0x81c2c92e47edaee6n,0x92722c851482353bn,0xa2bfe8a14cf10364n,0xa81a664bbc423001n,0xc24b8b70d0f89791n,0xc76c51a30654be30n,0xd192e819d6ef5218n,0xd69906245565a910n,0xf40e35855771202an,0x106aa07032bbd1b8n,0x19a4c116b8d2d0c8n,0x1e376c085141ab53n,0x2748774cdf8eeb99n,0x34b0bcb5e19b48a8n,0x391c0cb3c5c95a63n,0x4ed8aa4ae3418acbn,0x5b9cca4f7763e373n,0x682e6ff3d6b2b8a3n,0x748f82ee5defb2fcn,0x78a5636f43172f60n,0x84c87814a1f0ab72n,0x8cc702081a6439ecn,0x90befffa23631e28n,0xa4506cebde82bde9n,0xbef9a3f7b2c67915n,0xc67178f2e372532bn,0xca273eceea26619cn,0xd186b8c721c0c207n,0xeada7dd6cde0eb1en,0xf57d4f7fee6ed178n,0x06f067aa72176fban,0x0a637dc5a2c898a6n,0x113f9804bef90daen,0x1b710b35131c471bn,0x28db77f523047d84n,0x32caab7b40c72493n,0x3c9ebe0a15c9bebcn,0x431d67c49c100d4cn,0x4cc5d4becb3e42b6n,0x597f299cfc657e2an,0x5fcb6fab3ad6faecn,0x6c44198c4a475817n]),k$4=genBitMask(64),t$2=(e,r)=>rotateR(64,e,r,k$4),C$5=(e,r,n1)=>e&r^~e&n1,V$1=(e,r,n1)=>e&r^e&n1^r&n1,$$1=e=>t$2(e,28n)^t$2(e,34n)^t$2(e,39n),j$2=e=>t$2(e,14n)^t$2(e,18n)^t$2(e,41n),F$1=e=>t$2(e,1n)^t$2(e,8n)^e>>7n,W$2=e=>t$2(e,19n)^t$2(e,61n)^e>>6n;function q$1(e){if(e<=0)throw new KitError("SHA-512 truncation must be greater than 0");if(e>=512)throw new KitError("SHA-512 truncation must be less than 512");if(e===384)throw new KitError("SHA-512 truncation must not be 384");const r=new U8(64),n1=r.view(8);return n1.set(0,0x6a09e667f3bcc908n^0xa5a5a5a5a5a5a5a5n),n1.set(1,0xbb67ae8584caa73bn^0xa5a5a5a5a5a5a5a5n),n1.set(2,0x3c6ef372fe94f82bn^0xa5a5a5a5a5a5a5a5n),n1.set(3,0xa54ff53a5f1d36f1n^0xa5a5a5a5a5a5a5a5n),n1.set(4,0x510e527fade682d1n^0xa5a5a5a5a5a5a5a5n),n1.set(5,0x9b05688c2b3e6c1fn^0xa5a5a5a5a5a5a5a5n),n1.set(6,0x1f83d9abfb41bd6bn^0xa5a5a5a5a5a5a5a5n),n1.set(7,0x5be0cd19137e2179n^0xa5a5a5a5a5a5a5a5n),l$5(r,UTF8(`SHA-512/${e}`))}function l$5(e,r){e=e.slice(0);const n1=e.view(8),f1=r.byteLength,e1=BigInt(f1)<<3n,t1=128,r1=f1+17+127>>7,c1=new U8(r1*t1);c1.set(r),c1[f1]=128;const a1=new DataView(c1.buffer,c1.byteOffset,c1.byteLength);a1.setBigUint64(c1.byteLength-16,e1>>32n),a1.setBigUint64(c1.byteLength-8,e1&0xffffffffffffffffn);for(let s1=0;s1<c1.length;s1+=t1){const i1=n1.get(0),o1=n1.get(1),u1=n1.get(2),y1=n1.get(3),b1=n1.get(4),l1=n1.get(5),d1=n1.get(6),I1=n1.get(7);let g1=i1,O1=o1,B1=u1,p1=y1,E1=b1,m1=l1,A1=d1,w1=I1;const h1=new BigUint64Array(80);for(let S1=0;S1<h1.length;S1++){S1<16?h1[S1]=a1.getBigUint64(s1+(S1<<3)):h1[S1]=W$2(h1[S1-2])+h1[S1-7]+F$1(h1[S1-15])+h1[S1-16];const _1=w1+j$2(E1)+C$5(E1,m1,A1)+R$5[S1]+h1[S1],L1=$$1(g1)+V$1(g1,O1,B1);w1=A1,A1=m1,m1=E1,E1=p1+_1&0xffffffffffffffffn,p1=B1,B1=O1,O1=g1,g1=_1+L1&0xffffffffffffffffn}n1.set(0,i1+g1),n1.set(1,o1+O1),n1.set(2,u1+B1),n1.set(3,y1+p1),n1.set(4,b1+E1),n1.set(5,l1+m1),n1.set(6,d1+A1),n1.set(7,I1+w1)}return e}function z$1(e){const r=new U8(64),n1=r.view(8);return n1.set(0,0xcbbb9d5dc1059ed8n),n1.set(1,0x629a292a367cd507n),n1.set(2,0x9159015a3070dd17n),n1.set(3,0x152fecd8f70e5939n),n1.set(4,0x67332667ffc00b31n),n1.set(5,0x8eb44a8768581511n),n1.set(6,0xdb0c2e0d64f98fa7n),n1.set(7,0x47b5481dbefa4fa4n),l$5(r,e).slice(0,48)}function J$1(e){const r=new U8(64),n1=r.view(8);return n1.set(0,0x6a09e667f3bcc908n),n1.set(1,0xbb67ae8584caa73bn),n1.set(2,0x3c6ef372fe94f82bn),n1.set(3,0xa54ff53a5f1d36f1n),n1.set(4,0x510e527fade682d1n),n1.set(5,0x9b05688c2b3e6c1fn),n1.set(6,0x1f83d9abfb41bd6bn),n1.set(7,0x5be0cd19137e2179n),l$5(r,e)}const sha384=createHash(z$1,{ALGORITHM:"SHA-384",BLOCK_SIZE:128,DIGEST_SIZE:48,OID:"2.16.840.1.101.3.4.2.2"}),sha512=createHash(J$1,{ALGORITHM:"SHA-512",BLOCK_SIZE:128,DIGEST_SIZE:64,OID:"2.16.840.1.101.3.4.2.3"});function sha512t(e){const r=q$1(e);let n1;return e===224&&(n1="2.16.840.1.101.3.4.2.5"),e===256&&(n1="2.16.840.1.101.3.4.2.6"),createHash(f1=>l$5(r,f1).slice(0,e>>3),{ALGORITHM:`SHA-512/${e}`,BLOCK_SIZE:128,DIGEST_SIZE:e>>3,OID:n1})}const g$8=[[0n,36n,3n,41n,18n],[1n,44n,10n,45n,2n],[62n,6n,43n,15n,61n],[28n,55n,25n,21n,56n],[27n,20n,39n,8n,14n]],B$2=[0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n],R$4=[0x0000000000000001n,0x0000000000008082n,0x800000000000808an,0x8000000080008000n,0x000000000000808bn,0x0000000080000001n,0x8000000080008081n,0x8000000000008009n,0x000000000000008an,0x0000000000000088n,0x0000000080008009n,0x000000008000000an,0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n],m$5=genBitMask(64),u$3=(e,r)=>rotateL(64,e,r,m$5);function RCGen(e=6,r=24){const n1=[];for(let f1=0;f1<r;f1++){let e1=0n;for(let t1=0;t1<=e;t1++){const r1=t1+7*f1;let c1;if(r1%255===0)c1=1n;else{let a1=0x80n;for(let s1=1;s1<=r1%255;s1++){const i1=a1&1n;a1^=i1<<8n|i1<<4n|i1<<3n|i1<<2n,a1>>=1n}c1=a1>>7n}e1|=c1<<BigInt(2**t1-1)}n1.push(e1)}return n1}function l$4(){return Array.from({length:5}).map(()=>new BigUint64Array(5))}function k$3(e){const r=l$4(),n1=new DataView(e.buffer,e.byteOffset,e.byteLength);for(let f1=0;f1<5;f1++)for(let e1=0;e1<5;e1++)r[f1][e1]=n1.getBigUint64(e1*5+f1<<3,!0);return r}function C$4(e){const r=new Uint8Array(200),n1=new DataView(r.buffer,r.byteOffset,r.byteLength);for(let f1=0;f1<5;f1++)for(let e1=0;e1<5;e1++)n1.setBigUint64(e1*5+f1<<3,e[f1][e1],!0);return r}function L$5(e){const r=new BigUint64Array(5),n1=new BigUint64Array(5);for(let f1=0;f1<5;f1++)r[f1]=e[f1][0]^e[f1][1]^e[f1][2]^e[f1][3]^e[f1][4];for(let f1=0;f1<5;f1++){n1[f1]=r[(f1+4)%5]^u$3(r[(f1+1)%5],1n);for(let e1=0;e1<5;e1++)e[f1][e1]=e[f1][e1]^n1[f1]}return e}function _$3(e){const r=l$4();for(let n1=0;n1<5;n1++)for(let f1=0;f1<5;f1++)r[f1][(2*n1+3*f1)%5]=u$3(e[n1][f1],g$8[n1][f1]);return r}function P$2(e){const r=l$4();for(let n1=0;n1<5;n1++)for(let f1=0;f1<5;f1++)r[n1][f1]=e[n1][f1]^~e[(n1+1)%5][f1]&e[(n1+2)%5][f1];return r}function d$1(e,r){return e[0][0]=e[0][0]^r,e}function keccak_p_1600(e=24){let r;return e===12?r=B$2:e===24?r=R$4:r=RCGen(6,e),n1=>{if(n1.byteLength!==200)throw new KitError("Invalid state size");let f1=k$3(n1);for(let e1=0;e1<e;e1++)f1=d$1(P$2(_$3(L$5(f1))),r[e1]);return new U8(C$4(f1))}}function sponge_1600(e,r,n1,f1=keccak_p_1600()){return e1=>{const t1=n1(e1);let r1=new Uint8Array(200),c1=0;for(;c1<t1.byteLength;){const i1=c1+e,o1=t1.slice(c1,i1);r1.forEach((u1,y1)=>{r1[y1]=u1^o1[y1]}),r1=f1(r1),c1=i1}const a1=[r1.slice(0,e)];let s1=e;for(;s1<r;)r1=f1(r1),a1.push(r1.slice(0,e)),s1+=e;return joinBuffer(...a1).slice(0,r)}}const s$1=e=>r=>{const n1=r.length,f1=e-n1%e,e1=new U8(n1+f1);return e1.set(r),f1===1&&(e1[n1]=134),e1[n1]=6,e1[e1.length-1]|=128,e1},S$5=e=>r=>{const n1=r.length,f1=e-n1%e,e1=new U8(n1+f1);return e1.set(r),f1===1&&(e1[n1]=159),e1[n1]=31,e1[e1.length-1]|=128,e1};function Keccak_c(e,r,n1){const f1=1600-e>>3,e1=n1(f1);return t1=>sponge_1600(f1,r>>3,e1)(t1)}const sha3_224=createHash(e=>Keccak_c(448,224,s$1)(e),{ALGORITHM:"SHA3-224",BLOCK_SIZE:144,DIGEST_SIZE:28,OID:"2.16.840.1.101.3.4.2.7"}),sha3_256=createHash(e=>Keccak_c(512,256,s$1)(e),{ALGORITHM:"SHA3-256",BLOCK_SIZE:136,DIGEST_SIZE:32,OID:"2.16.840.1.101.3.4.2.8"}),sha3_384=createHash(e=>Keccak_c(768,384,s$1)(e),{ALGORITHM:"SHA3-384",BLOCK_SIZE:104,DIGEST_SIZE:48,OID:"2.16.840.1.101.3.4.2.9"}),sha3_512=createHash(e=>Keccak_c(1024,512,s$1)(e),{ALGORITHM:"SHA3-512",BLOCK_SIZE:72,DIGEST_SIZE:64,OID:"2.16.840.1.101.3.4.2.10"});function shake128(e){return createHash(r=>Keccak_c(256,e,S$5)(r),{ALGORITHM:`SHAKE128/${e}`,BLOCK_SIZE:168,DIGEST_SIZE:e>>3})}function shake256(e){return createHash(r=>Keccak_c(512,e,S$5)(r),{ALGORITHM:`SHAKE256/${e}`,BLOCK_SIZE:136,DIGEST_SIZE:e>>3})}function H$4(e){const r=[];do r.unshift(e&255),e=e>>8;while(e>0);return r.unshift(r.length),Uint8Array.from(r)}function f$2(e){const r=[];do r.unshift(e&255),e=e>>8;while(e>0);return r.push(r.length),Uint8Array.from(r)}function o$1(e){return e=typeof e=="string"?UTF8(e):e,[H$4(e.byteLength<<3),e]}function A$5(e,r){if(r<=0)throw new KitError("w must be greater than 0");const n1=H$4(r);let f1=n1.length;e.forEach(t1=>{f1+=t1.length});const e1=r-f1%r;return e.unshift(n1),e.push(new Uint8Array(e1)),e}const S$4=e=>r=>{const n1=r.length,f1=e-n1%e,e1=new U8(n1+f1);return e1.set(r),f1===1&&(e1[n1]=132),e1[n1]=4,e1[e1.length-1]|=128,e1};function L$4(e,r,n1,f1,e1,t1){return r.byteLength===0&&n1.byteLength===0?r1=>t1(e)(r1):r1=>{const c1=A$5([...o$1(r),...o$1(n1)],e1);return c1.push(r1),Keccak_c(f1,e,S$4)(joinBuffer(...c1))}}function cshake128(e,r=new Uint8Array,n1=new Uint8Array){return createHash(L$4(e,r,n1,256,168,shake128),{ALGORITHM:`cSHAKE128/${e}`,BLOCK_SIZE:168,DIGEST_SIZE:e>>3})}function cshake256(e,r=new Uint8Array,n1=new Uint8Array){return createHash(L$4(e,r,n1,512,136,shake256),{ALGORITHM:`cSHAKE256/${e}`,BLOCK_SIZE:136,DIGEST_SIZE:e>>3})}function p$5(e,r,n1,f1,e1){return(t1,r1)=>{const c1=A$5([...o$1("KMAC"),...o$1(r)],f1);return c1.push(...A$5(o$1(t1),f1)),c1.push(r1),c1.push(f$2(e1?0:e)),Keccak_c(n1,e,S$4)(joinBuffer(...c1))}}function kmac128(e,r=new Uint8Array(0),n1=128){return createKeyHash(p$5(e,r,256,168,!1),{ALGORITHM:`KMAC128/${e}`,BLOCK_SIZE:168,DIGEST_SIZE:e>>3,KEY_SIZE:n1>>3})}function kmac256(e,r=new Uint8Array(0),n1=256){return createKeyHash(p$5(e,r,512,136,!1),{ALGORITHM:`KMAC256/${e}`,BLOCK_SIZE:136,DIGEST_SIZE:e>>3,KEY_SIZE:n1>>3})}function kmac128XOF(e,r=new Uint8Array(0),n1=128){return createKeyHash(p$5(e,r,256,168,!0),{ALGORITHM:`KMAC128XOF/${e}`,BLOCK_SIZE:168,DIGEST_SIZE:e>>3,KEY_SIZE:n1>>3})}function kmac256XOF(e,r=new Uint8Array(0),n1=256){return createKeyHash(p$5(e,r,512,136,!0),{ALGORITHM:`KMAC256XOF/${e}`,BLOCK_SIZE:136,DIGEST_SIZE:e>>3,KEY_SIZE:n1>>3})}function b$4(e,r,n1,f1,e1){return t1=>{const r1=A$5([...o$1("TupleHash"),...o$1(r)],f1);return t1.forEach(c1=>{r1.push(...o$1(c1))}),r1.push(f$2(e1?0:e)),Keccak_c(n1,e,S$4)(joinBuffer(...r1))}}function tuplehash128(e,r=new Uint8Array){return createTupleHash(b$4(e,r,256,168,!1),{ALGORITHM:`TupleHash128/${e}`,BLOCK_SIZE:168,DIGEST_SIZE:e>>3})}function tuplehash256(e,r=new Uint8Array){return createTupleHash(b$4(e,r,512,136,!1),{ALGORITHM:`TupleHash256/${e}`,BLOCK_SIZE:136,DIGEST_SIZE:e>>3})}function tuplehash128XOF(e,r=new Uint8Array){return createTupleHash(b$4(e,r,256,168,!0),{ALGORITHM:`TupleHash128XOF/${e}`,BLOCK_SIZE:168,DIGEST_SIZE:e>>3})}function tuplehash256XOF(e,r=new Uint8Array){return createTupleHash(b$4(e,r,512,136,!0),{ALGORITHM:`TupleHash256XOF/${e}`,BLOCK_SIZE:136,DIGEST_SIZE:e>>3})}function U$5(e,r,n1,f1,e1,t1,r1){const c1=e>>3;return a1=>{const s1=Math.ceil(a1.byteLength/c1),i1=A$5([...o$1("ParallelHash"),...o$1(n1)],e1);i1.push(H$4(e));for(let o1=0;o1<s1;o1++){const u1=u8(a1).slice(o1*(e<<3),(o1+1)*(e<<3));i1.push(r1(u1))}return i1.push(f$2(s1)),i1.push(f$2(t1?0:r)),Keccak_c(f1,r,S$4)(joinBuffer(...i1))}}function parallelhash128(e,r,n1=new Uint8Array){return createHash(U$5(e,r,n1,256,168,!1,shake128(256)),{ALGORITHM:`ParallelHash128/${r}`,BLOCK_SIZE:168,DIGEST_SIZE:r>>3})}function parallelhash256(e,r,n1=new Uint8Array){return createHash(U$5(e,r,n1,512,136,!1,shake256(512)),{ALGORITHM:`ParallelHash256/${r}`,BLOCK_SIZE:136,DIGEST_SIZE:r>>3})}function parallelhash128XOF(e,r,n1=new Uint8Array){return createHash(U$5(e,r,n1,256,168,!0,shake128(256)),{ALGORITHM:"ParallelHash128XOF",BLOCK_SIZE:168,DIGEST_SIZE:r>>3})}function parallelhash256XOF(e,r,n1=new Uint8Array){return createHash(U$5(e,r,n1,512,136,!0,shake256(512)),{ALGORITHM:"ParallelHash256XOF",BLOCK_SIZE:136,DIGEST_SIZE:r>>3})}function f$1(e,r){return n1=>{const f1=n1.length+1,e1=Math.ceil(f1/e),t1=new U8(e1*e);return t1.set(n1),t1[n1.length]=r,t1[t1.length-1]^=128,t1}}function turboshake128(e,r=31){if(r<1||r>127)throw new KitError("Invalid Domain Separator");const n1=e>>3,f1=168,e1=keccak_p_1600(12),t1=f$1(f1,r);return createHash(r1=>sponge_1600(f1,n1,t1,e1)(r1),{ALGORITHM:`TurboSHAKE128/${e}`,BLOCK_SIZE:f1,DIGEST_SIZE:n1})}function turboshake256(e,r=31){if(r<1||r>127)throw new KitError("Invalid Domain Separator");const n1=e>>3,f1=136,e1=keccak_p_1600(12),t1=f$1(f1,r);return createHash(r1=>sponge_1600(f1,n1,t1,e1)(r1),{ALGORITHM:`TurboSHAKE256/${e}`,BLOCK_SIZE:f1,DIGEST_SIZE:n1})}function h$7(e){const r=[];for(;e>0;)r.unshift(e&255),e>>=8;return r.push(r.length),new Uint8Array(r)}function l$3(e,r,n1,f1){return e1=>{const t1=h$7(r.length),r1=joinBuffer(e1,r,t1);if(r1.length<=8192)return n1(e,7)(r1);{const c1=[];c1.push(r1.slice(0,8192)),c1.push(new Uint8Array([3,0,0,0,0,0,0,0]));let a1=8192,s1=0;for(;a1<r1.length;){const i1=a1+8192,o1=n1(f1,11)(r1.slice(a1,i1));c1.push(o1),a1=i1,s1++}return c1.push(h$7(s1)),c1.push(new Uint8Array([255,255])),n1(e,6)(joinBuffer(...c1))}}}function kt128(e,r=new Uint8Array){return createHash(l$3(e,r,turboshake128,256),{ALGORITHM:`KangarooTwelve128/${e}`,BLOCK_SIZE:8192,DIGEST_SIZE:e>>3})}function kt256(e,r=new Uint8Array){return createHash(l$3(e,r,turboshake256,512),{ALGORITHM:`KangarooTwelve256/${e}`,BLOCK_SIZE:8192,DIGEST_SIZE:e>>3})}function H$3(e,r,n1){const{BLOCK_SIZE:f1}=e,e1=new Uint8Array(f1);e1.set(r.length>f1?e(r):r);const t1=e1.map(a1=>a1^54),r1=e1.map(a1=>a1^92),c1=e(joinBuffer(t1,n1));return e(joinBuffer(r1,c1))}function hmac(e,r,n1){const{ALGORITHM:f1,BLOCK_SIZE:e1,DIGEST_SIZE:t1}=e;r=r?Math.min(r>>3,t1):t1,n1=n1?n1>>3:t1;const r1={ALGORITHM:`HMAC-${f1}-${r<<3}`,BLOCK_SIZE:e1,DIGEST_SIZE:r,KEY_SIZE:n1};return createKeyHash((c1,a1)=>H$3(e,c1,a1).slice(0,r),r1)}function p$4(e,r,n1=hmac(sha1)){const f1=n1(e,r),e1=f1[f1.length-1]&15;return f1.slice(e1,e1+4)}function totp(e){if(e instanceof Uint8Array){const r=e,n1=U8.fromBI(BigInt(Math.floor(Date.now()/3e4)),8,!1),f1=p$4(r,n1,hmac(sha1));return((0|(f1[0]&127)<<24|(f1[1]&255)<<16|(f1[2]&255)<<8|f1[3]&255)%1e6).toString().padStart(6,"0")}return r=>{let{mac:n1=hmac(sha1),current:f1=Date.now(),epoch:e1=0,step:t1=3e4,counter:r1=0,digits:c1=6}=e||{};if(!r1){const s1=BigInt(Math.floor((f1-e1)/t1));r1=U8.fromBI(s1,8,!1)}r1 instanceof Uint8Array||(r1=U8.fromBI(BigInt(r1),8,!1));const a1=p$4(r,r1,n1);return((0|(a1[0]&127)<<24|(a1[1]&255)<<16|(a1[2]&255)<<8|a1[3]&255)%10**c1).toString().padStart(c1,"0")}}function createCipher(e,r){return wrap((n1,f1)=>wrap(e(n1,f1),r),r)}function createPadding(e,r,n1){return wrap((f1,e1)=>typeof e1=="number"?e(f1,e1):r(f1),n1)}const PKCS7_PAD=createPadding((e,r)=>{const n1=r-e.length%r;return joinBuffer(e,new Uint8Array(n1).fill(n1))},e=>{const r=e[e.length-1];return new U8(e.slice(0,e.length-r))},{ALGORITHM:"PKCS#7"}),ISO7816_PAD=createPadding((e,r)=>{const n1=Math.ceil((e.length+1)/r),f1=new U8(n1*r);return f1.set(e),f1[e.length]=128,f1},e=>{let r=e.length-1;for(;e[r]===128;)if(r=r-1,r<0)return console.warn("This message may not be ISO/IEC 7816-4 padded"),new U8;return new U8(e.slice(0,r+1))},{ALGORITHM:"ISO/IEC 7816-4"}),X923_PAD=createPadding((e,r)=>{const n1=Math.ceil((e.length+1)/r),f1=new U8(n1*r);return f1.set(e),f1[f1.length-1]=f1.length-e.length,f1},e=>{const r=e[e.length-1];return new U8(e.slice(0,e.length-r))},{ALGORITHM:"ANSI X9.23"}),ZERO_PAD=createPadding((e,r)=>{const n1=r-e.length%r;return joinBuffer(e,new Uint8Array(n1))},e=>{let r=e.length-1;for(;e[r]===0;)if(r=r-1,r<0)return new U8;return new U8(e.slice(0,r+1))},{ALGORITHM:"Zero Padding"}),NO_PAD=createPadding(e=>new U8(e.slice(0)),e=>new U8(e.slice(0)),{ALGORITHM:"No Padding"}),ecb=wrap((e,r=PKCS7_PAD)=>{const n1={ALGORITHM:`ECB-${e.ALGORITHM}`,PADDING:r,BLOCK_SIZE:e.BLOCK_SIZE,KEY_SIZE:e.KEY_SIZE,MIN_KEY_SIZE:e.MIN_KEY_SIZE,MAX_KEY_SIZE:e.MAX_KEY_SIZE,IV_SIZE:0,MIN_IV_SIZE:0,MAX_IV_SIZE:0};return wrap(f1=>{f1=u8(f1);const{BLOCK_SIZE:e1}=e,t1=e(f1);return wrap({encrypt:r1=>{r1=u8(r1);const c1=r(r1,e1),a1=new U8(c1.length);for(let s1=0,i1=e1;s1<c1.length;){const o1=c1.subarray(s1,i1);a1.set(t1.encrypt(o1),s1),s1=i1,i1+=e1}return a1},decrypt:r1=>{if(r1=u8(r1),r1.length%e1!==0)throw new KitError("Decryption error");const c1=new U8(r1.length);for(let a1=0,s1=e1;a1<r1.length;){const i1=r1.subarray(a1,s1);c1.set(t1.decrypt(i1),a1),a1=s1,s1+=e1}return r(c1)}},n1)},n1)},{ALGORITHM:"ECB"}),cbc=wrap((e,r=PKCS7_PAD)=>{const n1={ALGORITHM:`CBC-${e.ALGORITHM}`,PADDING:r,BLOCK_SIZE:e.BLOCK_SIZE,KEY_SIZE:e.KEY_SIZE,MIN_KEY_SIZE:e.MIN_KEY_SIZE,MAX_KEY_SIZE:e.MAX_KEY_SIZE,IV_SIZE:e.BLOCK_SIZE,MIN_IV_SIZE:e.BLOCK_SIZE,MAX_IV_SIZE:e.BLOCK_SIZE};return wrap((f1,e1)=>{f1=u8(f1),e1=u8(e1);const{BLOCK_SIZE:t1}=e;if(e1.length!==t1)throw new KitError(`${n1.ALGORITHM} iv must be ${t1} byte`);const r1=e(f1);return wrap({encrypt:c1=>{c1=u8(c1);const a1=r(c1,t1),s1=new U8(a1.length);let i1=e1.slice(0);for(let o1=0,u1=t1;o1<a1.length;){const y1=a1.subarray(o1,u1);i1.forEach((b1,l1)=>{i1[l1]^=y1[l1]}),i1=r1.encrypt(i1),s1.set(i1,o1),o1=u1,u1+=t1}return s1},decrypt:c1=>{if(c1=u8(c1),c1.length%t1!==0)throw new KitError("Decryption error");const a1=new U8(c1.length);let s1=e1.slice(0);for(let i1=0,o1=t1;i1<c1.length;){const u1=c1.slice(i1,o1);r1.decrypt(u1).forEach((y1,b1)=>{s1[b1]^=y1}),a1.set(s1,i1),s1=u1,i1=o1,o1+=t1}return r(a1)}},n1)},n1)},{ALGORITHM:"CBC"}),pcbc=wrap((e,r=PKCS7_PAD)=>{const n1={ALGORITHM:`PCBC-${e.ALGORITHM}`,PADDING:r,BLOCK_SIZE:e.BLOCK_SIZE,KEY_SIZE:e.KEY_SIZE,MIN_KEY_SIZE:e.MIN_KEY_SIZE,MAX_KEY_SIZE:e.MAX_KEY_SIZE,IV_SIZE:e.BLOCK_SIZE,MIN_IV_SIZE:e.BLOCK_SIZE,MAX_IV_SIZE:e.BLOCK_SIZE};return wrap((f1,e1)=>{f1=u8(f1),e1=u8(e1);const{BLOCK_SIZE:t1}=e;if(e1.length!==t1)throw new KitError(`${n1.ALGORITHM} iv must be ${t1} byte`);const r1=e(f1);return wrap({encrypt:c1=>{c1=u8(c1);const a1=r(c1,t1),s1=new U8(a1.length),i1=e1.slice(0);for(let o1=0,u1=t1;o1<a1.length;){const y1=a1.subarray(o1,u1);i1.forEach((l1,d1)=>{i1[d1]^=y1[d1]});const b1=r1.encrypt(i1);s1.set(b1,o1),i1.forEach((l1,d1)=>{i1[d1]=b1[d1]^y1[d1]}),o1=u1,u1+=t1}return s1},decrypt:c1=>{if(c1=u8(c1),c1.length%t1!==0)throw new KitError("Decryption error");const a1=new U8(c1.length),s1=e1.slice(0);for(let i1=0,o1=t1;i1<c1.length;){const u1=c1.slice(i1,o1),y1=r1.decrypt(u1);y1.forEach((b1,l1)=>{y1[l1]^=s1[l1]}),a1.set(y1,i1),u1.forEach((b1,l1)=>{s1[l1]=u1[l1]^y1[l1]}),i1=o1,o1+=t1}return r(a1)}},n1)},n1)},{ALGORITHM:"PCBC"}),cfb=wrap((e,r=PKCS7_PAD)=>{const n1={ALGORITHM:`CFB-${e.ALGORITHM}`,PADDING:r,BLOCK_SIZE:e.BLOCK_SIZE,KEY_SIZE:e.KEY_SIZE,MIN_KEY_SIZE:e.MIN_KEY_SIZE,MAX_KEY_SIZE:e.MAX_KEY_SIZE,IV_SIZE:e.BLOCK_SIZE,MIN_IV_SIZE:e.BLOCK_SIZE,MAX_IV_SIZE:e.BLOCK_SIZE};return wrap((f1,e1)=>{f1=u8(f1),e1=u8(e1);const{BLOCK_SIZE:t1}=e;if(e1.length!==t1)throw new KitError(`${n1.ALGORITHM} iv must be ${t1} byte`);const r1=e(f1);return wrap({encrypt:c1=>{c1=u8(c1);const a1=r(c1,t1),s1=new U8(a1.length);let i1=e1.slice(0);for(let o1=0,u1=t1;o1<a1.length;){const y1=a1.subarray(o1,u1);i1=r1.encrypt(i1),i1.forEach((b1,l1)=>{i1[l1]^=y1[l1]}),s1.set(i1.subarray(0,y1.length),o1),o1=u1,u1+=t1}return s1},decrypt:c1=>{c1=u8(c1);const a1=new U8(c1.length);let s1=e1.slice(0);for(let i1=0,o1=t1;i1<c1.length;){const u1=c1.subarray(i1,o1);s1=r1.encrypt(s1),u1.forEach((y1,b1)=>{s1[b1]^=u1[b1]}),a1.set(s1.subarray(0,u1.length),i1),s1=U8.from(u1),i1=o1,o1+=t1}return r(a1)}},n1)},n1)},{ALGORITHM:"CFB"}),ofb=wrap((e,r=PKCS7_PAD)=>{const n1={ALGORITHM:`OFB-${e.ALGORITHM}`,PADDING:r,BLOCK_SIZE:e.BLOCK_SIZE,KEY_SIZE:e.KEY_SIZE,MIN_KEY_SIZE:e.MIN_KEY_SIZE,MAX_KEY_SIZE:e.MAX_KEY_SIZE,IV_SIZE:e.BLOCK_SIZE,MIN_IV_SIZE:e.BLOCK_SIZE,MAX_IV_SIZE:e.BLOCK_SIZE};return wrap((f1,e1)=>{f1=u8(f1),e1=u8(e1);const{BLOCK_SIZE:t1}=e;if(e1.length!==t1)throw new KitError(`${n1.ALGORITHM} iv must be ${t1} byte`);const r1=e(f1);let c1=r1.encrypt(e1),a1=c1,s1=t1;const i1=o1=>{if(s1>o1)return a1;const u1=[a1];for(;s1<o1;)c1=r1.encrypt(c1),u1.push(c1),s1+=t1;return a1=joinBuffer(...u1),a1};return wrap({encrypt:o1=>{o1=u8(o1);const u1=r(o1,t1);return a1=i1(u1.length),u1.map((y1,b1)=>y1^a1[b1])},decrypt:o1=>(o1=u8(o1),a1=i1(o1.length),r(o1.map((u1,y1)=>u1^a1[y1])))},n1)},n1)},{ALGORITHM:"OFB"}),ctr=wrap((e,r=PKCS7_PAD)=>{const n1={ALGORITHM:`CTR-${e.ALGORITHM}`,PADDING:r,BLOCK_SIZE:e.BLOCK_SIZE,KEY_SIZE:e.KEY_SIZE,MIN_KEY_SIZE:e.MIN_KEY_SIZE,MAX_KEY_SIZE:e.MAX_KEY_SIZE,IV_SIZE:e.BLOCK_SIZE,MIN_IV_SIZE:e.BLOCK_SIZE,MAX_IV_SIZE:e.BLOCK_SIZE};return wrap((f1,e1)=>{f1=u8(f1),e1=u8(e1);const{BLOCK_SIZE:t1}=e;if(e1.length!==t1)throw new KitError(`{info.ALGORITHM} iv must be ${t1} byte`);const r1=e(f1),c1=new Counter(e1.slice(0));let a1=new U8,s1=0;const i1=o1=>{if(s1>o1)return a1;const u1=[a1];for(;s1<o1;)u1.push(r1.encrypt(c1)),c1.inc(),s1+=t1;return a1=joinBuffer(...u1),a1};return wrap({encrypt:o1=>{o1=u8(o1);const u1=r(o1,t1);return a1=i1(u1.length),u1.map((y1,b1)=>y1^a1[b1])},decrypt:o1=>(o1=u8(o1),a1=i1(o1.length),r(o1.map((u1,y1)=>u1^a1[y1])))},n1)},n1)},{ALGORITHM:"CTR"});function K$5(e,r){const n1=0xe1n<<56n,f1=new DataView(r.buffer,r.byteOffset,r.byteLength);let e1=f1.getBigUint64(0,!1),t1=f1.getBigUint64(8,!1),r1=0n,c1=0n;for(let i1=0;i1<16;i1++){const o1=e[i1];for(let u1=7;u1>=0;u1--){o1>>u1&1&&(r1^=e1,c1^=t1);const y1=t1&1n;t1=e1<<63n|t1>>1n,t1=t1&0xffffffffffffffffn,e1=e1>>1n,y1&&(e1^=n1)}}const a1=new U8(16),s1=new DataView(a1.buffer,a1.byteOffset,a1.byteLength);return s1.setBigUint64(0,r1,!1),s1.setBigUint64(8,c1,!1),a1}function b$3(e,r,n1){const f1=Math.ceil(r.length/16),e1=Math.ceil(n1.length/16),t1=new Uint8Array((f1+e1+1)*16),r1=new DataView(t1.buffer,t1.byteOffset,t1.byteLength);t1.set(r),t1.set(n1,f1*16),r1.setBigUint64(t1.length-16,BigInt(r.length<<3),!1),r1.setBigUint64(t1.length-8,BigInt(n1.length<<3),!1);let c1=new U8(16);for(let a1=0;a1<t1.length;a1+=16){const s1=t1.subarray(a1,a1+16);c1.forEach((i1,o1)=>{c1[o1]^=s1[o1]}),c1=K$5(e,c1)}return c1}const gcm=wrap((e,r=PKCS7_PAD,n1=16)=>{const{BLOCK_SIZE:f1}=e;if(f1!==16)throw new KitError("GCM cipher block must be 128 bit");const e1={ALGORITHM:`GCM-${e.ALGORITHM}`,PADDING:r,BLOCK_SIZE:e.BLOCK_SIZE,KEY_SIZE:e.KEY_SIZE,MIN_KEY_SIZE:e.MIN_KEY_SIZE,MAX_KEY_SIZE:e.MAX_KEY_SIZE,IV_SIZE:12,MIN_IV_SIZE:0,MAX_IV_SIZE:1/0,AUTH_TAG_SIZE:n1};return wrap((t1,r1)=>{t1=u8(t1),r1=u8(r1);const c1=e(t1),a1=c1.encrypt(new Uint8Array(f1));let s1=new Counter(16);r1.length===12?(s1.set(r1),s1[15]=1):s1=new Counter(b$3(a1,new Uint8Array,r1.slice(0)));let i1=c1.encrypt(s1),o1=0;const u1=d1=>{if(o1>d1)return i1;const I1=[i1];for(;o1<d1;)s1.inc(),I1.push(c1.encrypt(s1)),o1+=f1;return i1=joinBuffer(...I1),i1},y1=d1=>{d1=u8(d1);const I1=r(d1,f1);return i1=u1(I1.length),I1.map((g1,O1)=>g1^i1[O1+f1])},b1=d1=>(d1=u8(d1),i1=u1(d1.length),r(d1.map((I1,g1)=>I1^i1[g1+f1]))),l1=(d1,I1=new Uint8Array)=>{d1=u8(d1),I1=u8(I1);const g1=b$3(a1,I1,d1);return g1.forEach((O1,B1)=>{g1[B1]^=i1[B1]}),g1.slice(0,n1)};return wrap({encrypt:y1,decrypt:b1,sign:l1,verify:(d1,I1,g1)=>{if(d1=u8(d1),I1=u8(I1),g1=g1?u8(g1):void 0,d1.length!==n1)return!1;const O1=l1(I1,g1);return d1.every((B1,p1)=>B1===O1[p1])}},e1)},e1)},{ALGORITHM:"GCM",IV_SIZE:12});function f(e){const r=new Uint8Array(256);r.forEach((f1,e1)=>{r[e1]=e1});let n1=0;for(let f1=0;f1<256;f1++)n1=(n1+r[f1]+e[f1%e.byteLength])%256,[r[f1],r[n1]]=[r[n1],r[f1]];return r}function y$6(e,r){r=r.slice(0);const n1=new U8(e.byteLength);let f1=0,e1=0;return e.forEach((t1,r1)=>{f1=(f1+1)%256,e1=(e1+r[f1])%256,[r[f1],r[e1]]=[r[e1],r[f1]],n1[r1]=e[r1]^r[(r[f1]+r[e1])%256]}),n1}function h$6(e){if(e.byteLength<5||e.byteLength>256)throw new KitError("RC4 key must be between 5 and 256 byte");const r=f(e);return{encrypt:n1=>y$6(n1,r),decrypt:n1=>y$6(n1,r)}}const arc4=createCipher(h$6,{ALGORITHM:"ARC4",KEY_SIZE:16,MIN_KEY_SIZE:5,MAX_KEY_SIZE:256}),g$7=new Uint32Array([1295307597,3545052371,886263092,1295307597,3545052371,886263092,1295307597,3545052371]);function m$4(e,r){if(e.length!==16)throw new KitError("Rabbit key must be 16 byte");let n1=0;const f1=new Uint8Array(32),e1=new Uint8Array(32),t1=new Uint32Array(f1.buffer),r1=new Uint32Array(e1.buffer),c1=(u1=!1)=>{for(let l1=0;l1<8;l1++){const d1=r1[l1]+g$7[l1]+n1;r1[l1]=d1|0,n1=d1>4294967295?1:0}const y1=new Uint32Array(8);for(let l1=0;l1<8;l1++){const d1=BigInt(t1[l1])+BigInt(r1[l1])&0xffffffffn,I1=d1*d1;y1[l1]=Number((I1^I1>>32n)&0xffffffffn)}if(t1[0]=4294967295&y1[0]+rotateL32(y1[7],16)+rotateL32(y1[6],16),t1[1]=4294967295&y1[1]+rotateL32(y1[0],8)+y1[7],t1[2]=4294967295&y1[2]+rotateL32(y1[1],16)+rotateL32(y1[0],16),t1[3]=4294967295&y1[3]+rotateL32(y1[2],8)+y1[1],t1[4]=4294967295&y1[4]+rotateL32(y1[3],16)+rotateL32(y1[2],16),t1[5]=4294967295&y1[5]+rotateL32(y1[4],8)+y1[3],t1[6]=4294967295&y1[6]+rotateL32(y1[5],16)+rotateL32(y1[4],16),t1[7]=4294967295&y1[7]+rotateL32(y1[6],8)+y1[5],u1)return new Uint8Array;const b1=new Uint32Array(4);return b1[0]=t1[0]^t1[5]>>>16^t1[3]<<16,b1[1]=t1[2]^t1[7]>>>16^t1[5]<<16,b1[2]=t1[4]^t1[1]>>>16^t1[7]<<16,b1[3]=t1[6]^t1[3]>>>16^t1[1]<<16,new Uint8Array(b1.buffer,b1.byteOffset,16)};(()=>{const u1=new Uint16Array(e.buffer,e.byteOffset,e.byteLength>>1);for(let y1=0;y1<8;y1++)if((y1&1)===0){const b1=u1[(y1+1)%8],l1=u1[y1];t1[y1]=b1<<16|l1;const d1=u1[(y1+4)%8],I1=u1[(y1+5)%8];r1[y1]=d1<<16|I1}else{const b1=u1[(y1+5)%8],l1=u1[(y1+4)%8];t1[y1]=b1<<16|l1;const d1=u1[y1],I1=u1[(y1+1)%8];r1[y1]=d1<<16|I1}for(let y1=0;y1<4;y1++)c1(!0);for(let y1=0;y1<8;y1++)r1[y1]^=t1[(y1+4)%8];if(r.length===8){const y1=new Uint32Array(r.buffer,r.byteOffset,r.byteLength>>2),b1=new Uint16Array(r.buffer,r.byteOffset,r.byteLength>>1);r1[0]^=y1[0],r1[1]^=b1[3]<<16|b1[1],r1[2]^=y1[1],r1[3]^=b1[2]<<16|b1[0],r1[4]^=y1[0],r1[5]^=b1[3]<<16|b1[1],r1[6]^=y1[1],r1[7]^=b1[2]<<16|b1[0];for(let l1=0;l1<4;l1++)c1(!0)}else if(r.length!==0&&r.length!==8)throw new KitError("Rabbit iv must be 8 byte")})();let a1=c1(),s1=1;const i1=u1=>{if(s1>=u1)return a1;for(a1=resizeBuffer(a1,u1<<4);s1<u1;)a1.set(c1(),s1<<4),s1++;return a1},o1=u1=>{const y1=Math.ceil(u1.length>>4)||1;return a1=i1(y1),U8.from(u1).map((b1,l1)=>b1^a1[l1])};return{encrypt:u1=>o1(u1),decrypt:u1=>o1(u1)}}const rabbit=createCipher(m$4,{ALGORITHM:"rabbit",KEY_SIZE:16,MIN_KEY_SIZE:16,MAX_KEY_SIZE:16,IV_SIZE:8,MIN_IV_SIZE:0,MAX_IV_SIZE:8});function b$2(e,r=20){const n1=u32(e),f1=n1.slice(0);for(let e1=0;e1<r;e1+=2)f1[4]^=rotateL32(f1[0]+f1[12],7),f1[8]^=rotateL32(f1[4]+f1[0],9),f1[12]^=rotateL32(f1[8]+f1[4],13),f1[0]^=rotateL32(f1[12]+f1[8],18),f1[9]^=rotateL32(f1[5]+f1[1],7),f1[13]^=rotateL32(f1[9]+f1[5],9),f1[1]^=rotateL32(f1[13]+f1[9],13),