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 155 kB
function L(f,n){return(f<<n|f>>>32-n)>>>0}function h1(f,n){return f>>>n|f<<32-n>>>0}function f0(f,n,t,e){return f=BigInt(f),e??=P1(f),n=BigInt(n),t=BigInt(t),n&=e,t%=f,n=n<<t|n>>f-t,n&e}function z0(f,n,t,e){return f=BigInt(f),e??=P1(f),n=BigInt(n),t=BigInt(t),n&=e,t%=f,n=n>>t|n<<f-t,n&e}function j1(f,n,t=1e3){if(f<=1n)throw new p("Max must be greater than 1");const e=new g(n);let r=0n,a=0;for(;a<t;){if(crypto.getRandomValues(e),r=e.toBI(),r<f)return{buffer:e,result:r};a++}throw new p("Failed to generate random bigint within max attempts")}function w1(f){return f===0n?0:f.toString(2).length}function P1(f){f=BigInt(f);let n=0x0n;for(let t=0;t<f;t++)n=n<<1n|1n;return n}function o2(f,n){let[t,e,r,a,c,s]=[1n,0n,0n,1n,f,n];if(n===0n)return{gcd:f,x:1n};for(;s!==0n;){const i=c/s;[c,s]=[s,c-i*s],[t,e]=[e,t-i*e],[r,a]=[a,r-i*a]}return{gcd:c,x:t}}function u2(f,n){return g1(f,n-1n>>1n,n)}function p3(f,n){if(u2(f,n)!==1n)throw new p("There is no square root");if(f===0n)return 0n;if(n===2n)return f;if(n%4n===3n)return g1(f,n+1n>>2n,n);let t=n-1n,e=0n;for(;r1(t,2n)===0n;)t>>=1n,e++;let r=2n;for(;u2(r,n)!==n-1n;)r++;let a=e,c=g1(r,t,n),s=g1(f,t,n),i=g1(f,t+1n>>1n,n);for(;s!==0n&&s!==1n;){let o=s,u=1n;for(;u<a&&(o=g1(o,2n,n),o!==1n);u++);const b=g1(c,1n<<a-u-1n,n);a=u,c=g1(b,2n,n),s=s*c%n,i=i*b%n}return i}function b2(f,n){return o2(f,n).gcd}function S3(f,n){return f*n/b2(f,n)}function r1(f,n){const t=f%n;return t<0n?t+n:t}function g1(f,n,t){f%=t;let e=1n;for(;n>0n;)n&1n&&(e=e*f%t),f=f*f%t,n>>=1n;return e}function V1(f,n){const{gcd:t,x:e}=o2(f,n);if(t!==1n)throw new p("Modular inverse does not exist");return r1(e,n)}function A3(f,n){if(f=r1(f,n),f===0n)return 0n;const t=p3(f,n),e=r1(n-t,n);return t<=e?t:e}class g extends Uint8Array{getWord(n,t,e=!1){const r=t*n,a=this.subarray(r,r+n);return e?a.toBI(!0):a.toBI()}setWord(n,t,e,r=!1){const a=t*n,c=typeof e=="bigint"?g.fromBI(e,n):e;this.set(r?c.toReversed():c,a)}view(n){const t=Math.floor(this.length/n);return{get:(e,r=!1)=>this.getWord(n,e,r),set:(e,r,a=!1)=>this.setWord(n,e,r,a),length:t}}to(n){return n(this)}toBI(n=!1){const t=n?this.toReversed():this;let e=0n;return t.forEach(r=>{e=e<<8n|BigInt(r)}),e}toUint8Array(){return new Uint8Array(this)}static fromString(n,t){return t(n)}static fromBI(n,t,e=!1){t=t||w1(n)+7>>3;const r=new g(t);if(e)for(let a=0;a<r.length;a++)r[a]=Number(n&0xffn),n>>=8n;else for(let a=r.length-1;a>=0;a--)r[a]=Number(n&0xffn),n>>=8n;return r}filter(n,t){const e=super.filter(n,t);return new g(e.buffer,e.byteOffset,e.byteLength)}static of(...n){const t=Uint8Array.of(...n);return new g(t.buffer,t.byteOffset,t.byteLength)}static from(n,t,e){const r=Uint8Array.from(n,t,e);return new g(r.buffer,r.byteOffset,r.byteLength)}map(n,t){const e=super.map(n,t);return new g(e.buffer,e.byteOffset,e.byteLength)}slice(n,t){const e=super.slice(n,t);return new g(e.buffer,e.byteOffset,e.byteLength)}subarray(n,t){const e=super.subarray(n,t);return new g(e.buffer,e.byteOffset,e.byteLength)}toReversed(){const n=super.toReversed();return new g(n.buffer,n.byteOffset,n.byteLength)}toSorted(n){const t=super.toSorted(n);return new g(t.buffer,t.byteOffset,t.byteLength)}with(n,t){const e=super.with(n,t);return new g(e.buffer,e.byteOffset,e.byteLength)}}function v(f){return new g(f.buffer,f.byteOffset,f.byteLength)}function z1(f){return new Uint32Array(f.buffer,f.byteOffset,f.byteLength>>2)}function X(...f){const n=f.reduce((r,a)=>r+a.byteLength,0),t=new g(n);let e=0;for(const r of f)t.set(new g(r),e),e+=r.byteLength;return t}function X0(f,n){const t=new g(n);return t.set(f),t}class X1 extends g{inc(n,t,e=!1){if(n=n||0,n<0||n>=this.length)throw new p("Invalid counter offset");if(t=t||this.length-n,t<0||n+t>this.length)throw new p("Invalid counter length");if(e)for(let r=n;r<n+t;r++){if(this[r]<255){this[r]+=1;break}this[r]=0}else for(let r=n+t-1;r>=n;r--){if(this[r]<255){this[r]+=1;break}this[r]=0}}}function G1(f){try{return[null,f()]}catch(n){return n instanceof Error?[n,null]:[new p("Unknown error"),null]}}function x(...f){return Object.assign(...f)}class p extends Error{constructor(n){super(n),this.name="mima-kit Error"}}const l2=40,E1=[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],_3=(1n<<26n)/E1[E1.length-1];function m3(f,n){const t=f-1n;let e=0n,r=t;for(;(r&1n)===0n;)r>>=1n,e++;n=n+1>>1,n>E1.length&&(n=E1.length);const a=[2n];for(let c=0;c<n;++c){let s;do s=E1[Math.floor(Math.random()*E1.length)];while(a.includes(s));if(a.push(s),O3(f,t,e,r,s)===!1)return!1}return!0}function O3(f,n,t,e,r){let a=g1(r,e,f);if(a===1n||a===n)return!0;let c=0n;for(let s=1;s<t;s++){if(c=g1(a,2n,f),c===1n&&a!==1n&&a!==n)return!1;a=c}return c===1n}function d2(f,n=l2){for(let t=1;t<E1.length;){let e=E1[t],r=t+1;for(;r<E1.length&&e<_3;)e*=E1[r++];for(e=f%e;t<r;)if(e%E1[t++]===0n)return!1}return m3(f,n)}function B3(f){crypto.getRandomValues(f),f[0]|=128;let n=f.toBI()|1n;const t=n%6n;return t!==1n&&t!==5n&&(n+=4n),n}const j0=f=>{const n=new g(f>>3);let t;do t=B3(n);while(!d2(t));return t};function L3(f,n=l2){if(n<=0||(f&1n)===0n)return!1;const t=f%6n;return t!==1n&&t!==5n?!1:f<=E1[E1.length-1]?E1.includes(f):d2(f,n)}function D1(f,n,t){function e(r){return typeof r=="string"?f(r):n(r)}return x(e,{FORMAT:t})}function Z3(f){const[n,t]=G1(()=>new TextEncoder().encode(f));if(!n)return v(t);const e=[];for(let r=0;r<f.length;r++){const a=f.codePointAt(r);a===void 0||(a<128?e.push(a):a<2048?(e.push(192|a>>6),e.push(128|a&63)):a<65536?(e.push(224|a>>12),e.push(128|a>>6&63),e.push(128|a&63)):a<1114112&&(e.push(240|a>>18),e.push(128|a>>12&63),e.push(128|a>>6&63),e.push(128|a&63),r++))}return g.from(e)}function U3(f){const[n,t]=G1(()=>new TextDecoder().decode(f));if(!n)return t;const e=[];for(let r=0;r<f.length;){const a=f[r++];if(a<128)e.push(String.fromCharCode(a));else if(a>=192&&a<224){const c=f[r++],s=(a&31)<<6|c&63;e.push(String.fromCharCode(s))}else if(a>=224&&a<240){const c=f[r++],s=f[r++],i=(a&15)<<12|(c&63)<<6|s&63;e.push(String.fromCharCode(i))}else if(a>=240&&a<248){const c=f[r++],s=f[r++],i=f[r++],o=(a&7)<<18|(c&63)<<12|(s&63)<<6|i&63;e.push(String.fromCodePoint(o))}else console.warn("Included an invalid UTF-8 byte")}return e.join("")}const V0=D1(Z3,U3,"utf-8");function K3(f){f=f.replace(/^0x/,"");const[n,t]=G1(()=>Buffer.from(f.replace(/[^0-9a-f]/gi,""),"hex"));if(!n)return v(t);const e=f.match(/[\da-f]{2}/gi);return e==null?new g:new g(e.map(r=>Number.parseInt(r,16)))}function $3(f){const[n,t]=G1(()=>Buffer.from(f).toString("hex"));if(!n)return t;let e="";for(let r=0;r<f.length;r++)e+=f[r].toString(16).padStart(2,"0");return e}const C3=D1(K3,$3,"hex");function M3(f){const[n,t]=G1(()=>Buffer.from(f.replace(/[^A-Z0-9+/]/gi,""),"base64"));return n?I2(f):v(t)}function T3(f){const[n,t]=G1(()=>Buffer.from(f).toString("base64"));return n?R3(f):t}const y2=D1(M3,T3,"base64");function G3(f){const[n,t]=G1(()=>Buffer.from(f.replace(/[^\w-]/g,""),"base64url"));return n?I2(f):v(t)}function D3(f){const[n,t]=G1(()=>Buffer.from(f).toString("base64url"));return n?y2(f).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,""):t}const v3=D1(G3,D3,"base64url");function I2(f){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";f=f.replace(/-/g,"+").replace(/_/g,"/").replace(/[^A-Z0-9+/]/gi,"");const t=f.length*.75,e=new g(t);let r=0,a=0;for(;r<f.length;){const c=n.indexOf(f.charAt(r++)),s=n.indexOf(f.charAt(r++)),i=n.indexOf(f.charAt(r++)),o=n.indexOf(f.charAt(r++)),u=c<<18|s<<12|i<<6|o;e[a++]=u>>16&255,e[a++]=u>>8&255,e[a++]=u&255}return e}function R3(f,n){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";t+="+/";let e="",r;for(r=0;r<f.length-2;r+=3)e+=t[f[r]>>2],e+=t[(f[r]&3)<<4|f[r+1]>>4],e+=t[(f[r+1]&15)<<2|f[r+2]>>6],e+=t[f[r+2]&63];return r===f.length-2?(e+=t[f[r]>>2],e+=t[(f[r]&3)<<4|f[r+1]>>4],e+=t[(f[r+1]&15)<<2],e+="="):r===f.length-1&&(e+=t[f[r]>>2],e+=t[(f[r]&3)<<4],e+="=="),e}function k3(f){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";if(typeof f=="string"){const r=f.toUpperCase().replace(/[^A-Z2-7]/g,"");return I0(r,n)}else if(f instanceof Uint8Array)return h0(f,n,!1);const{variant:t="rfc4648",padding:e=!1}=f;if(t==="rfc4648")return D1(function(r){return r=r.toUpperCase().replace(/[^A-Z2-7]/g,""),I0(r,n)},function(r){return h0(r,n,e)},"base32");if(t==="rfc4648-hex"){let r=function(s){return s=s.toUpperCase().replace(/[^0-9A-V]/g,""),I0(s,c)},a=function(s){return h0(s,c,e)};const c="0123456789ABCDEFGHIJKLMNOPQRSTUV";return D1(r,a,"base32-hex")}else if(t==="crockford"){let r=function(s){return s=s.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1").replace(/[^0-9A-HJKMNP-TV-Z]/g,""),I0(s,c)},a=function(s){return h0(s,c,e)};const c="0123456789ABCDEFGHJKMNPQRSTVWXYZ";return D1(r,a,"base32-crockford")}}const H3=x(k3,{FORMAT:"base32"});function I0(f,n){const t=f.length*.625,e=new g(t);let r=0,a=0;for(;r<f.length;){const c=n.indexOf(f.charAt(r++)),s=n.indexOf(f.charAt(r++)),i=n.indexOf(f.charAt(r++)),o=n.indexOf(f.charAt(r++)),u=n.indexOf(f.charAt(r++)),b=n.indexOf(f.charAt(r++)),l=n.indexOf(f.charAt(r++)),h=n.indexOf(f.charAt(r++));e[a++]=c<<3|s>>2,e[a++]=(s&3)<<6|i<<1|o>>4,e[a++]=(o&15)<<4|u>>1,e[a++]=(u&1)<<7|b<<2|l>>3,e[a++]=(l&7)<<5|h}return e}function h0(f,n,t){let e="",r;for(r=0;r<f.length-4;r+=5){const a=f[r],c=f[r+1],s=f[r+2],i=f[r+3],o=f[r+4];e+=n[a>>3],e+=n[(a&7)<<2|c>>6],e+=n[c>>1&31],e+=n[(c&1)<<4|s>>4],e+=n[(s&15)<<1|i>>7],e+=n[i>>2&31],e+=n[(i&3)<<3|o>>5],e+=n[o&31]}if(r===f.length-4){const a=f[r],c=f[r+1],s=f[r+2],i=f[r+3];e+=n[a>>3],e+=n[(a&7)<<2|c>>6],e+=n[c>>1&31],e+=n[(c&1)<<4|s>>4],e+=n[(s&15)<<1|i>>7],e+=n[i>>2&31],e+=n[(i&3)<<3],e+=t?"=":""}else if(r===f.length-3){const a=f[r],c=f[r+1],s=f[r+2];e+=n[a>>3],e+=n[(a&7)<<2|c>>6],e+=n[c>>1&31],e+=n[(c&1)<<4|s>>4],e+=n[(s&15)<<1],e+=t?"===":""}else if(r===f.length-2){const a=f[r],c=f[r+1];e+=n[a>>3],e+=n[(a&7)<<2|c>>6],e+=n[c>>1&31],e+=n[(c&1)<<4],e+=t?"====":""}else if(r===f.length-1){const a=f[r];e+=n[a>>3],e+=n[(a&7)<<2],e+=t?"======":""}return e}function Y3(f){const n=new Map;n.set("\u5BCC\u5F3A",0),n.set("\u6C11\u4E3B",1),n.set("\u6587\u660E",2),n.set("\u548C\u8C10",3),n.set("\u81EA\u7531",4),n.set("\u5E73\u7B49",5),n.set("\u516C\u6B63",6),n.set("\u6CD5\u6CBB",7),n.set("\u7231\u56FD",8),n.set("\u656C\u4E1A",9),n.set("\u8BDA\u4FE1",10),n.set("\u53CB\u5584",11);const t=i=>{const o=n.get(i);if(o===void 0)throw new p("\u4F60\u7ADF\u7136\u5728\u793E\u4F1A\u4E3B\u4E49\u6838\u5FC3\u4EF7\u503C\u89C2\u91CC\u5939\u5E26\u79C1\u8D27\uFF01");return o},e=f.match(/(\S){2}/g);if(e==null)return new g;let r=0,a=0,c=0;const s=[];for(let i=0;i<e.length;i++){const o=c%2===0;let u=t(e[i]);if(u===10||u===11){if(i++,i===e.length)throw new p("\u4F60\u7684\u793E\u4F1A\u4E3B\u4E49\u6838\u5FC3\u4EF7\u503C\u89C2\u7834\u788E\u4E86\uFF01");u=u===10?10+t(e[i]):6+t(e[i])}o?r=u:a=u,o||s.push((r<<4|a)&255),c++}return new g(s)}function N3(f){const n=()=>Math.random()>=.5,t=["\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 e="";return f.forEach(r=>{const a=r>>4&15,c=r&15;a<10?e+=t[a]:e+=t[11]+t[a-6],c<10?e+=t[c]:n()?e+=t[10]+t[c-10]:e+=t[11]+t[c-6]}),e}const P3=D1(Y3,N3,"core-socialist-values"),n1=(f,n)=>x(f,n),n0=(f,n)=>x(f,n),e0=(f,n)=>x(f,n),z3=(f,n,t,e)=>e<16?f^n^t:f&n|f&t|n&t,X3=(f,n,t,e)=>e<16?f^n^t:f&n|~f&t,j3=f=>f^L(f,9)^L(f,17),V3=f=>f^L(f,15)^L(f,23);function F3(f){const n=new g(32),t=n.view(4);t.set(0,0x7380166fn),t.set(1,0x4914b2b9n),t.set(2,0x172442d7n),t.set(3,0xda8a0600n),t.set(4,0xa96f30bcn),t.set(5,0x163138aan),t.set(6,0xe38dee4dn),t.set(7,0xb0fb0e4en);const e=f.length,r=BigInt(e)<<3n,a=64,c=e+9+63>>6,s=new g(c*a);s.set(f),s[e]=128;const i=new DataView(s.buffer,s.byteOffset,s.byteLength);i.setBigUint64(s.length-8,r,!1);for(let o=0;o<s.length;o+=a){const u=Number(t.get(0)),b=Number(t.get(1)),l=Number(t.get(2)),h=Number(t.get(3)),d=Number(t.get(4)),y=Number(t.get(5)),I=Number(t.get(6)),w=Number(t.get(7));let _=u,K=b,C=l,S=h,m=d,U=y,B=I,A=w;const E=new Uint32Array(68),O=new Uint32Array(64);for(let Z=0;Z<68;Z++)if(Z<16?E[Z]=i.getUint32(o+(Z<<2),!1):E[Z]=V3(E[Z-16]^E[Z-9]^L(E[Z-3],15))^L(E[Z-13],7)^E[Z-6],Z>3){const M=Z-4;O[M]=E[M]^E[Z];const V=M<16?2043430169:2055708042,j=L(L(_,12)+m+L(V,M),7),H=j^L(_,12),k=z3(_,K,C,M)+S+H+O[M],z=X3(m,U,B,M)+A+j+E[M];S=C,C=L(K,9),K=_,_=k,A=B,B=L(U,19),U=m,m=j3(z)}t.set(0,BigInt(u^_)),t.set(1,BigInt(b^K)),t.set(2,BigInt(l^C)),t.set(3,BigInt(h^S)),t.set(4,BigInt(d^m)),t.set(5,BigInt(y^U)),t.set(6,BigInt(I^B)),t.set(7,BigInt(w^A))}return n}const t0=n1(F3,{ALGORITHM:"SM3",BLOCK_SIZE:64,DIGEST_SIZE:32,OID:"1.2.156.10197.1.401"}),T=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 u1(f,n,t,e,r,a,c){const s=f+(n&t|~n&e)+r+c;return L(s,a)+n}function b1(f,n,t,e,r,a,c){const s=f+(n&e|t&~e)+r+c;return L(s,a)+n}function l1(f,n,t,e,r,a,c){const s=f+(n^t^e)+r+c;return L(s,a)+n}function d1(f,n,t,e,r,a,c){const s=f+(t^(n|~e))+r+c;return L(s,a)+n}function Q3(f){const n=new Uint32Array([1732584193,4023233417,2562383102,271733878]),t=f.length,e=BigInt(t)<<3n,r=64,a=t+9+63>>6,c=new g(a*r);c.set(f),c[t]=128,new DataView(c.buffer,c.byteOffset,c.byteLength).setBigUint64(c.length-8,e,!0);for(let s=0;s<c.length;){const i=s+r,o=new Uint32Array(c.buffer,c.byteOffset+s,r>>2);s=i;const u=n[0],b=n[1],l=n[2],h=n[3];let d=u,y=b,I=l,w=h;d=u1(d,y,I,w,o[0],7,T[0]),w=u1(w,d,y,I,o[1],12,T[1]),I=u1(I,w,d,y,o[2],17,T[2]),y=u1(y,I,w,d,o[3],22,T[3]),d=u1(d,y,I,w,o[4],7,T[4]),w=u1(w,d,y,I,o[5],12,T[5]),I=u1(I,w,d,y,o[6],17,T[6]),y=u1(y,I,w,d,o[7],22,T[7]),d=u1(d,y,I,w,o[8],7,T[8]),w=u1(w,d,y,I,o[9],12,T[9]),I=u1(I,w,d,y,o[10],17,T[10]),y=u1(y,I,w,d,o[11],22,T[11]),d=u1(d,y,I,w,o[12],7,T[12]),w=u1(w,d,y,I,o[13],12,T[13]),I=u1(I,w,d,y,o[14],17,T[14]),y=u1(y,I,w,d,o[15],22,T[15]),d=b1(d,y,I,w,o[1],5,T[16]),w=b1(w,d,y,I,o[6],9,T[17]),I=b1(I,w,d,y,o[11],14,T[18]),y=b1(y,I,w,d,o[0],20,T[19]),d=b1(d,y,I,w,o[5],5,T[20]),w=b1(w,d,y,I,o[10],9,T[21]),I=b1(I,w,d,y,o[15],14,T[22]),y=b1(y,I,w,d,o[4],20,T[23]),d=b1(d,y,I,w,o[9],5,T[24]),w=b1(w,d,y,I,o[14],9,T[25]),I=b1(I,w,d,y,o[3],14,T[26]),y=b1(y,I,w,d,o[8],20,T[27]),d=b1(d,y,I,w,o[13],5,T[28]),w=b1(w,d,y,I,o[2],9,T[29]),I=b1(I,w,d,y,o[7],14,T[30]),y=b1(y,I,w,d,o[12],20,T[31]),d=l1(d,y,I,w,o[5],4,T[32]),w=l1(w,d,y,I,o[8],11,T[33]),I=l1(I,w,d,y,o[11],16,T[34]),y=l1(y,I,w,d,o[14],23,T[35]),d=l1(d,y,I,w,o[1],4,T[36]),w=l1(w,d,y,I,o[4],11,T[37]),I=l1(I,w,d,y,o[7],16,T[38]),y=l1(y,I,w,d,o[10],23,T[39]),d=l1(d,y,I,w,o[13],4,T[40]),w=l1(w,d,y,I,o[0],11,T[41]),I=l1(I,w,d,y,o[3],16,T[42]),y=l1(y,I,w,d,o[6],23,T[43]),d=l1(d,y,I,w,o[9],4,T[44]),w=l1(w,d,y,I,o[12],11,T[45]),I=l1(I,w,d,y,o[15],16,T[46]),y=l1(y,I,w,d,o[2],23,T[47]),d=d1(d,y,I,w,o[0],6,T[48]),w=d1(w,d,y,I,o[7],10,T[49]),I=d1(I,w,d,y,o[14],15,T[50]),y=d1(y,I,w,d,o[5],21,T[51]),d=d1(d,y,I,w,o[12],6,T[52]),w=d1(w,d,y,I,o[3],10,T[53]),I=d1(I,w,d,y,o[10],15,T[54]),y=d1(y,I,w,d,o[1],21,T[55]),d=d1(d,y,I,w,o[8],6,T[56]),w=d1(w,d,y,I,o[15],10,T[57]),I=d1(I,w,d,y,o[6],15,T[58]),y=d1(y,I,w,d,o[13],21,T[59]),d=d1(d,y,I,w,o[4],6,T[60]),w=d1(w,d,y,I,o[11],10,T[61]),I=d1(I,w,d,y,o[2],15,T[62]),y=d1(y,I,w,d,o[9],21,T[63]),n[0]=u+d,n[1]=b+y,n[2]=l+I,n[3]=h+w}return new g(n.buffer)}const W3=n1(Q3,{ALGORITHM:"MD5",BLOCK_SIZE:64,DIGEST_SIZE:16,OID:"1.2.840.113549.2.5"});function q3(f){return f<20?1518500249:f<40?1859775393:f<60?2400959708:3395469782}const J3=(f,n,t)=>f&n^~f&t,h2=(f,n,t)=>f^n^t,x3=(f,n,t)=>f&n^f&t^n&t;function ff(f,n,t,e){return e<20?J3(f,n,t):e<40?h2(f,n,t):e<60?x3(f,n,t):h2(f,n,t)}function nf(f){const n=new g(20),t=n.view(4);t.set(0,0x67452301n),t.set(1,0xefcdab89n),t.set(2,0x98badcfen),t.set(3,0x10325476n),t.set(4,0xc3d2e1f0n);const e=f.length,r=BigInt(e)<<3n,a=64,c=e+9+63>>6,s=new g(c*a);s.set(f),s[e]=128;const i=new DataView(s.buffer,s.byteOffset,s.byteLength);i.setBigUint64(s.length-8,r);for(let o=0;o<s.length;o+=a){const u=Number(t.get(0)),b=Number(t.get(1)),l=Number(t.get(2)),h=Number(t.get(3)),d=Number(t.get(4));let y=u,I=b,w=l,_=h,K=d;const C=new Uint32Array(80);for(let S=0;S<80;S++){S<16?C[S]=i.getUint32(o+(S<<2)):C[S]=L(C[S-3]^C[S-8]^C[S-14]^C[S-16],1);const m=L(y,5)+ff(I,w,_,S)+q3(S)+K+C[S];K=_,_=w,w=L(I,30),I=y,y=m}t.set(0,BigInt(u+y)),t.set(1,BigInt(b+I)),t.set(2,BigInt(l+w)),t.set(3,BigInt(h+_)),t.set(4,BigInt(d+K))}return n}const w0=n1(nf,{ALGORITHM:"SHA-1",BLOCK_SIZE:64,DIGEST_SIZE:20,OID:"1.3.14.3.2.26"}),ef=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]),tf=(f,n,t)=>f&n^~f&t,rf=(f,n,t)=>f&n^f&t^n&t,af=f=>h1(f,2)^h1(f,13)^h1(f,22),cf=f=>h1(f,6)^h1(f,11)^h1(f,25),sf=f=>h1(f,7)^h1(f,18)^f>>>3,of=f=>h1(f,17)^h1(f,19)^f>>>10;function w2(f,n){f=f.slice(0);const t=f.view(4),e=n.length,r=BigInt(e)<<3n,a=64,c=e+9+63>>6,s=new g(c*a);s.set(n),s[e]=128;const i=new DataView(s.buffer,s.byteOffset,s.byteLength);i.setBigUint64(s.length-8,r);for(let o=0;o<s.length;o+=a){const u=Number(t.get(0)),b=Number(t.get(1)),l=Number(t.get(2)),h=Number(t.get(3)),d=Number(t.get(4)),y=Number(t.get(5)),I=Number(t.get(6)),w=Number(t.get(7));let _=u,K=b,C=l,S=h,m=d,U=y,B=I,A=w;const E=new Uint32Array(64);for(let O=0;O<E.length;O++){O<16?E[O]=i.getUint32(o+(O<<2)):E[O]=of(E[O-2])+E[O-7]+sf(E[O-15])+E[O-16];const Z=A+cf(m)+tf(m,U,B)+ef[O]+E[O],M=af(_)+rf(_,K,C);A=B,B=U,U=m,m=S+Z,S=C,C=K,K=_,_=Z+M}t.set(0,BigInt(u+_)),t.set(1,BigInt(b+K)),t.set(2,BigInt(l+C)),t.set(3,BigInt(h+S)),t.set(4,BigInt(d+m)),t.set(5,BigInt(y+U)),t.set(6,BigInt(I+B)),t.set(7,BigInt(w+A))}return f}function uf(f){const n=new g(32),t=n.view(4);return t.set(0,0xc1059ed8n),t.set(1,0x367cd507n),t.set(2,0x3070dd17n),t.set(3,0xf70e5939n),t.set(4,0xffc00b31n),t.set(5,0x68581511n),t.set(6,0x64f98fa7n),t.set(7,0xbefa4fa4n),w2(n,f).slice(0,28)}function bf(f){const n=new g(32),t=n.view(4);return t.set(0,0x6a09e667n),t.set(1,0xbb67ae85n),t.set(2,0x3c6ef372n),t.set(3,0xa54ff53an),t.set(4,0x510e527fn),t.set(5,0x9b05688cn),t.set(6,0x1f83d9abn),t.set(7,0x5be0cd19n),w2(n,f)}const lf=n1(uf,{ALGORITHM:"SHA-224",BLOCK_SIZE:64,DIGEST_SIZE:28,OID:"2.16.840.1.101.3.4.2.4"}),L1=n1(bf,{ALGORITHM:"SHA-256",BLOCK_SIZE:64,DIGEST_SIZE:32,OID:"2.16.840.1.101.3.4.2.1"}),df=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]),yf=P1(64),Z1=(f,n)=>z0(64,f,n,yf),If=(f,n,t)=>f&n^~f&t,hf=(f,n,t)=>f&n^f&t^n&t,wf=f=>Z1(f,28n)^Z1(f,34n)^Z1(f,39n),gf=f=>Z1(f,14n)^Z1(f,18n)^Z1(f,41n),Ef=f=>Z1(f,1n)^Z1(f,8n)^f>>7n,pf=f=>Z1(f,19n)^Z1(f,61n)^f>>6n;function Sf(f){if(f<=0)throw new p("SHA-512 truncation must be greater than 0");if(f>=512)throw new p("SHA-512 truncation must be less than 512");if(f===384)throw new p("SHA-512 truncation must not be 384");const n=new g(64),t=n.view(8);return t.set(0,0x6a09e667f3bcc908n^0xa5a5a5a5a5a5a5a5n),t.set(1,0xbb67ae8584caa73bn^0xa5a5a5a5a5a5a5a5n),t.set(2,0x3c6ef372fe94f82bn^0xa5a5a5a5a5a5a5a5n),t.set(3,0xa54ff53a5f1d36f1n^0xa5a5a5a5a5a5a5a5n),t.set(4,0x510e527fade682d1n^0xa5a5a5a5a5a5a5a5n),t.set(5,0x9b05688c2b3e6c1fn^0xa5a5a5a5a5a5a5a5n),t.set(6,0x1f83d9abfb41bd6bn^0xa5a5a5a5a5a5a5a5n),t.set(7,0x5be0cd19137e2179n^0xa5a5a5a5a5a5a5a5n),g0(n,V0(`SHA-512/${f}`))}function g0(f,n){f=f.slice(0);const t=f.view(8),e=n.byteLength,r=BigInt(e)<<3n,a=128,c=e+17+127>>7,s=new g(c*a);s.set(n),s[e]=128;const i=new DataView(s.buffer,s.byteOffset,s.byteLength);i.setBigUint64(s.byteLength-16,r>>32n),i.setBigUint64(s.byteLength-8,r&0xffffffffffffffffn);for(let o=0;o<s.length;o+=a){const u=t.get(0),b=t.get(1),l=t.get(2),h=t.get(3),d=t.get(4),y=t.get(5),I=t.get(6),w=t.get(7);let _=u,K=b,C=l,S=h,m=d,U=y,B=I,A=w;const E=new BigUint64Array(80);for(let O=0;O<E.length;O++){O<16?E[O]=i.getBigUint64(o+(O<<3)):E[O]=pf(E[O-2])+E[O-7]+Ef(E[O-15])+E[O-16];const Z=A+gf(m)+If(m,U,B)+df[O]+E[O],M=wf(_)+hf(_,K,C);A=B,B=U,U=m,m=S+Z&0xffffffffffffffffn,S=C,C=K,K=_,_=Z+M&0xffffffffffffffffn}t.set(0,u+_),t.set(1,b+K),t.set(2,l+C),t.set(3,h+S),t.set(4,d+m),t.set(5,y+U),t.set(6,I+B),t.set(7,w+A)}return f}function Af(f){const n=new g(64),t=n.view(8);return t.set(0,0xcbbb9d5dc1059ed8n),t.set(1,0x629a292a367cd507n),t.set(2,0x9159015a3070dd17n),t.set(3,0x152fecd8f70e5939n),t.set(4,0x67332667ffc00b31n),t.set(5,0x8eb44a8768581511n),t.set(6,0xdb0c2e0d64f98fa7n),t.set(7,0x47b5481dbefa4fa4n),g0(n,f).slice(0,48)}function _f(f){const n=new g(64),t=n.view(8);return t.set(0,0x6a09e667f3bcc908n),t.set(1,0xbb67ae8584caa73bn),t.set(2,0x3c6ef372fe94f82bn),t.set(3,0xa54ff53a5f1d36f1n),t.set(4,0x510e527fade682d1n),t.set(5,0x9b05688c2b3e6c1fn),t.set(6,0x1f83d9abfb41bd6bn),t.set(7,0x5be0cd19137e2179n),g0(n,f)}const mf=n1(Af,{ALGORITHM:"SHA-384",BLOCK_SIZE:128,DIGEST_SIZE:48,OID:"2.16.840.1.101.3.4.2.2"}),Of=n1(_f,{ALGORITHM:"SHA-512",BLOCK_SIZE:128,DIGEST_SIZE:64,OID:"2.16.840.1.101.3.4.2.3"});function Bf(f){const n=Sf(f);let t;return f===224&&(t="2.16.840.1.101.3.4.2.5"),f===256&&(t="2.16.840.1.101.3.4.2.6"),n1(e=>g0(n,e).slice(0,f>>3),{ALGORITHM:`SHA-512/${f}`,BLOCK_SIZE:128,DIGEST_SIZE:f>>3,OID:t})}const Lf=[[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]],Zf=[0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n],Uf=[0x0000000000000001n,0x0000000000008082n,0x800000000000808an,0x8000000080008000n,0x000000000000808bn,0x0000000080000001n,0x8000000080008081n,0x8000000000008009n,0x000000000000008an,0x0000000000000088n,0x0000000080008009n,0x000000008000000an,0x000000008000808bn,0x800000000000008bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800an,0x800000008000000an,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n],Kf=P1(64),g2=(f,n)=>f0(64,f,n,Kf);function $f(f=6,n=24){const t=[];for(let e=0;e<n;e++){let r=0n;for(let a=0;a<=f;a++){const c=a+7*e;let s;if(c%255===0)s=1n;else{let i=0x80n;for(let o=1;o<=c%255;o++){const u=i&1n;i^=u<<8n|u<<4n|u<<3n|u<<2n,i>>=1n}s=i>>7n}r|=s<<BigInt(2**a-1)}t.push(r)}return t}function F0(){return Array.from({length:5}).map(()=>new BigUint64Array(5))}function Cf(f){const n=F0(),t=new DataView(f.buffer,f.byteOffset,f.byteLength);for(let e=0;e<5;e++)for(let r=0;r<5;r++)n[e][r]=t.getBigUint64(r*5+e<<3,!0);return n}function Mf(f){const n=new Uint8Array(200),t=new DataView(n.buffer,n.byteOffset,n.byteLength);for(let e=0;e<5;e++)for(let r=0;r<5;r++)t.setBigUint64(r*5+e<<3,f[e][r],!0);return n}function Tf(f){const n=new BigUint64Array(5),t=new BigUint64Array(5);for(let e=0;e<5;e++)n[e]=f[e][0]^f[e][1]^f[e][2]^f[e][3]^f[e][4];for(let e=0;e<5;e++){t[e]=n[(e+4)%5]^g2(n[(e+1)%5],1n);for(let r=0;r<5;r++)f[e][r]=f[e][r]^t[e]}return f}function Gf(f){const n=F0();for(let t=0;t<5;t++)for(let e=0;e<5;e++)n[e][(2*t+3*e)%5]=g2(f[t][e],Lf[t][e]);return n}function Df(f){const n=F0();for(let t=0;t<5;t++)for(let e=0;e<5;e++)n[t][e]=f[t][e]^~f[(t+1)%5][e]&f[(t+2)%5][e];return n}function vf(f,n){return f[0][0]=f[0][0]^n,f}function E0(f=24){let n;return f===12?n=Zf:f===24?n=Uf:n=$f(6,f),t=>{if(t.byteLength!==200)throw new p("Invalid state size");let e=Cf(t);for(let r=0;r<f;r++)e=vf(Df(Gf(Tf(e))),n[r]);return new g(Mf(e))}}function p0(f,n,t,e=E0()){return r=>{const a=t(r);let c=new Uint8Array(200),s=0;for(;s<a.byteLength;){const u=s+f,b=a.slice(s,u);c.forEach((l,h)=>{c[h]=l^b[h]}),c=e(c),s=u}const i=[c.slice(0,f)];let o=f;for(;o<n;)c=e(c),i.push(c.slice(0,f)),o+=f;return X(...i).slice(0,n)}}const S0=f=>n=>{const t=n.length,e=f-t%f,r=new g(t+e);return r.set(n),e===1&&(r[t]=134),r[t]=6,r[r.length-1]|=128,r},E2=f=>n=>{const t=n.length,e=f-t%f,r=new g(t+e);return r.set(n),e===1&&(r[t]=159),r[t]=31,r[r.length-1]|=128,r};function U1(f,n,t){const e=1600-f>>3,r=t(e);return a=>p0(e,n>>3,r)(a)}const Rf=n1(f=>U1(448,224,S0)(f),{ALGORITHM:"SHA3-224",BLOCK_SIZE:144,DIGEST_SIZE:28,OID:"2.16.840.1.101.3.4.2.7"}),kf=n1(f=>U1(512,256,S0)(f),{ALGORITHM:"SHA3-256",BLOCK_SIZE:136,DIGEST_SIZE:32,OID:"2.16.840.1.101.3.4.2.8"}),Hf=n1(f=>U1(768,384,S0)(f),{ALGORITHM:"SHA3-384",BLOCK_SIZE:104,DIGEST_SIZE:48,OID:"2.16.840.1.101.3.4.2.9"}),Yf=n1(f=>U1(1024,512,S0)(f),{ALGORITHM:"SHA3-512",BLOCK_SIZE:72,DIGEST_SIZE:64,OID:"2.16.840.1.101.3.4.2.10"});function A0(f){return n1(n=>U1(256,f,E2)(n),{ALGORITHM:`SHAKE128/${f}`,BLOCK_SIZE:168,DIGEST_SIZE:f>>3})}function _0(f){return n1(n=>U1(512,f,E2)(n),{ALGORITHM:`SHAKE256/${f}`,BLOCK_SIZE:136,DIGEST_SIZE:f>>3})}function Q0(f){const n=[];do n.unshift(f&255),f=f>>8;while(f>0);return n.unshift(n.length),Uint8Array.from(n)}function m0(f){const n=[];do n.unshift(f&255),f=f>>8;while(f>0);return n.push(n.length),Uint8Array.from(n)}function K1(f){return f=typeof f=="string"?V0(f):f,[Q0(f.byteLength<<3),f]}function r0(f,n){if(n<=0)throw new p("w must be greater than 0");const t=Q0(n);let e=t.length;f.forEach(a=>{e+=a.length});const r=n-e%n;return f.unshift(t),f.push(new Uint8Array(r)),f}const O0=f=>n=>{const t=n.length,e=f-t%f,r=new g(t+e);return r.set(n),e===1&&(r[t]=132),r[t]=4,r[r.length-1]|=128,r};function p2(f,n,t,e,r,a){return n.byteLength===0&&t.byteLength===0?c=>a(f)(c):c=>{const s=r0([...K1(n),...K1(t)],r);return s.push(c),U1(e,f,O0)(X(...s))}}function Nf(f,n=new Uint8Array,t=new Uint8Array){return n1(p2(f,n,t,256,168,A0),{ALGORITHM:`cSHAKE128/${f}`,BLOCK_SIZE:168,DIGEST_SIZE:f>>3})}function Pf(f,n=new Uint8Array,t=new Uint8Array){return n1(p2(f,n,t,512,136,_0),{ALGORITHM:`cSHAKE256/${f}`,BLOCK_SIZE:136,DIGEST_SIZE:f>>3})}function B0(f,n,t,e,r){return(a,c)=>{const s=r0([...K1("KMAC"),...K1(n)],e);return s.push(...r0(K1(a),e)),s.push(c),s.push(m0(r?0:f)),U1(t,f,O0)(X(...s))}}function zf(f,n=new Uint8Array(0),t=128){return e0(B0(f,n,256,168,!1),{ALGORITHM:`KMAC128/${f}`,BLOCK_SIZE:168,DIGEST_SIZE:f>>3,KEY_SIZE:t>>3})}function Xf(f,n=new Uint8Array(0),t=256){return e0(B0(f,n,512,136,!1),{ALGORITHM:`KMAC256/${f}`,BLOCK_SIZE:136,DIGEST_SIZE:f>>3,KEY_SIZE:t>>3})}function jf(f,n=new Uint8Array(0),t=128){return e0(B0(f,n,256,168,!0),{ALGORITHM:`KMAC128XOF/${f}`,BLOCK_SIZE:168,DIGEST_SIZE:f>>3,KEY_SIZE:t>>3})}function Vf(f,n=new Uint8Array(0),t=256){return e0(B0(f,n,512,136,!0),{ALGORITHM:`KMAC256XOF/${f}`,BLOCK_SIZE:136,DIGEST_SIZE:f>>3,KEY_SIZE:t>>3})}function L0(f,n,t,e,r){return a=>{const c=r0([...K1("TupleHash"),...K1(n)],e);return a.forEach(s=>{c.push(...K1(s))}),c.push(m0(r?0:f)),U1(t,f,O0)(X(...c))}}function Ff(f,n=new Uint8Array){return n0(L0(f,n,256,168,!1),{ALGORITHM:`TupleHash128/${f}`,BLOCK_SIZE:168,DIGEST_SIZE:f>>3})}function Qf(f,n=new Uint8Array){return n0(L0(f,n,512,136,!1),{ALGORITHM:`TupleHash256/${f}`,BLOCK_SIZE:136,DIGEST_SIZE:f>>3})}function Wf(f,n=new Uint8Array){return n0(L0(f,n,256,168,!0),{ALGORITHM:`TupleHash128XOF/${f}`,BLOCK_SIZE:168,DIGEST_SIZE:f>>3})}function qf(f,n=new Uint8Array){return n0(L0(f,n,512,136,!0),{ALGORITHM:`TupleHash256XOF/${f}`,BLOCK_SIZE:136,DIGEST_SIZE:f>>3})}function Z0(f,n,t,e,r,a,c){const s=f>>3;return i=>{const o=Math.ceil(i.byteLength/s),u=r0([...K1("ParallelHash"),...K1(t)],r);u.push(Q0(f));for(let b=0;b<o;b++){const l=v(i).slice(b*(f<<3),(b+1)*(f<<3));u.push(c(l))}return u.push(m0(o)),u.push(m0(a?0:n)),U1(e,n,O0)(X(...u))}}function Jf(f,n,t=new Uint8Array){return n1(Z0(f,n,t,256,168,!1,A0(256)),{ALGORITHM:`ParallelHash128/${n}`,BLOCK_SIZE:168,DIGEST_SIZE:n>>3})}function xf(f,n,t=new Uint8Array){return n1(Z0(f,n,t,512,136,!1,_0(512)),{ALGORITHM:`ParallelHash256/${n}`,BLOCK_SIZE:136,DIGEST_SIZE:n>>3})}function fn(f,n,t=new Uint8Array){return n1(Z0(f,n,t,256,168,!0,A0(256)),{ALGORITHM:"ParallelHash128XOF",BLOCK_SIZE:168,DIGEST_SIZE:n>>3})}function nn(f,n,t=new Uint8Array){return n1(Z0(f,n,t,512,136,!0,_0(512)),{ALGORITHM:"ParallelHash256XOF",BLOCK_SIZE:136,DIGEST_SIZE:n>>3})}function S2(f,n){return t=>{const e=t.length+1,r=Math.ceil(e/f),a=new g(r*f);return a.set(t),a[t.length]=n,a[a.length-1]^=128,a}}function A2(f,n=31){if(n<1||n>127)throw new p("Invalid Domain Separator");const t=f>>3,e=168,r=E0(12),a=S2(e,n);return n1(c=>p0(e,t,a,r)(c),{ALGORITHM:`TurboSHAKE128/${f}`,BLOCK_SIZE:e,DIGEST_SIZE:t})}function _2(f,n=31){if(n<1||n>127)throw new p("Invalid Domain Separator");const t=f>>3,e=136,r=E0(12),a=S2(e,n);return n1(c=>p0(e,t,a,r)(c),{ALGORITHM:`TurboSHAKE256/${f}`,BLOCK_SIZE:e,DIGEST_SIZE:t})}function m2(f){const n=[];for(;f>0;)n.unshift(f&255),f>>=8;return n.push(n.length),new Uint8Array(n)}function O2(f,n,t,e){return r=>{const a=m2(n.length),c=X(r,n,a);if(c.length<=8192)return t(f,7)(c);{const s=[];s.push(c.slice(0,8192)),s.push(new Uint8Array([3,0,0,0,0,0,0,0]));let i=8192,o=0;for(;i<c.length;){const u=i+8192,b=t(e,11)(c.slice(i,u));s.push(b),i=u,o++}return s.push(m2(o)),s.push(new Uint8Array([255,255])),t(f,6)(X(...s))}}}function en(f,n=new Uint8Array){return n1(O2(f,n,A2,256),{ALGORITHM:`KangarooTwelve128/${f}`,BLOCK_SIZE:8192,DIGEST_SIZE:f>>3})}function tn(f,n=new Uint8Array){return n1(O2(f,n,_2,512),{ALGORITHM:`KangarooTwelve256/${f}`,BLOCK_SIZE:8192,DIGEST_SIZE:f>>3})}function rn(f,n,t){const{BLOCK_SIZE:e}=f,r=new Uint8Array(e);r.set(n.length>e?f(n):n);const a=r.map(i=>i^54),c=r.map(i=>i^92),s=f(X(a,t));return f(X(c,s))}function F1(f,n,t){const{ALGORITHM:e,BLOCK_SIZE:r,DIGEST_SIZE:a}=f;n=n?Math.min(n>>3,a):a,t=t?t>>3:a;const c={ALGORITHM:`HMAC-${e}-${n<<3}`,BLOCK_SIZE:r,DIGEST_SIZE:n,KEY_SIZE:t};return e0((s,i)=>rn(f,s,i).slice(0,n),c)}function B2(f,n,t=F1(w0)){const e=t(f,n),r=e[e.length-1]&15;return e.slice(r,r+4)}function an(f){if(f instanceof Uint8Array){const n=f,t=g.fromBI(BigInt(Math.floor(Date.now()/3e4)),8,!1),e=B2(n,t,F1(w0));return((0|(e[0]&127)<<24|(e[1]&255)<<16|(e[2]&255)<<8|e[3]&255)%1e6).toString().padStart(6,"0")}return n=>{let{mac:t=F1(w0),current:e=Date.now(),epoch:r=0,step:a=3e4,counter:c=0,digits:s=6}=f||{};if(!c){const o=BigInt(Math.floor((e-r)/a));c=g.fromBI(o,8,!1)}c instanceof Uint8Array||(c=g.fromBI(BigInt(c),8,!1));const i=B2(n,c,t);return((0|(i[0]&127)<<24|(i[1]&255)<<16|(i[2]&255)<<8|i[3]&255)%10**s).toString().padStart(s,"0")}}function o1(f,n){return x((t,e)=>x(f(t,e),n),n)}function a0(f,n,t){return x((e,r)=>typeof r=="number"?f(e,r):n(e),t)}const $1=a0((f,n)=>{const t=n-f.length%n;return X(f,new Uint8Array(t).fill(t))},f=>{const n=f[f.length-1];return new g(f.slice(0,f.length-n))},{ALGORITHM:"PKCS#7"}),cn=a0((f,n)=>{const t=Math.ceil((f.length+1)/n),e=new g(t*n);return e.set(f),e[f.length]=128,e},f=>{let n=f.length-1;for(;f[n]===128;)if(n=n-1,n<0)return console.warn("This message may not be ISO/IEC 7816-4 padded"),new g;return new g(f.slice(0,n+1))},{ALGORITHM:"ISO/IEC 7816-4"}),sn=a0((f,n)=>{const t=Math.ceil((f.length+1)/n),e=new g(t*n);return e.set(f),e[e.length-1]=e.length-f.length,e},f=>{const n=f[f.length-1];return new g(f.slice(0,f.length-n))},{ALGORITHM:"ANSI X9.23"}),on=a0((f,n)=>{const t=n-f.length%n;return X(f,new Uint8Array(t))},f=>{let n=f.length-1;for(;f[n]===0;)if(n=n-1,n<0)return new g;return new g(f.slice(0,n+1))},{ALGORITHM:"Zero Padding"}),un=a0(f=>new g(f.slice(0)),f=>new g(f.slice(0)),{ALGORITHM:"No Padding"}),bn=x((f,n=$1)=>{const t={ALGORITHM:`ECB-${f.ALGORITHM}`,PADDING:n,BLOCK_SIZE:f.BLOCK_SIZE,KEY_SIZE:f.KEY_SIZE,MIN_KEY_SIZE:f.MIN_KEY_SIZE,MAX_KEY_SIZE:f.MAX_KEY_SIZE,IV_SIZE:0,MIN_IV_SIZE:0,MAX_IV_SIZE:0};return x(e=>{e=v(e);const{BLOCK_SIZE:r}=f,a=f(e);return x({encrypt:c=>{c=v(c);const s=n(c,r),i=new g(s.length);for(let o=0,u=r;o<s.length;){const b=s.subarray(o,u);i.set(a.encrypt(b),o),o=u,u+=r}return i},decrypt:c=>{if(c=v(c),c.length%r!==0)throw new p("Decryption error");const s=new g(c.length);for(let i=0,o=r;i<c.length;){const u=c.subarray(i,o);s.set(a.decrypt(u),i),i=o,o+=r}return n(s)}},t)},t)},{ALGORITHM:"ECB"}),L2=x((f,n=$1)=>{const t={ALGORITHM:`CBC-${f.ALGORITHM}`,PADDING:n,BLOCK_SIZE:f.BLOCK_SIZE,KEY_SIZE:f.KEY_SIZE,MIN_KEY_SIZE:f.MIN_KEY_SIZE,MAX_KEY_SIZE:f.MAX_KEY_SIZE,IV_SIZE:f.BLOCK_SIZE,MIN_IV_SIZE:f.BLOCK_SIZE,MAX_IV_SIZE:f.BLOCK_SIZE};return x((e,r)=>{e=v(e),r=v(r);const{BLOCK_SIZE:a}=f;if(r.length!==a)throw new p(`${t.ALGORITHM} iv must be ${a} byte`);const c=f(e);return x({encrypt:s=>{s=v(s);const i=n(s,a),o=new g(i.length);let u=r.slice(0);for(let b=0,l=a;b<i.length;){const h=i.subarray(b,l);u.forEach((d,y)=>{u[y]^=h[y]}),u=c.encrypt(u),o.set(u,b),b=l,l+=a}return o},decrypt:s=>{if(s=v(s),s.length%a!==0)throw new p("Decryption error");const i=new g(s.length);let o=r.slice(0);for(let u=0,b=a;u<s.length;){const l=s.slice(u,b);c.decrypt(l).forEach((h,d)=>{o[d]^=h}),i.set(o,u),o=l,u=b,b+=a}return n(i)}},t)},t)},{ALGORITHM:"CBC"}),ln=x((f,n=$1)=>{const t={ALGORITHM:`PCBC-${f.ALGORITHM}`,PADDING:n,BLOCK_SIZE:f.BLOCK_SIZE,KEY_SIZE:f.KEY_SIZE,MIN_KEY_SIZE:f.MIN_KEY_SIZE,MAX_KEY_SIZE:f.MAX_KEY_SIZE,IV_SIZE:f.BLOCK_SIZE,MIN_IV_SIZE:f.BLOCK_SIZE,MAX_IV_SIZE:f.BLOCK_SIZE};return x((e,r)=>{e=v(e),r=v(r);const{BLOCK_SIZE:a}=f;if(r.length!==a)throw new p(`${t.ALGORITHM} iv must be ${a} byte`);const c=f(e);return x({encrypt:s=>{s=v(s);const i=n(s,a),o=new g(i.length),u=r.slice(0);for(let b=0,l=a;b<i.length;){const h=i.subarray(b,l);u.forEach((y,I)=>{u[I]^=h[I]});const d=c.encrypt(u);o.set(d,b),u.forEach((y,I)=>{u[I]=d[I]^h[I]}),b=l,l+=a}return o},decrypt:s=>{if(s=v(s),s.length%a!==0)throw new p("Decryption error");const i=new g(s.length),o=r.slice(0);for(let u=0,b=a;u<s.length;){const l=s.slice(u,b),h=c.decrypt(l);h.forEach((d,y)=>{h[y]^=o[y]}),i.set(h,u),l.forEach((d,y)=>{o[y]=l[y]^h[y]}),u=b,b+=a}return n(i)}},t)},t)},{ALGORITHM:"PCBC"}),dn=x((f,n=$1)=>{const t={ALGORITHM:`CFB-${f.ALGORITHM}`,PADDING:n,BLOCK_SIZE:f.BLOCK_SIZE,KEY_SIZE:f.KEY_SIZE,MIN_KEY_SIZE:f.MIN_KEY_SIZE,MAX_KEY_SIZE:f.MAX_KEY_SIZE,IV_SIZE:f.BLOCK_SIZE,MIN_IV_SIZE:f.BLOCK_SIZE,MAX_IV_SIZE:f.BLOCK_SIZE};return x((e,r)=>{e=v(e),r=v(r);const{BLOCK_SIZE:a}=f;if(r.length!==a)throw new p(`${t.ALGORITHM} iv must be ${a} byte`);const c=f(e);return x({encrypt:s=>{s=v(s);const i=n(s,a),o=new g(i.length);let u=r.slice(0);for(let b=0,l=a;b<i.length;){const h=i.subarray(b,l);u=c.encrypt(u),u.forEach((d,y)=>{u[y]^=h[y]}),o.set(u.subarray(0,h.length),b),b=l,l+=a}return o},decrypt:s=>{s=v(s);const i=new g(s.length);let o=r.slice(0);for(let u=0,b=a;u<s.length;){const l=s.subarray(u,b);o=c.encrypt(o),l.forEach((h,d)=>{o[d]^=l[d]}),i.set(o.subarray(0,l.length),u),o=g.from(l),u=b,b+=a}return n(i)}},t)},t)},{ALGORITHM:"CFB"}),yn=x((f,n=$1)=>{const t={ALGORITHM:`OFB-${f.ALGORITHM}`,PADDING:n,BLOCK_SIZE:f.BLOCK_SIZE,KEY_SIZE:f.KEY_SIZE,MIN_KEY_SIZE:f.MIN_KEY_SIZE,MAX_KEY_SIZE:f.MAX_KEY_SIZE,IV_SIZE:f.BLOCK_SIZE,MIN_IV_SIZE:f.BLOCK_SIZE,MAX_IV_SIZE:f.BLOCK_SIZE};return x((e,r)=>{e=v(e),r=v(r);const{BLOCK_SIZE:a}=f;if(r.length!==a)throw new p(`${t.ALGORITHM} iv must be ${a} byte`);const c=f(e);let s=c.encrypt(r),i=s,o=a;const u=b=>{if(o>b)return i;const l=[i];for(;o<b;)s=c.encrypt(s),l.push(s),o+=a;return i=X(...l),i};return x({encrypt:b=>{b=v(b);const l=n(b,a);return i=u(l.length),l.map((h,d)=>h^i[d])},decrypt:b=>(b=v(b),i=u(b.length),n(b.map((l,h)=>l^i[h])))},t)},t)},{ALGORITHM:"OFB"}),In=x((f,n=$1)=>{const t={ALGORITHM:`CTR-${f.ALGORITHM}`,PADDING:n,BLOCK_SIZE:f.BLOCK_SIZE,KEY_SIZE:f.KEY_SIZE,MIN_KEY_SIZE:f.MIN_KEY_SIZE,MAX_KEY_SIZE:f.MAX_KEY_SIZE,IV_SIZE:f.BLOCK_SIZE,MIN_IV_SIZE:f.BLOCK_SIZE,MAX_IV_SIZE:f.BLOCK_SIZE};return x((e,r)=>{e=v(e),r=v(r);const{BLOCK_SIZE:a}=f;if(r.length!==a)throw new p(`{info.ALGORITHM} iv must be ${a} byte`);const c=f(e),s=new X1(r.slice(0));let i=new g,o=0;const u=b=>{if(o>b)return i;const l=[i];for(;o<b;)l.push(c.encrypt(s)),s.inc(),o+=a;return i=X(...l),i};return x({encrypt:b=>{b=v(b);const l=n(b,a);return i=u(l.length),l.map((h,d)=>h^i[d])},decrypt:b=>(b=v(b),i=u(b.length),n(b.map((l,h)=>l^i[h])))},t)},t)},{ALGORITHM:"CTR"});function hn(f,n){const t=0xe1n<<56n,e=new DataView(n.buffer,n.byteOffset,n.byteLength);let r=e.getBigUint64(0,!1),a=e.getBigUint64(8,!1),c=0n,s=0n;for(let u=0;u<16;u++){const b=f[u];for(let l=7;l>=0;l--){b>>l&1&&(c^=r,s^=a);const h=a&1n;a=r<<63n|a>>1n,a=a&0xffffffffffffffffn,r=r>>1n,h&&(r^=t)}}const i=new g(16),o=new DataView(i.buffer,i.byteOffset,i.byteLength);return o.setBigUint64(0,c,!1),o.setBigUint64(8,s,!1),i}function Z2(f,n,t){const e=Math.ceil(n.length/16),r=Math.ceil(t.length/16),a=new Uint8Array((e+r+1)*16),c=new DataView(a.buffer,a.byteOffset,a.byteLength);a.set(n),a.set(t,e*16),c.setBigUint64(a.length-16,BigInt(n.length<<3),!1),c.setBigUint64(a.length-8,BigInt(t.length<<3),!1);let s=new g(16);for(let i=0;i<a.length;i+=16){const o=a.subarray(i,i+16);s.forEach((u,b)=>{s[b]^=o[b]}),s=hn(f,s)}return s}const wn=x((f,n=$1,t=16)=>{const{BLOCK_SIZE:e}=f;if(e!==16)throw new p("GCM cipher block must be 128 bit");const r={ALGORITHM:`GCM-${f.ALGORITHM}`,PADDING:n,BLOCK_SIZE:f.BLOCK_SIZE,KEY_SIZE:f.KEY_SIZE,MIN_KEY_SIZE:f.MIN_KEY_SIZE,MAX_KEY_SIZE:f.MAX_KEY_SIZE,IV_SIZE:12,MIN_IV_SIZE:0,MAX_IV_SIZE:1/0,AUTH_TAG_SIZE:t};return x((a,c)=>{a=v(a),c=v(c);const s=f(a),i=s.encrypt(new Uint8Array(e));let o=new X1(16);c.length===12?(o.set(c),o[15]=1):o=new X1(Z2(i,new Uint8Array,c.slice(0)));let u=s.encrypt(o),b=0;const l=I=>{if(b>I)return u;const w=[u];for(;b<I;)o.inc(),w.push(s.encrypt(o)),b+=e;return u=X(...w),u},h=I=>{I=v(I);const w=n(I,e);return u=l(w.length),w.map((_,K)=>_^u[K+e])},d=I=>(I=v(I),u=l(I.length),n(I.map((w,_)=>w^u[_+e]))),y=(I,w=new Uint8Array)=>{I=v(I),w=v(w);const _=Z2(i,w,I);return _.forEach((K,C)=>{_[C]^=u[C]}),_.slice(0,t)};return x({encrypt:h,decrypt:d,sign:y,verify:(I,w,_)=>{if(I=v(I),w=v(w),_=_?v(_):void 0,I.length!==t)return!1;const K=y(w,_);return I.every((C,S)=>C===K[S])}},r)},r)},{ALGORITHM:"GCM",IV_SIZE:12});function gn(f){const n=new Uint8Array(256);n.forEach((e,r)=>{n[r]=r});let t=0;for(let e=0;e<256;e++)t=(t+n[e]+f[e%f.byteLength])%256,[n[e],n[t]]=[n[t],n[e]];return n}function U2(f,n){n=n.slice(0);const t=new g(f.byteLength);let e=0,r=0;return f.forEach((a,c)=>{e=(e+1)%256,r=(r+n[e])%256,[n[e],n[r]]=[n[r],n[e]],t[c]=f[c]^n[(n[e]+n[r])%256]}),t}function En(f){if(f.byteLength<5||f.byteLength>256)throw new p("RC4 key must be between 5 and 256 byte");const n=gn(f);return{encrypt:t=>U2(t,n),decrypt:t=>U2(t,n)}}const pn=o1(En,{ALGORITHM:"ARC4",KEY_SIZE:16,MIN_KEY_SIZE:5,MAX_KEY_SIZE:256}),Sn=new Uint32Array([1295307597,3545052371,886263092,1295307597,3545052371,886263092,1295307597,3545052371]);function An(f,n){if(f.length!==16)throw new p("Rabbit key must be 16 byte");let t=0;const e=new Uint8Array(32),r=new Uint8Array(32),a=new Uint32Array(e.buffer),c=new Uint32Array(r.buffer),s=(l=!1)=>{for(let y=0;y<8;y++){const I=c[y]+Sn[y]+t;c[y]=I|0,t=I>4294967295?1:0}const h=new Uint32Array(8);for(let y=0;y<8;y++){const I=BigInt(a[y])+BigInt(c[y])&0xffffffffn,w=I*I;h[y]=Number((w^w>>32n)&0xffffffffn)}if(a[0]=4294967295&h[0]+L(h[7],16)+L(h[6],16),a[1]=4294967295&h[1]+L(h[0],8)+h[7],a[2]=4294967295&h[2]+L(h[1],16)+L(h[0],16),a[3]=4294967295&h[3]+L(h[2],8)+h[1],a[4]=4294967295&h[4]+L(h[3],16)+L(h[2],16),a[5]=4294967295&h[5]+L(h[4],8)+h[3],a[6]=4294967295&h[6]+L(h[5],16)+L(h[4],16),a[7]=4294967295&h[7]+L(h[6],8)+h[5],l)return new Uint8Array;const d=new Uint32Array(4);return d[0]=a[0]^a[5]>>>16^a[3]<<16,d[1]=a[2]^a[7]>>>16^a[5]<<16,d[2]=a[4]^a[1]>>>16^a[7]<<16,d[3]=a[6]^a[3]>>>16^a[1]<<16,new Uint8Array(d.buffer,d.byteOffset,16)};(()=>{const l=new Uint16Array(f.buffer,f.byteOffset,f.byteLength>>1);for(let h=0;h<8;h++)if((h&1)===0){const d=l[(h+1)%8],y=l[h];a[h]=d<<16|y;const I=l[(h+4)%8],w=l[(h+5)%8];c[h]=I<<16|w}else{const d=l[(h+5)%8],y=l[(h+4)%8];a[h]=d<<16|y;const I=l[h],w=l[(h+1)%8];c[h]=I<<16|w}for(let h=0;h<4;h++)s(!0);for(let h=0;h<8;h++)c[h]^=a[(h+4)%8];if(n.length===8){const h=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>2),d=new Uint16Array(n.buffer,n.byteOffset,n.byteLength>>1);c[0]^=h[0],c[1]^=d[3]<<16|d[1],c[2]^=h[1],c[3]^=d[2]<<16|d[0],c[4]^=h[0],c[5]^=d[3]<<16|d[1],c[6]^=h[1],c[7]^=d[2]<<16|d[0];for(let y=0;y<4;y++)s(!0)}else if(n.length!==0&&n.length!==8)throw new p("Rabbit iv must be 8 byte")})();let i=s(),o=1;const u=l=>{if(o>=l)return i;for(i=X0(i,l<<4);o<l;)i.set(s(),o<<4),o++;return i},b=l=>{const h=Math.ceil(l.length>>4)||1;return i=u(h),g.from(l).map((d,y)=>d^i[y])};return{encrypt:l=>b(l),decrypt:l=>b(l)}}const _n=o1(An,{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 K2(f,n=20){const t=z1(f),e=t.slice(0);for(let r=0;r<n;r+=2)e[4]^=L(e[0]+e[12],7),e[8]^=L(e[4]+e[0],9),e[12]^=L(e[8]+e[4],13),e[0]^=L(e[12]+e[8],18),e[9]^=L(e[5]+e[1],7),e[13]^=L(e[9]+e[5],9),e[1]^=L(e[13]+e[9],13),e[5]^=L(e[1]+e[13],18),e[14]^=L(e[10]+e[6],7),e[2]^=L(e[14]+e[10],9),e[6]^=L(e[2]+e[14],13),e[10]^=L(e[6]+e[2],18),e[3]^=L(e[15]+e[11],7),e[7]^=L(e[3]+e[15],9),e[11]^=L(e[7]+e[3],13),e[15]^=L(e[11]+e[7],18),e[1]^=L(e[0]+e[3],7),e[2]^=L(e[1]+e[0],9),e[3]^=L(e[2]+e[1],13),e[0]^=L(e[3]+e[2],18),e[6]^=L(e[5]+e[4],7),e[7]^=L(e[6]+e[5],9),e[4]^=L(e[7]+e[6],13),e[5]^=L(e[4]+e[7],18),e[11]^=L(e[10]+e[9],7),e[8]^=L(e[11]+e[10],9),e[9]^=L(e[8]+e[11],13),e[10]^=L(e[9]+e[8],18),e[12]^=L(e[15]+e[14],7),e[13]^=L(e[12]+e[15],9),e[14]^=L(e[13]+e[12],13),e[15]^=L(e[14]+e[13],18);for(let r=0;r<16;r++)e[r]+=t[r];return v(e)}function mn(f,n){if(n.byteLength!==8)throw new p("Salsa20 iv must be 8 byte");const t=new X1(64),e=z1(t),r=z1(f),a=z1(n);switch(f.byteLength){case 16:e[0]=1634760805,e[1]=r[0],e[2]=r[1],e[3]=r[2],e[4]=r[3],e[5]=824206446,e[6]=a[0],e[7]=a[1],e[10]=2036477238,e[11]=r[0],e[12]=r[1],e[13]=r[2],e[14]=r[3],e[15]=1797285236;break;case 32:e[0]=1634760805,e[1]=r[0],e[2]=r[1],e[3]=r[2],e[4]=r[3],e[5]=857760878,e[6]=a[0],e[7]=a[1],e[10]=2036477234,e[11]=r[4],e[12]=r[5],e[13]=r[6],e[14]=r[7],e[15]=1797285236;break;default:throw new p("Salsa20 key must be 16 or 32 byte")}return t}function On(f,n){const t=mn(f,n);let e=K2(t),r=1;const a=c=>{const s=(c.length>>6)+1;if(r>s)return v(c).map((i,o)=>i^e[o]);for(e=X0(e,s<<6);s>r;)t.inc(32,8,!0),e.set(K2(t),r<<6),r++;return v(c).map((i,o)=>i^e[o])};return{encrypt:c=>a(c),decrypt:c=>a(c)}}const Bn=o1(On,{ALGORITHM:"Salsa20",KEY_SIZE:32,MIN_KEY_SIZE:16,MAX_KEY_SIZE:32,IV_SIZE:8,MIN_IV_SIZE:8,MAX_IV_SIZE:8}),U0=new Uint8Array([62,114,91,71,202,224,0,51,4,209,84,152,9,185,109,203,123,27,249,50,175,157,106,165,184,45,252,29,8,83,3,144,77,78,132,153,228,206,217,145,221,182,133,72,139,41,110,172,205,193,248,30,115,67,105,198,181,189,253,57,99,32,212,56,118,125,178,167,207,237,87,197,243,44,187,20,33,6,85,155,227,239,94,49,79,127,90,164,13,130,81,73,95,186,88,28,74,22,213,23,168,146,36,31,140,255,216,174,46,1,211,173,59,75,218,70,235,201,222,154,143,135,215,58,128,111,47,200,177,180,55,247,10,34,19,40,124,204,60,137,199,195,150,86,7,191,126,240,11,43,151,82,53,65,121,97,166,76,16,254,188,38,149,136,138,176,163,251,192,24,148,242,225,229,233,93,208,220,17,102,100,92,236,89,66,117,18,245,116,156,170,35,14,134,171,190,42,2,231,103,230,68,162,108,194,147,159,241,246,250,54,210,80,104,158,98,113,21,61,214,64,196,226,15,142,131,119,107,37,5,63,12,48,234,112,183,161,232,169,101,141,39,26,219,129,179,160,244,69,122,25,223,238,120,52,96]),K0=new Uint8Array([85,194,99,113,59,200,71,134,159,60,218,91,41,170,253,119,140,197,148,12,166,26,19,0,227,168,22,114,64,249,248,66,68,38,104,150,129,217,69,62,16,118,198,167,139,57,67,225,58,181,86,42,192,109,179,5,34,102,191,220,11,250,98,72,221,32,17,6,54,201,193,207,246,39,82,187,105,245,212,135,127,132,76,210,156,87,164,188,79,154,223,254,214,141,122,235,43,83,216,92,161,20,23,251,35,213,125,48,103,115,8,9,238,183,112,63,97,178,25,142,78,229,75,147,143,93,219,169,173,241,174,46,203,13,252,244,45,70,110,29,151,232,209,233,77,55,165,117,94,131,158,171,130,157,185,28,224,205,73,137,1,182,189,88,36,162,95,56,120,153,21,144,80,184,149,228,208,145,199,206,237,15,180,111,160,204,240,2,74,121,195,222,163,239,234,81,230,107,24,236,27,44,128,247,116,231,255,33,90,106,84,30,65,49,146,53,196,51,7,10,186,126,14,52,136,177,152,124,243,61,96,108,123,202,211,31,50,101,4,40,100,190,133,155,47,89,138,215,176,37,172,175,18,3,226,242]),Ln=new Uint16Array([17623,9916,25195,4958,22409,13794,28981,2479,19832,12051,27588,6897,24102,15437,30874,18348]);function c0(f,n){return(f<<n|f>>>31-n)&2147483647}function Q1(f,n){const t=f+n;return(t&2147483647)+(t>>>31)}const Zn=f=>f^L(f,2)^L(f,10)^L(f,18)^L(f,24),Un=f=>f^L(f,8)^L(f,14)^L(f,22)^L(f,30);function W0(f,n){n[0]=(f[15]&2147450880)<<1|f[14]&65535,n[1]=(f[11]&65535)<<16|f[9]>>>15,n[2]=(f[7]&65535)<<16|f[5]>>>15,n[3]=(f[2]&65535)<<16|f[0]>>>15}function q0(f,n,t,e){const r=(f^e[0])+e[1],a=e[0]+n&4294967295,c=e[1]^t,s=Zn(a<<16|c>>>16);e[0]=U0[s>>>24]<<24|K0[s>>>16&255]<<16|U0[s>>>8&255]<<8|K0[s&255];const i=Un(c<<16|a>>>16);return e[1]=U0[i>>>24]<<24|K0[i>>>16&255]<<16|U0[i>>>8&255]<<8|K0[i&255],r}function J0(f,n){let t,e;t=f[0],e=c0(f[0],8),t=Q1(t,e),e=c0(f[4],20),t=Q1(t,e),e=c0(f[10],21),t=Q1(t,e),e=c0(f[13],17),t=Q1(t,e),e=c0(f[15],15),t=Q1(t,e),t=n?Q1(t,n):t,t=t||2147483647;for(let r=0;r<15;r++)f[r]=f[r+1];f[15]=t}function x0(f,n){if(f.byteLength!==16)throw new p("ZUC requires a key of 16 bytes");if(n.byteLength!==16)throw new p("ZUC requires an IV of 16 bytes");const t=new Uint32Array(16),e=new Uint32Array(4),r=new Uint32Array(2);return(function(){for(let a=0;a<16;a++)t[a]=f[a]<<23|Ln[a]<<8|n[a];for(let a=0;a<32;a++){W0(t,e);const c=q0(e[0],e[1],e[2],r);J0(t,c>>>1)}W0(t,e),q0(e[0],e[1],e[2],r),J0(t)})(),()=>{W0(t,e);const a=q0(e[0],e[1],e[2],r)^e[3];return J0(t),a}}function Kn(f,n,t){const e=new Uint8Array(16);return e.set(f,0),e[4]=n<<3|t<<2,e.set(e.subarray(0,5),8),e}function $n(f,n,t){const e=new Uint8Array(16);return e.set(f,0),e[4]=n<<3,e.set(e.subarray(0,5),8),e[8]^=t<<7,e[14]^=t<<7,e}function $2(f,n){const t=n%8,e=n>>>3;return(t===0?f.getUint32(e,!1):f.getUint32(e,!1)<<t|f.getUint32(e+4,!1)>>>32-t)&4294967295}const Cn=x(f=>{const{BEARER:n,DIRECTION:t,KEY:e,M:r}=f;let{COUNTER:a,LENGTH:c}=f;a=typeof a=="number"?new Uint8Array([a>>24,a>>16,a>>8,a]):a,c=r.byteLength<<3;const s=c+31>>5,i=new Uint8Array(s<<2),o=new DataView(i.buffer,i.byteOffset,i.byteLength),u=Kn(a,n,t),b=x0(e,u);for(let l=0;l<s;l++)o.setUint32(l<<2,b(),!1);return new g(r.map((l,h)=>l^i[h]))},{ALGORITHM:"ZUC-EEA3",KEY_SIZE:16}),Mn=x(f=>{const{BEARER:n,DIRECTION:t,KEY:e,M:r}=f;let{COUNTER:a,LENGTH:c}=f;a=typeof a=="number"?new Uint8Array([a>>24,a>>16,a>>8,a]):a;const s=c+64+31>>5,i=new Uint8Array(s<<2),o=new DataView(i.buffer,i.byteOffset,i.byteLength),u=$n(a,n,t),b=x0(e,u);for(let h=0;h<s;h++)o.setUint32(h<<2,b(),!1);let l=0;for(let h=0;h<c;h++)r[h>>>3]&1<<7-h%8&&(l^=$2(o,h));return l^=$2(o,c),l^=o.getUint32(i.byteLength-4),new g([l>>24,l>>16,l>>8,l])},{ALGORITHM:"ZUC-EIA3",KEY_SIZE:16}),C1=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,