Files
kane-diagnostics/hubzilla/addon/g1wallet/vendor/scrypt-js-3.0.1.min.js
2026-06-08 03:33:50 -04:00

1 line
5.8 KiB
JavaScript

"use strict";!function(r){const n=2147483647;function t(r){const n=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]);let t=1779033703,e=3144134277,o=1013904242,f=2773480762,i=1359893119,u=2600822924,s=528734635,c=1541459225;const l=new Uint32Array(64);function a(r){let a=0,p=r.length;for(;p>=64;){let h,y,w,g,d,m=t,b=e,A=o,U=f,E=i,k=u,I=s,N=c;for(y=0;y<16;y++)w=a+4*y,l[y]=(255&r[w])<<24|(255&r[w+1])<<16|(255&r[w+2])<<8|255&r[w+3];for(y=16;y<64;y++)h=l[y-2],g=(h>>>17|h<<15)^(h>>>19|h<<13)^h>>>10,h=l[y-15],d=(h>>>7|h<<25)^(h>>>18|h<<14)^h>>>3,l[y]=(g+l[y-7]|0)+(d+l[y-16]|0)|0;for(y=0;y<64;y++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&k^~E&I)|0)+(N+(n[y]+l[y]|0)|0)|0,d=((m>>>2|m<<30)^(m>>>13|m<<19)^(m>>>22|m<<10))+(m&b^m&A^b&A)|0,N=I,I=k,k=E,E=U+g|0,U=A,A=b,b=m,m=g+d|0;t=t+m|0,e=e+b|0,o=o+A|0,f=f+U|0,i=i+E|0,u=u+k|0,s=s+I|0,c=c+N|0,a+=64,p-=64}}a(r);let p,h=r.length%64,y=r.length/536870912|0,w=r.length<<3,g=h<56?56:120,d=r.slice(r.length-h,r.length);for(d.push(128),p=h+1;p<g;p++)d.push(0);return d.push(y>>>24&255),d.push(y>>>16&255),d.push(y>>>8&255),d.push(y>>>0&255),d.push(w>>>24&255),d.push(w>>>16&255),d.push(w>>>8&255),d.push(w>>>0&255),a(d),[t>>>24&255,t>>>16&255,t>>>8&255,t>>>0&255,e>>>24&255,e>>>16&255,e>>>8&255,e>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,c>>>24&255,c>>>16&255,c>>>8&255,c>>>0&255]}function e(r,n,e){r=r.length<=64?r:t(r);const o=64+n.length+4,f=new Array(o),i=new Array(64);let u,s=[];for(u=0;u<64;u++)f[u]=54;for(u=0;u<r.length;u++)f[u]^=r[u];for(u=0;u<n.length;u++)f[64+u]=n[u];for(u=o-4;u<o;u++)f[u]=0;for(u=0;u<64;u++)i[u]=92;for(u=0;u<r.length;u++)i[u]^=r[u];function c(){for(let r=o-1;r>=o-4;r--){if(f[r]++,f[r]<=255)return;f[r]=0}}for(;e>=32;)c(),s=s.concat(t(i.concat(t(f)))),e-=32;return e>0&&(c(),s=s.concat(t(i.concat(t(f))).slice(0,e))),s}function o(r,n,t,e,o){let f;for(s(r,16*(2*t-1),o,0,16),f=0;f<2*t;f++)u(r,16*f,o,16),i(o,e),s(o,0,r,n+16*f,16);for(f=0;f<t;f++)s(r,n+2*f*16,r,16*f,16);for(f=0;f<t;f++)s(r,n+16*(2*f+1),r,16*(f+t),16)}function f(r,n){return r<<n|r>>>32-n}function i(r,n){s(r,0,n,0,16);for(let r=8;r>0;r-=2)n[4]^=f(n[0]+n[12],7),n[8]^=f(n[4]+n[0],9),n[12]^=f(n[8]+n[4],13),n[0]^=f(n[12]+n[8],18),n[9]^=f(n[5]+n[1],7),n[13]^=f(n[9]+n[5],9),n[1]^=f(n[13]+n[9],13),n[5]^=f(n[1]+n[13],18),n[14]^=f(n[10]+n[6],7),n[2]^=f(n[14]+n[10],9),n[6]^=f(n[2]+n[14],13),n[10]^=f(n[6]+n[2],18),n[3]^=f(n[15]+n[11],7),n[7]^=f(n[3]+n[15],9),n[11]^=f(n[7]+n[3],13),n[15]^=f(n[11]+n[7],18),n[1]^=f(n[0]+n[3],7),n[2]^=f(n[1]+n[0],9),n[3]^=f(n[2]+n[1],13),n[0]^=f(n[3]+n[2],18),n[6]^=f(n[5]+n[4],7),n[7]^=f(n[6]+n[5],9),n[4]^=f(n[7]+n[6],13),n[5]^=f(n[4]+n[7],18),n[11]^=f(n[10]+n[9],7),n[8]^=f(n[11]+n[10],9),n[9]^=f(n[8]+n[11],13),n[10]^=f(n[9]+n[8],18),n[12]^=f(n[15]+n[14],7),n[13]^=f(n[12]+n[15],9),n[14]^=f(n[13]+n[12],13),n[15]^=f(n[14]+n[13],18);for(let t=0;t<16;++t)r[t]+=n[t]}function u(r,n,t,e){for(let o=0;o<e;o++)t[o]^=r[n+o]}function s(r,n,t,e,o){for(;o--;)t[e++]=r[n++]}function c(r){if(!r||"number"!=typeof r.length)return!1;for(let n=0;n<r.length;n++){const t=r[n];if("number"!=typeof t||t%1||t<0||t>=256)return!1}return!0}function l(r,n){if("number"!=typeof r||r%1)throw new Error("invalid "+n);return r}function a(r,t,f,i,a,p,h){if(f=l(f,"N"),i=l(i,"r"),a=l(a,"p"),p=l(p,"dkLen"),0===f||f&f-1)throw new Error("N must be power of 2");if(f>n/128/i)throw new Error("N too large");if(i>n/128/a)throw new Error("r too large");if(!c(r))throw new Error("password must be an array or buffer");if(r=Array.prototype.slice.call(r),!c(t))throw new Error("salt must be an array or buffer");t=Array.prototype.slice.call(t);let y=e(r,t,128*a*i);const w=new Uint32Array(32*a*i);for(let r=0;r<w.length;r++){const n=4*r;w[r]=(255&y[n+3])<<24|(255&y[n+2])<<16|(255&y[n+1])<<8|255&y[n+0]}const g=new Uint32Array(64*i),d=new Uint32Array(32*i*f),m=32*i,b=new Uint32Array(16),A=new Uint32Array(16),U=a*f*2;let E,k,I=0,N=null,x=!1,v=0,L=0;const P=h?parseInt(1e3/i):4294967295,S="undefined"!=typeof setImmediate?setImmediate:setTimeout,T=function(){if(x)return h(new Error("cancelled"),I/U);let n;switch(v){case 0:k=32*L*i,s(w,k,g,0,m),v=1,E=0;case 1:n=f-E,n>P&&(n=P);for(let r=0;r<n;r++)s(g,0,d,(E+r)*m,m),o(g,m,i,b,A);if(E+=n,I+=n,h){const r=parseInt(1e3*I/U);if(r!==N){if(x=h(null,I/U),x)break;N=r}}if(E<f)break;E=0,v=2;case 2:n=f-E,n>P&&(n=P);for(let r=0;r<n;r++){const r=g[16*(2*i-1)]&f-1;u(d,r*m,g,m),o(g,m,i,b,A)}if(E+=n,I+=n,h){const r=parseInt(1e3*I/U);if(r!==N){if(x=h(null,I/U),x)break;N=r}}if(E<f)break;if(s(g,0,w,k,m),L++,L<a){v=0;break}y=[];for(let r=0;r<w.length;r++)y.push(255&w[r]),y.push(w[r]>>8&255),y.push(w[r]>>16&255),y.push(w[r]>>24&255);const t=e(r,y,p);return h&&h(null,1,t),t}h&&S(T)};if(!h)for(;;){const r=T();if(null!=r)return r}T()}const p={scrypt:function(r,n,t,e,o,f,i){return new Promise(function(u,s){let c=0;i&&i(0),a(r,n,t,e,o,f,function(r,n,t){if(r)s(r);else if(t)i&&1!==c&&i(1),u(new Uint8Array(t));else if(i&&n!==c)return c=n,i(n)})})},syncScrypt:function(r,n,t,e,o,f){return new Uint8Array(a(r,n,t,e,o,f))}};"undefined"!=typeof exports?module.exports=p:"function"==typeof define&&define.amd?define(p):r&&(r.scrypt&&(r._scrypt=r.scrypt),r.scrypt=p)}(this);