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 • 134 kB
JavaScript
function k1(n,t,F){function e(r){return typeof r=="string"?n(r):t(r)}return v(e,{FORMAT:F})}function e3(n){const t=[];for(let F=0;F<n.length;F++){const e=n.codePointAt(F);e!==void 0&&(e<128?t.push(e):e<2048?(t.push(192|e>>6),t.push(128|e&63)):e<65536?(t.push(224|e>>12),t.push(128|e>>6&63),t.push(128|e&63)):e<1114112&&(t.push(240|e>>18),t.push(128|e>>12&63),t.push(128|e>>6&63),t.push(128|e&63),F++))}return I.from(t)}function r3(n){const t=[];let F=0;for(;F<n.length;){const e=n[F++];if(e<128)t.push(String.fromCharCode(e));else if(e>=192&&e<224){const r=n[F++],i=(e&31)<<6|r&63;t.push(String.fromCharCode(i))}else if(e>=224&&e<240){const r=n[F++],i=n[F++],o=(e&15)<<12|(r&63)<<6|i&63;t.push(String.fromCharCode(o))}else if(e>=240&&e<248){const r=n[F++],i=n[F++],o=n[F++],u=(e&7)<<18|(r&63)<<12|(i&63)<<6|o&63;t.push(String.fromCodePoint(u))}}return t.join("")}const t2=k1(e3,r3,"utf-8");function i3(n){const t=n.match(/[\da-f]{2}/gi);return t==null?new I:new I(t.map(F=>Number.parseInt(F,16)))}function o3(n){let t="";for(let F=0;F<n.length;F++)t+=n[F].toString(16).padStart(2,"0");return t}const s3=k1(i3,o3,"hex");function u3(n){return W2(n,!1)}function c3(n){return B3(n,!1)}const Q2=k1(u3,c3,"base64");function E3(n){return W2(n,!0)}function f3(n){return Q2(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}const A3=k1(E3,f3,"base64url");function W2(n,t){const F="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";if(t)for(n=n.replace(/-/g,"+").replace(/_/g,"/");n.length%4;)n+="=";n=n.replace(/[^A-Z0-9+/]/gi,"");const e=n.length*.75,r=new I(e);let i=0,o=0;for(;i<n.length;){const u=F.indexOf(n.charAt(i++)),s=F.indexOf(n.charAt(i++)),c=F.indexOf(n.charAt(i++)),E=F.indexOf(n.charAt(i++)),A=u<<18|s<<12|c<<6|E;r[o++]=A>>16&255,r[o++]=A>>8&255,r[o++]=A&255}return r}function B3(n,t){let F="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";F+=t?"-_":"+/";let e="",r;for(r=0;r<n.length-2;r+=3)e+=F[n[r]>>2],e+=F[(n[r]&3)<<4|n[r+1]>>4],e+=F[(n[r+1]&15)<<2|n[r+2]>>6],e+=F[n[r+2]&63];return r===n.length-2?(e+=F[n[r]>>2],e+=F[(n[r]&3)<<4|n[r+1]>>4],e+=F[(n[r+1]&15)<<2],e+=t?"":"="):r===n.length-1&&(e+=F[n[r]>>2],e+=F[(n[r]&3)<<4],e+=t?"":"=="),e}function a3(n){const t=new Map;t.set("\u5BCC\u5F3A",0),t.set("\u6C11\u4E3B",1),t.set("\u6587\u660E",2),t.set("\u548C\u8C10",3),t.set("\u81EA\u7531",4),t.set("\u5E73\u7B49",5),t.set("\u516C\u6B63",6),t.set("\u6CD5\u6CBB",7),t.set("\u7231\u56FD",8),t.set("\u656C\u4E1A",9),t.set("\u8BDA\u4FE1",10),t.set("\u53CB\u5584",11);const F=s=>{const c=t.get(s);if(c===void 0)throw new D("\u4F60\u7ADF\u7136\u5728\u793E\u4F1A\u4E3B\u4E49\u6838\u5FC3\u4EF7\u503C\u89C2\u91CC\u5939\u5E26\u79C1\u8D27\uFF01");return c},e=n.match(/(\S){2}/g);if(e==null)return new I;let r=0,i=0,o=0;const u=[];for(let s=0;s<e.length;s++){const c=o%2===0;let E=F(e[s]);if(E===10||E===11){if(s++,s===e.length)throw new D("\u4F60\u7684\u793E\u4F1A\u4E3B\u4E49\u6838\u5FC3\u4EF7\u503C\u89C2\u7834\u788E\u4E86\uFF01");E=E===10?10+F(e[s]):6+F(e[s])}c?r=E:i=E,c||u.push((r<<4|i)&255),o++}return new I(u)}function I3(n){const t=()=>Math.random()>=.5,F=["\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 n.forEach(r=>{const i=r>>4&15,o=r&15;i<10?e+=F[i]:e+=F[11]+F[i-6],o<10?e+=F[o]:t()?e+=F[10]+F[o-10]:e+=F[11]+F[o-6]}),e}const l3=k1(a3,I3,"core-socialist-values");function b(n,t){return n>>>=0,t%=32,n=n<<t|n>>>32-t,n>>>0}function F1(n,t){return n>>>=0,t%=32,n=n>>>t|n<<32-t,n>>>0}function Y1(n,t,F,e){return n=BigInt(n),e??(e=O1(n)),t=BigInt(t),F=BigInt(F),t&=e,F%=n,t=t<<F|t>>n-F,t&e}function d2(n,t,F,e){return n=BigInt(n),e??(e=O1(n)),t=BigInt(t),F=BigInt(F),t&=e,F%=n,t=t>>F|t<<n-F,t&e}function L1(n,t){let F=0n;const e=new I(t);do crypto.getRandomValues(e),F=e.toBI();while(F>=n);return{buffer:e,result:F}}function B1(n){let t=0;for(;n>0;)t++,n>>=1n;return t}function O1(n){n=BigInt(n);let t=0x0n;for(let F=0;F<n;F++)t=t<<1n|1n;return t}function j2(n,t){let[F,e,r,i,o,u]=[1n,0n,0n,1n,n,t];if(t===0n)return{gcd:n,a_inv:1n,b_inv:0n};for(;u!==0n;){const s=o/u;[o,u]=[u,o-s*u],[F,e]=[e,F-s*e],[r,i]=[i,r-s*i]}return{gcd:o,a_inv:F,b_inv:r}}function z2(n,t){return e1(n,t-1n>>1n,t)}function C3(n,t){if(z2(n,t)!==1n)throw new D("There is no square root");if(n===0n)return 0n;if(t===2n)return n;if(t%4n===3n)return e1(n,t+1n>>2n,t);let F=t-1n,e=0n;for(;V(F,2n)===0n;)F>>=1n,e++;let r=2n;for(;z2(r,t)!==t-1n;)r++;let i=e,o=e1(r,F,t),u=e1(n,F,t),s=e1(n,F+1n>>1n,t);for(;u!==0n&&u!==1n;){let c=u,E=1n;for(;E<i&&(c=e1(c,2n,t),c!==1n);E++);const A=e1(o,1n<<i-E-1n,t);i=E,o=e1(A,2n,t),u=u*o%t,s=s*A%t}return s}function q2(n,t){return j2(n,t).gcd}function y3(n,t){return n*t/q2(n,t)}function V(n,t){const F=n%t;return F<0n?F+t:F}function e1(n,t,F){n%=F;let e=1n;for(;t>0n;)t&1n&&(e=e*n%F),n=n*n%F,t>>=1n;return e}function M1(n,t){const{gcd:F,a_inv:e}=j2(n,t);if(F!==1n)throw new D("Modular inverse does not exist");return V(e,t)}function D3(n,t){return n=V(n,t),C3(n,t)}class I extends Uint8Array{getWord(t,F,e=!1){const r=F*t,i=this.subarray(r,r+t);return e?i.toBI(!0):i.toBI()}setWord(t,F,e,r=!1){const i=F*t,o=typeof e=="bigint"?I.fromBI(e,t):e;this.set(r?o.toReversed():o,i)}view(t){const F=Math.floor(this.length/t);return{get:(e,r=!1)=>this.getWord(t,e,r),set:(e,r,i=!1)=>this.setWord(t,e,r,i),length:F}}to(t){return t(this)}toBI(t=!1){const F=t?this.toReversed():this;let e=0n;return F.forEach(r=>e=e<<8n|BigInt(r)),e}toUint8Array(){return new Uint8Array(this)}static fromString(t,F=t2){return F(t)}static fromBI(t,F,e=!1){F=F||B1(t)+7>>3;const r=new I(F);if(e)for(let i=0;i<r.length;i++)r[i]=Number(t&0xFFn),t>>=8n;else for(let i=r.length-1;i>=0;i--)r[i]=Number(t&0xFFn),t>>=8n;return r}static from(t,F,e){return new I(super.from(t,F,e))}filter(t,F){return new I(super.filter(t,F))}map(t,F){return new I(super.map(t,F))}static of(...t){return new I(super.of(...t))}toReversed(){return super.reverse()}toSorted(t){return super.sort(t)}reverse(){return super.reverse()}slice(t,F){return new I(super.slice(t,F))}subarray(t,F){return new I(super.subarray(t,F))}with(t,F){return new I(super.with(t,F))}}function M(...n){const t=n.reduce((r,i)=>r+i.byteLength,0),F=new I(t);let e=0;for(const r of n)F.set(new I(r),e),e+=r.byteLength;return F}function Z2(n,t){const F=new I(t);return F.set(new I(n)),F}class K1 extends I{inc(t,F,e=!1){if(t=t||0,t<0||t>=this.length)throw new D("Invalid counter offset");if(F=F||this.length-t,F<0||t+F>this.length)throw new D("Invalid counter length");if(e)for(let r=t;r<t+F;r++){if(this[r]<255){this[r]+=1;break}this[r]=0}else for(let r=t+F-1;r>=t;r--){if(this[r]<255){this[r]+=1;break}this[r]=0}}}function v(...n){return n.length===0?{}:Object.assign(...n)}class D extends Error{constructor(t){super(t),this.name="mima-kit Error"}}const J2=40,r1=[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],w3=(1n<<26n)/r1[r1.length-1];function h3(n,t){const F=n-1n;let e=0n,r=F;for(;(r&1n)===0n;)r>>=1n,e++;t=t+1>>1,t>r1.length&&(t=r1.length);const i=[2n];for(let o=0;o<t;++o){let u;do u=r1[Math.floor(Math.random()*r1.length)];while(i.includes(u));if(i.push(u),g3(n,F,e,r,u)===!1)return!1}return!0}function g3(n,t,F,e,r){let i=e1(r,e,n);if(i===1n||i===t)return!0;let o=0n;for(let u=1;u<F;u++){if(o=e1(i,2n,n),o===1n&&i!==1n&&i!==t)return!1;i=o}return o===1n}function x2(n,t=J2){for(let F=1;F<r1.length;){let e=r1[F],r=F+1;for(;r<r1.length&&e<w3;)e*=r1[r++];for(e=n%e;F<r;)if(e%r1[F++]===0n)return!1}return h3(n,t)}function b3(n){crypto.getRandomValues(n),n[0]|=128;let t=n.toBI()|1n;const F=t%6n;return F!==1n&&F!==5n&&(t+=4n),t}const U2=n=>{const t=new I(n>>3);let F;do F=b3(t);while(!x2(F));return F};function p3(n,t=J2){if(t<=0||(n&1n)===0n)return!1;const F=n%6n;return F!==1n&&F!==5n?!1:n<=r1[r1.length-1]?r1.includes(n):x2(n,t)}const X=(n,t)=>v(n,t),N1=(n,t)=>v(n,t),X1=(n,t)=>v(n,t),Z=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 q(n,t,F,e,r,i,o){const u=n+(t&F|~t&e)+r+o;return b(u,i)+t}function J(n,t,F,e,r,i,o){const u=n+(t&e|F&~e)+r+o;return b(u,i)+t}function x(n,t,F,e,r,i,o){const u=n+(t^F^e)+r+o;return b(u,i)+t}function n1(n,t,F,e,r,i,o){const u=n+(F^(t|~e))+r+o;return b(u,i)+t}function S3(n){const t=new Uint32Array([1732584193,4023233417,2562383102,271733878]),F=n.length,e=BigInt(F)<<3n,r=64,i=F+9+63>>6,o=new I(i*r);o.set(n),o[F]=128,new DataView(o.buffer).setBigUint64(o.length-8,e,!0);for(let u=0;u<o.length;){const s=o.subarray(u,u+=r).buffer,c=t[0],E=t[1],A=t[2],B=t[3];let f=c,l=E,a=A,C=B;const y=new Uint32Array(s);f=q(f,l,a,C,y[0],7,Z[0]),C=q(C,f,l,a,y[1],12,Z[1]),a=q(a,C,f,l,y[2],17,Z[2]),l=q(l,a,C,f,y[3],22,Z[3]),f=q(f,l,a,C,y[4],7,Z[4]),C=q(C,f,l,a,y[5],12,Z[5]),a=q(a,C,f,l,y[6],17,Z[6]),l=q(l,a,C,f,y[7],22,Z[7]),f=q(f,l,a,C,y[8],7,Z[8]),C=q(C,f,l,a,y[9],12,Z[9]),a=q(a,C,f,l,y[10],17,Z[10]),l=q(l,a,C,f,y[11],22,Z[11]),f=q(f,l,a,C,y[12],7,Z[12]),C=q(C,f,l,a,y[13],12,Z[13]),a=q(a,C,f,l,y[14],17,Z[14]),l=q(l,a,C,f,y[15],22,Z[15]),f=J(f,l,a,C,y[1],5,Z[16]),C=J(C,f,l,a,y[6],9,Z[17]),a=J(a,C,f,l,y[11],14,Z[18]),l=J(l,a,C,f,y[0],20,Z[19]),f=J(f,l,a,C,y[5],5,Z[20]),C=J(C,f,l,a,y[10],9,Z[21]),a=J(a,C,f,l,y[15],14,Z[22]),l=J(l,a,C,f,y[4],20,Z[23]),f=J(f,l,a,C,y[9],5,Z[24]),C=J(C,f,l,a,y[14],9,Z[25]),a=J(a,C,f,l,y[3],14,Z[26]),l=J(l,a,C,f,y[8],20,Z[27]),f=J(f,l,a,C,y[13],5,Z[28]),C=J(C,f,l,a,y[2],9,Z[29]),a=J(a,C,f,l,y[7],14,Z[30]),l=J(l,a,C,f,y[12],20,Z[31]),f=x(f,l,a,C,y[5],4,Z[32]),C=x(C,f,l,a,y[8],11,Z[33]),a=x(a,C,f,l,y[11],16,Z[34]),l=x(l,a,C,f,y[14],23,Z[35]),f=x(f,l,a,C,y[1],4,Z[36]),C=x(C,f,l,a,y[4],11,Z[37]),a=x(a,C,f,l,y[7],16,Z[38]),l=x(l,a,C,f,y[10],23,Z[39]),f=x(f,l,a,C,y[13],4,Z[40]),C=x(C,f,l,a,y[0],11,Z[41]),a=x(a,C,f,l,y[3],16,Z[42]),l=x(l,a,C,f,y[6],23,Z[43]),f=x(f,l,a,C,y[9],4,Z[44]),C=x(C,f,l,a,y[12],11,Z[45]),a=x(a,C,f,l,y[15],16,Z[46]),l=x(l,a,C,f,y[2],23,Z[47]),f=n1(f,l,a,C,y[0],6,Z[48]),C=n1(C,f,l,a,y[7],10,Z[49]),a=n1(a,C,f,l,y[14],15,Z[50]),l=n1(l,a,C,f,y[5],21,Z[51]),f=n1(f,l,a,C,y[12],6,Z[52]),C=n1(C,f,l,a,y[3],10,Z[53]),a=n1(a,C,f,l,y[10],15,Z[54]),l=n1(l,a,C,f,y[1],21,Z[55]),f=n1(f,l,a,C,y[8],6,Z[56]),C=n1(C,f,l,a,y[15],10,Z[57]),a=n1(a,C,f,l,y[6],15,Z[58]),l=n1(l,a,C,f,y[13],21,Z[59]),f=n1(f,l,a,C,y[4],6,Z[60]),C=n1(C,f,l,a,y[11],10,Z[61]),a=n1(a,C,f,l,y[2],15,Z[62]),l=n1(l,a,C,f,y[9],21,Z[63]),t[0]=c+f,t[1]=E+l,t[2]=A+a,t[3]=B+C}return new I(t.buffer)}const _3=X(S3,{ALGORITHM:"MD5",BLOCK_SIZE:64,DIGEST_SIZE:16,OID:"1.2.840.113549.2.5"});function m3(n){return n<20?1518500249:n<40?1859775393:n<60?2400959708:3395469782}const d3=(n,t,F)=>n&t^~n&F,n0=(n,t,F)=>n^t^F,Z3=(n,t,F)=>n&t^n&F^t&F;function U3(n,t,F,e){return e<20?d3(n,t,F):e<40?n0(n,t,F):e<60?Z3(n,t,F):n0(n,t,F)}function $3(n){const t=new I(20),F=t.view(4);F.set(0,0x67452301n),F.set(1,0xEFCDAB89n),F.set(2,0x98BADCFEn),F.set(3,0x10325476n),F.set(4,0xC3D2E1F0n);const e=n.length,r=BigInt(e)<<3n,i=64,o=e+9+63>>6,u=new I(o*i);u.set(n),u[e]=128;const s=new DataView(u.buffer);s.setBigUint64(u.length-8,r);for(let c=0;c<u.length;c+=i){const E=Number(F.get(0)),A=Number(F.get(1)),B=Number(F.get(2)),f=Number(F.get(3)),l=Number(F.get(4));let a=E,C=A,y=B,m=f,K=l;const U=new Uint32Array(80);for(let p=0;p<80;p++){p<16?U[p]=s.getUint32(c+(p<<2)):U[p]=b(U[p-3]^U[p-8]^U[p-14]^U[p-16],1);const g=b(a,5)+U3(C,y,m,p)+m3(p)+K+U[p];K=m,m=y,y=b(C,30),C=a,a=g}F.set(0,BigInt(E+a)),F.set(1,BigInt(A+C)),F.set(2,BigInt(B+y)),F.set(3,BigInt(f+m)),F.set(4,BigInt(l+K))}return t}const O3=X($3,{ALGORITHM:"SHA-1",BLOCK_SIZE:64,DIGEST_SIZE:20,OID:"1.3.14.3.2.26"}),K3=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]),L3=(n,t,F)=>n&t^~n&F,M3=(n,t,F)=>n&t^n&F^t&F,T3=n=>F1(n,2)^F1(n,13)^F1(n,22),G3=n=>F1(n,6)^F1(n,11)^F1(n,25),H3=n=>F1(n,7)^F1(n,18)^n>>>3,R3=n=>F1(n,17)^F1(n,19)^n>>>10;function t0(n,t){n=n.slice(0);const F=n.view(4),e=t.length,r=BigInt(e)<<3n,i=64,o=e+9+63>>6,u=new I(o*i);u.set(t),u[e]=128;const s=new DataView(u.buffer);s.setBigUint64(u.length-8,r);for(let c=0;c<u.length;c+=i){const E=Number(F.get(0)),A=Number(F.get(1)),B=Number(F.get(2)),f=Number(F.get(3)),l=Number(F.get(4)),a=Number(F.get(5)),C=Number(F.get(6)),y=Number(F.get(7));let m=E,K=A,U=B,p=f,g=l,$=a,d=C,_=y;const S=new Uint32Array(64);for(let h=0;h<S.length;h++){h<16?S[h]=s.getUint32(c+(h<<2)):S[h]=R3(S[h-2])+S[h-7]+H3(S[h-15])+S[h-16];const O=_+G3(g)+L3(g,$,d)+K3[h]+S[h],L=T3(m)+M3(m,K,U);_=d,d=$,$=g,g=p+O,p=U,U=K,K=m,m=O+L}F.set(0,BigInt(E+m)),F.set(1,BigInt(A+K)),F.set(2,BigInt(B+U)),F.set(3,BigInt(f+p)),F.set(4,BigInt(l+g)),F.set(5,BigInt(a+$)),F.set(6,BigInt(C+d)),F.set(7,BigInt(y+_))}return n}function v3(n){const t=new I(32),F=t.view(4);return F.set(0,0xC1059ED8n),F.set(1,0x367CD507n),F.set(2,0x3070DD17n),F.set(3,0xF70E5939n),F.set(4,0xFFC00B31n),F.set(5,0x68581511n),F.set(6,0x64F98FA7n),F.set(7,0xBEFA4FA4n),t0(t,n).slice(0,28)}function k3(n){const t=new I(32),F=t.view(4);return F.set(0,0x6A09E667n),F.set(1,0xBB67AE85n),F.set(2,0x3C6EF372n),F.set(3,0xA54FF53An),F.set(4,0x510E527Fn),F.set(5,0x9B05688Cn),F.set(6,0x1F83D9ABn),F.set(7,0x5BE0CD19n),t0(t,n)}const Y3=X(v3,{ALGORITHM:"SHA-224",BLOCK_SIZE:64,DIGEST_SIZE:28,OID:"2.16.840.1.101.3.4.2.4"}),C1=X(k3,{ALGORITHM:"SHA-256",BLOCK_SIZE:64,DIGEST_SIZE:32,OID:"2.16.840.1.101.3.4.2.1"}),N3=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]),X3=O1(64),a1=(n,t)=>d2(64,n,t,X3),V3=(n,t,F)=>n&t^~n&F,P3=(n,t,F)=>n&t^n&F^t&F,Q3=n=>a1(n,28n)^a1(n,34n)^a1(n,39n),W3=n=>a1(n,14n)^a1(n,18n)^a1(n,41n),j3=n=>a1(n,1n)^a1(n,8n)^n>>7n,z3=n=>a1(n,19n)^a1(n,61n)^n>>6n;function q3(n){if(n<=0)throw new D("SHA-512 truncation must be greater than 0");if(n>=512)throw new D("SHA-512 truncation must be less than 512");if(n===384)throw new D("SHA-512 truncation must not be 384");const t=new I(64),F=t.view(8);return F.set(0,0x6A09E667F3BCC908n^0xA5A5A5A5A5A5A5A5n),F.set(1,0xBB67AE8584CAA73Bn^0xA5A5A5A5A5A5A5A5n),F.set(2,0x3C6EF372FE94F82Bn^0xA5A5A5A5A5A5A5A5n),F.set(3,0xA54FF53A5F1D36F1n^0xA5A5A5A5A5A5A5A5n),F.set(4,0x510E527FADE682D1n^0xA5A5A5A5A5A5A5A5n),F.set(5,0x9B05688C2B3E6C1Fn^0xA5A5A5A5A5A5A5A5n),F.set(6,0x1F83D9ABFB41BD6Bn^0xA5A5A5A5A5A5A5A5n),F.set(7,0x5BE0CD19137E2179n^0xA5A5A5A5A5A5A5A5n),F2(t,t2(`SHA-512/${n}`))}function F2(n,t){n=n.slice(0);const F=n.view(8),e=t.byteLength,r=BigInt(e)<<3n,i=128,o=e+17+127>>7,u=new I(o*i);u.set(t),u[e]=128;const s=new DataView(u.buffer);s.setBigUint64(u.byteLength-16,r>>32n),s.setBigUint64(u.byteLength-8,r&0xFFFFFFFFFFFFFFFFn);for(let c=0;c<u.length;c+=i){const E=F.get(0),A=F.get(1),B=F.get(2),f=F.get(3),l=F.get(4),a=F.get(5),C=F.get(6),y=F.get(7);let m=E,K=A,U=B,p=f,g=l,$=a,d=C,_=y;const S=new BigUint64Array(80);for(let h=0;h<S.length;h++){h<16?S[h]=s.getBigUint64(c+(h<<3)):S[h]=z3(S[h-2])+S[h-7]+j3(S[h-15])+S[h-16];const O=_+W3(g)+V3(g,$,d)+N3[h]+S[h],L=Q3(m)+P3(m,K,U);_=d,d=$,$=g,g=p+O&0xFFFFFFFFFFFFFFFFn,p=U,U=K,K=m,m=O+L&0xFFFFFFFFFFFFFFFFn}F.set(0,E+m),F.set(1,A+K),F.set(2,B+U),F.set(3,f+p),F.set(4,l+g),F.set(5,a+$),F.set(6,C+d),F.set(7,y+_)}return n}function J3(n){const t=new I(64),F=t.view(8);return F.set(0,0xCBBB9D5DC1059ED8n),F.set(1,0x629A292A367CD507n),F.set(2,0x9159015A3070DD17n),F.set(3,0x152FECD8F70E5939n),F.set(4,0x67332667FFC00B31n),F.set(5,0x8EB44A8768581511n),F.set(6,0xDB0C2E0D64F98FA7n),F.set(7,0x47B5481DBEFA4FA4n),F2(t,n).slice(0,48)}function x3(n){const t=new I(64),F=t.view(8);return F.set(0,0x6A09E667F3BCC908n),F.set(1,0xBB67AE8584CAA73Bn),F.set(2,0x3C6EF372FE94F82Bn),F.set(3,0xA54FF53A5F1D36F1n),F.set(4,0x510E527FADE682D1n),F.set(5,0x9B05688C2B3E6C1Fn),F.set(6,0x1F83D9ABFB41BD6Bn),F.set(7,0x5BE0CD19137E2179n),F2(t,n)}const n4=X(J3,{ALGORITHM:"SHA-384",BLOCK_SIZE:128,DIGEST_SIZE:48,OID:"2.16.840.1.101.3.4.2.2"}),t4=X(x3,{ALGORITHM:"SHA-512",BLOCK_SIZE:128,DIGEST_SIZE:64,OID:"2.16.840.1.101.3.4.2.3"});function F4(n){const t=q3(n);let F;return n===224&&(F="2.16.840.1.101.3.4.2.5"),n===256&&(F="2.16.840.1.101.3.4.2.6"),X(e=>F2(t,e).slice(0,n>>3),{ALGORITHM:`SHA-512/${n}`,BLOCK_SIZE:128,DIGEST_SIZE:n>>3,OID:F})}const e4=[[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]],r4=[0x000000008000808Bn,0x800000000000008Bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800An,0x800000008000000An,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n],i4=[0x0000000000000001n,0x0000000000008082n,0x800000000000808An,0x8000000080008000n,0x000000000000808Bn,0x0000000080000001n,0x8000000080008081n,0x8000000000008009n,0x000000000000008An,0x0000000000000088n,0x0000000080008009n,0x000000008000000An,0x000000008000808Bn,0x800000000000008Bn,0x8000000000008089n,0x8000000000008003n,0x8000000000008002n,0x8000000000000080n,0x000000000000800An,0x800000008000000An,0x8000000080008081n,0x8000000000008080n,0x0000000080000001n,0x8000000080008008n],o4=O1(64),F0=(n,t)=>Y1(64,n,t,o4);function s4(n=6,t=24){const F=[];for(let e=0;e<t;e++){let r=0n;for(let i=0;i<=n;i++){const o=i+7*e;let u;if(o%255===0)u=1n;else{let s=0x80n;for(let c=1;c<=o%255;c++){const E=s&1n;s^=E<<8n|E<<4n|E<<3n|E<<2n,s>>=1n}u=s>>7n}r|=u<<BigInt(2**i-1)}F.push(r)}return F}function $2(){return Array.from({length:5}).map(()=>new BigUint64Array(5))}function u4(n){const t=$2(),F=new DataView(n.buffer);for(let e=0;e<5;e++)for(let r=0;r<5;r++)t[e][r]=F.getBigUint64(r*5+e<<3,!0);return t}function c4(n){const t=new Uint8Array(200),F=new DataView(t.buffer);for(let e=0;e<5;e++)for(let r=0;r<5;r++)F.setBigUint64(r*5+e<<3,n[e][r],!0);return t}function E4(n){const t=new BigUint64Array(5),F=new BigUint64Array(5);for(let e=0;e<5;e++)t[e]=n[e][0]^n[e][1]^n[e][2]^n[e][3]^n[e][4];for(let e=0;e<5;e++){F[e]=t[(e+4)%5]^F0(t[(e+1)%5],1n);for(let r=0;r<5;r++)n[e][r]=n[e][r]^F[e]}return n}function f4(n){const t=$2();for(let F=0;F<5;F++)for(let e=0;e<5;e++)t[e][(2*F+3*e)%5]=F0(n[F][e],e4[F][e]);return t}function A4(n){const t=$2();for(let F=0;F<5;F++)for(let e=0;e<5;e++)t[F][e]=n[F][e]^~n[(F+1)%5][e]&n[(F+2)%5][e];return t}function B4(n,t){return n[0][0]=n[0][0]^t,n}function e2(n=24){let t;return n===12?t=r4:n===24?t=i4:t=s4(6,n),F=>{if(F.byteLength!==200)throw new D("Invalid state size");let e=u4(F);for(let r=0;r<n;r++)e=B4(A4(f4(E4(e))),t[r]);return new I(c4(e))}}function r2(n,t,F,e=e2()){return r=>{const i=F(r);let o=new Uint8Array(200),u=0;for(;u<i.byteLength;){const E=i.slice(u,u+=n);o.forEach((A,B)=>o[B]=A^E[B]),o=e(o)}const s=[o.slice(0,n)];let c=n;for(;c<t;)o=e(o),s.push(o.slice(0,n)),c+=n;return M(...s).slice(0,t)}}const i2=n=>t=>{const F=t.length,e=n-F%n,r=new Uint8Array(F+e);return r.set(t),e===1&&(r[F]=134),r[F]=6,r[r.length-1]|=128,r},e0=n=>t=>{const F=t.length,e=n-F%n,r=new Uint8Array(F+e);return r.set(t),e===1&&(r[F]=159),r[F]=31,r[r.length-1]|=128,r};function I1(n,t,F){const e=1600-n>>3,r=F(e);return i=>r2(e,t>>3,r)(i)}const a4=X(n=>I1(448,224,i2)(n),{ALGORITHM:"SHA3-224",BLOCK_SIZE:144,DIGEST_SIZE:28,OID:"2.16.840.1.101.3.4.2.7"}),I4=X(n=>I1(512,256,i2)(n),{ALGORITHM:"SHA3-256",BLOCK_SIZE:136,DIGEST_SIZE:32,OID:"2.16.840.1.101.3.4.2.8"}),l4=X(n=>I1(768,384,i2)(n),{ALGORITHM:"SHA3-384",BLOCK_SIZE:104,DIGEST_SIZE:48,OID:"2.16.840.1.101.3.4.2.9"}),C4=X(n=>I1(1024,512,i2)(n),{ALGORITHM:"SHA3-512",BLOCK_SIZE:72,DIGEST_SIZE:64,OID:"2.16.840.1.101.3.4.2.10"});function o2(n){return X(t=>I1(256,n,e0)(t),{ALGORITHM:`SHAKE128/${n}`,BLOCK_SIZE:168,DIGEST_SIZE:n>>3})}function s2(n){return X(t=>I1(512,n,e0)(t),{ALGORITHM:`SHAKE256/${n}`,BLOCK_SIZE:136,DIGEST_SIZE:n>>3})}function O2(n){const t=[];do t.unshift(n&255),n=n>>8;while(n>0);return t.unshift(t.length),Uint8Array.from(t)}function u2(n){const t=[];do t.unshift(n&255),n=n>>8;while(n>0);return t.push(t.length),Uint8Array.from(t)}function l1(n){return n=typeof n=="string"?t2(n):n,[O2(n.byteLength<<3),n]}function V1(n,t){if(t<=0)throw new D("w must be greater than 0");const F=O2(t);let e=F.length;n.forEach(i=>e+=i.length);const r=t-e%t;return n.unshift(F),n.push(new Uint8Array(r)),n}const c2=n=>t=>{const F=t.length,e=n-F%n,r=new Uint8Array(F+e);return r.set(t),e===1&&(r[F]=132),r[F]=4,r[r.length-1]|=128,r};function r0(n,t,F,e,r,i){return t.byteLength===0&&F.byteLength===0?o=>i(n)(o):o=>{const u=V1([...l1(t),...l1(F)],r);return u.push(o),I1(e,n,c2)(M(...u))}}function y4(n,t=new Uint8Array,F=new Uint8Array){return X(r0(n,t,F,256,168,o2),{ALGORITHM:`cSHAKE128/${n}`,BLOCK_SIZE:168,DIGEST_SIZE:n>>3})}function D4(n,t=new Uint8Array,F=new Uint8Array){return X(r0(n,t,F,512,136,s2),{ALGORITHM:`cSHAKE256/${n}`,BLOCK_SIZE:136,DIGEST_SIZE:n>>3})}function E2(n,t,F,e,r){return(i,o)=>{const u=V1([...l1("KMAC"),...l1(t)],e);return u.push(...V1(l1(i),e)),u.push(o),u.push(u2(r?0:n)),I1(F,n,c2)(M(...u))}}function w4(n,t=new Uint8Array(0),F=128){return X1(E2(n,t,256,168,!1),{ALGORITHM:`KMAC128/${n}`,BLOCK_SIZE:168,DIGEST_SIZE:n>>3,KEY_SIZE:F>>3})}function h4(n,t=new Uint8Array(0),F=256){return X1(E2(n,t,512,136,!1),{ALGORITHM:`KMAC256/${n}`,BLOCK_SIZE:136,DIGEST_SIZE:n>>3,KEY_SIZE:F>>3})}function g4(n,t=new Uint8Array(0),F=128){return X1(E2(n,t,256,168,!0),{ALGORITHM:`KMAC128XOF/${n}`,BLOCK_SIZE:168,DIGEST_SIZE:n>>3,KEY_SIZE:F>>3})}function b4(n,t=new Uint8Array(0),F=256){return X1(E2(n,t,512,136,!0),{ALGORITHM:`KMAC256XOF/${n}`,BLOCK_SIZE:136,DIGEST_SIZE:n>>3,KEY_SIZE:F>>3})}function f2(n,t,F,e,r){return i=>{const o=V1([...l1("TupleHash"),...l1(t)],e);return i.forEach(u=>o.push(...l1(u))),o.push(u2(r?0:n)),I1(F,n,c2)(M(...o))}}function p4(n,t=new Uint8Array){return N1(f2(n,t,256,168,!1),{ALGORITHM:`TupleHash128/${n}`,BLOCK_SIZE:168,DIGEST_SIZE:n>>3})}function S4(n,t=new Uint8Array){return N1(f2(n,t,512,136,!1),{ALGORITHM:`TupleHash256/${n}`,BLOCK_SIZE:136,DIGEST_SIZE:n>>3})}function _4(n,t=new Uint8Array){return N1(f2(n,t,256,168,!0),{ALGORITHM:`TupleHash128XOF/${n}`,BLOCK_SIZE:168,DIGEST_SIZE:n>>3})}function m4(n,t=new Uint8Array){return N1(f2(n,t,512,136,!0),{ALGORITHM:`TupleHash256XOF/${n}`,BLOCK_SIZE:136,DIGEST_SIZE:n>>3})}function A2(n,t,F,e,r,i,o){const u=n>>3;return s=>{const c=Math.ceil(s.byteLength/u),E=V1([...l1("ParallelHash"),...l1(F)],r);E.push(O2(n));for(let A=0;A<c;A++){const B=s.slice(A*(n<<3),(A+1)*(n<<3));E.push(o(B))}return E.push(u2(c)),E.push(u2(i?0:t)),I1(e,t,c2)(M(...E))}}function d4(n,t,F=new Uint8Array){return X(A2(n,t,F,256,168,!1,o2(256)),{ALGORITHM:`ParallelHash128/${t}`,BLOCK_SIZE:168,DIGEST_SIZE:t>>3})}function Z4(n,t,F=new Uint8Array){return X(A2(n,t,F,512,136,!1,s2(512)),{ALGORITHM:`ParallelHash256/${t}`,BLOCK_SIZE:136,DIGEST_SIZE:t>>3})}function U4(n,t,F=new Uint8Array){return X(A2(n,t,F,256,168,!0,o2(256)),{ALGORITHM:"ParallelHash128XOF",BLOCK_SIZE:168,DIGEST_SIZE:t>>3})}function $4(n,t,F=new Uint8Array){return X(A2(n,t,F,512,136,!0,s2(512)),{ALGORITHM:"ParallelHash256XOF",BLOCK_SIZE:136,DIGEST_SIZE:t>>3})}function i0(n,t){return F=>{const e=F.length+1,r=Math.ceil(e/n),i=new Uint8Array(r*n);return i.set(F),i[F.length]=t,i[i.length-1]^=128,i}}function o0(n,t=31){if(t<1||t>127)throw new D("Invalid Domain Separator");const F=n>>3,e=168,r=e2(12),i=i0(e,t);return X(o=>r2(e,F,i,r)(o),{ALGORITHM:`TurboSHAKE128/${n}`,BLOCK_SIZE:e,DIGEST_SIZE:F})}function s0(n,t=31){if(t<1||t>127)throw new D("Invalid Domain Separator");const F=n>>3,e=136,r=e2(12),i=i0(e,t);return X(o=>r2(e,F,i,r)(o),{ALGORITHM:`TurboSHAKE256/${n}`,BLOCK_SIZE:e,DIGEST_SIZE:F})}function u0(n){const t=[];for(;n>0;)t.unshift(n&255),n>>=8;return t.push(t.length),new Uint8Array(t)}function c0(n,t,F,e){return r=>{const i=u0(t.length),o=M(r,t,i);if(o.length<=8192)return F(n,7)(o);{const u=[];u.push(o.slice(0,8192)),u.push(new Uint8Array([3,0,0,0,0,0,0,0]));let s=8192,c=0;for(;s<o.length;){const E=F(e,11)(o.slice(s,s+=8192));u.push(E),c++}return u.push(u0(c)),u.push(new Uint8Array([255,255])),F(n,6)(M(...u))}}}function O4(n,t=new Uint8Array){return X(c0(n,t,o0,256),{ALGORITHM:`KangarooTwelve128/${n}`,BLOCK_SIZE:8192,DIGEST_SIZE:n>>3})}function K4(n,t=new Uint8Array){return X(c0(n,t,s0,512),{ALGORITHM:`KangarooTwelve256/${n}`,BLOCK_SIZE:8192,DIGEST_SIZE:n>>3})}const L4=(n,t,F,e)=>e<16?n^t^F:n&t|n&F|t&F,M4=(n,t,F,e)=>e<16?n^t^F:n&t|~n&F,T4=n=>n^b(n,9)^b(n,17),G4=n=>n^b(n,15)^b(n,23);function H4(n){const t=new I(32),F=t.view(4);F.set(0,0x7380166Fn),F.set(1,0x4914B2B9n),F.set(2,0x172442D7n),F.set(3,0xDA8A0600n),F.set(4,0xA96F30BCn),F.set(5,0x163138AAn),F.set(6,0xE38DEE4Dn),F.set(7,0xB0FB0E4En);const e=n.length,r=BigInt(e)<<3n,i=64,o=e+9+63>>6,u=new I(o*i);u.set(n),u[e]=128;const s=new DataView(u.buffer);s.setBigUint64(u.length-8,r,!1);for(let c=0;c<u.length;c+=i){const E=Number(F.get(0)),A=Number(F.get(1)),B=Number(F.get(2)),f=Number(F.get(3)),l=Number(F.get(4)),a=Number(F.get(5)),C=Number(F.get(6)),y=Number(F.get(7));let m=E,K=A,U=B,p=f,g=l,$=a,d=C,_=y;const S=new Uint32Array(68),h=new Uint32Array(64);for(let O=0;O<68;O++)if(O<16?S[O]=s.getUint32(c+(O<<2),!1):S[O]=G4(S[O-16]^S[O-9]^b(S[O-3],15))^b(S[O-13],7)^S[O-6],O>3){const L=O-4;h[L]=S[L]^S[O];const G=L<16?2043430169:2055708042,H=b(b(m,12)+g+b(G,L),7),k=H^b(m,12),N=L4(m,K,U,L)+p+k+h[L],Q=M4(g,$,d,L)+_+H+S[L];p=U,U=b(K,9),K=m,m=N,_=d,d=b($,19),$=g,g=T4(Q)}F.set(0,BigInt(E^m)),F.set(1,BigInt(A^K)),F.set(2,BigInt(B^U)),F.set(3,BigInt(f^p)),F.set(4,BigInt(l^g)),F.set(5,BigInt(a^$)),F.set(6,BigInt(C^d)),F.set(7,BigInt(y^_))}return t}const P1=X(H4,{ALGORITHM:"SM3",BLOCK_SIZE:64,DIGEST_SIZE:32,OID:"1.2.156.10197.1.401"});function R4(n,t,F){const{BLOCK_SIZE:e}=n,r=new Uint8Array(e);r.set(t.length>e?n(t):t);const i=r.map(s=>s^54),o=r.map(s=>s^92),u=n(M(i,F));return n(M(o,u))}function E0(n,t,F){const{ALGORITHM:e,BLOCK_SIZE:r,DIGEST_SIZE:i}=n;t=t?Math.min(t>>3,i):i,F=F?F>>3:i;const o={ALGORITHM:`HMAC-${e}-${t<<3}`,BLOCK_SIZE:r,DIGEST_SIZE:t,KEY_SIZE:F};return X1((u,s)=>R4(n,u,s).slice(0,t),o)}function z(n,t){return v((F,e)=>v(n(F,e),t),t)}function Q1(n,t,F){return v((e,r)=>typeof r=="number"?n(e,r):t(e),F)}const y1=Q1((n,t)=>{const F=t-n.length%t;return M(n,new Uint8Array(F).fill(F))},n=>{const t=n[n.length-1];return new I(n.slice(0,n.length-t))},{ALGORITHM:"PKCS#7"}),v4=Q1((n,t)=>{const F=Math.ceil((n.length+1)/t),e=new I(F*t);return e.set(n),e[n.length]=128,e},n=>{let t=n.length-1;for(;n[t]===128;)if(t=t-1,t<0)return console.warn("This message may not be ISO/IEC 7816-4 padded"),new I;return new I(n.slice(0,t+1))},{ALGORITHM:"ISO/IEC 7816-4"}),k4=Q1((n,t)=>{const F=Math.ceil((n.length+1)/t),e=new I(F*t);return e.set(n),e[e.length-1]=e.length-n.length,e},n=>{const t=n[n.length-1];return new I(n.slice(0,n.length-t))},{ALGORITHM:"ANSI X9.23"}),Y4=Q1((n,t)=>{const F=t-n.length%t;return M(n,new Uint8Array(F))},n=>{let t=n.length-1;for(;n[t]===0;)if(t=t-1,t<0)return new I;return new I(n.slice(0,t+1))},{ALGORITHM:"Zero Padding"}),N4=Q1(n=>new I(n.slice(0)),n=>new I(n.slice(0)),{ALGORITHM:"No Padding"}),X4=v((n,t=y1)=>{const F={ALGORITHM:`ECB-${n.ALGORITHM}`,PADDING:t,BLOCK_SIZE:n.BLOCK_SIZE,KEY_SIZE:n.KEY_SIZE,MIN_KEY_SIZE:n.MIN_KEY_SIZE,MAX_KEY_SIZE:n.MAX_KEY_SIZE,IV_SIZE:0,MIN_IV_SIZE:0,MAX_IV_SIZE:0};return v(e=>{const{BLOCK_SIZE:r}=n,i=n(e);return v({encrypt:o=>{const u=t(o,r),s=new I(u.length);for(let c=0;c<u.length;){const E=c,A=u.subarray(c,c+=r);s.set(i.encrypt(A),E)}return s},decrypt:o=>{if(o.length%r!==0)throw new D("Decryption error");const u=new I(o.length);for(let s=0;s<o.length;){const c=s,E=o.subarray(s,s+=r);u.set(i.decrypt(E),c)}return t(u)}},F)},F)},{ALGORITHM:"ECB"}),f0=v((n,t=y1)=>{const F={ALGORITHM:`CBC-${n.ALGORITHM}`,PADDING:t,BLOCK_SIZE:n.BLOCK_SIZE,KEY_SIZE:n.KEY_SIZE,MIN_KEY_SIZE:n.MIN_KEY_SIZE,MAX_KEY_SIZE:n.MAX_KEY_SIZE,IV_SIZE:n.BLOCK_SIZE,MIN_IV_SIZE:n.BLOCK_SIZE,MAX_IV_SIZE:n.BLOCK_SIZE};return v((e,r)=>{const{BLOCK_SIZE:i}=n;if(r.length!==i)throw new D(`${F.ALGORITHM} iv must be ${i} byte`);const o=n(e);return v({encrypt:u=>{const s=t(u,i),c=new I(s.length);let E=r.slice(0);for(let A=0;A<s.length;){const B=A,f=s.subarray(A,A+=i);E.forEach((l,a)=>E[a]^=f[a]),E=o.encrypt(E),c.set(E,B)}return c},decrypt:u=>{if(u.length%i!==0)throw new D("Decryption error");const s=new I(u.length);let c=r;for(let E=0;E<u.length;){const A=E,B=u.slice(E,E+=i);o.decrypt(B).forEach((f,l)=>c[l]^=f),s.set(c,A),c=B}return t(s)}},F)},F)},{ALGORITHM:"CBC"}),V4=v((n,t=y1)=>{const F={ALGORITHM:`PCBC-${n.ALGORITHM}`,PADDING:t,BLOCK_SIZE:n.BLOCK_SIZE,KEY_SIZE:n.KEY_SIZE,MIN_KEY_SIZE:n.MIN_KEY_SIZE,MAX_KEY_SIZE:n.MAX_KEY_SIZE,IV_SIZE:n.BLOCK_SIZE,MIN_IV_SIZE:n.BLOCK_SIZE,MAX_IV_SIZE:n.BLOCK_SIZE};return v((e,r)=>{const{BLOCK_SIZE:i}=n;if(r.length!==i)throw new D(`${F.ALGORITHM} iv must be ${i} byte`);const o=n(e);return v({encrypt:u=>{const s=t(u,i),c=new I(s.length),E=r.slice(0);for(let A=0;A<s.length;){const B=A,f=s.subarray(A,A+=i);E.forEach((a,C)=>E[C]^=f[C]);const l=o.encrypt(E);c.set(l,B),E.forEach((a,C)=>E[C]=l[C]^f[C])}return c},decrypt:u=>{if(u.length%i!==0)throw new D("Decryption error");const s=new I(u.length),c=r.slice(0);for(let E=0;E<u.length;){const A=E,B=u.slice(E,E+=i),f=o.decrypt(B);f.forEach((l,a)=>f[a]^=c[a]),s.set(f,A),B.forEach((l,a)=>c[a]=B[a]^f[a])}return t(s)}},F)},F)},{ALGORITHM:"PCBC"}),P4=v((n,t=y1)=>{const F={ALGORITHM:`CFB-${n.ALGORITHM}`,PADDING:t,BLOCK_SIZE:n.BLOCK_SIZE,KEY_SIZE:n.KEY_SIZE,MIN_KEY_SIZE:n.MIN_KEY_SIZE,MAX_KEY_SIZE:n.MAX_KEY_SIZE,IV_SIZE:n.BLOCK_SIZE,MIN_IV_SIZE:n.BLOCK_SIZE,MAX_IV_SIZE:n.BLOCK_SIZE};return v((e,r)=>{const{BLOCK_SIZE:i}=n;if(r.length!==i)throw new D(`${F.ALGORITHM} iv must be ${i} byte`);const o=n(e);return v({encrypt:u=>{const s=t(u,i),c=new I(s.length);let E=r;for(let A=0;A<s.length;){const B=A,f=s.subarray(A,A+=i);E=o.encrypt(E),E.forEach((l,a)=>E[a]^=f[a]),c.set(E.subarray(0,f.length),B)}return c},decrypt:u=>{const s=new I(u.length);let c=r;for(let E=0;E<u.length;){const A=E,B=u.subarray(E,E+=i);c=o.encrypt(c),B.forEach((f,l)=>c[l]^=B[l]),s.set(c.subarray(0,B.length),A),c=B}return t(s)}},F)},F)},{ALGORITHM:"CFB"}),Q4=v((n,t=y1)=>{const F={ALGORITHM:`OFB-${n.ALGORITHM}`,PADDING:t,BLOCK_SIZE:n.BLOCK_SIZE,KEY_SIZE:n.KEY_SIZE,MIN_KEY_SIZE:n.MIN_KEY_SIZE,MAX_KEY_SIZE:n.MAX_KEY_SIZE,IV_SIZE:n.BLOCK_SIZE,MIN_IV_SIZE:n.BLOCK_SIZE,MAX_IV_SIZE:n.BLOCK_SIZE};return v((e,r)=>{const{BLOCK_SIZE:i}=n;if(r.length!==i)throw new D(`${F.ALGORITHM} iv must be ${i} byte`);const o=n(e);let u=o.encrypt(r),s=u,c=i;const E=A=>{if(c>A)return s;const B=[s];for(;c<A;)u=o.encrypt(u),B.push(u),c+=i;return s=M(...B),s};return v({encrypt:A=>{const B=t(A,i);return s=E(B.length),B.map((f,l)=>f^s[l])},decrypt:A=>(s=E(A.length),t(A.map((B,f)=>B^s[f])))},F)},F)},{ALGORITHM:"OFB"}),W4=v((n,t=y1)=>{const F={ALGORITHM:`CTR-${n.ALGORITHM}`,PADDING:t,BLOCK_SIZE:n.BLOCK_SIZE,KEY_SIZE:n.KEY_SIZE,MIN_KEY_SIZE:n.MIN_KEY_SIZE,MAX_KEY_SIZE:n.MAX_KEY_SIZE,IV_SIZE:n.BLOCK_SIZE,MIN_IV_SIZE:n.BLOCK_SIZE,MAX_IV_SIZE:n.BLOCK_SIZE};return v((e,r)=>{const{BLOCK_SIZE:i}=n;if(r.length!==i)throw new D(`{info.ALGORITHM} iv must be ${i} byte`);const o=n(e),u=new K1(r.slice());let s=new I,c=0;const E=A=>{if(c>A)return s;const B=[s];for(;c<A;)B.push(o.encrypt(u)),u.inc(),c+=i;return s=M(...B),s};return v({encrypt:A=>{const B=t(A,i);return s=E(B.length),B.map((f,l)=>f^s[l])},decrypt:A=>(s=E(A.length),t(A.map((B,f)=>B^s[f])))},F)},F)},{ALGORITHM:"CTR"});function j4(n,t){const F=0xE1n<<56n,e=new DataView(t.buffer);let r=e.getBigUint64(0,!1),i=e.getBigUint64(8,!1),o=0n,u=0n;for(let E=0;E<16;E++){const A=n[E];for(let B=7;B>=0;B--){A>>B&1&&(o^=r,u^=i);const f=i&1n;i=r<<63n|i>>1n,i=i&0xFFFFFFFFFFFFFFFFn,r=r>>1n,f&&(r^=F)}}const s=new I(16),c=new DataView(s.buffer);return c.setBigUint64(0,o,!1),c.setBigUint64(8,u,!1),s}function A0(n,t,F){const e=Math.ceil(t.length/16),r=Math.ceil(F.length/16),i=new Uint8Array((e+r+1)*16),o=new DataView(i.buffer);i.set(t),i.set(F,e*16),o.setBigUint64(i.length-16,BigInt(t.length<<3),!1),o.setBigUint64(i.length-8,BigInt(F.length<<3),!1);let u=new I(16);for(let s=0;s<i.length;s+=16){const c=i.subarray(s,s+16);u.forEach((E,A)=>u[A]^=c[A]),u=j4(n,u)}return u}const z4=v((n,t=y1,F=16)=>{const{BLOCK_SIZE:e}=n;if(e!==16)throw new D("GCM cipher block must be 128 bit");const r={ALGORITHM:`GCM-${n.ALGORITHM}`,PADDING:t,BLOCK_SIZE:n.BLOCK_SIZE,KEY_SIZE:n.KEY_SIZE,MIN_KEY_SIZE:n.MIN_KEY_SIZE,MAX_KEY_SIZE:n.MAX_KEY_SIZE,IV_SIZE:12,MIN_IV_SIZE:0,MAX_IV_SIZE:1/0,AUTH_TAG_SIZE:F};return v((i,o)=>{const u=n(i),s=u.encrypt(new Uint8Array(e));let c=new K1(16);o.length===12?(c.set(o),c[15]=1):c=new K1(A0(s,new Uint8Array,o.slice(0)));let E=u.encrypt(c),A=0;const B=C=>{if(A>C)return E;const y=[E];for(;A<C;)c.inc(),y.push(u.encrypt(c)),A+=e;return E=M(...y),E},f=C=>{const y=t(C,e);return E=B(y.length),y.map((m,K)=>m^E[K+e])},l=C=>(E=B(C.length),t(C.map((y,m)=>y^E[m+e]))),a=(C,y=new Uint8Array)=>{const m=A0(s,y,C);return m.forEach((K,U)=>m[U]^=E[U]),m.slice(0,F)};return v({encrypt:f,decrypt:l,sign:a,verify:(C,y,m)=>{if(C.length!==F)return!1;const K=a(y,m);return C.every((U,p)=>U===K[p])}},r)},r)},{ALGORITHM:"GCM",IV_SIZE:12}),B2=new Uint8Array([214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72]),q4=new Uint32Array([462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257]);function B0(n){return B2[n>>24&255]<<24|B2[n>>16&255]<<16|B2[n>>8&255]<<8|B2[n&255]}function J4(n){const t=B0(n);return t^b(t,2)^b(t,10)^b(t,18)^b(t,24)}function x4(n){const t=B0(n);return t^b(t,13)^b(t,23)}function n5(n){if(n.length!==16)throw new D("SM4 key must be 16 byte");const t=new DataView(n.buffer);let F=2746333894^t.getUint32(0,!1),e=1453994832^t.getUint32(4,!1),r=1736282519^t.getUint32(8,!1),i=2993693404^t.getUint32(12,!1);const o=new Uint32Array(32);for(let u=0;u<32;u++)o[u]=F^x4(e^r^i^q4[u]),F=e,e=r,r=i,i=o[u];return o}function t5(n,t,F,e,r){return n^J4(t^F^e^r)}function a0(n,t){if(n.length!==16)throw new D("SM4 block must be 16 byte");const F=new DataView(n.buffer,n.byteOffset);let e=F.getUint32(0,!1),r=F.getUint32(4,!1),i=F.getUint32(8,!1),o=F.getUint32(12,!1),u;for(let E=0;E<32;E++)u=t5(e,r,i,o,t[E]),e=r,r=i,i=o,o=u;const s=new I(16),c=new DataView(s.buffer);return c.setUint32(0,o,!1),c.setUint32(4,i,!1),c.setUint32(8,r,!1),c.setUint32(12,e,!1),s}function F5(n){const t=n5(n),F=t.toReversed();return{encrypt:e=>a0(e,t),decrypt:e=>a0(e,F)}}const e5=z(F5,{ALGORITHM:"SM4",BLOCK_SIZE:16,KEY_SIZE:16,MIN_KEY_SIZE:16,MAX_KEY_SIZE:16}),D1=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),r5=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),i5=[1,2,4,8,16,32,64,128,27,54];function R(n,t){let F=0;if(t===1)return n;for(let e=0;e<8;e++){t&1&&(F^=n);const r=n&128;n<<=1,r&&(n^=27),t>>=1}return F&255}function o5(n,t){const F=n.byteLength>>2,e=new Uint8Array(t+1<<4);e.set(n);let r=0;for(let i=F;i<t+1<<2;i++){const o=i-1<<2,u=e.slice(o,o+4);if(i%F===0){const E=u[0];u[0]=D1[u[1]]^i5[r],u[1]=D1[u[2]],u[2]=D1[u[3]],u[3]=D1[E],r++}else F>6&&i%F===4&&(u[0]=D1[u[0]],u[1]=D1[u[1]],u[2]=D1[u[2]],u[3]=D1[u[3]]);const s=i-F<<2,c=e.subarray(s,s+4);for(let E=0;E<4;E++)u[E]^=c[E];e.set(u,i<<2)}return e}function s5(n,t,F){if(n.byteLength!==16)throw new D("AES block must be 16 byte");const e=new I(n.slice(0)),r=s=>{for(let c=0;c<e.byteLength;c++)e[c]^=s[c]},i=()=>{for(let s=0;s<e.byteLength;s++)e[s]=D1[e[s]]},o=()=>{const s=e[1];e[1]=e[5],e[5]=e[9],e[9]=e[13],e[13]=s;const c=e[2],E=e[6];e[2]=e[10],e[6]=e[14],e[10]=c,e[14]=E;const A=e[15];e[15]=e[11],e[11]=e[7],e[7]=e[3],e[3]=A},u=()=>{for(let s=0;s<4;s++){const c=e[s<<2],E=e[(s<<2)+1],A=e[(s<<2)+2],B=e[(s<<2)+3],f=R(c,2)^R(E,3)^R(A,1)^R(B,1),l=R(c,1)^R(E,2)^R(A,3)^R(B,1),a=R(c,1)^R(E,1)^R(A,2)^R(B,3),C=R(c,3)^R(E,1)^R(A,1)^R(B,2);e[s<<2]=f,e[(s<<2)+1]=l,e[(s<<2)+2]=a,e[(s<<2)+3]=C}};r(t.subarray(0,16));for(let s=1;s<F;s++)i(),o(),u(),r(t.subarray(s<<4,s+1<<4));return i(),o(),r(t.subarray(t.length-16,t.length)),e}function u5(n,t,F){if(n.byteLength!==16)throw new D("AES block must be 16 byte");const e=new I(n.slice(0)),r=s=>{for(let c=0;c<e.byteLength;c++)e[c]^=s[c]},i=()=>{for(let s=0;s<e.byteLength;s++)e[s]=r5[e[s]]},o=()=>{const s=e[13];e[13]=e[9],e[9]=e[5],e[5]=e[1],e[1]=s;const c=e[2],E=e[6];e[2]=e[10],e[6]=e[14],e[10]=c,e[14]=E;const A=e[3];e[3]=e[7],e[7]=e[11],e[11]=e[15],e[15]=A},u=()=>{for(let s=0;s<4;s++){const c=e[s<<2],E=e[(s<<2)+1],A=e[(s<<2)+2],B=e[(s<<2)+3],f=R(c,14)^R(E,11)^R(A,13)^R(B,9),l=R(c,9)^R(E,14)^R(A,11)^R(B,13),a=R(c,13)^R(E,9)^R(A,14)^R(B,11),C=R(c,11)^R(E,13)^R(A,9)^R(B,14);e[s<<2]=f,e[(s<<2)+1]=l,e[(s<<2)+2]=a,e[(s<<2)+3]=C}};r(t.subarray(t.length-16,t.length));for(let s=F-1;s>0;s--)o(),i(),r(t.subarray(s<<4,s+1<<4)),u();return o(),i(),r(t.subarray(0,16)),e}function c5(n,t){if(n.byteLength!==t>>3)throw new D(`AES key must be ${t>>3} byte`);const F=t===128?10:t===192?12:14,e=o5(n,F);return{encrypt:r=>s5(r,e,F),decrypt:r=>u5(r,e,F)}}function I0(n){return z(t=>c5(t,n),{ALGORITHM:`AES-${n}`,BLOCK_SIZE:16,KEY_SIZE:n>>3,MIN_KEY_SIZE:n>>3,MAX_KEY_SIZE:n>>3})}const p1=new Uint8Array([99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22]),S1=new Uint8Array([226,78,84,252,148,194,74,204,98,13,106,70,60,77,139,209,94,250,100,203,180,151,190,43,188,119,46,3,211,25,89,193,29,6,65,107,85,240,153,105,234,156,24,174,99,223,231,187,0,115,102,251,150,76,133,228,58,9,69,170,15,238,16,235,45,127,244,41,172,207,173,145,141,120,200,149,249,47,206,205,8,122,136,56,92,131,42,40,71,219,184,199,147,164,18,83,255,135,14,49,54,33,88,72,1,142,55,116,50,202,233,177,183,171,12,215,196,86,66,38,7,152,96,217,182,185,17,64,236,32,140,189,160,201,132,4,73,35,241,79,80,31,19,220,216,192,158,87,227,195,123,101,59,2,143,62,232,37,146,229,21,221,253,23,169,191,212,154,126,197,57,103,254,118,157,67,167,225,208,245,104,242,27,52,112,5,163,138,213,121,134,168,48,198,81,75,30,166,39,246,53,210,110,36,22,130,95,218,230,117,162,239,44,178,28,159,93,111,128,10,114,68,155,108,144,11,91,51,125,90,82,243,97,161,247,176,214,63,124,109,237,20,224,165,61,34,179,248,137,222,113,26,175,186,181,129]),_1=new Uint8Array([82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125]),m1=new Uint8Array([48,104,153,27,135,185,33,120,80,57,219,225,114,9,98,60,62,126,94,142,241,160,204,163,42,29,251,182,214,32,196,141,129,101,245,137,203,157,119,198,87,67,86,23,212,64,26,77,192,99,108,227,183,200,100,106,83,170,56,152,12,244,155,237,127,34,118,175,221,58,11,88,103,136,6,195,53,13,1,139,140,194,230,95,2,36,117,147,102,30,229,226,84,216,16,206,122,232,8,44,18,151,50,171,180,39,10,35,223,239,202,217,184,250,220,49,107,209,173,25,73,189,81,150,238,228,168,65,218,255,205,85,134,54,190,97,82,248,187,14,130,72,105,154,224,71,158,92,4,75,52,21,121,38,167,222,41,174,146,215,132,233,210,186,93,243,197,176,191,164,59,113,68,70,43,252,235,111,213,246,20,254,124,112,90,125,253,47,24,131,22,165,145,31,5,149,116,169,193,91,74,133,109,19,7,79,78,69,178,15,201,28,166,188,236,115,144,123,207,89,143,161,249,45,242,177,0,148,55,159,208,46,156,110,40,63,128,240,61,211,37,138,181,231,66,179,199,234,247,76,17,51,3,162,172,96]),K2=new Uint8Array([81,124,193,183,39,34,10,148,254,19,171,232,250,154,110,224]),L2=new Uint8Array([109,177,74,204,158,33,200,32,255,40,177,213,239,93,226,176]),M2=new Uint8Array([219,146,55,29,33,38,233,112,3,36,151,117,4,232,201,14]);function w1(n,t){const F=n.length,e=F<<3,r=t%e;if(r===0)return n.slice(0);const i=r>>3,o=r%8,u=new I(n.length);for(let s=0;s<F;s++){const c=n[s],E=n[(s+1)%F];u[s]=c<<o|E>>8-o}if(i>0){const s=new Uint8Array(u);for(let c=0;c<F;c++)u[c]=s[(c+i)%F]}return u}function d1(n,t){const F=n.length,e=F<<3,r=t%e;if(r===0)return n.slice(0);const i=r>>3,o=r%8,u=new I(n.length);for(let s=0;s<F;s++){const c=n[s],E=n[(s-1+F)%F];u[s]=c>>o|E<<8-o}if(i>0){const s=new Uint8Array(u);for(let c=0;c<F;c++)u[c]=s[(c-i+F)%F]}return u}function P(n,t){return n.map((F,e)=>n[e]^t[e])}function a2(n,t){return T2(E5(P(n,t)))}function l0(n,t){return T2(C0(P(n,t)))}function E5(n){const t=new Uint8Array(16);return t[0]=p1[n[0]],t[1]=S1[n[1]],t[2]=_1[n[2]],t[3]=m1[n[3]],t[4]=p1[n[4]],t[5]=S1[n[5]],t[6]=_1[n[6]],t[7]=m1[n[7]],t[8]=p1[n[8]],t[9]=S1[n[9]],t[10]=_1[n[10]],t[11]=m1[n[11]],t[12]=p1[n[12]],t[13]=S1[n[13]],t[14]=_1[n[14]],t[15]=m1[n[15]],t}function C0(n){const t=new Uint8Array(16);return t[0]=_1[n[0]],t[1]=m1[n[1]],t[2]=p1[n[2]],t[3]=S1[n[3]],t[4]=_1[n[4]],t[5]=m1[n[5]],t[6]=p1[n[6]],t[7]=S1[n[7]],t[8]=_1[n[8]],t[9]=m1[n[9]],t[10]=p1[n[10]],t[11]=S1[n[11]],t[12]=_1[n[12]],t[13]=m1[n[13]],t[14]=p1[n[14]],t[15]=S1[n[15]],t}function T2(n){const t=new Uint8Array(16);return t[0]=n[3]^n[4]^n[6]^n[8]^n[9]^n[13]^n[14],t[1]=n[2]^n[5]^n[7]^n[8]^n[9]^n[12]^n[15],t[2]=n[1]^n[4]^n[6]^n[10]^n[11]^n[12]^n[15],t[3]=n[0]^n[5]^n[7]^n[10]^n[11]^n[13]^n[14],t[4]=n[0]^n[2]^n[5]^n[8]^n[11]^n[14]^n[15],t[5]=n[1]^n[3]^n[4]^n[9]^n[10]^n[14]^n[15],t[6]=n[0]^n[2]^n[7]^n[9]^n[10]^n[12]^n[13],t[7]=n[1]^n[3]^n[6]^n[8]^n[11]^n[12]^n[13],t[8]=n[0]^n[1]^n[4]^n[7]^n[10]^n[13]^n[15],t[9]=n[0]^n[1]^n[5]^n[6]^n[11]^n[12]^n[14],t[10]=n[2]^n[3]^n[5]^n[6]^n[8]^n[13]^n[15],t[11]=n[2]^n[3]^n[4]^n[7]^n[9]^n[12]^n[14],t[12]=n[1]^n[2]^n[6]^n[7]^n[9]^n[11]^n[12],t[13]=n[0]^n[3]^n[6]^n[7]^n[8]^n[10]^n[13],t[14]=n[0]^n[3]^n[4]^n[5]^n[9]^n[11]^n[14],t[15]=n[1]^n[2]^n[4]^n[5]^n[8]^n[10]^n[15],t}function f5(n,t){const F=new Uint8Array(32);F.set(n),n=F;const e=new Uint8Array(16),r=new Uint8Array(16);e.set(n.subarray(0,16)),r.set(n.subarray(16,32));let i,o,u;switch(t){case 12:i=K2,o=L2,u=M2;break;case 14:i=L2,o=M2,u=K2;break;case 16:i=M2,o=K2,u=L2;break}const s=new Uint8Array(16),c=new Uint8Array(16),E=new Uint8Array(16),A=new Uint8Array(16);s.set(e),c.set(a2(s,i)),c.forEach((l,a)=>c[a]^=r[a]),E.set(l0(c,o)),E.forEach((l,a)=>E[a]^=s[a]),A.set(a2(E,u)),A.forEach((l,a)=>A[a]^=c[a]);const B=A5([s,c,E,A],t),f=B5(B,t);return{EK:B,DK:f}}function A5(n,t){const[F,e,r,i]=n,o=P(d1(e,19),F),u=P(d1(r,19),e),s=P(d1(i,19),r),c=P(d1(F,19),i),E=P(d1(e,31),F),A=P(d1(r,31),e),B=P(d1(i,31),r),f=P(d1(F,31),i),l=P(w1(e,61),F),a=P(w1(r,61),e),C=P(w1(i,61),r),y=P(w1(F,61),i),m=P(w1(e,31),F);if(t===12)return[o,u,s,c,E,A,B,f,l,a,C,y,m];const K=P(w1(r,31),e),U=P(w1(i,31),r);if(t===14)return[o,u,s,c,E,A,B,f,l,a,C,y,m,K,U];const p=P(w1(F,31),i),g=P(w1(e,19),F);return[o,u,s,c,E,A,B,f,l,a,C,y,m,K,U,p,g]}function B5(n,t){const F=Array.from({le