]> git.ardis.lu - event-hashes/commitdiff
Bump noble-hashes to 2.4.0 main
authorArdis Lu <ardisglu@gmail.com>
Sun, 11 Oct 2026 06:59:57 +0000 (23:59 -0700)
committerArdis Lu <ardisglu@gmail.com>
Sun, 11 Oct 2026 06:59:57 +0000 (23:59 -0700)
index.html
keccak256.js

index f54117c397a2e334cc49c950209d1f3c77f4ee41..18013bd7ee67187f845fc385c4bc06d9ace1451a 100644 (file)
   </footer>
 
   <script type="module">
-    // From noble-hashes v1.4.0
+    // From noble-hashes v2.4.0
     import { keccak256 } from '/keccak256.js';
 
     const encoder = new TextEncoder();
index cc88ab209b956ca124988f164b2bae7056e7ebfd..38847e5ff18fca74d380068a14c895788309f96f 100644 (file)
@@ -1,2 +1,2 @@
-function b(t){if(!Number.isSafeInteger(t)||t<0)throw new Error()}function M(t){return t instanceof Uint8Array||t!=null&&typeof t=="object"&&t.constructor.name==="Uint8Array"}function p(t,...e){if(!M(t))throw new Error();if(e.length>0&&!e.includes(t.length))throw new Error()}function k(t,e=!0){if(t.d)throw new Error();if(e&&t.f)throw new Error()}function m(t,e){p(t);let n=e.o;if(t.length<n)throw new Error()}var x=4294967295n,A=32n;function D(t,e=!1){return e?{h:Number(t&x),l:Number(t>>A&x)}:{h:Number(t>>A&x)|0,l:Number(t&x)|0}}function B(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}=D(t[s],e);[n[s],r[s]]=[i,o]}return[n,r]}var O=(t,e,n)=>t<<n|e>>>32-n,I=(t,e,n)=>e<<n|t>>>32-n,S=(t,e,n)=>e<<n-32|t>>>64-n,H=(t,e,n)=>t<<n-32|e>>>64-n;var E=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4));var L=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,P=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;function _(t){for(let e=0;e<t.length;e++)t[e]=P(t[e])}function W(t){if(typeof t!="string")throw new Error();return new Uint8Array(new TextEncoder().encode(t))}function w(t){return typeof t=="string"&&(t=W(t)),p(t),t}var ot={}.toString;function U(t){let e=r=>t().u(w(r)).g(),n=t();return e.o=n.o,e.b=n.b,e.c=()=>t(),e}function T(t){let e=(r,s)=>t(s).u(w(r)).g(),n=t({});return e.o=n.o,e.b=n.b,e.c=r=>t(r),e}var X=[],$=[],C=[],v=0n,h=1n,q=2n,z=7n,G=256n,J=113n;for(let t=0,e=h,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],X.push(2*(5*r+n)),$.push((t+1)*(t+2)/2%64);let s=v;for(let i=0;i<7;i++)e=(e<<h^(e>>z)*J)%G,e&q&&(s^=h<<(h<<BigInt(i))-h);C.push(s)}var[K,Q]=B(C,!0),F=(t,e,n)=>n>32?S(t,e,n):O(t,e,n),j=(t,e,n)=>n>32?H(t,e,n):I(t,e,n);function Y(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,l=(o+2)%10,a=n[l],u=n[l+1],R=F(a,u,1)^n[c],V=j(a,u,1)^n[c+1];for(let d=0;d<50;d+=10)t[o+d]^=R,t[o+d+1]^=V}let s=t[2],i=t[3];for(let o=0;o<24;o++){let c=$[o],l=F(s,i,c),a=j(s,i,c),u=X[o];s=t[u],i=t[u+1],t[u]=l,t[u+1]=a}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]^=K[r],t[1]^=Q[r]}n.fill(0)}var g=class t{constructor(e,n,r,s=!1,i=24){if(this.b=e,this.s=n,this.o=r,this.e=s,this.r=i,this.po=0,this.p=0,this.f=!1,this.d=!1,b(r),0>=this.b||this.b>=200)throw new Error();this.q=new Uint8Array(200),this.s3=E(this.q)}k(){L||_(this.s3),Y(this.s3,this.r),L||_(this.s3),this.p=0,this.po=0}u(e){k(this);let{b:n,q:r}=this;e=w(e);let s=e.length;for(let i=0;i<s;){let o=Math.min(n-this.po,s-i);for(let c=0;c<o;c++)r[this.po++]^=e[i++];this.po===n&&this.k()}return this}fi(){if(this.f)return;this.f=!0;let{q:e,s:n,po:r,b:s}=this;e[r]^=n,n&128&&r===s-1&&this.k(),e[s-1]^=128,this.k()}w(e){k(this,!1),p(e),this.fi();let n=this.q,{b:r}=this;for(let s=0,i=e.length;s<i;){this.p>=r&&this.k();let o=Math.min(r-this.p,i-s);e.set(n.subarray(this.p,this.p+o),s),this.p+=o,s+=o}return e}x(e){if(!this.e)throw new Error();return this.w(e)}xof(e){return b(e),this.x(new Uint8Array(e))}di(e){if(m(e,this),this.f)throw new Error();return this.w(e),this.de(),e}g(){return this.di(new Uint8Array(this.o))}de(){this.d=!0,this.q.fill(0)}c(e){let{b:n,s:r,o:s,r:i,e:o}=this;return e||(e=new t(n,r,s,o,i)),e.s3.set(this.s3),e.po=this.po,e.p=this.p,e.f=this.f,e.r=i,e.s=r,e.o=s,e.e=o,e.d=this.d,e}},f=(t,e,n)=>U(()=>new g(e,t,n)),ft=f(6,144,224/8),ut=f(6,136,256/8),pt=f(6,104,384/8),ht=f(6,72,512/8),lt=f(1,144,224/8),Z=f(1,136,256/8),at=f(1,104,384/8),dt=f(1,72,512/8),N=(t,e,n)=>T((r={})=>new g(e,t,r.D===void 0?n:r.D,!0)),xt=N(31,168,128/8),yt=N(31,136,256/8);export{Z as keccak256};
+var d=BigInt(4294967295),_=BigInt(32);function N(t,e=!1){return e?{h:Number(t&d),l:Number(t>>_&d)}:{h:Number(t>>_&d)|0,l:Number(t&d)|0}}function A(t,e=!1){let o=t.length,r=new Uint32Array(o),i=new Uint32Array(o);for(let n=0;n<o;n++){let{h:s,l:f}=N(t[n],e);[r[n],i[n]]=[s,f]}return[r,i]}function O(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var y=t=>t?`"${t}" `:"";function p(t,e=""){if(typeof t!="number")throw new TypeError(y(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(y(e)+"expected integer >= 0, got "+t);return t}function B(t,e=""){if(typeof t!="boolean")throw new TypeError(y(e)+"expected boolean, got type="+typeof t);return t}function w(t,e,o=""){if(O(t)&&(e===void 0||t.length===e))return t;e!==void 0&&p(e,"length");let r=O(t),i=e!==void 0?` of length ${e}`:"",n=r?`length=${t.length}`:`type=${typeof t}`,s=y(o)+"expected Uint8Array"+i+", got "+n;throw r?new RangeError(s):new TypeError(s)}var P=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)},T=(t,e)=>{P(t,e);let o=Object.getPrototypeOf(t);if(o!==Object.prototype&&o!==null)throw new TypeError(`"${e}" expected plain object`);if(Object.hasOwn(t,"__proto__"))throw new TypeError(`"${e}.__proto__" is not allowed`)};function b(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function I(t,e){w(t,void 0,"output");let o=e.outputLen;if(!(t.length>=o))throw new RangeError('"output" expected length >= '+o)}function k(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function m(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}var M=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function V(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function D(t){for(let e=0;e<t.length;e++)t[e]=V(t[e]);return t}var L=M?t=>t:D;function U(t,e,o="opts"){return T(t,"defaults"),e!==void 0&&T(e,o),Object.assign(Object.create(null),t,e)}function H(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=U({},e,"info");let o=(i,n)=>t(n).update(i).digest(),r=t(void 0);return o.outputLen=r.outputLen,o.blockLen=r.blockLen,o.canXOF=r.canXOF,o.create=i=>t(i),Object.assign(o,e),Object.freeze(o)}var Y=BigInt(0),l=BigInt(1),z=BigInt(2),K=BigInt(7),q=BigInt(256),C=BigInt(113),$=[],R=[],F=[];for(let t=0,e=l,o=1,r=0;t<24;t++){[o,r]=[r,(2*o+3*r)%5],$.push(2*(5*r+o)),R.push((t+1)*(t+2)/2%64);let i=Y;for(let n=0;n<7;n++)e=(e<<l^(e>>K)*C)%q,e&z&&(i^=l<<(l<<BigInt(n))-l);F.push(i)}var X=A(F,!0),G=X[0],J=X[1],Q=(t,e,o)=>t<<o|e>>>32-o,W=(t,e,o)=>e<<o|t>>>32-o,Z=(t,e,o)=>e<<o-32|t>>>64-o,v=(t,e,o)=>t<<o-32|e>>>64-o,S=(t,e,o)=>o>32?Z(t,e,o):Q(t,e,o),j=(t,e,o)=>o>32?v(t,e,o):W(t,e,o),x=new Uint32Array(10);function tt(t,e=24){if(!(t instanceof Uint32Array))throw new TypeError('"s" expected Uint32Array(50), got type='+typeof t);if(t.length!==50)throw new RangeError('"s" expected Uint32Array(50), got length='+t.length);if(p(e,"rounds"),e<1||e>24)throw new Error('"rounds" expected integer 1..24');for(let o=24-e;o<24;o++){for(let n=0;n<10;n++)x[n]=t[n]^t[n+10]^t[n+20]^t[n+30]^t[n+40];for(let n=0;n<10;n+=2){let s=(n+8)%10,f=(n+2)%10,u=x[f],c=x[f+1],g=S(u,c,1)^x[s],a=j(u,c,1)^x[s+1];for(let h=0;h<50;h+=10)t[n+h]^=g,t[n+h+1]^=a}let r=t[2],i=t[3];for(let n=0;n<24;n++){let s=R[n],f=S(r,i,s),u=j(r,i,s),c=$[n];r=t[c],i=t[c+1],t[c]=f,t[c+1]=u}for(let n=0;n<50;n+=10){let s=t[n],f=t[n+1],u=t[n+2],c=t[n+3];t[n]^=~t[n+2]&t[n+4],t[n+1]^=~t[n+3]&t[n+5],t[n+2]^=~t[n+4]&t[n+6],t[n+3]^=~t[n+5]&t[n+7],t[n+4]^=~t[n+6]&t[n+8],t[n+5]^=~t[n+7]&t[n+9],t[n+6]^=~t[n+8]&s,t[n+7]^=~t[n+9]&f,t[n+8]^=~s&u,t[n+9]^=~f&c}t[0]^=G[o],t[1]^=J[o]}m(x)}var E=class t{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(e,o,r,i=!1,n=24){if(p(e,"blockLen"),p(o,"suffix"),p(n,"rounds"),B(i,"enableXOF"),this.blockLen=e,this.suffix=o,this.outputLen=r,this.enableXOF=i,this.canXOF=i,this.rounds=n,p(r,"outputLen"),!(0<e&&e<200))throw new Error('"blockLen" must be 1..199');this.state=new Uint8Array(200),this.state32=k(this.state)}clone(){return this._cloneInto()}keccak(){L(this.state32),tt(this.state32,this.rounds),L(this.state32),this.posOut=0,this.pos=0}update(e){b(this),w(e);let{blockLen:o,state:r,state32:i}=this,n=e.length,s=o%4===0&&e.byteOffset%4===0,f=o/4,u=s&&n>=o?k(e):void 0;for(let c=0;c<n;){if(u!==void 0&&this.pos===0&&c%4===0&&n-c>=o){for(let a=0,h=c/4;a<f;a++)i[a]^=u[h+a];c+=o,this.pos=o,this.keccak();continue}let g=Math.min(o-this.pos,n-c);for(let a=0;a<g;a++)r[this.pos++]^=e[c++];this.pos===o&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:o,pos:r,blockLen:i}=this;e[r]^=o,(o&128)!==0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){b(this,!1),w(e),this.finish();let o=this.state,{blockLen:r}=this;for(let i=0,n=e.length;i<n;){this.posOut>=r&&this.keccak();let s=Math.min(r-this.posOut,n-i);e.set(o.subarray(this.posOut,this.posOut+s),i),this.posOut+=s,i+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not enabled");return this.writeInto(e)}xof(e){return p(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(I(e,this),this.finished)throw new Error("digest() was already called");this.writeInto(e.length===this.outputLen?e:e.subarray(0,this.outputLen)),this.destroy()}digest(){let e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,m(this.state)}_cloneInto(e){let{blockLen:o,suffix:r,outputLen:i,rounds:n,enableXOF:s}=this;return e||=new t(o,r,i,s,n),e.blockLen=o,e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=r,e.outputLen=i,e.enableXOF=s,e.canXOF=this.canXOF,e.destroyed=this.destroyed,e}},et=(t,e,o,r={})=>H(()=>new E(e,t,o),r);var nt=et(1,136,32);export{nt as keccak256};
 // noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com)
This page took 0.046841 seconds and 4 git commands to generate.