-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.min.js
1 lines (1 loc) · 6.55 KB
/
index.min.js
1
const t=[1,0,32898,0,32906,-2147483648,-2147450880,-2147483648,32907,0,-2147483647,0,-2147450751,-2147483648,32777,-2147483648,138,0,136,0,-2147450871,0,-2147483638,0,-2147450741,0,139,-2147483648,32905,-2147483648,32771,-2147483648,32770,-2147483648,128,-2147483648,32778,0,-2147483638,-2147483648,-2147450751,-2147483648,32896,-2147483648,-2147483647,0,-2147450872,-2147483648];function e(e){for(let r=0;r<48;r+=2){let n=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],o=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],h=e[5]^e[15]^e[25]^e[35]^e[45],u=e[6]^e[16]^e[26]^e[36]^e[46],c=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],a=e[9]^e[19]^e[29]^e[39]^e[49],g=l^(s<<1|o>>>31),d=a^(o<<1|s>>>31);e[0]^=g,e[1]^=d,e[10]^=g,e[11]^=d,e[20]^=g,e[21]^=d,e[30]^=g,e[31]^=d,e[40]^=g,e[41]^=d,g=n^(f<<1|h>>>31),d=i^(h<<1|f>>>31),e[2]^=g,e[3]^=d,e[12]^=g,e[13]^=d,e[22]^=g,e[23]^=d,e[32]^=g,e[33]^=d,e[42]^=g,e[43]^=d,g=s^(u<<1|c>>>31),d=o^(c<<1|u>>>31),e[4]^=g,e[5]^=d,e[14]^=g,e[15]^=d,e[24]^=g,e[25]^=d,e[34]^=g,e[35]^=d,e[44]^=g,e[45]^=d,g=f^(l<<1|a>>>31),d=h^(a<<1|l>>>31),e[6]^=g,e[7]^=d,e[16]^=g,e[17]^=d,e[26]^=g,e[27]^=d,e[36]^=g,e[37]^=d,e[46]^=g,e[47]^=d,g=u^(n<<1|i>>>31),d=c^(i<<1|n>>>31),e[8]^=g,e[9]^=d,e[18]^=g,e[19]^=d,e[28]^=g,e[29]^=d,e[38]^=g,e[39]^=d,e[48]^=g,e[49]^=d;let p=e[0],_=e[1],b=e[11]<<4|e[10]>>>28,y=e[10]<<4|e[11]>>>28,w=e[20]<<3|e[21]>>>29,x=e[21]<<3|e[20]>>>29,k=e[31]<<9|e[30]>>>23,A=e[30]<<9|e[31]>>>23,m=e[40]<<18|e[41]>>>14,z=e[41]<<18|e[40]>>>14,E=e[2]<<1|e[3]>>>31,U=e[3]<<1|e[2]>>>31,C=e[13]<<12|e[12]>>>20,T=e[12]<<12|e[13]>>>20,S=e[22]<<10|e[23]>>>22,B=e[23]<<10|e[22]>>>22,P=e[33]<<13|e[32]>>>19,$=e[32]<<13|e[33]>>>19,v=e[42]<<2|e[43]>>>30,I=e[43]<<2|e[42]>>>30,L=e[5]<<30|e[4]>>>2,M=e[4]<<30|e[5]>>>2,N=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,V=e[25]<<11|e[24]>>>21,W=e[24]<<11|e[25]>>>21,j=e[34]<<15|e[35]>>>17,q=e[35]<<15|e[34]>>>17,D=e[45]<<29|e[44]>>>3,F=e[44]<<29|e[45]>>>3,G=e[6]<<28|e[7]>>>4,H=e[7]<<28|e[6]>>>4,J=e[17]<<23|e[16]>>>9,K=e[16]<<23|e[17]>>>9,Q=e[26]<<25|e[27]>>>7,R=e[27]<<25|e[26]>>>7,X=e[36]<<21|e[37]>>>11,Y=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,tt=e[46]<<24|e[47]>>>8,et=e[8]<<27|e[9]>>>5,rt=e[9]<<27|e[8]>>>5,nt=e[18]<<20|e[19]>>>12,it=e[19]<<20|e[18]>>>12,st=e[29]<<7|e[28]>>>25,ot=e[28]<<7|e[29]>>>25,ft=e[38]<<8|e[39]>>>24,ht=e[39]<<8|e[38]>>>24,ut=e[48]<<14|e[49]>>>18,ct=e[49]<<14|e[48]>>>18;e[0]=p^~C&V,e[1]=_^~T&W,e[10]=G^~nt&w,e[11]=H^~it&x,e[20]=E^~N&Q,e[21]=U^~O&R,e[30]=et^~b&S,e[31]=rt^~y&B,e[40]=L^~J&st,e[41]=M^~K&ot,e[2]=C^~V&X,e[3]=T^~W&Y,e[12]=nt^~w&P,e[13]=it^~x&$,e[22]=N^~Q&ft,e[23]=O^~R&ht,e[32]=b^~S&j,e[33]=y^~B&q,e[42]=J^~st&k,e[43]=K^~ot&A,e[4]=V^~X&ut,e[5]=W^~Y&ct,e[14]=w^~P&D,e[15]=x^~$&F,e[24]=Q^~ft&m,e[25]=R^~ht&z,e[34]=S^~j&Z,e[35]=B^~q&tt,e[44]=st^~k&v,e[45]=ot^~A&I,e[6]=X^~ut&p,e[7]=Y^~ct&_,e[16]=P^~D&G,e[17]=$^~F&H,e[26]=ft^~m&E,e[27]=ht^~z&U,e[36]=j^~Z&et,e[37]=q^~tt&rt,e[46]=k^~v&L,e[47]=A^~I&M,e[8]=ut^~p&C,e[9]=ct^~_&T,e[18]=D^~G&nt,e[19]=F^~H&it,e[28]=m^~E&N,e[29]=z^~U&O,e[38]=Z^~et&b,e[39]=tt^~rt&y,e[48]=v^~L&J,e[49]=I^~M&K,e[0]^=t[r],e[1]^=t[r+1]}}function r(t,e){if(Array.isArray(t)){if(t.every((t=>Number.isSafeInteger(t)&&t>=0&&t<=255)))return t}else{if(t instanceof Uint8Array)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(e&&"string"==typeof t)return e(t)}throw new TypeError("expected array of bytes")}function n(t){let e=t.length,r=new Uint8Array(e<<2),n=0;for(let e of t)r[n++]=e,r[n++]=e>>8,r[n++]=e>>16,r[n++]=e>>24;return r}function i(t){let e=[];for(let n=0,i=(t=r(t,c)).length;n<i;n++){let r=t[n];e.push(s(r>>4),s(15&r))}return String.fromCharCode(...e)}function s(t){return t<10?48+t:87+t}function o(t){if("string"!=typeof t)throw new TypeError("expected string");let e=t.startsWith("0x")?2:0,r=0,n=t.length,i=new Uint8Array(n+1-e>>1);for(1&n&&(i[r++]=f(t,e++));e<n;)i[r++]=f(t,e++)<<4|f(t,e++);return i}function f(t,e){let r=t.charCodeAt(e);if(r-=r<=57?48:r<=90?55:87,!(r>=0&&r<16))throw new TypeError(`expected hex digit: ${t[e]}`);return r}function h(t){let e=[];for(let n=0,i=(t=r(t,o)).length;n<i;){let r=t[n++];r<128?e.push(r):r<224?e.push((31&r)<<6|u(t,n++)):r<240?e.push((15&r)<<12|u(t,n++)<<6|u(t,n++)):e.push((7&r)<<18|u(t,n++)<<12|u(t,n++)<<6|u(t,n++))}return String.fromCodePoint(...e)}function u(t,e){let r=t[e];if(128!=(192&r))throw new Error(`malformed utf8 at ${e}: expected continuation`);return 63&r}function c(t){if("string"!=typeof t)throw new TypeError("expected string");let e=[];for(let r=0,n=t.length;r<n;){let n=t.codePointAt(r++);n<2048?n<128?e.push(n):e.push(192|n>>6,128|63&n):n<65536?e.push(224|n>>12,128|n>>6&63,128|63&n):(e.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n),r++)}return Uint8Array.from(e)}function l(t=256){return new _(t,1)}function a(t=256){return new _(t,6)}function g(t){return new p(t,31)}class d{constructor(t,e){if(31&t)throw new Error("capacity % 32 != 0");if(t<0||t>=1600)throw new Error("capacity must be [0,1600)");this.block_count=1600-t>>5,this.block_index=0,this.suffix=e,this.ragged_block=0,this.ragged_shift=0;let r=this.sponge=[];for(let t=0;t<50;t++)r[t]=0}update_hex(t){return this.update(o(t))}update(t){let n=0,i=(t=r(t,c)).length;if(this.ragged_shift>0&&(n=this._add_ragged(t,0),n==i))return this;let{sponge:s,block_index:o,block_count:f}=this;for(;;){let r=Math.min(f,o+(i-n>>2));for(;o<r;)s[o++]^=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;if(r<f)break;e(s),o=0}return this.block_index=o,n<i&&this._add_ragged(t,n),this}_add_ragged(t,e){let{ragged_shift:r,ragged_block:n}=this,i=0;for(;e<t.length&&r<32;i++,e++,r+=8)n|=t[e]<<r;return 32==r&&(this._add_block(n),r=0,n=0),this.ragged_block=n,this.ragged_shift=r,i}_add_block(t){let{sponge:r,block_index:n,block_count:i}=this;r[n++]^=t,n==i&&(e(r),n=0),this.block_index=n}finalize(){let{sponge:t,suffix:r,ragged_shift:n,block_index:i,block_count:s}=this;if(n){if(-1==n)return;r=this.ragged_block|r<<n}t[i]^=r,t[s-1]^=2147483648,e(t),this.ragged_shift=-1}}class p extends d{constructor(t,e){super(t<<1,e),this.size0=t>>2,this.byte_offset=0}hex(t){return i(this.bytes(t))}bytes(t){this.finalize(),t||(t=this.size0);let{sponge:r,byte_offset:i,block_count:s}=this,o=3&i,f=(o>0)+(t+3>>2),h=(i>>2)%s,u=[];for(let t=0;t<f;t++)u.push(r[h++]),h==s&&(e(r),h=0);return this.byte_offset=i+t,n(u).slice(o,o+t)}}class _ extends d{constructor(t,e){super(t<<1,e),this.size=t>>5}get hex(){return i(this.bytes)}get bytes(){return this.finalize(),n(this.sponge.slice(0,this.size))}}export{o as bytes_from_hex,c as bytes_from_utf8,i as hex_from_bytes,l as keccak,a as sha3,g as shake,h as utf8_from_bytes};