-// https://github.com/denoland/deno_std/blob/main/hash/_sha3/keccakf.ts
-const KECCAK_ROUNDS = 24;
-const KECCAK_RC = [
- 0x1,
- 0x0,
- 0x8082,
- 0x0,
- 0x808a,
- 0x80000000,
- 0x80008000,
- 0x80000000,
- 0x808b,
- 0x0,
- 0x80000001,
- 0x0,
- 0x80008081,
- 0x80000000,
- 0x8009,
- 0x80000000,
- 0x8a,
- 0x0,
- 0x88,
- 0x0,
- 0x80008009,
- 0x0,
- 0x8000000a,
- 0x0,
- 0x8000808b,
- 0x0,
- 0x8b,
- 0x80000000,
- 0x8089,
- 0x80000000,
- 0x8003,
- 0x80000000,
- 0x8002,
- 0x80000000,
- 0x80,
- 0x80000000,
- 0x800a,
- 0x0,
- 0x8000000a,
- 0x80000000,
- 0x80008081,
- 0x80000000,
- 0x8080,
- 0x80000000,
- 0x80000001,
- 0x0,
- 0x80008008,
- 0x80000000,
-];
+function k(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function v(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function A(t,...e){if(!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function $(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");k(t.outputLen),k(t.blockLen)}function F(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function X(t,e){A(t);let n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}var M={number:k,bool:v,bytes:A,hash:$,exists:F,output:X},p=M;var w=BigInt(4294967295),L=BigInt(32);function m(t,e=!1){return e?{h:Number(t&w),l:Number(t>>L&w)}:{h:Number(t>>L&w)|0,l:Number(t&w)|0}}function P(t,e=!1){let n=new Uint32Array(t.length),o=new Uint32Array(t.length);for(let r=0;r<t.length;r++){let{h:i,l:s}=m(t[r],e);[n[r],o[r]]=[i,s]}return[n,o]}var C=(t,e)=>BigInt(t>>>0)<<L|BigInt(e>>>0),D=(t,e,n)=>t>>>n,R=(t,e,n)=>t<<32-n|e>>>n,V=(t,e,n)=>t>>>n|e<<32-n,W=(t,e,n)=>t<<32-n|e>>>n,q=(t,e,n)=>t<<64-n|e>>>n-32,z=(t,e,n)=>t>>>n-32|e<<64-n,G=(t,e)=>e,J=(t,e)=>t,Q=(t,e,n)=>t<<n|e>>>32-n,Y=(t,e,n)=>e<<n|t>>>32-n,Z=(t,e,n)=>e<<n-32|t>>>64-n,K=(t,e,n)=>t<<n-32|e>>>64-n;function tt(t,e,n,o){let r=(e>>>0)+(o>>>0);return{h:t+n+(r/2**32|0)|0,l:r|0}}var et=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),nt=(t,e,n,o)=>e+n+o+(t/2**32|0)|0,ot=(t,e,n,o)=>(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),rt=(t,e,n,o,r)=>e+n+o+r+(t/2**32|0)|0,st=(t,e,n,o,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0)+(r>>>0),it=(t,e,n,o,r,i)=>e+n+o+r+i+(t/2**32|0)|0,ct={fromBig:m,split:P,toBig:C,shrSH:D,shrSL:R,rotrSH:V,rotrSL:W,rotrBH:q,rotrBL:z,rotr32H:G,rotr32L:J,rotlSH:Q,rotlSL:Y,rotlBH:Z,rotlBL:K,add:tt,add3L:et,add3H:nt,add4L:ot,add4H:rt,add5H:it,add5L:st},h=ct;var ft={node:void 0,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0};var B=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));var ut=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!ut)throw new Error("Non little-endian hardware is not supported");var Bt=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function pt(t){if(typeof t!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof t}`);return new TextEncoder().encode(t)}function b(t){if(typeof t=="string"&&(t=pt(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}var g=class{clone(){return this._cloneInto()}};function O(t){let e=o=>t().update(b(o)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function I(t){let e=(o,r)=>t(r).update(b(o)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=o=>t(o),e}var[U,H,T]=[[],[],[]],ht=BigInt(0),a=BigInt(1),lt=BigInt(2),at=BigInt(7),dt=BigInt(256),xt=BigInt(113);for(let t=0,e=a,n=1,o=0;t<24;t++){[n,o]=[o,(2*n+3*o)%5],U.push(2*(5*o+n)),H.push((t+1)*(t+2)/2%64);let r=ht;for(let i=0;i<7;i++)e=(e<<a^(e>>at)*xt)%dt,e<&&(r^=a<<(a<<BigInt(i))-a);T.push(r)}var[yt,wt]=h.split(T,!0),E=(t,e,n)=>n>32?h.rotlBH(t,e,n):h.rotlSH(t,e,n),_=(t,e,n)=>n>32?h.rotlBL(t,e,n):h.rotlSL(t,e,n);function gt(t,e=24){let n=new Uint32Array(10);for(let o=24-e;o<24;o++){for(let s=0;s<10;s++)n[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){let c=(s+8)%10,d=(s+2)%10,x=n[d],u=n[d+1],j=E(x,u,1)^n[c],N=_(x,u,1)^n[c+1];for(let y=0;y<50;y+=10)t[s+y]^=j,t[s+y+1]^=N}let r=t[2],i=t[3];for(let s=0;s<24;s++){let c=H[s],d=E(r,i,c),x=_(r,i,c),u=U[s];r=t[u],i=t[u+1],t[u]=d,t[u+1]=x}for(let s=0;s<50;s+=10){for(let c=0;c<10;c++)n[c]=t[s+c];for(let c=0;c<10;c++)t[s+c]^=~n[(c+2)%10]&n[(c+4)%10]}t[0]^=yt[o],t[1]^=wt[o]}n.fill(0)}var l=class extends g{constructor(e,n,o,r=!1,i=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=o,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,p.number(o),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=B(this.state)}keccak(){gt(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){p.exists(this);let{blockLen:n,state:o}=this;e=b(e);let r=e.length;for(let i=0;i<r;){let s=Math.min(n-this.pos,r-i);for(let c=0;c<s;c++)o[this.pos++]^=e[i++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:n,pos:o,blockLen:r}=this;e[o]^=n,n&128&&o===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){p.exists(this,!1),p.bytes(e),this.finish();let n=this.state,{blockLen:o}=this;for(let r=0,i=e.length;r<i;){this.posOut>=o&&this.keccak();let s=Math.min(o-this.posOut,i-r);e.set(n.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return p.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(p.output(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:n,suffix:o,outputLen:r,rounds:i,enableXOF:s}=this;return e||(e=new l(n,o,r,s,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=o,e.outputLen=r,e.enableXOF=s,e.destroyed=this.destroyed,e}},f=(t,e,n)=>O(()=>new l(e,t,n)),Ut=f(6,144,224/8),Ht=f(6,136,256/8),Tt=f(6,104,384/8),St=f(6,72,512/8),jt=f(1,144,224/8),bt=f(1,136,256/8),Nt=f(1,104,384/8),vt=f(1,72,512/8),S=(t,e,n)=>I((o={})=>new l(e,t,o.dkLen===void 0?n:o.dkLen,!0)),$t=S(31,168,128/8),Ft=S(31,136,256/8);export{bt as keccak_256};
+/*! Bundled license information:
-function keccakf(state) {
- const s = new Uint32Array(state.buffer);
- let bc0 = 0;
- let bc1 = 0;
- let bc2 = 0;
- let bc3 = 0;
- let bc4 = 0;
- let bc5 = 0;
- let bc6 = 0;
- let bc7 = 0;
- let bc8 = 0;
- let bc9 = 0;
- let d0 = 0;
- let d1 = 0;
- let d2 = 0;
- let d3 = 0;
- let d4 = 0;
- let d5 = 0;
- let d6 = 0;
- let d7 = 0;
- let d8 = 0;
- let d9 = 0;
- let t0 = 0;
- let t1 = 0;
-
- for (let n = 0; n < KECCAK_ROUNDS * 2; n += 8) {
- // Round 1
- bc0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
- bc1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
- bc2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
- bc3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
- bc4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
- bc5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
- bc6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
- bc7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
- bc8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
- bc9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
-
- d0 = bc8 ^ ((bc2 << 1) | (bc3 >>> 31));
- d1 = bc9 ^ ((bc3 << 1) | (bc2 >>> 31));
- d2 = bc0 ^ ((bc4 << 1) | (bc5 >>> 31));
- d3 = bc1 ^ ((bc5 << 1) | (bc4 >>> 31));
- d4 = bc2 ^ ((bc6 << 1) | (bc7 >>> 31));
- d5 = bc3 ^ ((bc7 << 1) | (bc6 >>> 31));
- d6 = bc4 ^ ((bc8 << 1) | (bc9 >>> 31));
- d7 = bc5 ^ ((bc9 << 1) | (bc8 >>> 31));
- d8 = bc6 ^ ((bc0 << 1) | (bc1 >>> 31));
- d9 = bc7 ^ ((bc1 << 1) | (bc0 >>> 31));
-
- bc0 = s[0] ^ d0;
- bc1 = s[1] ^ d1;
- t0 = s[12] ^ d2;
- t1 = s[13] ^ d3;
- bc2 = (t1 << 12) | (t0 >>> 20);
- bc3 = (t0 << 12) | (t1 >>> 20);
- t0 = s[24] ^ d4;
- t1 = s[25] ^ d5;
- bc4 = (t1 << 11) | (t0 >>> 21);
- bc5 = (t0 << 11) | (t1 >>> 21);
- t0 = s[36] ^ d6;
- t1 = s[37] ^ d7;
- bc6 = (t0 << 21) | (t1 >>> 11);
- bc7 = (t1 << 21) | (t0 >>> 11);
- t0 = s[48] ^ d8;
- t1 = s[49] ^ d9;
- bc8 = (t0 << 14) | (t1 >>> 18);
- bc9 = (t1 << 14) | (t0 >>> 18);
- s[0] = bc0 ^ (bc4 & ~bc2) ^ KECCAK_RC[n];
- s[1] = bc1 ^ (bc5 & ~bc3) ^ KECCAK_RC[n + 1];
- s[12] = bc2 ^ (bc6 & ~bc4);
- s[13] = bc3 ^ (bc7 & ~bc5);
- s[24] = bc4 ^ (bc8 & ~bc6);
- s[25] = bc5 ^ (bc9 & ~bc7);
- s[36] = bc6 ^ (bc0 & ~bc8);
- s[37] = bc7 ^ (bc1 & ~bc9);
- s[48] = bc8 ^ (bc2 & ~bc0);
- s[49] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[20] ^ d0;
- t1 = s[21] ^ d1;
- bc4 = (t0 << 3) | (t1 >>> 29);
- bc5 = (t1 << 3) | (t0 >>> 29);
- t0 = s[32] ^ d2;
- t1 = s[33] ^ d3;
- bc6 = (t1 << 13) | (t0 >>> 19);
- bc7 = (t0 << 13) | (t1 >>> 19);
- t0 = s[44] ^ d4;
- t1 = s[45] ^ d5;
- bc8 = (t1 << 29) | (t0 >>> 3);
- bc9 = (t0 << 29) | (t1 >>> 3);
- t0 = s[6] ^ d6;
- t1 = s[7] ^ d7;
- bc0 = (t0 << 28) | (t1 >>> 4);
- bc1 = (t1 << 28) | (t0 >>> 4);
- t0 = s[18] ^ d8;
- t1 = s[19] ^ d9;
- bc2 = (t0 << 20) | (t1 >>> 12);
- bc3 = (t1 << 20) | (t0 >>> 12);
- s[20] = bc0 ^ (bc4 & ~bc2);
- s[21] = bc1 ^ (bc5 & ~bc3);
- s[32] = bc2 ^ (bc6 & ~bc4);
- s[33] = bc3 ^ (bc7 & ~bc5);
- s[44] = bc4 ^ (bc8 & ~bc6);
- s[45] = bc5 ^ (bc9 & ~bc7);
- s[6] = bc6 ^ (bc0 & ~bc8);
- s[7] = bc7 ^ (bc1 & ~bc9);
- s[18] = bc8 ^ (bc2 & ~bc0);
- s[19] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[40] ^ d0;
- t1 = s[41] ^ d1;
- bc8 = (t0 << 18) | (t1 >>> 14);
- bc9 = (t1 << 18) | (t0 >>> 14);
- t0 = s[2] ^ d2;
- t1 = s[3] ^ d3;
- bc0 = (t0 << 1) | (t1 >>> 31);
- bc1 = (t1 << 1) | (t0 >>> 31);
- t0 = s[14] ^ d4;
- t1 = s[15] ^ d5;
- bc2 = (t0 << 6) | (t1 >>> 26);
- bc3 = (t1 << 6) | (t0 >>> 26);
- t0 = s[26] ^ d6;
- t1 = s[27] ^ d7;
- bc4 = (t0 << 25) | (t1 >>> 7);
- bc5 = (t1 << 25) | (t0 >>> 7);
- t0 = s[38] ^ d8;
- t1 = s[39] ^ d9;
- bc6 = (t0 << 8) | (t1 >>> 24);
- bc7 = (t1 << 8) | (t0 >>> 24);
- s[40] = bc0 ^ (bc4 & ~bc2);
- s[41] = bc1 ^ (bc5 & ~bc3);
- s[2] = bc2 ^ (bc6 & ~bc4);
- s[3] = bc3 ^ (bc7 & ~bc5);
- s[14] = bc4 ^ (bc8 & ~bc6);
- s[15] = bc5 ^ (bc9 & ~bc7);
- s[26] = bc6 ^ (bc0 & ~bc8);
- s[27] = bc7 ^ (bc1 & ~bc9);
- s[38] = bc8 ^ (bc2 & ~bc0);
- s[39] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[10] ^ d0;
- t1 = s[11] ^ d1;
- bc2 = (t1 << 4) | (t0 >>> 28);
- bc3 = (t0 << 4) | (t1 >>> 28);
- t0 = s[22] ^ d2;
- t1 = s[23] ^ d3;
- bc4 = (t0 << 10) | (t1 >>> 22);
- bc5 = (t1 << 10) | (t0 >>> 22);
- t0 = s[34] ^ d4;
- t1 = s[35] ^ d5;
- bc6 = (t0 << 15) | (t1 >>> 17);
- bc7 = (t1 << 15) | (t0 >>> 17);
- t0 = s[46] ^ d6;
- t1 = s[47] ^ d7;
- bc8 = (t1 << 24) | (t0 >>> 8);
- bc9 = (t0 << 24) | (t1 >>> 8);
- t0 = s[8] ^ d8;
- t1 = s[9] ^ d9;
- bc0 = (t0 << 27) | (t1 >>> 5);
- bc1 = (t1 << 27) | (t0 >>> 5);
- s[10] = bc0 ^ (bc4 & ~bc2);
- s[11] = bc1 ^ (bc5 & ~bc3);
- s[22] = bc2 ^ (bc6 & ~bc4);
- s[23] = bc3 ^ (bc7 & ~bc5);
- s[34] = bc4 ^ (bc8 & ~bc6);
- s[35] = bc5 ^ (bc9 & ~bc7);
- s[46] = bc6 ^ (bc0 & ~bc8);
- s[47] = bc7 ^ (bc1 & ~bc9);
- s[8] = bc8 ^ (bc2 & ~bc0);
- s[9] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[30] ^ d0;
- t1 = s[31] ^ d1;
- bc6 = (t1 << 9) | (t0 >>> 23);
- bc7 = (t0 << 9) | (t1 >>> 23);
- t0 = s[42] ^ d2;
- t1 = s[43] ^ d3;
- bc8 = (t0 << 2) | (t1 >>> 30);
- bc9 = (t1 << 2) | (t0 >>> 30);
- t0 = s[4] ^ d4;
- t1 = s[5] ^ d5;
- bc0 = (t1 << 30) | (t0 >>> 2);
- bc1 = (t0 << 30) | (t1 >>> 2);
- t0 = s[16] ^ d6;
- t1 = s[17] ^ d7;
- bc2 = (t1 << 23) | (t0 >>> 9);
- bc3 = (t0 << 23) | (t1 >>> 9);
- t0 = s[28] ^ d8;
- t1 = s[29] ^ d9;
- bc4 = (t1 << 7) | (t0 >>> 25);
- bc5 = (t0 << 7) | (t1 >>> 25);
- s[30] = bc0 ^ (bc4 & ~bc2);
- s[31] = bc1 ^ (bc5 & ~bc3);
- s[42] = bc2 ^ (bc6 & ~bc4);
- s[43] = bc3 ^ (bc7 & ~bc5);
- s[4] = bc4 ^ (bc8 & ~bc6);
- s[5] = bc5 ^ (bc9 & ~bc7);
- s[16] = bc6 ^ (bc0 & ~bc8);
- s[17] = bc7 ^ (bc1 & ~bc9);
- s[28] = bc8 ^ (bc2 & ~bc0);
- s[29] = bc9 ^ (bc3 & ~bc1);
-
- // Round 2
- bc0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
- bc1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
- bc2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
- bc3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
- bc4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
- bc5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
- bc6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
- bc7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
- bc8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
- bc9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
-
- d0 = bc8 ^ ((bc2 << 1) | (bc3 >>> 31));
- d1 = bc9 ^ ((bc3 << 1) | (bc2 >>> 31));
- d2 = bc0 ^ ((bc4 << 1) | (bc5 >>> 31));
- d3 = bc1 ^ ((bc5 << 1) | (bc4 >>> 31));
- d4 = bc2 ^ ((bc6 << 1) | (bc7 >>> 31));
- d5 = bc3 ^ ((bc7 << 1) | (bc6 >>> 31));
- d6 = bc4 ^ ((bc8 << 1) | (bc9 >>> 31));
- d7 = bc5 ^ ((bc9 << 1) | (bc8 >>> 31));
- d8 = bc6 ^ ((bc0 << 1) | (bc1 >>> 31));
- d9 = bc7 ^ ((bc1 << 1) | (bc0 >>> 31));
-
- bc0 = s[0] ^ d0;
- bc1 = s[1] ^ d1;
- t0 = s[32] ^ d2;
- t1 = s[33] ^ d3;
- bc2 = (t1 << 12) | (t0 >>> 20);
- bc3 = (t0 << 12) | (t1 >>> 20);
- t0 = s[14] ^ d4;
- t1 = s[15] ^ d5;
- bc4 = (t1 << 11) | (t0 >>> 21);
- bc5 = (t0 << 11) | (t1 >>> 21);
- t0 = s[46] ^ d6;
- t1 = s[47] ^ d7;
- bc6 = (t0 << 21) | (t1 >>> 11);
- bc7 = (t1 << 21) | (t0 >>> 11);
- t0 = s[28] ^ d8;
- t1 = s[29] ^ d9;
- bc8 = (t0 << 14) | (t1 >>> 18);
- bc9 = (t1 << 14) | (t0 >>> 18);
- s[0] = bc0 ^ (bc4 & ~bc2) ^ KECCAK_RC[n + 2];
- s[1] = bc1 ^ (bc5 & ~bc3) ^ KECCAK_RC[n + 3];
- s[32] = bc2 ^ (bc6 & ~bc4);
- s[33] = bc3 ^ (bc7 & ~bc5);
- s[14] = bc4 ^ (bc8 & ~bc6);
- s[15] = bc5 ^ (bc9 & ~bc7);
- s[46] = bc6 ^ (bc0 & ~bc8);
- s[47] = bc7 ^ (bc1 & ~bc9);
- s[28] = bc8 ^ (bc2 & ~bc0);
- s[29] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[40] ^ d0;
- t1 = s[41] ^ d1;
- bc4 = (t0 << 3) | (t1 >>> 29);
- bc5 = (t1 << 3) | (t0 >>> 29);
- t0 = s[22] ^ d2;
- t1 = s[23] ^ d3;
- bc6 = (t1 << 13) | (t0 >>> 19);
- bc7 = (t0 << 13) | (t1 >>> 19);
- t0 = s[4] ^ d4;
- t1 = s[5] ^ d5;
- bc8 = (t1 << 29) | (t0 >>> 3);
- bc9 = (t0 << 29) | (t1 >>> 3);
- t0 = s[36] ^ d6;
- t1 = s[37] ^ d7;
- bc0 = (t0 << 28) | (t1 >>> 4);
- bc1 = (t1 << 28) | (t0 >>> 4);
- t0 = s[18] ^ d8;
- t1 = s[19] ^ d9;
- bc2 = (t0 << 20) | (t1 >>> 12);
- bc3 = (t1 << 20) | (t0 >>> 12);
- s[40] = bc0 ^ (bc4 & ~bc2);
- s[41] = bc1 ^ (bc5 & ~bc3);
- s[22] = bc2 ^ (bc6 & ~bc4);
- s[23] = bc3 ^ (bc7 & ~bc5);
- s[4] = bc4 ^ (bc8 & ~bc6);
- s[5] = bc5 ^ (bc9 & ~bc7);
- s[36] = bc6 ^ (bc0 & ~bc8);
- s[37] = bc7 ^ (bc1 & ~bc9);
- s[18] = bc8 ^ (bc2 & ~bc0);
- s[19] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[30] ^ d0;
- t1 = s[31] ^ d1;
- bc8 = (t0 << 18) | (t1 >>> 14);
- bc9 = (t1 << 18) | (t0 >>> 14);
- t0 = s[12] ^ d2;
- t1 = s[13] ^ d3;
- bc0 = (t0 << 1) | (t1 >>> 31);
- bc1 = (t1 << 1) | (t0 >>> 31);
- t0 = s[44] ^ d4;
- t1 = s[45] ^ d5;
- bc2 = (t0 << 6) | (t1 >>> 26);
- bc3 = (t1 << 6) | (t0 >>> 26);
- t0 = s[26] ^ d6;
- t1 = s[27] ^ d7;
- bc4 = (t0 << 25) | (t1 >>> 7);
- bc5 = (t1 << 25) | (t0 >>> 7);
- t0 = s[8] ^ d8;
- t1 = s[9] ^ d9;
- bc6 = (t0 << 8) | (t1 >>> 24);
- bc7 = (t1 << 8) | (t0 >>> 24);
- s[30] = bc0 ^ (bc4 & ~bc2);
- s[31] = bc1 ^ (bc5 & ~bc3);
- s[12] = bc2 ^ (bc6 & ~bc4);
- s[13] = bc3 ^ (bc7 & ~bc5);
- s[44] = bc4 ^ (bc8 & ~bc6);
- s[45] = bc5 ^ (bc9 & ~bc7);
- s[26] = bc6 ^ (bc0 & ~bc8);
- s[27] = bc7 ^ (bc1 & ~bc9);
- s[8] = bc8 ^ (bc2 & ~bc0);
- s[9] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[20] ^ d0;
- t1 = s[21] ^ d1;
- bc2 = (t1 << 4) | (t0 >>> 28);
- bc3 = (t0 << 4) | (t1 >>> 28);
- t0 = s[2] ^ d2;
- t1 = s[3] ^ d3;
- bc4 = (t0 << 10) | (t1 >>> 22);
- bc5 = (t1 << 10) | (t0 >>> 22);
- t0 = s[34] ^ d4;
- t1 = s[35] ^ d5;
- bc6 = (t0 << 15) | (t1 >>> 17);
- bc7 = (t1 << 15) | (t0 >>> 17);
- t0 = s[16] ^ d6;
- t1 = s[17] ^ d7;
- bc8 = (t1 << 24) | (t0 >>> 8);
- bc9 = (t0 << 24) | (t1 >>> 8);
- t0 = s[48] ^ d8;
- t1 = s[49] ^ d9;
- bc0 = (t0 << 27) | (t1 >>> 5);
- bc1 = (t1 << 27) | (t0 >>> 5);
- s[20] = bc0 ^ (bc4 & ~bc2);
- s[21] = bc1 ^ (bc5 & ~bc3);
- s[2] = bc2 ^ (bc6 & ~bc4);
- s[3] = bc3 ^ (bc7 & ~bc5);
- s[34] = bc4 ^ (bc8 & ~bc6);
- s[35] = bc5 ^ (bc9 & ~bc7);
- s[16] = bc6 ^ (bc0 & ~bc8);
- s[17] = bc7 ^ (bc1 & ~bc9);
- s[48] = bc8 ^ (bc2 & ~bc0);
- s[49] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[10] ^ d0;
- t1 = s[11] ^ d1;
- bc6 = (t1 << 9) | (t0 >>> 23);
- bc7 = (t0 << 9) | (t1 >>> 23);
- t0 = s[42] ^ d2;
- t1 = s[43] ^ d3;
- bc8 = (t0 << 2) | (t1 >>> 30);
- bc9 = (t1 << 2) | (t0 >>> 30);
- t0 = s[24] ^ d4;
- t1 = s[25] ^ d5;
- bc0 = (t1 << 30) | (t0 >>> 2);
- bc1 = (t0 << 30) | (t1 >>> 2);
- t0 = s[6] ^ d6;
- t1 = s[7] ^ d7;
- bc2 = (t1 << 23) | (t0 >>> 9);
- bc3 = (t0 << 23) | (t1 >>> 9);
- t0 = s[38] ^ d8;
- t1 = s[39] ^ d9;
- bc4 = (t1 << 7) | (t0 >>> 25);
- bc5 = (t0 << 7) | (t1 >>> 25);
- s[10] = bc0 ^ (bc4 & ~bc2);
- s[11] = bc1 ^ (bc5 & ~bc3);
- s[42] = bc2 ^ (bc6 & ~bc4);
- s[43] = bc3 ^ (bc7 & ~bc5);
- s[24] = bc4 ^ (bc8 & ~bc6);
- s[25] = bc5 ^ (bc9 & ~bc7);
- s[6] = bc6 ^ (bc0 & ~bc8);
- s[7] = bc7 ^ (bc1 & ~bc9);
- s[38] = bc8 ^ (bc2 & ~bc0);
- s[39] = bc9 ^ (bc3 & ~bc1);
-
- // Round 3
- bc0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
- bc1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
- bc2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
- bc3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
- bc4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
- bc5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
- bc6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
- bc7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
- bc8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
- bc9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
-
- d0 = bc8 ^ ((bc2 << 1) | (bc3 >>> 31));
- d1 = bc9 ^ ((bc3 << 1) | (bc2 >>> 31));
- d2 = bc0 ^ ((bc4 << 1) | (bc5 >>> 31));
- d3 = bc1 ^ ((bc5 << 1) | (bc4 >>> 31));
- d4 = bc2 ^ ((bc6 << 1) | (bc7 >>> 31));
- d5 = bc3 ^ ((bc7 << 1) | (bc6 >>> 31));
- d6 = bc4 ^ ((bc8 << 1) | (bc9 >>> 31));
- d7 = bc5 ^ ((bc9 << 1) | (bc8 >>> 31));
- d8 = bc6 ^ ((bc0 << 1) | (bc1 >>> 31));
- d9 = bc7 ^ ((bc1 << 1) | (bc0 >>> 31));
-
- bc0 = s[0] ^ d0;
- bc1 = s[1] ^ d1;
- t0 = s[22] ^ d2;
- t1 = s[23] ^ d3;
- bc2 = (t1 << 12) | (t0 >>> 20);
- bc3 = (t0 << 12) | (t1 >>> 20);
- t0 = s[44] ^ d4;
- t1 = s[45] ^ d5;
- bc4 = (t1 << 11) | (t0 >>> 21);
- bc5 = (t0 << 11) | (t1 >>> 21);
- t0 = s[16] ^ d6;
- t1 = s[17] ^ d7;
- bc6 = (t0 << 21) | (t1 >>> 11);
- bc7 = (t1 << 21) | (t0 >>> 11);
- t0 = s[38] ^ d8;
- t1 = s[39] ^ d9;
- bc8 = (t0 << 14) | (t1 >>> 18);
- bc9 = (t1 << 14) | (t0 >>> 18);
- s[0] = bc0 ^ (bc4 & ~bc2) ^ KECCAK_RC[n + 4];
- s[1] = bc1 ^ (bc5 & ~bc3) ^ KECCAK_RC[n + 5];
- s[22] = bc2 ^ (bc6 & ~bc4);
- s[23] = bc3 ^ (bc7 & ~bc5);
- s[44] = bc4 ^ (bc8 & ~bc6);
- s[45] = bc5 ^ (bc9 & ~bc7);
- s[16] = bc6 ^ (bc0 & ~bc8);
- s[17] = bc7 ^ (bc1 & ~bc9);
- s[38] = bc8 ^ (bc2 & ~bc0);
- s[39] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[30] ^ d0;
- t1 = s[31] ^ d1;
- bc4 = (t0 << 3) | (t1 >>> 29);
- bc5 = (t1 << 3) | (t0 >>> 29);
- t0 = s[2] ^ d2;
- t1 = s[3] ^ d3;
- bc6 = (t1 << 13) | (t0 >>> 19);
- bc7 = (t0 << 13) | (t1 >>> 19);
- t0 = s[24] ^ d4;
- t1 = s[25] ^ d5;
- bc8 = (t1 << 29) | (t0 >>> 3);
- bc9 = (t0 << 29) | (t1 >>> 3);
- t0 = s[46] ^ d6;
- t1 = s[47] ^ d7;
- bc0 = (t0 << 28) | (t1 >>> 4);
- bc1 = (t1 << 28) | (t0 >>> 4);
- t0 = s[18] ^ d8;
- t1 = s[19] ^ d9;
- bc2 = (t0 << 20) | (t1 >>> 12);
- bc3 = (t1 << 20) | (t0 >>> 12);
- s[30] = bc0 ^ (bc4 & ~bc2);
- s[31] = bc1 ^ (bc5 & ~bc3);
- s[2] = bc2 ^ (bc6 & ~bc4);
- s[3] = bc3 ^ (bc7 & ~bc5);
- s[24] = bc4 ^ (bc8 & ~bc6);
- s[25] = bc5 ^ (bc9 & ~bc7);
- s[46] = bc6 ^ (bc0 & ~bc8);
- s[47] = bc7 ^ (bc1 & ~bc9);
- s[18] = bc8 ^ (bc2 & ~bc0);
- s[19] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[10] ^ d0;
- t1 = s[11] ^ d1;
- bc8 = (t0 << 18) | (t1 >>> 14);
- bc9 = (t1 << 18) | (t0 >>> 14);
- t0 = s[32] ^ d2;
- t1 = s[33] ^ d3;
- bc0 = (t0 << 1) | (t1 >>> 31);
- bc1 = (t1 << 1) | (t0 >>> 31);
- t0 = s[4] ^ d4;
- t1 = s[5] ^ d5;
- bc2 = (t0 << 6) | (t1 >>> 26);
- bc3 = (t1 << 6) | (t0 >>> 26);
- t0 = s[26] ^ d6;
- t1 = s[27] ^ d7;
- bc4 = (t0 << 25) | (t1 >>> 7);
- bc5 = (t1 << 25) | (t0 >>> 7);
- t0 = s[48] ^ d8;
- t1 = s[49] ^ d9;
- bc6 = (t0 << 8) | (t1 >>> 24);
- bc7 = (t1 << 8) | (t0 >>> 24);
- s[10] = bc0 ^ (bc4 & ~bc2);
- s[11] = bc1 ^ (bc5 & ~bc3);
- s[32] = bc2 ^ (bc6 & ~bc4);
- s[33] = bc3 ^ (bc7 & ~bc5);
- s[4] = bc4 ^ (bc8 & ~bc6);
- s[5] = bc5 ^ (bc9 & ~bc7);
- s[26] = bc6 ^ (bc0 & ~bc8);
- s[27] = bc7 ^ (bc1 & ~bc9);
- s[48] = bc8 ^ (bc2 & ~bc0);
- s[49] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[40] ^ d0;
- t1 = s[41] ^ d1;
- bc2 = (t1 << 4) | (t0 >>> 28);
- bc3 = (t0 << 4) | (t1 >>> 28);
- t0 = s[12] ^ d2;
- t1 = s[13] ^ d3;
- bc4 = (t0 << 10) | (t1 >>> 22);
- bc5 = (t1 << 10) | (t0 >>> 22);
- t0 = s[34] ^ d4;
- t1 = s[35] ^ d5;
- bc6 = (t0 << 15) | (t1 >>> 17);
- bc7 = (t1 << 15) | (t0 >>> 17);
- t0 = s[6] ^ d6;
- t1 = s[7] ^ d7;
- bc8 = (t1 << 24) | (t0 >>> 8);
- bc9 = (t0 << 24) | (t1 >>> 8);
- t0 = s[28] ^ d8;
- t1 = s[29] ^ d9;
- bc0 = (t0 << 27) | (t1 >>> 5);
- bc1 = (t1 << 27) | (t0 >>> 5);
- s[40] = bc0 ^ (bc4 & ~bc2);
- s[41] = bc1 ^ (bc5 & ~bc3);
- s[12] = bc2 ^ (bc6 & ~bc4);
- s[13] = bc3 ^ (bc7 & ~bc5);
- s[34] = bc4 ^ (bc8 & ~bc6);
- s[35] = bc5 ^ (bc9 & ~bc7);
- s[6] = bc6 ^ (bc0 & ~bc8);
- s[7] = bc7 ^ (bc1 & ~bc9);
- s[28] = bc8 ^ (bc2 & ~bc0);
- s[29] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[20] ^ d0;
- t1 = s[21] ^ d1;
- bc6 = (t1 << 9) | (t0 >>> 23);
- bc7 = (t0 << 9) | (t1 >>> 23);
- t0 = s[42] ^ d2;
- t1 = s[43] ^ d3;
- bc8 = (t0 << 2) | (t1 >>> 30);
- bc9 = (t1 << 2) | (t0 >>> 30);
- t0 = s[14] ^ d4;
- t1 = s[15] ^ d5;
- bc0 = (t1 << 30) | (t0 >>> 2);
- bc1 = (t0 << 30) | (t1 >>> 2);
- t0 = s[36] ^ d6;
- t1 = s[37] ^ d7;
- bc2 = (t1 << 23) | (t0 >>> 9);
- bc3 = (t0 << 23) | (t1 >>> 9);
- t0 = s[8] ^ d8;
- t1 = s[9] ^ d9;
- bc4 = (t1 << 7) | (t0 >>> 25);
- bc5 = (t0 << 7) | (t1 >>> 25);
- s[20] = bc0 ^ (bc4 & ~bc2);
- s[21] = bc1 ^ (bc5 & ~bc3);
- s[42] = bc2 ^ (bc6 & ~bc4);
- s[43] = bc3 ^ (bc7 & ~bc5);
- s[14] = bc4 ^ (bc8 & ~bc6);
- s[15] = bc5 ^ (bc9 & ~bc7);
- s[36] = bc6 ^ (bc0 & ~bc8);
- s[37] = bc7 ^ (bc1 & ~bc9);
- s[8] = bc8 ^ (bc2 & ~bc0);
- s[9] = bc9 ^ (bc3 & ~bc1);
-
- // Round 4
- bc0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40];
- bc1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41];
- bc2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42];
- bc3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43];
- bc4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44];
- bc5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45];
- bc6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46];
- bc7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47];
- bc8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48];
- bc9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49];
-
- d0 = bc8 ^ ((bc2 << 1) | (bc3 >>> 31));
- d1 = bc9 ^ ((bc3 << 1) | (bc2 >>> 31));
- d2 = bc0 ^ ((bc4 << 1) | (bc5 >>> 31));
- d3 = bc1 ^ ((bc5 << 1) | (bc4 >>> 31));
- d4 = bc2 ^ ((bc6 << 1) | (bc7 >>> 31));
- d5 = bc3 ^ ((bc7 << 1) | (bc6 >>> 31));
- d6 = bc4 ^ ((bc8 << 1) | (bc9 >>> 31));
- d7 = bc5 ^ ((bc9 << 1) | (bc8 >>> 31));
- d8 = bc6 ^ ((bc0 << 1) | (bc1 >>> 31));
- d9 = bc7 ^ ((bc1 << 1) | (bc0 >>> 31));
-
- bc0 = s[0] ^ d0;
- bc1 = s[1] ^ d1;
- t0 = s[2] ^ d2;
- t1 = s[3] ^ d3;
- bc2 = (t1 << 12) | (t0 >>> 20);
- bc3 = (t0 << 12) | (t1 >>> 20);
- t0 = s[4] ^ d4;
- t1 = s[5] ^ d5;
- bc4 = (t1 << 11) | (t0 >>> 21);
- bc5 = (t0 << 11) | (t1 >>> 21);
- t0 = s[6] ^ d6;
- t1 = s[7] ^ d7;
- bc6 = (t0 << 21) | (t1 >>> 11);
- bc7 = (t1 << 21) | (t0 >>> 11);
- t0 = s[8] ^ d8;
- t1 = s[9] ^ d9;
- bc8 = (t0 << 14) | (t1 >>> 18);
- bc9 = (t1 << 14) | (t0 >>> 18);
- s[0] = bc0 ^ (bc4 & ~bc2) ^ KECCAK_RC[n + 6];
- s[1] = bc1 ^ (bc5 & ~bc3) ^ KECCAK_RC[n + 7];
- s[2] = bc2 ^ (bc6 & ~bc4);
- s[3] = bc3 ^ (bc7 & ~bc5);
- s[4] = bc4 ^ (bc8 & ~bc6);
- s[5] = bc5 ^ (bc9 & ~bc7);
- s[6] = bc6 ^ (bc0 & ~bc8);
- s[7] = bc7 ^ (bc1 & ~bc9);
- s[8] = bc8 ^ (bc2 & ~bc0);
- s[9] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[10] ^ d0;
- t1 = s[11] ^ d1;
- bc4 = (t0 << 3) | (t1 >>> 29);
- bc5 = (t1 << 3) | (t0 >>> 29);
- t0 = s[12] ^ d2;
- t1 = s[13] ^ d3;
- bc6 = (t1 << 13) | (t0 >>> 19);
- bc7 = (t0 << 13) | (t1 >>> 19);
- t0 = s[14] ^ d4;
- t1 = s[15] ^ d5;
- bc8 = (t1 << 29) | (t0 >>> 3);
- bc9 = (t0 << 29) | (t1 >>> 3);
- t0 = s[16] ^ d6;
- t1 = s[17] ^ d7;
- bc0 = (t0 << 28) | (t1 >>> 4);
- bc1 = (t1 << 28) | (t0 >>> 4);
- t0 = s[18] ^ d8;
- t1 = s[19] ^ d9;
- bc2 = (t0 << 20) | (t1 >>> 12);
- bc3 = (t1 << 20) | (t0 >>> 12);
- s[10] = bc0 ^ (bc4 & ~bc2);
- s[11] = bc1 ^ (bc5 & ~bc3);
- s[12] = bc2 ^ (bc6 & ~bc4);
- s[13] = bc3 ^ (bc7 & ~bc5);
- s[14] = bc4 ^ (bc8 & ~bc6);
- s[15] = bc5 ^ (bc9 & ~bc7);
- s[16] = bc6 ^ (bc0 & ~bc8);
- s[17] = bc7 ^ (bc1 & ~bc9);
- s[18] = bc8 ^ (bc2 & ~bc0);
- s[19] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[20] ^ d0;
- t1 = s[21] ^ d1;
- bc8 = (t0 << 18) | (t1 >>> 14);
- bc9 = (t1 << 18) | (t0 >>> 14);
- t0 = s[22] ^ d2;
- t1 = s[23] ^ d3;
- bc0 = (t0 << 1) | (t1 >>> 31);
- bc1 = (t1 << 1) | (t0 >>> 31);
- t0 = s[24] ^ d4;
- t1 = s[25] ^ d5;
- bc2 = (t0 << 6) | (t1 >>> 26);
- bc3 = (t1 << 6) | (t0 >>> 26);
- t0 = s[26] ^ d6;
- t1 = s[27] ^ d7;
- bc4 = (t0 << 25) | (t1 >>> 7);
- bc5 = (t1 << 25) | (t0 >>> 7);
- t0 = s[28] ^ d8;
- t1 = s[29] ^ d9;
- bc6 = (t0 << 8) | (t1 >>> 24);
- bc7 = (t1 << 8) | (t0 >>> 24);
- s[20] = bc0 ^ (bc4 & ~bc2);
- s[21] = bc1 ^ (bc5 & ~bc3);
- s[22] = bc2 ^ (bc6 & ~bc4);
- s[23] = bc3 ^ (bc7 & ~bc5);
- s[24] = bc4 ^ (bc8 & ~bc6);
- s[25] = bc5 ^ (bc9 & ~bc7);
- s[26] = bc6 ^ (bc0 & ~bc8);
- s[27] = bc7 ^ (bc1 & ~bc9);
- s[28] = bc8 ^ (bc2 & ~bc0);
- s[29] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[30] ^ d0;
- t1 = s[31] ^ d1;
- bc2 = (t1 << 4) | (t0 >>> 28);
- bc3 = (t0 << 4) | (t1 >>> 28);
- t0 = s[32] ^ d2;
- t1 = s[33] ^ d3;
- bc4 = (t0 << 10) | (t1 >>> 22);
- bc5 = (t1 << 10) | (t0 >>> 22);
- t0 = s[34] ^ d4;
- t1 = s[35] ^ d5;
- bc6 = (t0 << 15) | (t1 >>> 17);
- bc7 = (t1 << 15) | (t0 >>> 17);
- t0 = s[36] ^ d6;
- t1 = s[37] ^ d7;
- bc8 = (t1 << 24) | (t0 >>> 8);
- bc9 = (t0 << 24) | (t1 >>> 8);
- t0 = s[38] ^ d8;
- t1 = s[39] ^ d9;
- bc0 = (t0 << 27) | (t1 >>> 5);
- bc1 = (t1 << 27) | (t0 >>> 5);
- s[30] = bc0 ^ (bc4 & ~bc2);
- s[31] = bc1 ^ (bc5 & ~bc3);
- s[32] = bc2 ^ (bc6 & ~bc4);
- s[33] = bc3 ^ (bc7 & ~bc5);
- s[34] = bc4 ^ (bc8 & ~bc6);
- s[35] = bc5 ^ (bc9 & ~bc7);
- s[36] = bc6 ^ (bc0 & ~bc8);
- s[37] = bc7 ^ (bc1 & ~bc9);
- s[38] = bc8 ^ (bc2 & ~bc0);
- s[39] = bc9 ^ (bc3 & ~bc1);
-
- t0 = s[40] ^ d0;
- t1 = s[41] ^ d1;
- bc6 = (t1 << 9) | (t0 >>> 23);
- bc7 = (t0 << 9) | (t1 >>> 23);
- t0 = s[42] ^ d2;
- t1 = s[43] ^ d3;
- bc8 = (t0 << 2) | (t1 >>> 30);
- bc9 = (t1 << 2) | (t0 >>> 30);
- t0 = s[44] ^ d4;
- t1 = s[45] ^ d5;
- bc0 = (t1 << 30) | (t0 >>> 2);
- bc1 = (t0 << 30) | (t1 >>> 2);
- t0 = s[46] ^ d6;
- t1 = s[47] ^ d7;
- bc2 = (t1 << 23) | (t0 >>> 9);
- bc3 = (t0 << 23) | (t1 >>> 9);
- t0 = s[48] ^ d8;
- t1 = s[49] ^ d9;
- bc4 = (t1 << 7) | (t0 >>> 25);
- bc5 = (t0 << 7) | (t1 >>> 25);
- s[40] = bc0 ^ (bc4 & ~bc2);
- s[41] = bc1 ^ (bc5 & ~bc3);
- s[42] = bc2 ^ (bc6 & ~bc4);
- s[43] = bc3 ^ (bc7 & ~bc5);
- s[44] = bc4 ^ (bc8 & ~bc6);
- s[45] = bc5 ^ (bc9 & ~bc7);
- s[46] = bc6 ^ (bc0 & ~bc8);
- s[47] = bc7 ^ (bc1 & ~bc9);
- s[48] = bc8 ^ (bc2 & ~bc0);
- s[49] = bc9 ^ (bc3 & ~bc1);
- }
-}
-
-// https://github.com/denoland/deno_std/blob/main/hash/_sha3/sponge.ts
-const STATE_SIZE = 200;
-const TYPE_ERROR_MSG = "sha3: `data` is invalid type";
-
-class Sponge {
- #option;
- #state;
- #rp;
- #absorbing;
-
- constructor(option) {
- this.#option = option;
- this.#state = new Uint8Array(STATE_SIZE);
- this.#rp = 0;
- this.#absorbing = true;
- }
-
- /** Applies padding to internal state */
- pad() {
- this.#state[this.#rp] ^= this.#option.dsbyte;
- this.#state[this.#option.rate - 1] ^= 0x80;
- }
-
- /** Squeezes internal state */
- squeeze(length) {
- if (length < 0) {
- throw new Error("sha3: length cannot be negative");
- }
-
- this.pad();
-
- const hash = new Uint8Array(length);
- let pos = 0;
- while (length > 0) {
- const r = length > this.#option.rate ? this.#option.rate : length;
- this.#option.permutator(this.#state);
- hash.set(this.#state.slice(0, r), pos);
- length -= r;
- pos += r;
- }
-
- this.#absorbing = false;
- return hash;
- }
-
- /** Updates internal state by absorbing */
- update(data) {
- if (!this.#absorbing) {
- throw new Error("sha3: cannot update already finalized hash");
- }
-
- let msg;
-
- if (typeof data === "string") {
- msg = new TextEncoder().encode(data);
- } else if (typeof data === "object") {
- if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
- msg = new Uint8Array(data);
- } else {
- throw new Error(TYPE_ERROR_MSG);
- }
- } else {
- throw new Error(TYPE_ERROR_MSG);
- }
-
- let rp = this.#rp;
-
- for (let i = 0; i < msg.length; ++i) {
- this.#state[rp++] ^= msg[i];
- if (rp >= this.#option.rate) {
- this.#option.permutator(this.#state);
- rp = 0;
- }
- }
-
- this.#rp = rp;
- return this;
- }
-
- /** Returns the hash in ArrayBuffer */
- digest() {
- return this.squeeze(this.#option.bitsize >> 3);
- }
-}
-
-// https://github.com/denoland/deno_std/blob/main/hash/_sha3/keccak.ts
-export class Keccak256 extends Sponge {
- constructor() {
- super({
- bitsize: 256,
- rate: 136,
- dsbyte: 1,
- permutator: keccakf,
- });
- }
-}
+@noble/hashes/esm/utils.js:
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
+*/