]> git.ardis.lu - erc-165-calculator/commitdiff
Upgrade noble-hashes to 1.3.2
authorArdis Lu <ardisglu@gmail.com>
Thu, 24 Aug 2023 03:45:46 +0000 (20:45 -0700)
committerArdis Lu <ardisglu@gmail.com>
Thu, 24 Aug 2023 03:45:46 +0000 (20:45 -0700)
index.html
keccak256.js

index d9e590c6afa0149039cef5a7a143f5563e54302e..e6077d16c29fdd81204afe65fd84f69c9f5fb977 100644 (file)
@@ -77,7 +77,7 @@
   </main>
 
   <script type="module">
-    // From noble-hashes v1.3.1
+    // From noble-hashes v1.3.2
     import { keccak256 } from '/keccak256.js';
 
     document.querySelector('form').addEventListener('submit', e => {
index 0918a76a5af0e9fd2bef432c4a272c49011a9d0f..94a2632a932da7e58b65f147220f0b3b3584f885 100644 (file)
@@ -1,4 +1,4 @@
-function k(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function F(t){if(typeof t!="boolean")throw new Error(`Expected boolean, not ${t}`)}function m(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function X(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 $(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 R(t,e){m(t);let o=e.outputLen;if(t.length<o)throw new Error(`digestInto() expects output buffer of length at least ${o}`)}var V={number:k,bool:F,bytes:m,hash:X,exists:$,output:R},p=V;var w=BigInt(4294967295),L=BigInt(32);function O(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 M(t,e=!1){let o=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let r=0;r<t.length;r++){let{h:i,l:s}=O(t[r],e);[o[r],n[r]]=[i,s]}return[o,n]}var P=(t,e)=>BigInt(t>>>0)<<L|BigInt(e>>>0),W=(t,e,o)=>t>>>o,v=(t,e,o)=>t<<32-o|e>>>o,C=(t,e,o)=>t>>>o|e<<32-o,D=(t,e,o)=>t<<32-o|e>>>o,q=(t,e,o)=>t<<64-o|e>>>o-32,z=(t,e,o)=>t>>>o-32|e<<64-o,G=(t,e)=>e,J=(t,e)=>t,K=(t,e,o)=>t<<o|e>>>32-o,Q=(t,e,o)=>e<<o|t>>>32-o,Y=(t,e,o)=>e<<o-32|t>>>64-o,Z=(t,e,o)=>t<<o-32|e>>>64-o;function tt(t,e,o,n){let r=(e>>>0)+(n>>>0);return{h:t+o+(r/2**32|0)|0,l:r|0}}var et=(t,e,o)=>(t>>>0)+(e>>>0)+(o>>>0),ot=(t,e,o,n)=>e+o+n+(t/2**32|0)|0,nt=(t,e,o,n)=>(t>>>0)+(e>>>0)+(o>>>0)+(n>>>0),rt=(t,e,o,n,r)=>e+o+n+r+(t/2**32|0)|0,st=(t,e,o,n,r)=>(t>>>0)+(e>>>0)+(o>>>0)+(n>>>0)+(r>>>0),it=(t,e,o,n,r,i)=>e+o+n+r+i+(t/2**32|0)|0,ct={fromBig:O,split:M,toBig:P,shrSH:W,shrSL:v,rotrSH:C,rotrSL:D,rotrBH:q,rotrBL:z,rotr32H:G,rotr32L:J,rotlSH:K,rotlSL:Q,rotlBH:Y,rotlBL:Z,add:tt,add3L:et,add3H:ot,add4L:nt,add4H:rt,add5H:it,add5L:st},h=ct;var ft=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var ut=t=>t instanceof Uint8Array;var A=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));var pt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!pt)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 ht(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function g(t){if(typeof t=="string"&&(t=ht(t)),!ut(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var y=class{clone(){return this._cloneInto()}};function B(t){let e=n=>t().update(g(n)).digest(),o=t();return e.outputLen=o.outputLen,e.blockLen=o.blockLen,e.create=()=>t(),e}function I(t){let e=(n,r)=>t(r).update(g(n)).digest(),o=t({});return e.outputLen=o.outputLen,e.blockLen=o.blockLen,e.create=n=>t(n),e}var[H,U,S]=[[],[],[]],lt=BigInt(0),l=BigInt(1),at=BigInt(2),dt=BigInt(7),xt=BigInt(256),wt=BigInt(113);for(let t=0,e=l,o=1,n=0;t<24;t++){[o,n]=[n,(2*o+3*n)%5],H.push(2*(5*n+o)),U.push((t+1)*(t+2)/2%64);let r=lt;for(let i=0;i<7;i++)e=(e<<l^(e>>dt)*wt)%xt,e&at&&(r^=l<<(l<<BigInt(i))-l);S.push(r)}var[yt,gt]=h.split(S,!0),E=(t,e,o)=>o>32?h.rotlBH(t,e,o):h.rotlSH(t,e,o),_=(t,e,o)=>o>32?h.rotlBL(t,e,o):h.rotlSL(t,e,o);function bt(t,e=24){let o=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let s=0;s<10;s++)o[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,a=(s+2)%10,d=o[a],u=o[a+1],j=E(d,u,1)^o[c],N=_(d,u,1)^o[c+1];for(let x=0;x<50;x+=10)t[s+x]^=j,t[s+x+1]^=N}let r=t[2],i=t[3];for(let s=0;s<24;s++){let c=U[s],a=E(r,i,c),d=_(r,i,c),u=H[s];r=t[u],i=t[u+1],t[u]=a,t[u+1]=d}for(let s=0;s<50;s+=10){for(let c=0;c<10;c++)o[c]=t[s+c];for(let c=0;c<10;c++)t[s+c]^=~o[(c+2)%10]&o[(c+4)%10]}t[0]^=yt[n],t[1]^=gt[n]}o.fill(0)}var b=class t extends y{constructor(e,o,n,r=!1,i=24){if(super(),this.blockLen=e,this.suffix=o,this.outputLen=n,this.enableXOF=r,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,p.number(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=A(this.state)}keccak(){bt(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){p.exists(this);let{blockLen:o,state:n}=this;e=g(e);let r=e.length;for(let i=0;i<r;){let s=Math.min(o-this.pos,r-i);for(let c=0;c<s;c++)n[this.pos++]^=e[i++];this.pos===o&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:o,pos:n,blockLen:r}=this;e[n]^=o,o&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){p.exists(this,!1),p.bytes(e),this.finish();let o=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let s=Math.min(n-this.posOut,i-r);e.set(o.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:o,suffix:n,outputLen:r,rounds:i,enableXOF:s}=this;return e||(e=new t(o,n,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=n,e.outputLen=r,e.enableXOF=s,e.destroyed=this.destroyed,e}},f=(t,e,o)=>B(()=>new b(e,t,o)),Ut=f(6,144,224/8),St=f(6,136,256/8),Tt=f(6,104,384/8),jt=f(6,72,512/8),Nt=f(1,144,224/8),kt=f(1,136,256/8),Ft=f(1,104,384/8),Xt=f(1,72,512/8),T=(t,e,o)=>I((n={})=>new b(e,t,n.dkLen===void 0?o:n.dkLen,!0)),$t=T(31,168,128/8),Rt=T(31,136,256/8);export{kt as keccak256};
+function g(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function b(t,...e){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(t.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${t.length}`)}function k(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 L(t,e){b(t);let n=e.outputLen;if(t.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}var d=BigInt(4294967295),m=BigInt(32);function V(t,e=!1){return e?{h:Number(t&d),l:Number(t>>m&d)}:{h:Number(t>>m&d)|0,l:Number(t&d)|0}}function A(t,e=!1){let n=new Uint32Array(t.length),r=new Uint32Array(t.length);for(let s=0;s<t.length;s++){let{h:i,l:o}=V(t[s],e);[n[s],r[s]]=[i,o]}return[n,r]}var O=(t,e,n)=>t<<n|e>>>32-n,B=(t,e,n)=>e<<n|t>>>32-n,_=(t,e,n)=>e<<n-32|t>>>64-n,I=(t,e,n)=>t<<n-32|e>>>64-n;var M=t=>t instanceof Uint8Array;var E=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));var W=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!W)throw new Error("Non little-endian hardware is not supported");function C(t){if(typeof t!="string")throw new Error(`utf8ToBytes expected string, got ${typeof t}`);return new Uint8Array(new TextEncoder().encode(t))}function w(t){if(typeof t=="string"&&(t=C(t)),!M(t))throw new Error(`expected Uint8Array, got ${typeof t}`);return t}var x=class{clone(){return this._cloneInto()}},tt={}.toString;function H(t){let e=r=>t().update(w(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function U(t){let e=(r,s)=>t(s).update(w(r)).digest(),n=t({});return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=r=>t(r),e}var[N,F,X]=[[],[],[]],D=BigInt(0),h=BigInt(1),P=BigInt(2),v=BigInt(7),q=BigInt(256),z=BigInt(113);for(let t=0,e=h,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],N.push(2*(5*r+n)),F.push((t+1)*(t+2)/2%64);let s=D;for(let i=0;i<7;i++)e=(e<<h^(e>>v)*z)%q,e&P&&(s^=h<<(h<<BigInt(i))-h);X.push(s)}var[G,J]=A(X,!0),S=(t,e,n)=>n>32?_(t,e,n):O(t,e,n),T=(t,e,n)=>n>32?I(t,e,n):B(t,e,n);function K(t,e=24){let n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)n[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){let c=(o+8)%10,p=(o+2)%10,l=n[p],u=n[p+1],j=S(l,u,1)^n[c],R=T(l,u,1)^n[c+1];for(let a=0;a<50;a+=10)t[o+a]^=j,t[o+a+1]^=R}let s=t[2],i=t[3];for(let o=0;o<24;o++){let c=F[o],p=S(s,i,c),l=T(s,i,c),u=N[o];s=t[u],i=t[u+1],t[u]=p,t[u+1]=l}for(let o=0;o<50;o+=10){for(let c=0;c<10;c++)n[c]=t[o+c];for(let c=0;c<10;c++)t[o+c]^=~n[(c+2)%10]&n[(c+4)%10]}t[0]^=G[r],t[1]^=J[r]}n.fill(0)}var y=class t extends x{constructor(e,n,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,g(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=E(this.state)}keccak(){K(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){k(this);let{blockLen:n,state:r}=this;e=w(e);let s=e.length;for(let i=0;i<s;){let o=Math.min(n-this.pos,s-i);for(let c=0;c<o;c++)r[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:r,blockLen:s}=this;e[r]^=n,n&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){k(this,!1),b(e),this.finish();let n=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();let o=Math.min(r-this.posOut,i-s);e.set(n.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return g(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(L(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:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new t(n,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}},f=(t,e,n)=>H(()=>new y(e,t,n)),st=f(6,144,224/8),it=f(6,136,256/8),ct=f(6,104,384/8),ft=f(6,72,512/8),ut=f(1,144,224/8),Q=f(1,136,256/8),ht=f(1,104,384/8),pt=f(1,72,512/8),$=(t,e,n)=>U((r={})=>new y(e,t,r.dkLen===void 0?n:r.dkLen,!0)),lt=$(31,168,128/8),at=$(31,136,256/8);export{Q as keccak256};
 /*! Bundled license information:
 
 @noble/hashes/esm/utils.js:
This page took 0.037955 seconds and 4 git commands to generate.