diff --git a/nacl-fast.js b/nacl-fast.js index d5badd2a..f1c61781 100644 --- a/nacl-fast.js +++ b/nacl-fast.js @@ -790,19 +790,13 @@ function crypto_box_open(m, c, d, n, y, x) { } function add64() { - var a = 0, b = 0, c = 0, d = 0, m16 = 65535, l, h, i; + var l = 0, h = 0, i, t; for (i = 0; i < arguments.length; i++) { - l = arguments[i].lo; - h = arguments[i].hi; - a += (l & m16); b += (l >>> 16); - c += (h & m16); d += (h >>> 16); + t = l; + l = (t + arguments[i].lo)>>>0; + h = (h + arguments[i].hi + ((l>>0; } - - b += (a >>> 16); - c += (b >>> 16); - d += (c >>> 16); - - return new u64((c & m16) | (d << 16), (a & m16) | (b << 16)); + return new u64(h, l); } function shr64(x, c) { diff --git a/nacl-fast.min.js b/nacl-fast.min.js index e39f85d8..5b94a28a 100644 --- a/nacl-fast.min.js +++ b/nacl-fast.min.js @@ -1 +1 @@ -!function(r){"use strict";function n(r,n){var t=255&r[n+3];return t=t<<8|255&r[n+2],t=t<<8|255&r[n+1],t<<8|255&r[n+0]}function t(r,n){var t=r[n]<<24|r[n+1]<<16|r[n+2]<<8|r[n+3],e=r[n+4]<<24|r[n+5]<<16|r[n+6]<<8|r[n+7];return new ln(t,e)}function e(r,n,t){var e;for(e=0;4>e;e++)r[n+e]=255&t,t>>>=8}function o(r,n,t){r[n]=t.hi>>24&255,r[n+1]=t.hi>>16&255,r[n+2]=t.hi>>8&255,r[n+3]=255&t.hi,r[n+4]=t.lo>>24&255,r[n+5]=t.lo>>16&255,r[n+6]=t.lo>>8&255,r[n+7]=255&t.lo}function i(r,n,t,e,o){var i,f=0;for(i=0;o>i;i++)f|=r[n+i]^t[e+i];return(1&f-1>>>8)-1}function f(r,n,t,e){return i(r,n,t,e,16)}function h(r,n,t,e){return i(r,n,t,e,32)}function a(r,t,o,i){for(var f,h=n(i,0),a=n(o,0),u=n(o,4),s=n(o,8),c=n(o,12),w=n(i,4),y=n(t,0),l=n(t,4),v=n(t,8),p=n(t,12),b=n(i,8),g=n(o,16),A=n(o,20),_=n(o,24),U=n(o,28),d=n(i,12),E=h,x=a,m=u,B=s,S=c,T=w,Y=y,K=l,k=v,C=p,L=b,R=g,z=A,P=_,F=U,N=d,O=0;20>O;O+=2)f=E+z|0,S^=f<<7|f>>>25,f=S+E|0,k^=f<<9|f>>>23,f=k+S|0,z^=f<<13|f>>>19,f=z+k|0,E^=f<<18|f>>>14,f=T+x|0,C^=f<<7|f>>>25,f=C+T|0,P^=f<<9|f>>>23,f=P+C|0,x^=f<<13|f>>>19,f=x+P|0,T^=f<<18|f>>>14,f=L+Y|0,F^=f<<7|f>>>25,f=F+L|0,m^=f<<9|f>>>23,f=m+F|0,Y^=f<<13|f>>>19,f=Y+m|0,L^=f<<18|f>>>14,f=N+R|0,B^=f<<7|f>>>25,f=B+N|0,K^=f<<9|f>>>23,f=K+B|0,R^=f<<13|f>>>19,f=R+K|0,N^=f<<18|f>>>14,f=E+B|0,x^=f<<7|f>>>25,f=x+E|0,m^=f<<9|f>>>23,f=m+x|0,B^=f<<13|f>>>19,f=B+m|0,E^=f<<18|f>>>14,f=T+S|0,Y^=f<<7|f>>>25,f=Y+T|0,K^=f<<9|f>>>23,f=K+Y|0,S^=f<<13|f>>>19,f=S+K|0,T^=f<<18|f>>>14,f=L+C|0,R^=f<<7|f>>>25,f=R+L|0,k^=f<<9|f>>>23,f=k+R|0,C^=f<<13|f>>>19,f=C+k|0,L^=f<<18|f>>>14,f=N+F|0,z^=f<<7|f>>>25,f=z+N|0,P^=f<<9|f>>>23,f=P+z|0,F^=f<<13|f>>>19,f=F+P|0,N^=f<<18|f>>>14;E=E+h|0,x=x+a|0,m=m+u|0,B=B+s|0,S=S+c|0,T=T+w|0,Y=Y+y|0,K=K+l|0,k=k+v|0,C=C+p|0,L=L+b|0,R=R+g|0,z=z+A|0,P=P+_|0,F=F+U|0,N=N+d|0,e(r,0,E),e(r,4,x),e(r,8,m),e(r,12,B),e(r,16,S),e(r,20,T),e(r,24,Y),e(r,28,K),e(r,32,k),e(r,36,C),e(r,40,L),e(r,44,R),e(r,48,z),e(r,52,P),e(r,56,F),e(r,60,N)}function u(r,t,o,i){for(var f,h=n(i,0),a=n(o,0),u=n(o,4),s=n(o,8),c=n(o,12),w=n(i,4),y=n(t,0),l=n(t,4),v=n(t,8),p=n(t,12),b=n(i,8),g=n(o,16),A=n(o,20),_=n(o,24),U=n(o,28),d=n(i,12),E=h,x=a,m=u,B=s,S=c,T=w,Y=y,K=l,k=v,C=p,L=b,R=g,z=A,P=_,F=U,N=d,O=0;20>O;O+=2)f=E+z|0,S^=f<<7|f>>>25,f=S+E|0,k^=f<<9|f>>>23,f=k+S|0,z^=f<<13|f>>>19,f=z+k|0,E^=f<<18|f>>>14,f=T+x|0,C^=f<<7|f>>>25,f=C+T|0,P^=f<<9|f>>>23,f=P+C|0,x^=f<<13|f>>>19,f=x+P|0,T^=f<<18|f>>>14,f=L+Y|0,F^=f<<7|f>>>25,f=F+L|0,m^=f<<9|f>>>23,f=m+F|0,Y^=f<<13|f>>>19,f=Y+m|0,L^=f<<18|f>>>14,f=N+R|0,B^=f<<7|f>>>25,f=B+N|0,K^=f<<9|f>>>23,f=K+B|0,R^=f<<13|f>>>19,f=R+K|0,N^=f<<18|f>>>14,f=E+B|0,x^=f<<7|f>>>25,f=x+E|0,m^=f<<9|f>>>23,f=m+x|0,B^=f<<13|f>>>19,f=B+m|0,E^=f<<18|f>>>14,f=T+S|0,Y^=f<<7|f>>>25,f=Y+T|0,K^=f<<9|f>>>23,f=K+Y|0,S^=f<<13|f>>>19,f=S+K|0,T^=f<<18|f>>>14,f=L+C|0,R^=f<<7|f>>>25,f=R+L|0,k^=f<<9|f>>>23,f=k+R|0,C^=f<<13|f>>>19,f=C+k|0,L^=f<<18|f>>>14,f=N+F|0,z^=f<<7|f>>>25,f=z+N|0,P^=f<<9|f>>>23,f=P+z|0,F^=f<<13|f>>>19,f=F+P|0,N^=f<<18|f>>>14;e(r,0,E),e(r,4,T),e(r,8,L),e(r,12,N),e(r,16,Y),e(r,20,K),e(r,24,k),e(r,28,C)}function s(r,n,t,e){a(r,n,t,e)}function c(r,n,t,e){u(r,n,t,e)}function w(r,n,t,e,o,i,f){var h,a,u=new Uint8Array(16),c=new Uint8Array(64);for(a=0;16>a;a++)u[a]=0;for(a=0;8>a;a++)u[a]=i[a];for(;o>=64;){for(s(c,u,f,Sn),a=0;64>a;a++)r[n+a]=t[e+a]^c[a];for(h=1,a=8;16>a;a++)h=h+(255&u[a])|0,u[a]=255&h,h>>>=8;o-=64,n+=64,e+=64}if(o>0)for(s(c,u,f,Sn),a=0;o>a;a++)r[n+a]=t[e+a]^c[a];return 0}function y(r,n,t,e,o){var i,f,h=new Uint8Array(16),a=new Uint8Array(64);for(f=0;16>f;f++)h[f]=0;for(f=0;8>f;f++)h[f]=e[f];for(;t>=64;){for(s(a,h,o,Sn),f=0;64>f;f++)r[n+f]=a[f];for(i=1,f=8;16>f;f++)i=i+(255&h[f])|0,h[f]=255&i,i>>>=8;t-=64,n+=64}if(t>0)for(s(a,h,o,Sn),f=0;t>f;f++)r[n+f]=a[f];return 0}function l(r,n,t,e,o){var i=new Uint8Array(32);c(i,e,o,Sn);for(var f=new Uint8Array(8),h=0;8>h;h++)f[h]=e[h+16];return y(r,n,t,f,i)}function v(r,n,t,e,o,i,f){var h=new Uint8Array(32);c(h,i,f,Sn);for(var a=new Uint8Array(8),u=0;8>u;u++)a[u]=i[u+16];return w(r,n,t,e,o,a,h)}function p(r,n){return 255&r[n]|(255&r[n+1])<<8}function b(r,n,t){r[n]=t>>>0&255,r[n+1]=t>>>8&255}function g(r,n,t,e,o,i){var f=new Tn(i);return f.update(t,e,o),f.finish(r,n),0}function A(r,n,t,e,o,i){var h=new Uint8Array(16);return g(h,0,t,e,o,i),f(r,n,h,0)}function _(r,n,t,e,o){var i;if(32>t)return-1;for(v(r,0,n,0,t,e,o),g(r,16,r,32,t-32,r),i=0;16>i;i++)r[i]=0;return 0}function U(r,n,t,e,o){var i,f=new Uint8Array(32);if(32>t)return-1;if(l(f,0,32,e,o),0!==A(n,16,n,32,t-32,f))return-1;for(v(r,0,n,0,t,e,o),i=0;32>i;i++)r[i]=0;return 0}function d(r,n){var t;for(t=0;16>t;t++)r[t]=0|n[t]}function E(r){var n,t;for(t=0;16>t;t++)r[t]+=65536,n=Math.floor(r[t]/65536),r[(t+1)*(15>t?1:0)]+=n-1+37*(n-1)*(15===t?1:0),r[t]-=65536*n}function x(r,n,t){for(var e,o=~(t-1),i=0;16>i;i++)e=o&(r[i]^n[i]),r[i]^=e,n[i]^=e}function m(r,n){var t,e,o,i=vn(),f=vn();for(t=0;16>t;t++)f[t]=n[t];for(E(f),E(f),E(f),e=0;2>e;e++){for(i[0]=f[0]-65517,t=1;15>t;t++)i[t]=f[t]-65535-(i[t-1]>>16&1),i[t-1]&=65535;i[15]=f[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,x(f,i,1-o)}for(t=0;16>t;t++)r[2*t]=255&f[t],r[2*t+1]=f[t]>>8}function B(r,n){var t=new Uint8Array(32),e=new Uint8Array(32);return m(t,r),m(e,n),h(t,0,e,0)}function S(r){var n=new Uint8Array(32);return m(n,r),1&n[0]}function T(r,n){var t;for(t=0;16>t;t++)r[t]=n[2*t]+(n[2*t+1]<<8);r[15]&=32767}function Y(r,n,t){var e;for(e=0;16>e;e++)r[e]=n[e]+t[e]|0}function K(r,n,t){var e;for(e=0;16>e;e++)r[e]=n[e]-t[e]|0}function k(r,n,t){var e,o,i=new Float64Array(31);for(e=0;31>e;e++)i[e]=0;for(e=0;16>e;e++)for(o=0;16>o;o++)i[e+o]+=n[e]*t[o];for(e=0;15>e;e++)i[e]+=38*i[e+16];for(e=0;16>e;e++)r[e]=i[e];E(r),E(r)}function C(r,n){k(r,n,n)}function L(r,n){var t,e=vn();for(t=0;16>t;t++)e[t]=n[t];for(t=253;t>=0;t--)C(e,e),2!==t&&4!==t&&k(e,e,n);for(t=0;16>t;t++)r[t]=e[t]}function R(r,n){var t,e=vn();for(t=0;16>t;t++)e[t]=n[t];for(t=250;t>=0;t--)C(e,e),1!==t&&k(e,e,n);for(t=0;16>t;t++)r[t]=e[t]}function z(r,n,t){var e,o,i=new Uint8Array(32),f=new Float64Array(80),h=vn(),a=vn(),u=vn(),s=vn(),c=vn(),w=vn();for(o=0;31>o;o++)i[o]=n[o];for(i[31]=127&n[31]|64,i[0]&=248,T(f,t),o=0;16>o;o++)a[o]=f[o],s[o]=h[o]=u[o]=0;for(h[0]=s[0]=1,o=254;o>=0;--o)e=i[o>>>3]>>>(7&o)&1,x(h,a,e),x(u,s,e),Y(c,h,u),K(h,h,u),Y(u,a,s),K(a,a,s),C(s,c),C(w,h),k(h,u,h),k(u,a,c),Y(c,h,u),K(h,h,u),C(a,h),K(u,s,w),k(h,u,Un),Y(h,h,s),k(u,u,h),k(h,s,w),k(s,a,f),C(a,c),x(h,a,e),x(u,s,e);for(o=0;16>o;o++)f[o+16]=h[o],f[o+32]=u[o],f[o+48]=a[o],f[o+64]=s[o];var y=f.subarray(32),l=f.subarray(16);return L(y,y),k(l,l,y),m(r,l),0}function P(r,n){return z(r,n,gn)}function F(r,n){return pn(n,32),P(r,n)}function N(r,n,t){var e=new Uint8Array(32);return z(e,t,n),c(r,bn,e,Sn)}function O(r,n,t,e,o,i){var f=new Uint8Array(32);return N(f,o,i),Yn(r,n,t,e,f)}function M(r,n,t,e,o,i){var f=new Uint8Array(32);return N(f,o,i),Kn(r,n,t,e,f)}function G(){var r,n,t,e=0,o=0,i=0,f=0,h=65535;for(t=0;t>>16,i+=n&h,f+=n>>>16;return o+=e>>>16,i+=o>>>16,f+=i>>>16,new ln(i&h|f<<16,e&h|o<<16)}function I(r,n){return new ln(r.hi>>>n,r.lo>>>n|r.hi<<32-n)}function Z(){var r,n=0,t=0;for(r=0;rn?(t=r.hi>>>n|r.lo<>>n|r.hi<n&&(t=r.lo>>>n|r.hi<>>n|r.lo<f;f++)a[f]=s[f]=t(r,8*f);for(var w=0;e>=128;){for(f=0;16>f;f++)c[f]=t(n,8*f+w);for(f=0;80>f;f++){for(h=0;8>h;h++)u[h]=s[h];for(i=G(s[7],D(s[4]),V(s[4],s[5],s[6]),kn[f],c[f%16]),u[7]=G(i,X(s[0]),q(s[0],s[1],s[2])),u[3]=G(u[3],i),h=0;8>h;h++)s[(h+1)%8]=u[h];if(f%16===15)for(h=0;16>h;h++)c[h]=G(c[h],c[(h+9)%16],H(c[(h+1)%16]),J(c[(h+14)%16]))}for(f=0;8>f;f++)s[f]=G(s[f],a[f]),a[f]=s[f];w+=128,e-=128}for(f=0;8>f;f++)o(r,8*f,a[f]);return e}function W(r,n,t){var e,i=new Uint8Array(64),f=new Uint8Array(256),h=t;for(e=0;64>e;e++)i[e]=Cn[e];for(Q(i,n,t),t%=128,e=0;256>e;e++)f[e]=0;for(e=0;t>e;e++)f[e]=n[h-t+e];for(f[t]=128,t=256-128*(112>t?1:0),f[t-9]=0,o(f,t-8,new ln(h/536870912|0,h<<3)),Q(i,f,t),e=0;64>e;e++)r[e]=i[e];return 0}function $(r,n){var t=vn(),e=vn(),o=vn(),i=vn(),f=vn(),h=vn(),a=vn(),u=vn(),s=vn();K(t,r[1],r[0]),K(s,n[1],n[0]),k(t,t,s),Y(e,r[0],r[1]),Y(s,n[0],n[1]),k(e,e,s),k(o,r[3],n[3]),k(o,o,En),k(i,r[2],n[2]),Y(i,i,i),K(f,e,t),K(h,i,o),Y(a,i,o),Y(u,e,t),k(r[0],f,h),k(r[1],u,a),k(r[2],a,h),k(r[3],f,u)}function rn(r,n,t){var e;for(e=0;4>e;e++)x(r[e],n[e],t)}function nn(r,n){var t=vn(),e=vn(),o=vn();L(o,n[2]),k(t,n[0],o),k(e,n[1],o),m(r,e),r[31]^=S(t)<<7}function tn(r,n,t){var e,o;for(d(r[0],An),d(r[1],_n),d(r[2],_n),d(r[3],An),o=255;o>=0;--o)e=t[o/8|0]>>(7&o)&1,rn(r,n,e),$(n,r),$(r,r),rn(r,n,e)}function en(r,n){var t=[vn(),vn(),vn(),vn()];d(t[0],xn),d(t[1],mn),d(t[2],_n),k(t[3],xn,mn),tn(r,t,n)}function on(r,n){var t,e=new Uint8Array(64),o=[vn(),vn(),vn(),vn()];for(pn(n,32),W(e,n,32),e[0]&=248,e[31]&=127,e[31]|=64,en(o,e),nn(r,o),t=0;32>t;t++)n[t+32]=r[t];return 0}function fn(r,n){var t,e,o,i;for(e=63;e>=32;--e){for(t=0,o=e-32,i=e-12;i>o;++o)n[o]+=t-16*n[e]*Ln[o-(e-32)],t=n[o]+128>>8,n[o]-=256*t;n[o]+=t,n[e]=0}for(t=0,o=0;32>o;o++)n[o]+=t-(n[31]>>4)*Ln[o],t=n[o]>>8,n[o]&=255;for(o=0;32>o;o++)n[o]-=t*Ln[o];for(e=0;32>e;e++)n[e+1]+=n[e]>>8,r[e]=255&n[e]}function hn(r){var n,t=new Float64Array(64);for(n=0;64>n;n++)t[n]=r[n];for(n=0;64>n;n++)r[n]=0;fn(r,t)}function an(r,n,t,e){var o,i,f=new Uint8Array(64),h=new Uint8Array(64),a=new Uint8Array(64),u=new Float64Array(64),s=[vn(),vn(),vn(),vn()];W(f,e,32),f[0]&=248,f[31]&=127,f[31]|=64;var c=t+64;for(o=0;t>o;o++)r[64+o]=n[o];for(o=0;32>o;o++)r[32+o]=f[32+o];for(W(a,r.subarray(32),t+32),hn(a),en(s,a),nn(r,s),o=32;64>o;o++)r[o]=e[o];for(W(h,r,t+64),hn(h),o=0;64>o;o++)u[o]=0;for(o=0;32>o;o++)u[o]=a[o];for(o=0;32>o;o++)for(i=0;32>i;i++)u[o+i]+=h[o]*f[i];return fn(r.subarray(32),u),c}function un(r,n){var t=vn(),e=vn(),o=vn(),i=vn(),f=vn(),h=vn(),a=vn();return d(r[2],_n),T(r[1],n),C(o,r[1]),k(i,o,dn),K(o,o,r[2]),Y(i,r[2],i),C(f,i),C(h,f),k(a,h,f),k(t,a,o),k(t,t,i),R(t,t),k(t,t,o),k(t,t,i),k(t,t,i),k(r[0],t,i),C(e,r[0]),k(e,e,i),B(e,o)&&k(r[0],r[0],Bn),C(e,r[0]),k(e,e,i),B(e,o)?-1:(S(r[0])===n[31]>>7&&K(r[0],An,r[0]),k(r[3],r[0],r[1]),0)}function sn(r,n,t,e){var o,i,f=new Uint8Array(32),a=new Uint8Array(64),u=[vn(),vn(),vn(),vn()],s=[vn(),vn(),vn(),vn()];if(i=-1,64>t)return-1;if(un(s,e))return-1;for(o=0;t>o;o++)r[o]=n[o];for(o=0;32>o;o++)r[o+32]=e[o];if(W(a,r,t),hn(a),tn(u,s,a),en(s,n.subarray(32)),$(u,s),nn(f,u),t-=64,h(n,0,f,0)){for(o=0;t>o;o++)r[o]=0;return-1}for(o=0;t>o;o++)r[o]=n[o+64];return i=t}function cn(r,n){if(r.length!==Rn)throw new Error("bad key size");if(n.length!==zn)throw new Error("bad nonce size")}function wn(r,n){if(r.length!==Mn)throw new Error("bad public key size");if(n.length!==Gn)throw new Error("bad secret key size")}function yn(){for(var r,n={}.toString,t=0;t>>13|e<<3),o=p(r,4),this.r[2]=7939&(e>>>10|o<<6),i=p(r,6),this.r[3]=8191&(o>>>7|i<<9),f=p(r,8),this.r[4]=255&(i>>>4|f<<12),this.r[5]=f>>>1&8190,h=p(r,10),this.r[6]=8191&(f>>>14|h<<2),a=p(r,12),this.r[7]=8065&(h>>>11|a<<5),u=p(r,14),this.r[8]=8191&(a>>>8|u<<8),this.r[9]=u>>>5&127,n=0;8>n;n++)this.pad[n]=p(r,16+2*n)};Tn.prototype.blocks=function(r,n,t){for(var e,o,i,f,h,a,u,s,c,w,y,l=this.fin?0:2048,v=new Uint32Array(10);t>=16;){for(e=p(r,n+0),this.h[0]+=8191&e,o=p(r,n+2),this.h[1]+=8191&(e>>>13|o<<3),i=p(r,n+4),this.h[2]+=8191&(o>>>10|i<<6),f=p(r,n+6),this.h[3]+=8191&(i>>>7|f<<9),h=p(r,n+8),this.h[4]+=8191&(f>>>4|h<<12),this.h[5]+=h>>>1&8191,a=p(r,n+10),this.h[6]+=8191&(h>>>14|a<<2),u=p(r,n+12),this.h[7]+=8191&(a>>>11|u<<5),s=p(r,n+14),this.h[8]+=8191&(u>>>8|s<<8),this.h[9]+=s>>>5|l,w=0,c=0;10>w;w++){for(v[w]=c,y=0;10>y;y++)v[w]+=this.h[y]*(w>=y?this.r[w-y]:5*this.r[w+10-y]),4===y&&(c=v[w]>>>13,v[w]&=8191);c+=v[w]>>>13,v[w]&=8191}for(c=(c<<2)+c|0,c=c+v[0]|0,v[0]=8191&c,c>>>=13,v[1]+=c,w=0;10>w;w++)this.h[w]=v[w];n+=16,t-=16}},Tn.prototype.finish=function(r,n){var t,e,o,i,f=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;16>i;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(t=this.h[1]>>>13,this.h[1]&=8191,i=2;10>i;i++)this.h[i]+=t,t=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*t,t=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=t,t=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=t,f[0]=this.h[0]+5,t=f[0]>>>13,f[0]&=8191,i=1;10>i;i++)f[i]=this.h[i]+t,t=f[i]>>>13,f[i]&=8191;for(f[9]-=8192,e=(f[9]>>>15)-1,i=0;10>i;i++)f[i]&=e;for(e=~e,i=0;10>i;i++)this.h[i]=this.h[i]&e|f[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;8>i;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;for(i=0;8>i;i++)b(r,n+2*i,this.h[i])},Tn.prototype.update=function(r,n,t){var e,o;if(this.leftover){for(o=16-this.leftover,o>t&&(o=t),e=0;o>e;e++)this.buffer[this.leftover+e]=r[n+e];if(t-=o,n+=o,this.leftover+=o,this.leftover<16)return;this.blocks(buffer,0,16),this.leftover=0}if(t>=16&&(o=t-t%16,this.blocks(r,n,o),n+=o,t-=o),t){for(e=0;t>e;e++)this.buffer[this.leftover+e]=r[n+e];this.leftover+=t}};var Yn=_,Kn=U,kn=[new ln(1116352408,3609767458),new ln(1899447441,602891725),new ln(3049323471,3964484399),new ln(3921009573,2173295548),new ln(961987163,4081628472),new ln(1508970993,3053834265),new ln(2453635748,2937671579),new ln(2870763221,3664609560),new ln(3624381080,2734883394),new ln(310598401,1164996542),new ln(607225278,1323610764),new ln(1426881987,3590304994),new ln(1925078388,4068182383),new ln(2162078206,991336113),new ln(2614888103,633803317),new ln(3248222580,3479774868),new ln(3835390401,2666613458),new ln(4022224774,944711139),new ln(264347078,2341262773),new ln(604807628,2007800933),new ln(770255983,1495990901),new ln(1249150122,1856431235),new ln(1555081692,3175218132),new ln(1996064986,2198950837),new ln(2554220882,3999719339),new ln(2821834349,766784016),new ln(2952996808,2566594879),new ln(3210313671,3203337956),new ln(3336571891,1034457026),new ln(3584528711,2466948901),new ln(113926993,3758326383),new ln(338241895,168717936),new ln(666307205,1188179964),new ln(773529912,1546045734),new ln(1294757372,1522805485),new ln(1396182291,2643833823),new ln(1695183700,2343527390),new ln(1986661051,1014477480),new ln(2177026350,1206759142),new ln(2456956037,344077627),new ln(2730485921,1290863460),new ln(2820302411,3158454273),new ln(3259730800,3505952657),new ln(3345764771,106217008),new ln(3516065817,3606008344),new ln(3600352804,1432725776),new ln(4094571909,1467031594),new ln(275423344,851169720),new ln(430227734,3100823752),new ln(506948616,1363258195),new ln(659060556,3750685593),new ln(883997877,3785050280),new ln(958139571,3318307427),new ln(1322822218,3812723403),new ln(1537002063,2003034995),new ln(1747873779,3602036899),new ln(1955562222,1575990012),new ln(2024104815,1125592928),new ln(2227730452,2716904306),new ln(2361852424,442776044),new ln(2428436474,593698344),new ln(2756734187,3733110249),new ln(3204031479,2999351573),new ln(3329325298,3815920427),new ln(3391569614,3928383900),new ln(3515267271,566280711),new ln(3940187606,3454069534),new ln(4118630271,4000239992),new ln(116418474,1914138554),new ln(174292421,2731055270),new ln(289380356,3203993006),new ln(460393269,320620315),new ln(685471733,587496836),new ln(852142971,1086792851),new ln(1017036298,365543100),new ln(1126000580,2618297676),new ln(1288033470,3409855158),new ln(1501505948,4234509866),new ln(1607167915,987167468),new ln(1816402316,1246189591)],Cn=new Uint8Array([106,9,230,103,243,188,201,8,187,103,174,133,132,202,167,59,60,110,243,114,254,148,248,43,165,79,245,58,95,29,54,241,81,14,82,127,173,230,130,209,155,5,104,140,43,62,108,31,31,131,217,171,251,65,189,107,91,224,205,25,19,126,33,121]),Ln=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),Rn=32,zn=24,Pn=32,Fn=16,Nn=32,On=32,Mn=32,Gn=32,In=32,Zn=zn,jn=Pn,Vn=Fn,qn=64,Xn=32,Dn=64,Hn=64;r.lowlevel={crypto_stream_xor:v,crypto_stream:l,crypto_stream_salsa20_xor:w,crypto_stream_salsa20:y,crypto_onetimeauth:g,crypto_onetimeauth_verify:A,crypto_verify_16:f,crypto_verify_32:h,crypto_secretbox:_,crypto_secretbox_open:U,crypto_scalarmult:z,crypto_scalarmult_base:P,crypto_box_beforenm:N,crypto_box_afternm:Yn,crypto_box:O,crypto_box_open:M,crypto_box_keypair:F,crypto_hash:W,crypto_hashblocks:Q,crypto_sign:an,crypto_sign_keypair:on,crypto_sign_open:sn,crypto_secretbox_KEYBYTES:Rn,crypto_secretbox_NONCEBYTES:zn,crypto_secretbox_ZEROBYTES:Pn,crypto_secretbox_BOXZEROBYTES:Fn,crypto_scalarmult_BYTES:Nn,crypto_scalarmult_SCALARBYTES:On,crypto_box_PUBLICKEYBYTES:Mn,crypto_box_SECRETKEYBYTES:Gn,crypto_box_BEFORENMBYTES:In,crypto_box_NONCEBYTES:Zn,crypto_box_ZEROBYTES:jn,crypto_box_BOXZEROBYTES:Vn,crypto_sign_BYTES:qn,crypto_sign_PUBLICKEYBYTES:Xn,crypto_sign_SECRETKEYBYTES:Dn,crypto_hash_BYTES:Hn},r.util={},r.util.decodeUTF8=function(r){var n,t=unescape(encodeURIComponent(r)),e=new Uint8Array(t.length);for(n=0;nn;n++)t.push(String.fromCharCode(r[n]));return btoa(t.join(""))},r.util.decodeBase64=function(r){if("undefined"==typeof atob)return new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0));var n,t=atob(r),e=new Uint8Array(t.length);for(n=0;ne;e++)o[e]=n[e];for(e=0;ef?!1:i.subarray(0,f)},r.sign.keyPair=function(){var r=new Uint8Array(Xn),n=new Uint8Array(Dn);return on(r,n),{publicKey:r,secretKey:n}},r.sign.keyPair.fromSecretKey=function(r){if(yn(r),r.length!==Dn)throw new Error("bad secret key size");var n,t=new Uint8Array(Xn);for(n=0;32>n;n++)t[n]=r[32+n];return{publicKey:t,secretKey:r}},r.sign.publicKeyLength=Xn,r.sign.secretKeyLength=Dn,r.sign.signatureLength=qn,r.hash=function(r){yn(r);var n=new Uint8Array(Hn);return W(n,r,r.length),n},r.hash.hashLength=Hn,r.verify=function(r,n){return yn(r,n),0===r.length||0===n.length?!1:r.length!==n.length?!1:0===i(r,0,n,0,r.length)?!0:!1},r.setPRNG=function(r){pn=r},function(){var n;"undefined"!=typeof window?(window.crypto&&window.crypto.getRandomValues?n=window.crypto:window.msCrypto&&window.msCrypto.getRandomValues&&(n=window.msCrypto),n&&r.setPRNG(function(r,t){var e,o=new Uint8Array(t);for(n.getRandomValues(o),e=0;t>e;e++)r[e]=o[e]})):"undefined"!=typeof require&&(n=require("crypto"),n&&r.setPRNG(function(r,t){var e,o=n.randomBytes(t);for(e=0;t>e;e++)r[e]=o[e]}))}()}("undefined"!=typeof module&&module.exports?module.exports:window.nacl=window.nacl||{}); \ No newline at end of file +!function(r){"use strict";function n(r,n){var t=255&r[n+3];return t=t<<8|255&r[n+2],t=t<<8|255&r[n+1],t<<8|255&r[n+0]}function t(r,n){var t=r[n]<<24|r[n+1]<<16|r[n+2]<<8|r[n+3],e=r[n+4]<<24|r[n+5]<<16|r[n+6]<<8|r[n+7];return new ln(t,e)}function e(r,n,t){var e;for(e=0;4>e;e++)r[n+e]=255&t,t>>>=8}function o(r,n,t){r[n]=t.hi>>24&255,r[n+1]=t.hi>>16&255,r[n+2]=t.hi>>8&255,r[n+3]=255&t.hi,r[n+4]=t.lo>>24&255,r[n+5]=t.lo>>16&255,r[n+6]=t.lo>>8&255,r[n+7]=255&t.lo}function i(r,n,t,e,o){var i,f=0;for(i=0;o>i;i++)f|=r[n+i]^t[e+i];return(1&f-1>>>8)-1}function f(r,n,t,e){return i(r,n,t,e,16)}function h(r,n,t,e){return i(r,n,t,e,32)}function a(r,t,o,i){for(var f,h=n(i,0),a=n(o,0),u=n(o,4),s=n(o,8),c=n(o,12),w=n(i,4),y=n(t,0),l=n(t,4),v=n(t,8),p=n(t,12),b=n(i,8),g=n(o,16),A=n(o,20),_=n(o,24),U=n(o,28),d=n(i,12),E=h,x=a,m=u,B=s,S=c,T=w,Y=y,K=l,k=v,C=p,L=b,R=g,z=A,P=_,F=U,N=d,O=0;20>O;O+=2)f=E+z|0,S^=f<<7|f>>>25,f=S+E|0,k^=f<<9|f>>>23,f=k+S|0,z^=f<<13|f>>>19,f=z+k|0,E^=f<<18|f>>>14,f=T+x|0,C^=f<<7|f>>>25,f=C+T|0,P^=f<<9|f>>>23,f=P+C|0,x^=f<<13|f>>>19,f=x+P|0,T^=f<<18|f>>>14,f=L+Y|0,F^=f<<7|f>>>25,f=F+L|0,m^=f<<9|f>>>23,f=m+F|0,Y^=f<<13|f>>>19,f=Y+m|0,L^=f<<18|f>>>14,f=N+R|0,B^=f<<7|f>>>25,f=B+N|0,K^=f<<9|f>>>23,f=K+B|0,R^=f<<13|f>>>19,f=R+K|0,N^=f<<18|f>>>14,f=E+B|0,x^=f<<7|f>>>25,f=x+E|0,m^=f<<9|f>>>23,f=m+x|0,B^=f<<13|f>>>19,f=B+m|0,E^=f<<18|f>>>14,f=T+S|0,Y^=f<<7|f>>>25,f=Y+T|0,K^=f<<9|f>>>23,f=K+Y|0,S^=f<<13|f>>>19,f=S+K|0,T^=f<<18|f>>>14,f=L+C|0,R^=f<<7|f>>>25,f=R+L|0,k^=f<<9|f>>>23,f=k+R|0,C^=f<<13|f>>>19,f=C+k|0,L^=f<<18|f>>>14,f=N+F|0,z^=f<<7|f>>>25,f=z+N|0,P^=f<<9|f>>>23,f=P+z|0,F^=f<<13|f>>>19,f=F+P|0,N^=f<<18|f>>>14;E=E+h|0,x=x+a|0,m=m+u|0,B=B+s|0,S=S+c|0,T=T+w|0,Y=Y+y|0,K=K+l|0,k=k+v|0,C=C+p|0,L=L+b|0,R=R+g|0,z=z+A|0,P=P+_|0,F=F+U|0,N=N+d|0,e(r,0,E),e(r,4,x),e(r,8,m),e(r,12,B),e(r,16,S),e(r,20,T),e(r,24,Y),e(r,28,K),e(r,32,k),e(r,36,C),e(r,40,L),e(r,44,R),e(r,48,z),e(r,52,P),e(r,56,F),e(r,60,N)}function u(r,t,o,i){for(var f,h=n(i,0),a=n(o,0),u=n(o,4),s=n(o,8),c=n(o,12),w=n(i,4),y=n(t,0),l=n(t,4),v=n(t,8),p=n(t,12),b=n(i,8),g=n(o,16),A=n(o,20),_=n(o,24),U=n(o,28),d=n(i,12),E=h,x=a,m=u,B=s,S=c,T=w,Y=y,K=l,k=v,C=p,L=b,R=g,z=A,P=_,F=U,N=d,O=0;20>O;O+=2)f=E+z|0,S^=f<<7|f>>>25,f=S+E|0,k^=f<<9|f>>>23,f=k+S|0,z^=f<<13|f>>>19,f=z+k|0,E^=f<<18|f>>>14,f=T+x|0,C^=f<<7|f>>>25,f=C+T|0,P^=f<<9|f>>>23,f=P+C|0,x^=f<<13|f>>>19,f=x+P|0,T^=f<<18|f>>>14,f=L+Y|0,F^=f<<7|f>>>25,f=F+L|0,m^=f<<9|f>>>23,f=m+F|0,Y^=f<<13|f>>>19,f=Y+m|0,L^=f<<18|f>>>14,f=N+R|0,B^=f<<7|f>>>25,f=B+N|0,K^=f<<9|f>>>23,f=K+B|0,R^=f<<13|f>>>19,f=R+K|0,N^=f<<18|f>>>14,f=E+B|0,x^=f<<7|f>>>25,f=x+E|0,m^=f<<9|f>>>23,f=m+x|0,B^=f<<13|f>>>19,f=B+m|0,E^=f<<18|f>>>14,f=T+S|0,Y^=f<<7|f>>>25,f=Y+T|0,K^=f<<9|f>>>23,f=K+Y|0,S^=f<<13|f>>>19,f=S+K|0,T^=f<<18|f>>>14,f=L+C|0,R^=f<<7|f>>>25,f=R+L|0,k^=f<<9|f>>>23,f=k+R|0,C^=f<<13|f>>>19,f=C+k|0,L^=f<<18|f>>>14,f=N+F|0,z^=f<<7|f>>>25,f=z+N|0,P^=f<<9|f>>>23,f=P+z|0,F^=f<<13|f>>>19,f=F+P|0,N^=f<<18|f>>>14;e(r,0,E),e(r,4,T),e(r,8,L),e(r,12,N),e(r,16,Y),e(r,20,K),e(r,24,k),e(r,28,C)}function s(r,n,t,e){a(r,n,t,e)}function c(r,n,t,e){u(r,n,t,e)}function w(r,n,t,e,o,i,f){var h,a,u=new Uint8Array(16),c=new Uint8Array(64);for(a=0;16>a;a++)u[a]=0;for(a=0;8>a;a++)u[a]=i[a];for(;o>=64;){for(s(c,u,f,Sn),a=0;64>a;a++)r[n+a]=t[e+a]^c[a];for(h=1,a=8;16>a;a++)h=h+(255&u[a])|0,u[a]=255&h,h>>>=8;o-=64,n+=64,e+=64}if(o>0)for(s(c,u,f,Sn),a=0;o>a;a++)r[n+a]=t[e+a]^c[a];return 0}function y(r,n,t,e,o){var i,f,h=new Uint8Array(16),a=new Uint8Array(64);for(f=0;16>f;f++)h[f]=0;for(f=0;8>f;f++)h[f]=e[f];for(;t>=64;){for(s(a,h,o,Sn),f=0;64>f;f++)r[n+f]=a[f];for(i=1,f=8;16>f;f++)i=i+(255&h[f])|0,h[f]=255&i,i>>>=8;t-=64,n+=64}if(t>0)for(s(a,h,o,Sn),f=0;t>f;f++)r[n+f]=a[f];return 0}function l(r,n,t,e,o){var i=new Uint8Array(32);c(i,e,o,Sn);for(var f=new Uint8Array(8),h=0;8>h;h++)f[h]=e[h+16];return y(r,n,t,f,i)}function v(r,n,t,e,o,i,f){var h=new Uint8Array(32);c(h,i,f,Sn);for(var a=new Uint8Array(8),u=0;8>u;u++)a[u]=i[u+16];return w(r,n,t,e,o,a,h)}function p(r,n){return 255&r[n]|(255&r[n+1])<<8}function b(r,n,t){r[n]=t>>>0&255,r[n+1]=t>>>8&255}function g(r,n,t,e,o,i){var f=new Tn(i);return f.update(t,e,o),f.finish(r,n),0}function A(r,n,t,e,o,i){var h=new Uint8Array(16);return g(h,0,t,e,o,i),f(r,n,h,0)}function _(r,n,t,e,o){var i;if(32>t)return-1;for(v(r,0,n,0,t,e,o),g(r,16,r,32,t-32,r),i=0;16>i;i++)r[i]=0;return 0}function U(r,n,t,e,o){var i,f=new Uint8Array(32);if(32>t)return-1;if(l(f,0,32,e,o),0!==A(n,16,n,32,t-32,f))return-1;for(v(r,0,n,0,t,e,o),i=0;32>i;i++)r[i]=0;return 0}function d(r,n){var t;for(t=0;16>t;t++)r[t]=0|n[t]}function E(r){var n,t;for(t=0;16>t;t++)r[t]+=65536,n=Math.floor(r[t]/65536),r[(t+1)*(15>t?1:0)]+=n-1+37*(n-1)*(15===t?1:0),r[t]-=65536*n}function x(r,n,t){for(var e,o=~(t-1),i=0;16>i;i++)e=o&(r[i]^n[i]),r[i]^=e,n[i]^=e}function m(r,n){var t,e,o,i=vn(),f=vn();for(t=0;16>t;t++)f[t]=n[t];for(E(f),E(f),E(f),e=0;2>e;e++){for(i[0]=f[0]-65517,t=1;15>t;t++)i[t]=f[t]-65535-(i[t-1]>>16&1),i[t-1]&=65535;i[15]=f[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,x(f,i,1-o)}for(t=0;16>t;t++)r[2*t]=255&f[t],r[2*t+1]=f[t]>>8}function B(r,n){var t=new Uint8Array(32),e=new Uint8Array(32);return m(t,r),m(e,n),h(t,0,e,0)}function S(r){var n=new Uint8Array(32);return m(n,r),1&n[0]}function T(r,n){var t;for(t=0;16>t;t++)r[t]=n[2*t]+(n[2*t+1]<<8);r[15]&=32767}function Y(r,n,t){var e;for(e=0;16>e;e++)r[e]=n[e]+t[e]|0}function K(r,n,t){var e;for(e=0;16>e;e++)r[e]=n[e]-t[e]|0}function k(r,n,t){var e,o,i=new Float64Array(31);for(e=0;31>e;e++)i[e]=0;for(e=0;16>e;e++)for(o=0;16>o;o++)i[e+o]+=n[e]*t[o];for(e=0;15>e;e++)i[e]+=38*i[e+16];for(e=0;16>e;e++)r[e]=i[e];E(r),E(r)}function C(r,n){k(r,n,n)}function L(r,n){var t,e=vn();for(t=0;16>t;t++)e[t]=n[t];for(t=253;t>=0;t--)C(e,e),2!==t&&4!==t&&k(e,e,n);for(t=0;16>t;t++)r[t]=e[t]}function R(r,n){var t,e=vn();for(t=0;16>t;t++)e[t]=n[t];for(t=250;t>=0;t--)C(e,e),1!==t&&k(e,e,n);for(t=0;16>t;t++)r[t]=e[t]}function z(r,n,t){var e,o,i=new Uint8Array(32),f=new Float64Array(80),h=vn(),a=vn(),u=vn(),s=vn(),c=vn(),w=vn();for(o=0;31>o;o++)i[o]=n[o];for(i[31]=127&n[31]|64,i[0]&=248,T(f,t),o=0;16>o;o++)a[o]=f[o],s[o]=h[o]=u[o]=0;for(h[0]=s[0]=1,o=254;o>=0;--o)e=i[o>>>3]>>>(7&o)&1,x(h,a,e),x(u,s,e),Y(c,h,u),K(h,h,u),Y(u,a,s),K(a,a,s),C(s,c),C(w,h),k(h,u,h),k(u,a,c),Y(c,h,u),K(h,h,u),C(a,h),K(u,s,w),k(h,u,Un),Y(h,h,s),k(u,u,h),k(h,s,w),k(s,a,f),C(a,c),x(h,a,e),x(u,s,e);for(o=0;16>o;o++)f[o+16]=h[o],f[o+32]=u[o],f[o+48]=a[o],f[o+64]=s[o];var y=f.subarray(32),l=f.subarray(16);return L(y,y),k(l,l,y),m(r,l),0}function P(r,n){return z(r,n,gn)}function F(r,n){return pn(n,32),P(r,n)}function N(r,n,t){var e=new Uint8Array(32);return z(e,t,n),c(r,bn,e,Sn)}function O(r,n,t,e,o,i){var f=new Uint8Array(32);return N(f,o,i),Yn(r,n,t,e,f)}function M(r,n,t,e,o,i){var f=new Uint8Array(32);return N(f,o,i),Kn(r,n,t,e,f)}function G(){var r,n,t=0,e=0;for(r=0;r>>0,e=e+arguments[r].hi+(n>t?1:0)>>>0;return new ln(e,t)}function I(r,n){return new ln(r.hi>>>n,r.lo>>>n|r.hi<<32-n)}function Z(){var r,n=0,t=0;for(r=0;rn?(t=r.hi>>>n|r.lo<>>n|r.hi<n&&(t=r.lo>>>n|r.hi<>>n|r.lo<f;f++)a[f]=s[f]=t(r,8*f);for(var w=0;e>=128;){for(f=0;16>f;f++)c[f]=t(n,8*f+w);for(f=0;80>f;f++){for(h=0;8>h;h++)u[h]=s[h];for(i=G(s[7],D(s[4]),V(s[4],s[5],s[6]),kn[f],c[f%16]),u[7]=G(i,X(s[0]),q(s[0],s[1],s[2])),u[3]=G(u[3],i),h=0;8>h;h++)s[(h+1)%8]=u[h];if(f%16===15)for(h=0;16>h;h++)c[h]=G(c[h],c[(h+9)%16],H(c[(h+1)%16]),J(c[(h+14)%16]))}for(f=0;8>f;f++)s[f]=G(s[f],a[f]),a[f]=s[f];w+=128,e-=128}for(f=0;8>f;f++)o(r,8*f,a[f]);return e}function W(r,n,t){var e,i=new Uint8Array(64),f=new Uint8Array(256),h=t;for(e=0;64>e;e++)i[e]=Cn[e];for(Q(i,n,t),t%=128,e=0;256>e;e++)f[e]=0;for(e=0;t>e;e++)f[e]=n[h-t+e];for(f[t]=128,t=256-128*(112>t?1:0),f[t-9]=0,o(f,t-8,new ln(h/536870912|0,h<<3)),Q(i,f,t),e=0;64>e;e++)r[e]=i[e];return 0}function $(r,n){var t=vn(),e=vn(),o=vn(),i=vn(),f=vn(),h=vn(),a=vn(),u=vn(),s=vn();K(t,r[1],r[0]),K(s,n[1],n[0]),k(t,t,s),Y(e,r[0],r[1]),Y(s,n[0],n[1]),k(e,e,s),k(o,r[3],n[3]),k(o,o,En),k(i,r[2],n[2]),Y(i,i,i),K(f,e,t),K(h,i,o),Y(a,i,o),Y(u,e,t),k(r[0],f,h),k(r[1],u,a),k(r[2],a,h),k(r[3],f,u)}function rn(r,n,t){var e;for(e=0;4>e;e++)x(r[e],n[e],t)}function nn(r,n){var t=vn(),e=vn(),o=vn();L(o,n[2]),k(t,n[0],o),k(e,n[1],o),m(r,e),r[31]^=S(t)<<7}function tn(r,n,t){var e,o;for(d(r[0],An),d(r[1],_n),d(r[2],_n),d(r[3],An),o=255;o>=0;--o)e=t[o/8|0]>>(7&o)&1,rn(r,n,e),$(n,r),$(r,r),rn(r,n,e)}function en(r,n){var t=[vn(),vn(),vn(),vn()];d(t[0],xn),d(t[1],mn),d(t[2],_n),k(t[3],xn,mn),tn(r,t,n)}function on(r,n){var t,e=new Uint8Array(64),o=[vn(),vn(),vn(),vn()];for(pn(n,32),W(e,n,32),e[0]&=248,e[31]&=127,e[31]|=64,en(o,e),nn(r,o),t=0;32>t;t++)n[t+32]=r[t];return 0}function fn(r,n){var t,e,o,i;for(e=63;e>=32;--e){for(t=0,o=e-32,i=e-12;i>o;++o)n[o]+=t-16*n[e]*Ln[o-(e-32)],t=n[o]+128>>8,n[o]-=256*t;n[o]+=t,n[e]=0}for(t=0,o=0;32>o;o++)n[o]+=t-(n[31]>>4)*Ln[o],t=n[o]>>8,n[o]&=255;for(o=0;32>o;o++)n[o]-=t*Ln[o];for(e=0;32>e;e++)n[e+1]+=n[e]>>8,r[e]=255&n[e]}function hn(r){var n,t=new Float64Array(64);for(n=0;64>n;n++)t[n]=r[n];for(n=0;64>n;n++)r[n]=0;fn(r,t)}function an(r,n,t,e){var o,i,f=new Uint8Array(64),h=new Uint8Array(64),a=new Uint8Array(64),u=new Float64Array(64),s=[vn(),vn(),vn(),vn()];W(f,e,32),f[0]&=248,f[31]&=127,f[31]|=64;var c=t+64;for(o=0;t>o;o++)r[64+o]=n[o];for(o=0;32>o;o++)r[32+o]=f[32+o];for(W(a,r.subarray(32),t+32),hn(a),en(s,a),nn(r,s),o=32;64>o;o++)r[o]=e[o];for(W(h,r,t+64),hn(h),o=0;64>o;o++)u[o]=0;for(o=0;32>o;o++)u[o]=a[o];for(o=0;32>o;o++)for(i=0;32>i;i++)u[o+i]+=h[o]*f[i];return fn(r.subarray(32),u),c}function un(r,n){var t=vn(),e=vn(),o=vn(),i=vn(),f=vn(),h=vn(),a=vn();return d(r[2],_n),T(r[1],n),C(o,r[1]),k(i,o,dn),K(o,o,r[2]),Y(i,r[2],i),C(f,i),C(h,f),k(a,h,f),k(t,a,o),k(t,t,i),R(t,t),k(t,t,o),k(t,t,i),k(t,t,i),k(r[0],t,i),C(e,r[0]),k(e,e,i),B(e,o)&&k(r[0],r[0],Bn),C(e,r[0]),k(e,e,i),B(e,o)?-1:(S(r[0])===n[31]>>7&&K(r[0],An,r[0]),k(r[3],r[0],r[1]),0)}function sn(r,n,t,e){var o,i,f=new Uint8Array(32),a=new Uint8Array(64),u=[vn(),vn(),vn(),vn()],s=[vn(),vn(),vn(),vn()];if(i=-1,64>t)return-1;if(un(s,e))return-1;for(o=0;t>o;o++)r[o]=n[o];for(o=0;32>o;o++)r[o+32]=e[o];if(W(a,r,t),hn(a),tn(u,s,a),en(s,n.subarray(32)),$(u,s),nn(f,u),t-=64,h(n,0,f,0)){for(o=0;t>o;o++)r[o]=0;return-1}for(o=0;t>o;o++)r[o]=n[o+64];return i=t}function cn(r,n){if(r.length!==Rn)throw new Error("bad key size");if(n.length!==zn)throw new Error("bad nonce size")}function wn(r,n){if(r.length!==Mn)throw new Error("bad public key size");if(n.length!==Gn)throw new Error("bad secret key size")}function yn(){for(var r,n={}.toString,t=0;t>>13|e<<3),o=p(r,4),this.r[2]=7939&(e>>>10|o<<6),i=p(r,6),this.r[3]=8191&(o>>>7|i<<9),f=p(r,8),this.r[4]=255&(i>>>4|f<<12),this.r[5]=f>>>1&8190,h=p(r,10),this.r[6]=8191&(f>>>14|h<<2),a=p(r,12),this.r[7]=8065&(h>>>11|a<<5),u=p(r,14),this.r[8]=8191&(a>>>8|u<<8),this.r[9]=u>>>5&127,n=0;8>n;n++)this.pad[n]=p(r,16+2*n)};Tn.prototype.blocks=function(r,n,t){for(var e,o,i,f,h,a,u,s,c,w,y,l=this.fin?0:2048,v=new Uint32Array(10);t>=16;){for(e=p(r,n+0),this.h[0]+=8191&e,o=p(r,n+2),this.h[1]+=8191&(e>>>13|o<<3),i=p(r,n+4),this.h[2]+=8191&(o>>>10|i<<6),f=p(r,n+6),this.h[3]+=8191&(i>>>7|f<<9),h=p(r,n+8),this.h[4]+=8191&(f>>>4|h<<12),this.h[5]+=h>>>1&8191,a=p(r,n+10),this.h[6]+=8191&(h>>>14|a<<2),u=p(r,n+12),this.h[7]+=8191&(a>>>11|u<<5),s=p(r,n+14),this.h[8]+=8191&(u>>>8|s<<8),this.h[9]+=s>>>5|l,w=0,c=0;10>w;w++){for(v[w]=c,y=0;10>y;y++)v[w]+=this.h[y]*(w>=y?this.r[w-y]:5*this.r[w+10-y]),4===y&&(c=v[w]>>>13,v[w]&=8191);c+=v[w]>>>13,v[w]&=8191}for(c=(c<<2)+c|0,c=c+v[0]|0,v[0]=8191&c,c>>>=13,v[1]+=c,w=0;10>w;w++)this.h[w]=v[w];n+=16,t-=16}},Tn.prototype.finish=function(r,n){var t,e,o,i,f=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;16>i;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(t=this.h[1]>>>13,this.h[1]&=8191,i=2;10>i;i++)this.h[i]+=t,t=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*t,t=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=t,t=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=t,f[0]=this.h[0]+5,t=f[0]>>>13,f[0]&=8191,i=1;10>i;i++)f[i]=this.h[i]+t,t=f[i]>>>13,f[i]&=8191;for(f[9]-=8192,e=(f[9]>>>15)-1,i=0;10>i;i++)f[i]&=e;for(e=~e,i=0;10>i;i++)this.h[i]=this.h[i]&e|f[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;8>i;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;for(i=0;8>i;i++)b(r,n+2*i,this.h[i])},Tn.prototype.update=function(r,n,t){var e,o;if(this.leftover){for(o=16-this.leftover,o>t&&(o=t),e=0;o>e;e++)this.buffer[this.leftover+e]=r[n+e];if(t-=o,n+=o,this.leftover+=o,this.leftover<16)return;this.blocks(buffer,0,16),this.leftover=0}if(t>=16&&(o=t-t%16,this.blocks(r,n,o),n+=o,t-=o),t){for(e=0;t>e;e++)this.buffer[this.leftover+e]=r[n+e];this.leftover+=t}};var Yn=_,Kn=U,kn=[new ln(1116352408,3609767458),new ln(1899447441,602891725),new ln(3049323471,3964484399),new ln(3921009573,2173295548),new ln(961987163,4081628472),new ln(1508970993,3053834265),new ln(2453635748,2937671579),new ln(2870763221,3664609560),new ln(3624381080,2734883394),new ln(310598401,1164996542),new ln(607225278,1323610764),new ln(1426881987,3590304994),new ln(1925078388,4068182383),new ln(2162078206,991336113),new ln(2614888103,633803317),new ln(3248222580,3479774868),new ln(3835390401,2666613458),new ln(4022224774,944711139),new ln(264347078,2341262773),new ln(604807628,2007800933),new ln(770255983,1495990901),new ln(1249150122,1856431235),new ln(1555081692,3175218132),new ln(1996064986,2198950837),new ln(2554220882,3999719339),new ln(2821834349,766784016),new ln(2952996808,2566594879),new ln(3210313671,3203337956),new ln(3336571891,1034457026),new ln(3584528711,2466948901),new ln(113926993,3758326383),new ln(338241895,168717936),new ln(666307205,1188179964),new ln(773529912,1546045734),new ln(1294757372,1522805485),new ln(1396182291,2643833823),new ln(1695183700,2343527390),new ln(1986661051,1014477480),new ln(2177026350,1206759142),new ln(2456956037,344077627),new ln(2730485921,1290863460),new ln(2820302411,3158454273),new ln(3259730800,3505952657),new ln(3345764771,106217008),new ln(3516065817,3606008344),new ln(3600352804,1432725776),new ln(4094571909,1467031594),new ln(275423344,851169720),new ln(430227734,3100823752),new ln(506948616,1363258195),new ln(659060556,3750685593),new ln(883997877,3785050280),new ln(958139571,3318307427),new ln(1322822218,3812723403),new ln(1537002063,2003034995),new ln(1747873779,3602036899),new ln(1955562222,1575990012),new ln(2024104815,1125592928),new ln(2227730452,2716904306),new ln(2361852424,442776044),new ln(2428436474,593698344),new ln(2756734187,3733110249),new ln(3204031479,2999351573),new ln(3329325298,3815920427),new ln(3391569614,3928383900),new ln(3515267271,566280711),new ln(3940187606,3454069534),new ln(4118630271,4000239992),new ln(116418474,1914138554),new ln(174292421,2731055270),new ln(289380356,3203993006),new ln(460393269,320620315),new ln(685471733,587496836),new ln(852142971,1086792851),new ln(1017036298,365543100),new ln(1126000580,2618297676),new ln(1288033470,3409855158),new ln(1501505948,4234509866),new ln(1607167915,987167468),new ln(1816402316,1246189591)],Cn=new Uint8Array([106,9,230,103,243,188,201,8,187,103,174,133,132,202,167,59,60,110,243,114,254,148,248,43,165,79,245,58,95,29,54,241,81,14,82,127,173,230,130,209,155,5,104,140,43,62,108,31,31,131,217,171,251,65,189,107,91,224,205,25,19,126,33,121]),Ln=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),Rn=32,zn=24,Pn=32,Fn=16,Nn=32,On=32,Mn=32,Gn=32,In=32,Zn=zn,jn=Pn,Vn=Fn,qn=64,Xn=32,Dn=64,Hn=64;r.lowlevel={crypto_stream_xor:v,crypto_stream:l,crypto_stream_salsa20_xor:w,crypto_stream_salsa20:y,crypto_onetimeauth:g,crypto_onetimeauth_verify:A,crypto_verify_16:f,crypto_verify_32:h,crypto_secretbox:_,crypto_secretbox_open:U,crypto_scalarmult:z,crypto_scalarmult_base:P,crypto_box_beforenm:N,crypto_box_afternm:Yn,crypto_box:O,crypto_box_open:M,crypto_box_keypair:F,crypto_hash:W,crypto_hashblocks:Q,crypto_sign:an,crypto_sign_keypair:on,crypto_sign_open:sn,crypto_secretbox_KEYBYTES:Rn,crypto_secretbox_NONCEBYTES:zn,crypto_secretbox_ZEROBYTES:Pn,crypto_secretbox_BOXZEROBYTES:Fn,crypto_scalarmult_BYTES:Nn,crypto_scalarmult_SCALARBYTES:On,crypto_box_PUBLICKEYBYTES:Mn,crypto_box_SECRETKEYBYTES:Gn,crypto_box_BEFORENMBYTES:In,crypto_box_NONCEBYTES:Zn,crypto_box_ZEROBYTES:jn,crypto_box_BOXZEROBYTES:Vn,crypto_sign_BYTES:qn,crypto_sign_PUBLICKEYBYTES:Xn,crypto_sign_SECRETKEYBYTES:Dn,crypto_hash_BYTES:Hn},r.util={},r.util.decodeUTF8=function(r){var n,t=unescape(encodeURIComponent(r)),e=new Uint8Array(t.length);for(n=0;nn;n++)t.push(String.fromCharCode(r[n]));return btoa(t.join(""))},r.util.decodeBase64=function(r){if("undefined"==typeof atob)return new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0));var n,t=atob(r),e=new Uint8Array(t.length);for(n=0;ne;e++)o[e]=n[e];for(e=0;ef?!1:i.subarray(0,f)},r.sign.keyPair=function(){var r=new Uint8Array(Xn),n=new Uint8Array(Dn);return on(r,n),{publicKey:r,secretKey:n}},r.sign.keyPair.fromSecretKey=function(r){if(yn(r),r.length!==Dn)throw new Error("bad secret key size");var n,t=new Uint8Array(Xn);for(n=0;32>n;n++)t[n]=r[32+n];return{publicKey:t,secretKey:r}},r.sign.publicKeyLength=Xn,r.sign.secretKeyLength=Dn,r.sign.signatureLength=qn,r.hash=function(r){yn(r);var n=new Uint8Array(Hn);return W(n,r,r.length),n},r.hash.hashLength=Hn,r.verify=function(r,n){return yn(r,n),0===r.length||0===n.length?!1:r.length!==n.length?!1:0===i(r,0,n,0,r.length)?!0:!1},r.setPRNG=function(r){pn=r},function(){var n;"undefined"!=typeof window?(window.crypto&&window.crypto.getRandomValues?n=window.crypto:window.msCrypto&&window.msCrypto.getRandomValues&&(n=window.msCrypto),n&&r.setPRNG(function(r,t){var e,o=new Uint8Array(t);for(n.getRandomValues(o),e=0;t>e;e++)r[e]=o[e]})):"undefined"!=typeof require&&(n=require("crypto"),n&&r.setPRNG(function(r,t){var e,o=n.randomBytes(t);for(e=0;t>e;e++)r[e]=o[e]}))}()}("undefined"!=typeof module&&module.exports?module.exports:window.nacl=window.nacl||{}); \ No newline at end of file diff --git a/nacl.js b/nacl.js index 5d0eed0f..21255765 100644 --- a/nacl.js +++ b/nacl.js @@ -469,19 +469,13 @@ function crypto_box_open(m, c, d, n, y, x) { } function add64() { - var a = 0, b = 0, c = 0, d = 0, m16 = 65535, l, h, i; + var l = 0, h = 0, i, t; for (i = 0; i < arguments.length; i++) { - l = arguments[i].lo; - h = arguments[i].hi; - a += (l & m16); b += (l >>> 16); - c += (h & m16); d += (h >>> 16); + t = l; + l = (t + arguments[i].lo)>>>0; + h = (h + arguments[i].hi + ((l>>0; } - - b += (a >>> 16); - c += (b >>> 16); - d += (c >>> 16); - - return new u64((c & m16) | (d << 16), (a & m16) | (b << 16)); + return new u64(h, l); } function shr64(x, c) { diff --git a/nacl.min.js b/nacl.min.js index d5d3e6e5..bd0b19d1 100644 --- a/nacl.min.js +++ b/nacl.min.js @@ -1 +1 @@ -!function(r){"use strict";function n(r,n){return r<>>32-n}function e(r,n){var e=255&r[n+3];return e=e<<8|255&r[n+2],e=e<<8|255&r[n+1],e<<8|255&r[n+0]}function t(r,n){var e=r[n]<<24|r[n+1]<<16|r[n+2]<<8|r[n+3],t=r[n+4]<<24|r[n+5]<<16|r[n+6]<<8|r[n+7];return new sn(e,t)}function o(r,n,e){var t;for(t=0;4>t;t++)r[n+t]=255&e,e>>>=8}function i(r,n,e){r[n]=e.hi>>24&255,r[n+1]=e.hi>>16&255,r[n+2]=e.hi>>8&255,r[n+3]=255&e.hi,r[n+4]=e.lo>>24&255,r[n+5]=e.lo>>16&255,r[n+6]=e.lo>>8&255,r[n+7]=255&e.lo}function a(r,n,e,t,o){var i,a=0;for(i=0;o>i;i++)a|=r[n+i]^e[t+i];return(1&a-1>>>8)-1}function f(r,n,e,t){return a(r,n,e,t,16)}function u(r,n,e,t){return a(r,n,e,t,32)}function c(r,t,i,a,f){var u,c,w,y=new Uint32Array(16),l=new Uint32Array(16),s=new Uint32Array(16),h=new Uint32Array(4);for(u=0;4>u;u++)l[5*u]=e(a,4*u),l[1+u]=e(i,4*u),l[6+u]=e(t,4*u),l[11+u]=e(i,16+4*u);for(u=0;16>u;u++)s[u]=l[u];for(u=0;20>u;u++){for(c=0;4>c;c++){for(w=0;4>w;w++)h[w]=l[(5*c+4*w)%16];for(h[1]^=n(h[0]+h[3]|0,7),h[2]^=n(h[1]+h[0]|0,9),h[3]^=n(h[2]+h[1]|0,13),h[0]^=n(h[3]+h[2]|0,18),w=0;4>w;w++)y[4*c+(c+w)%4]=h[w]}for(w=0;16>w;w++)l[w]=y[w]}if(f){for(u=0;16>u;u++)l[u]=l[u]+s[u]|0;for(u=0;4>u;u++)l[5*u]=l[5*u]-e(a,4*u)|0,l[6+u]=l[6+u]-e(t,4*u)|0;for(u=0;4>u;u++)o(r,4*u,l[5*u]),o(r,16+4*u,l[6+u])}else for(u=0;16>u;u++)o(r,4*u,l[u]+s[u]|0)}function w(r,n,e,t){return c(r,n,e,t,!1),0}function y(r,n,e,t){return c(r,n,e,t,!0),0}function l(r,n,e,t,o,i,a){var f,u,c=new Uint8Array(16),y=new Uint8Array(64);if(!o)return 0;for(u=0;16>u;u++)c[u]=0;for(u=0;8>u;u++)c[u]=i[u];for(;o>=64;){for(w(y,c,a,Bn),u=0;64>u;u++)r[n+u]=(e?e[t+u]:0)^y[u];for(f=1,u=8;16>u;u++)f=f+(255&c[u])|0,c[u]=255&f,f>>>=8;o-=64,n+=64,e&&(t+=64)}if(o>0)for(w(y,c,a,Bn),u=0;o>u;u++)r[n+u]=(e?e[t+u]:0)^y[u];return 0}function s(r,n,e,t,o){return l(r,n,null,0,e,t,o)}function h(r,n,e,t,o){var i=new Uint8Array(32);return y(i,t,o,Bn),s(r,n,e,t.subarray(16),i)}function g(r,n,e,t,o,i,a){var f=new Uint8Array(32);return y(f,i,a,Bn),l(r,n,e,t,o,i.subarray(16),f)}function v(r,n){var e,t=0;for(e=0;17>e;e++)t=t+(r[e]+n[e]|0)|0,r[e]=255&t,t>>>=8}function b(r,n,e,t,o,i){var a,f,u,c,w=new Uint32Array(17),y=new Uint32Array(17),l=new Uint32Array(17),s=new Uint32Array(17),h=new Uint32Array(17);for(u=0;17>u;u++)y[u]=l[u]=0;for(u=0;16>u;u++)y[u]=i[u];for(y[3]&=15,y[4]&=252,y[7]&=15,y[8]&=252,y[11]&=15,y[12]&=252,y[15]&=15;o>0;){for(u=0;17>u;u++)s[u]=0;for(u=0;16>u&&o>u;++u)s[u]=e[t+u];for(s[u]=1,t+=u,o-=u,v(l,s),f=0;17>f;f++)for(w[f]=0,u=0;17>u;u++)w[f]=w[f]+l[u]*(f>=u?y[f-u]:320*y[f+17-u]|0)|0|0;for(f=0;17>f;f++)l[f]=w[f];for(c=0,u=0;16>u;u++)c=c+l[u]|0,l[u]=255&c,c>>>=8;for(c=c+l[16]|0,l[16]=3&c,c=5*(c>>>2)|0,u=0;16>u;u++)c=c+l[u]|0,l[u]=255&c,c>>>=8;c=c+l[16]|0,l[16]=c}for(u=0;17>u;u++)h[u]=l[u];for(v(l,Sn),a=0|-(l[16]>>>7),u=0;17>u;u++)l[u]^=a&(h[u]^l[u]);for(u=0;16>u;u++)s[u]=i[u+16];for(s[16]=0,v(l,s),u=0;16>u;u++)r[n+u]=l[u];return 0}function p(r,n,e,t,o,i){var a=new Uint8Array(16);return b(a,0,e,t,o,i),f(r,n,a,0)}function A(r,n,e,t,o){var i;if(32>e)return-1;for(g(r,0,n,0,e,t,o),b(r,16,r,32,e-32,r),i=0;16>i;i++)r[i]=0;return 0}function _(r,n,e,t,o){var i,a=new Uint8Array(32);if(32>e)return-1;if(h(a,0,32,t,o),0!==p(n,16,n,32,e-32,a))return-1;for(g(r,0,n,0,e,t,o),i=0;32>i;i++)r[i]=0;return 0}function U(r,n){var e;for(e=0;16>e;e++)r[e]=0|n[e]}function d(r){var n,e;for(e=0;16>e;e++)r[e]+=65536,n=Math.floor(r[e]/65536),r[(e+1)*(15>e?1:0)]+=n-1+37*(n-1)*(15===e?1:0),r[e]-=65536*n}function E(r,n,e){for(var t,o=~(e-1),i=0;16>i;i++)t=o&(r[i]^n[i]),r[i]^=t,n[i]^=t}function x(r,n){var e,t,o,i=hn(),a=hn();for(e=0;16>e;e++)a[e]=n[e];for(d(a),d(a),d(a),t=0;2>t;t++){for(i[0]=a[0]-65517,e=1;15>e;e++)i[e]=a[e]-65535-(i[e-1]>>16&1),i[e-1]&=65535;i[15]=a[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,E(a,i,1-o)}for(e=0;16>e;e++)r[2*e]=255&a[e],r[2*e+1]=a[e]>>8}function m(r,n){var e=new Uint8Array(32),t=new Uint8Array(32);return x(e,r),x(t,n),u(e,0,t,0)}function B(r){var n=new Uint8Array(32);return x(n,r),1&n[0]}function S(r,n){var e;for(e=0;16>e;e++)r[e]=n[2*e]+(n[2*e+1]<<8);r[15]&=32767}function T(r,n,e){var t;for(t=0;16>t;t++)r[t]=n[t]+e[t]|0}function Y(r,n,e){var t;for(t=0;16>t;t++)r[t]=n[t]-e[t]|0}function K(r,n,e){var t,o,i=new Float64Array(31);for(t=0;31>t;t++)i[t]=0;for(t=0;16>t;t++)for(o=0;16>o;o++)i[t+o]+=n[t]*e[o];for(t=0;15>t;t++)i[t]+=38*i[t+16];for(t=0;16>t;t++)r[t]=i[t];d(r),d(r)}function C(r,n){K(r,n,n)}function L(r,n){var e,t=hn();for(e=0;16>e;e++)t[e]=n[e];for(e=253;e>=0;e--)C(t,t),2!==e&&4!==e&&K(t,t,n);for(e=0;16>e;e++)r[e]=t[e]}function R(r,n){var e,t=hn();for(e=0;16>e;e++)t[e]=n[e];for(e=250;e>=0;e--)C(t,t),1!==e&&K(t,t,n);for(e=0;16>e;e++)r[e]=t[e]}function k(r,n,e){var t,o,i=new Uint8Array(32),a=new Float64Array(80),f=hn(),u=hn(),c=hn(),w=hn(),y=hn(),l=hn();for(o=0;31>o;o++)i[o]=n[o];for(i[31]=127&n[31]|64,i[0]&=248,S(a,e),o=0;16>o;o++)u[o]=a[o],w[o]=f[o]=c[o]=0;for(f[0]=w[0]=1,o=254;o>=0;--o)t=i[o>>>3]>>>(7&o)&1,E(f,u,t),E(c,w,t),T(y,f,c),Y(f,f,c),T(c,u,w),Y(u,u,w),C(w,y),C(l,f),K(f,c,f),K(c,u,y),T(y,f,c),Y(f,f,c),C(u,f),Y(c,w,l),K(f,c,_n),T(f,f,w),K(c,c,f),K(f,w,l),K(w,u,a),C(u,y),E(f,u,t),E(c,w,t);for(o=0;16>o;o++)a[o+16]=f[o],a[o+32]=c[o],a[o+48]=u[o],a[o+64]=w[o];var s=a.subarray(32),h=a.subarray(16);return L(s,s),K(h,h,s),x(r,h),0}function z(r,n){return k(r,n,bn)}function P(r,n){return gn(n,32),z(r,n)}function F(r,n,e){var t=new Uint8Array(32);return k(t,e,n),y(r,vn,t,Bn)}function N(r,n,e,t,o,i){var a=new Uint8Array(32);return F(a,o,i),Tn(r,n,e,t,a)}function O(r,n,e,t,o,i){var a=new Uint8Array(32);return F(a,o,i),Yn(r,n,e,t,a)}function M(){var r,n,e,t=0,o=0,i=0,a=0,f=65535;for(e=0;e>>16,i+=n&f,a+=n>>>16;return o+=t>>>16,i+=o>>>16,a+=i>>>16,new sn(i&f|a<<16,t&f|o<<16)}function G(r,n){return new sn(r.hi>>>n,r.lo>>>n|r.hi<<32-n)}function I(){var r,n=0,e=0;for(r=0;rn?(e=r.hi>>>n|r.lo<>>n|r.hi<n&&(e=r.lo>>>n|r.hi<>>n|r.lo<a;a++)u[a]=w[a]=t(r,8*a);for(var l=0;e>=128;){for(a=0;16>a;a++)y[a]=t(n,8*a+l);for(a=0;80>a;a++){for(f=0;8>f;f++)c[f]=w[f];for(o=M(w[7],X(w[4]),j(w[4],w[5],w[6]),Kn[a],y[a%16]),c[7]=M(o,q(w[0]),V(w[0],w[1],w[2])),c[3]=M(c[3],o),f=0;8>f;f++)w[(f+1)%8]=c[f];if(a%16===15)for(f=0;16>f;f++)y[f]=M(y[f],y[(f+9)%16],D(y[(f+1)%16]),H(y[(f+14)%16]))}for(a=0;8>a;a++)w[a]=M(w[a],u[a]),u[a]=w[a];l+=128,e-=128}for(a=0;8>a;a++)i(r,8*a,u[a]);return e}function Q(r,n,e){var t,o=new Uint8Array(64),a=new Uint8Array(256),f=e;for(t=0;64>t;t++)o[t]=Cn[t];for(J(o,n,e),e%=128,t=0;256>t;t++)a[t]=0;for(t=0;e>t;t++)a[t]=n[f-e+t];for(a[e]=128,e=256-128*(112>e?1:0),a[e-9]=0,i(a,e-8,new sn(f/536870912|0,f<<3)),J(o,a,e),t=0;64>t;t++)r[t]=o[t];return 0}function W(r,n){var e=hn(),t=hn(),o=hn(),i=hn(),a=hn(),f=hn(),u=hn(),c=hn(),w=hn();Y(e,r[1],r[0]),Y(w,n[1],n[0]),K(e,e,w),T(t,r[0],r[1]),T(w,n[0],n[1]),K(t,t,w),K(o,r[3],n[3]),K(o,o,dn),K(i,r[2],n[2]),T(i,i,i),Y(a,t,e),Y(f,i,o),T(u,i,o),T(c,t,e),K(r[0],a,f),K(r[1],c,u),K(r[2],u,f),K(r[3],a,c)}function $(r,n,e){var t;for(t=0;4>t;t++)E(r[t],n[t],e)}function rn(r,n){var e=hn(),t=hn(),o=hn();L(o,n[2]),K(e,n[0],o),K(t,n[1],o),x(r,t),r[31]^=B(e)<<7}function nn(r,n,e){var t,o;for(U(r[0],pn),U(r[1],An),U(r[2],An),U(r[3],pn),o=255;o>=0;--o)t=e[o/8|0]>>(7&o)&1,$(r,n,t),W(n,r),W(r,r),$(r,n,t)}function en(r,n){var e=[hn(),hn(),hn(),hn()];U(e[0],En),U(e[1],xn),U(e[2],An),K(e[3],En,xn),nn(r,e,n)}function tn(r,n){var e,t=new Uint8Array(64),o=[hn(),hn(),hn(),hn()];for(gn(n,32),Q(t,n,32),t[0]&=248,t[31]&=127,t[31]|=64,en(o,t),rn(r,o),e=0;32>e;e++)n[e+32]=r[e];return 0}function on(r,n){var e,t,o,i;for(t=63;t>=32;--t){for(e=0,o=t-32,i=t-12;i>o;++o)n[o]+=e-16*n[t]*Ln[o-(t-32)],e=n[o]+128>>8,n[o]-=256*e;n[o]+=e,n[t]=0}for(e=0,o=0;32>o;o++)n[o]+=e-(n[31]>>4)*Ln[o],e=n[o]>>8,n[o]&=255;for(o=0;32>o;o++)n[o]-=e*Ln[o];for(t=0;32>t;t++)n[t+1]+=n[t]>>8,r[t]=255&n[t]}function an(r){var n,e=new Float64Array(64);for(n=0;64>n;n++)e[n]=r[n];for(n=0;64>n;n++)r[n]=0;on(r,e)}function fn(r,n,e,t){var o,i,a=new Uint8Array(64),f=new Uint8Array(64),u=new Uint8Array(64),c=new Float64Array(64),w=[hn(),hn(),hn(),hn()];Q(a,t,32),a[0]&=248,a[31]&=127,a[31]|=64;var y=e+64;for(o=0;e>o;o++)r[64+o]=n[o];for(o=0;32>o;o++)r[32+o]=a[32+o];for(Q(u,r.subarray(32),e+32),an(u),en(w,u),rn(r,w),o=32;64>o;o++)r[o]=t[o];for(Q(f,r,e+64),an(f),o=0;64>o;o++)c[o]=0;for(o=0;32>o;o++)c[o]=u[o];for(o=0;32>o;o++)for(i=0;32>i;i++)c[o+i]+=f[o]*a[i];return on(r.subarray(32),c),y}function un(r,n){var e=hn(),t=hn(),o=hn(),i=hn(),a=hn(),f=hn(),u=hn();return U(r[2],An),S(r[1],n),C(o,r[1]),K(i,o,Un),Y(o,o,r[2]),T(i,r[2],i),C(a,i),C(f,a),K(u,f,a),K(e,u,o),K(e,e,i),R(e,e),K(e,e,o),K(e,e,i),K(e,e,i),K(r[0],e,i),C(t,r[0]),K(t,t,i),m(t,o)&&K(r[0],r[0],mn),C(t,r[0]),K(t,t,i),m(t,o)?-1:(B(r[0])===n[31]>>7&&Y(r[0],pn,r[0]),K(r[3],r[0],r[1]),0)}function cn(r,n,e,t){var o,i,a=new Uint8Array(32),f=new Uint8Array(64),c=[hn(),hn(),hn(),hn()],w=[hn(),hn(),hn(),hn()];if(i=-1,64>e)return-1;if(un(w,t))return-1;for(o=0;e>o;o++)r[o]=n[o];for(o=0;32>o;o++)r[o+32]=t[o];if(Q(f,r,e),an(f),nn(c,w,f),en(w,n.subarray(32)),W(c,w),rn(a,c),e-=64,u(n,0,a,0)){for(o=0;e>o;o++)r[o]=0;return-1}for(o=0;e>o;o++)r[o]=n[o+64];return i=e}function wn(r,n){if(r.length!==Rn)throw new Error("bad key size");if(n.length!==kn)throw new Error("bad nonce size")}function yn(r,n){if(r.length!==On)throw new Error("bad public key size");if(n.length!==Mn)throw new Error("bad secret key size")}function ln(){for(var r,n={}.toString,e=0;en;n++)e.push(String.fromCharCode(r[n]));return btoa(e.join(""))},r.util.decodeBase64=function(r){if("undefined"==typeof atob)return new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0));var n,e=atob(r),t=new Uint8Array(e.length);for(n=0;nt;t++)o[t]=n[t];for(t=0;ta?!1:i.subarray(0,a)},r.sign.keyPair=function(){var r=new Uint8Array(qn),n=new Uint8Array(Xn);return tn(r,n),{publicKey:r,secretKey:n}},r.sign.keyPair.fromSecretKey=function(r){if(ln(r),r.length!==Xn)throw new Error("bad secret key size");var n,e=new Uint8Array(qn);for(n=0;32>n;n++)e[n]=r[32+n];return{publicKey:e,secretKey:r}},r.sign.publicKeyLength=qn,r.sign.secretKeyLength=Xn,r.sign.signatureLength=Vn,r.hash=function(r){ln(r);var n=new Uint8Array(Dn);return Q(n,r,r.length),n},r.hash.hashLength=Dn,r.verify=function(r,n){return ln(r,n),0===r.length||0===n.length?!1:r.length!==n.length?!1:0===a(r,0,n,0,r.length)?!0:!1},r.setPRNG=function(r){gn=r},function(){var n;"undefined"!=typeof window?(window.crypto&&window.crypto.getRandomValues?n=window.crypto:window.msCrypto&&window.msCrypto.getRandomValues&&(n=window.msCrypto),n&&r.setPRNG(function(r,e){var t,o=new Uint8Array(e);for(n.getRandomValues(o),t=0;e>t;t++)r[t]=o[t]})):"undefined"!=typeof require&&(n=require("crypto"),n&&r.setPRNG(function(r,e){var t,o=n.randomBytes(e);for(t=0;e>t;t++)r[t]=o[t]}))}()}("undefined"!=typeof module&&module.exports?module.exports:window.nacl=window.nacl||{}); \ No newline at end of file +!function(r){"use strict";function n(r,n){return r<>>32-n}function e(r,n){var e=255&r[n+3];return e=e<<8|255&r[n+2],e=e<<8|255&r[n+1],e<<8|255&r[n+0]}function t(r,n){var e=r[n]<<24|r[n+1]<<16|r[n+2]<<8|r[n+3],t=r[n+4]<<24|r[n+5]<<16|r[n+6]<<8|r[n+7];return new sn(e,t)}function o(r,n,e){var t;for(t=0;4>t;t++)r[n+t]=255&e,e>>>=8}function i(r,n,e){r[n]=e.hi>>24&255,r[n+1]=e.hi>>16&255,r[n+2]=e.hi>>8&255,r[n+3]=255&e.hi,r[n+4]=e.lo>>24&255,r[n+5]=e.lo>>16&255,r[n+6]=e.lo>>8&255,r[n+7]=255&e.lo}function a(r,n,e,t,o){var i,a=0;for(i=0;o>i;i++)a|=r[n+i]^e[t+i];return(1&a-1>>>8)-1}function f(r,n,e,t){return a(r,n,e,t,16)}function u(r,n,e,t){return a(r,n,e,t,32)}function c(r,t,i,a,f){var u,c,w,y=new Uint32Array(16),l=new Uint32Array(16),s=new Uint32Array(16),h=new Uint32Array(4);for(u=0;4>u;u++)l[5*u]=e(a,4*u),l[1+u]=e(i,4*u),l[6+u]=e(t,4*u),l[11+u]=e(i,16+4*u);for(u=0;16>u;u++)s[u]=l[u];for(u=0;20>u;u++){for(c=0;4>c;c++){for(w=0;4>w;w++)h[w]=l[(5*c+4*w)%16];for(h[1]^=n(h[0]+h[3]|0,7),h[2]^=n(h[1]+h[0]|0,9),h[3]^=n(h[2]+h[1]|0,13),h[0]^=n(h[3]+h[2]|0,18),w=0;4>w;w++)y[4*c+(c+w)%4]=h[w]}for(w=0;16>w;w++)l[w]=y[w]}if(f){for(u=0;16>u;u++)l[u]=l[u]+s[u]|0;for(u=0;4>u;u++)l[5*u]=l[5*u]-e(a,4*u)|0,l[6+u]=l[6+u]-e(t,4*u)|0;for(u=0;4>u;u++)o(r,4*u,l[5*u]),o(r,16+4*u,l[6+u])}else for(u=0;16>u;u++)o(r,4*u,l[u]+s[u]|0)}function w(r,n,e,t){return c(r,n,e,t,!1),0}function y(r,n,e,t){return c(r,n,e,t,!0),0}function l(r,n,e,t,o,i,a){var f,u,c=new Uint8Array(16),y=new Uint8Array(64);if(!o)return 0;for(u=0;16>u;u++)c[u]=0;for(u=0;8>u;u++)c[u]=i[u];for(;o>=64;){for(w(y,c,a,Bn),u=0;64>u;u++)r[n+u]=(e?e[t+u]:0)^y[u];for(f=1,u=8;16>u;u++)f=f+(255&c[u])|0,c[u]=255&f,f>>>=8;o-=64,n+=64,e&&(t+=64)}if(o>0)for(w(y,c,a,Bn),u=0;o>u;u++)r[n+u]=(e?e[t+u]:0)^y[u];return 0}function s(r,n,e,t,o){return l(r,n,null,0,e,t,o)}function h(r,n,e,t,o){var i=new Uint8Array(32);return y(i,t,o,Bn),s(r,n,e,t.subarray(16),i)}function g(r,n,e,t,o,i,a){var f=new Uint8Array(32);return y(f,i,a,Bn),l(r,n,e,t,o,i.subarray(16),f)}function v(r,n){var e,t=0;for(e=0;17>e;e++)t=t+(r[e]+n[e]|0)|0,r[e]=255&t,t>>>=8}function b(r,n,e,t,o,i){var a,f,u,c,w=new Uint32Array(17),y=new Uint32Array(17),l=new Uint32Array(17),s=new Uint32Array(17),h=new Uint32Array(17);for(u=0;17>u;u++)y[u]=l[u]=0;for(u=0;16>u;u++)y[u]=i[u];for(y[3]&=15,y[4]&=252,y[7]&=15,y[8]&=252,y[11]&=15,y[12]&=252,y[15]&=15;o>0;){for(u=0;17>u;u++)s[u]=0;for(u=0;16>u&&o>u;++u)s[u]=e[t+u];for(s[u]=1,t+=u,o-=u,v(l,s),f=0;17>f;f++)for(w[f]=0,u=0;17>u;u++)w[f]=w[f]+l[u]*(f>=u?y[f-u]:320*y[f+17-u]|0)|0|0;for(f=0;17>f;f++)l[f]=w[f];for(c=0,u=0;16>u;u++)c=c+l[u]|0,l[u]=255&c,c>>>=8;for(c=c+l[16]|0,l[16]=3&c,c=5*(c>>>2)|0,u=0;16>u;u++)c=c+l[u]|0,l[u]=255&c,c>>>=8;c=c+l[16]|0,l[16]=c}for(u=0;17>u;u++)h[u]=l[u];for(v(l,Sn),a=0|-(l[16]>>>7),u=0;17>u;u++)l[u]^=a&(h[u]^l[u]);for(u=0;16>u;u++)s[u]=i[u+16];for(s[16]=0,v(l,s),u=0;16>u;u++)r[n+u]=l[u];return 0}function p(r,n,e,t,o,i){var a=new Uint8Array(16);return b(a,0,e,t,o,i),f(r,n,a,0)}function A(r,n,e,t,o){var i;if(32>e)return-1;for(g(r,0,n,0,e,t,o),b(r,16,r,32,e-32,r),i=0;16>i;i++)r[i]=0;return 0}function _(r,n,e,t,o){var i,a=new Uint8Array(32);if(32>e)return-1;if(h(a,0,32,t,o),0!==p(n,16,n,32,e-32,a))return-1;for(g(r,0,n,0,e,t,o),i=0;32>i;i++)r[i]=0;return 0}function U(r,n){var e;for(e=0;16>e;e++)r[e]=0|n[e]}function d(r){var n,e;for(e=0;16>e;e++)r[e]+=65536,n=Math.floor(r[e]/65536),r[(e+1)*(15>e?1:0)]+=n-1+37*(n-1)*(15===e?1:0),r[e]-=65536*n}function E(r,n,e){for(var t,o=~(e-1),i=0;16>i;i++)t=o&(r[i]^n[i]),r[i]^=t,n[i]^=t}function x(r,n){var e,t,o,i=hn(),a=hn();for(e=0;16>e;e++)a[e]=n[e];for(d(a),d(a),d(a),t=0;2>t;t++){for(i[0]=a[0]-65517,e=1;15>e;e++)i[e]=a[e]-65535-(i[e-1]>>16&1),i[e-1]&=65535;i[15]=a[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,E(a,i,1-o)}for(e=0;16>e;e++)r[2*e]=255&a[e],r[2*e+1]=a[e]>>8}function m(r,n){var e=new Uint8Array(32),t=new Uint8Array(32);return x(e,r),x(t,n),u(e,0,t,0)}function B(r){var n=new Uint8Array(32);return x(n,r),1&n[0]}function S(r,n){var e;for(e=0;16>e;e++)r[e]=n[2*e]+(n[2*e+1]<<8);r[15]&=32767}function T(r,n,e){var t;for(t=0;16>t;t++)r[t]=n[t]+e[t]|0}function Y(r,n,e){var t;for(t=0;16>t;t++)r[t]=n[t]-e[t]|0}function K(r,n,e){var t,o,i=new Float64Array(31);for(t=0;31>t;t++)i[t]=0;for(t=0;16>t;t++)for(o=0;16>o;o++)i[t+o]+=n[t]*e[o];for(t=0;15>t;t++)i[t]+=38*i[t+16];for(t=0;16>t;t++)r[t]=i[t];d(r),d(r)}function C(r,n){K(r,n,n)}function L(r,n){var e,t=hn();for(e=0;16>e;e++)t[e]=n[e];for(e=253;e>=0;e--)C(t,t),2!==e&&4!==e&&K(t,t,n);for(e=0;16>e;e++)r[e]=t[e]}function R(r,n){var e,t=hn();for(e=0;16>e;e++)t[e]=n[e];for(e=250;e>=0;e--)C(t,t),1!==e&&K(t,t,n);for(e=0;16>e;e++)r[e]=t[e]}function k(r,n,e){var t,o,i=new Uint8Array(32),a=new Float64Array(80),f=hn(),u=hn(),c=hn(),w=hn(),y=hn(),l=hn();for(o=0;31>o;o++)i[o]=n[o];for(i[31]=127&n[31]|64,i[0]&=248,S(a,e),o=0;16>o;o++)u[o]=a[o],w[o]=f[o]=c[o]=0;for(f[0]=w[0]=1,o=254;o>=0;--o)t=i[o>>>3]>>>(7&o)&1,E(f,u,t),E(c,w,t),T(y,f,c),Y(f,f,c),T(c,u,w),Y(u,u,w),C(w,y),C(l,f),K(f,c,f),K(c,u,y),T(y,f,c),Y(f,f,c),C(u,f),Y(c,w,l),K(f,c,_n),T(f,f,w),K(c,c,f),K(f,w,l),K(w,u,a),C(u,y),E(f,u,t),E(c,w,t);for(o=0;16>o;o++)a[o+16]=f[o],a[o+32]=c[o],a[o+48]=u[o],a[o+64]=w[o];var s=a.subarray(32),h=a.subarray(16);return L(s,s),K(h,h,s),x(r,h),0}function z(r,n){return k(r,n,bn)}function P(r,n){return gn(n,32),z(r,n)}function F(r,n,e){var t=new Uint8Array(32);return k(t,e,n),y(r,vn,t,Bn)}function N(r,n,e,t,o,i){var a=new Uint8Array(32);return F(a,o,i),Tn(r,n,e,t,a)}function O(r,n,e,t,o,i){var a=new Uint8Array(32);return F(a,o,i),Yn(r,n,e,t,a)}function M(){var r,n,e=0,t=0;for(r=0;r>>0,t=t+arguments[r].hi+(n>e?1:0)>>>0;return new sn(t,e)}function G(r,n){return new sn(r.hi>>>n,r.lo>>>n|r.hi<<32-n)}function I(){var r,n=0,e=0;for(r=0;rn?(e=r.hi>>>n|r.lo<>>n|r.hi<n&&(e=r.lo>>>n|r.hi<>>n|r.lo<a;a++)u[a]=w[a]=t(r,8*a);for(var l=0;e>=128;){for(a=0;16>a;a++)y[a]=t(n,8*a+l);for(a=0;80>a;a++){for(f=0;8>f;f++)c[f]=w[f];for(o=M(w[7],X(w[4]),j(w[4],w[5],w[6]),Kn[a],y[a%16]),c[7]=M(o,q(w[0]),V(w[0],w[1],w[2])),c[3]=M(c[3],o),f=0;8>f;f++)w[(f+1)%8]=c[f];if(a%16===15)for(f=0;16>f;f++)y[f]=M(y[f],y[(f+9)%16],D(y[(f+1)%16]),H(y[(f+14)%16]))}for(a=0;8>a;a++)w[a]=M(w[a],u[a]),u[a]=w[a];l+=128,e-=128}for(a=0;8>a;a++)i(r,8*a,u[a]);return e}function Q(r,n,e){var t,o=new Uint8Array(64),a=new Uint8Array(256),f=e;for(t=0;64>t;t++)o[t]=Cn[t];for(J(o,n,e),e%=128,t=0;256>t;t++)a[t]=0;for(t=0;e>t;t++)a[t]=n[f-e+t];for(a[e]=128,e=256-128*(112>e?1:0),a[e-9]=0,i(a,e-8,new sn(f/536870912|0,f<<3)),J(o,a,e),t=0;64>t;t++)r[t]=o[t];return 0}function W(r,n){var e=hn(),t=hn(),o=hn(),i=hn(),a=hn(),f=hn(),u=hn(),c=hn(),w=hn();Y(e,r[1],r[0]),Y(w,n[1],n[0]),K(e,e,w),T(t,r[0],r[1]),T(w,n[0],n[1]),K(t,t,w),K(o,r[3],n[3]),K(o,o,dn),K(i,r[2],n[2]),T(i,i,i),Y(a,t,e),Y(f,i,o),T(u,i,o),T(c,t,e),K(r[0],a,f),K(r[1],c,u),K(r[2],u,f),K(r[3],a,c)}function $(r,n,e){var t;for(t=0;4>t;t++)E(r[t],n[t],e)}function rn(r,n){var e=hn(),t=hn(),o=hn();L(o,n[2]),K(e,n[0],o),K(t,n[1],o),x(r,t),r[31]^=B(e)<<7}function nn(r,n,e){var t,o;for(U(r[0],pn),U(r[1],An),U(r[2],An),U(r[3],pn),o=255;o>=0;--o)t=e[o/8|0]>>(7&o)&1,$(r,n,t),W(n,r),W(r,r),$(r,n,t)}function en(r,n){var e=[hn(),hn(),hn(),hn()];U(e[0],En),U(e[1],xn),U(e[2],An),K(e[3],En,xn),nn(r,e,n)}function tn(r,n){var e,t=new Uint8Array(64),o=[hn(),hn(),hn(),hn()];for(gn(n,32),Q(t,n,32),t[0]&=248,t[31]&=127,t[31]|=64,en(o,t),rn(r,o),e=0;32>e;e++)n[e+32]=r[e];return 0}function on(r,n){var e,t,o,i;for(t=63;t>=32;--t){for(e=0,o=t-32,i=t-12;i>o;++o)n[o]+=e-16*n[t]*Ln[o-(t-32)],e=n[o]+128>>8,n[o]-=256*e;n[o]+=e,n[t]=0}for(e=0,o=0;32>o;o++)n[o]+=e-(n[31]>>4)*Ln[o],e=n[o]>>8,n[o]&=255;for(o=0;32>o;o++)n[o]-=e*Ln[o];for(t=0;32>t;t++)n[t+1]+=n[t]>>8,r[t]=255&n[t]}function an(r){var n,e=new Float64Array(64);for(n=0;64>n;n++)e[n]=r[n];for(n=0;64>n;n++)r[n]=0;on(r,e)}function fn(r,n,e,t){var o,i,a=new Uint8Array(64),f=new Uint8Array(64),u=new Uint8Array(64),c=new Float64Array(64),w=[hn(),hn(),hn(),hn()];Q(a,t,32),a[0]&=248,a[31]&=127,a[31]|=64;var y=e+64;for(o=0;e>o;o++)r[64+o]=n[o];for(o=0;32>o;o++)r[32+o]=a[32+o];for(Q(u,r.subarray(32),e+32),an(u),en(w,u),rn(r,w),o=32;64>o;o++)r[o]=t[o];for(Q(f,r,e+64),an(f),o=0;64>o;o++)c[o]=0;for(o=0;32>o;o++)c[o]=u[o];for(o=0;32>o;o++)for(i=0;32>i;i++)c[o+i]+=f[o]*a[i];return on(r.subarray(32),c),y}function un(r,n){var e=hn(),t=hn(),o=hn(),i=hn(),a=hn(),f=hn(),u=hn();return U(r[2],An),S(r[1],n),C(o,r[1]),K(i,o,Un),Y(o,o,r[2]),T(i,r[2],i),C(a,i),C(f,a),K(u,f,a),K(e,u,o),K(e,e,i),R(e,e),K(e,e,o),K(e,e,i),K(e,e,i),K(r[0],e,i),C(t,r[0]),K(t,t,i),m(t,o)&&K(r[0],r[0],mn),C(t,r[0]),K(t,t,i),m(t,o)?-1:(B(r[0])===n[31]>>7&&Y(r[0],pn,r[0]),K(r[3],r[0],r[1]),0)}function cn(r,n,e,t){var o,i,a=new Uint8Array(32),f=new Uint8Array(64),c=[hn(),hn(),hn(),hn()],w=[hn(),hn(),hn(),hn()];if(i=-1,64>e)return-1;if(un(w,t))return-1;for(o=0;e>o;o++)r[o]=n[o];for(o=0;32>o;o++)r[o+32]=t[o];if(Q(f,r,e),an(f),nn(c,w,f),en(w,n.subarray(32)),W(c,w),rn(a,c),e-=64,u(n,0,a,0)){for(o=0;e>o;o++)r[o]=0;return-1}for(o=0;e>o;o++)r[o]=n[o+64];return i=e}function wn(r,n){if(r.length!==Rn)throw new Error("bad key size");if(n.length!==kn)throw new Error("bad nonce size")}function yn(r,n){if(r.length!==On)throw new Error("bad public key size");if(n.length!==Mn)throw new Error("bad secret key size")}function ln(){for(var r,n={}.toString,e=0;en;n++)e.push(String.fromCharCode(r[n]));return btoa(e.join(""))},r.util.decodeBase64=function(r){if("undefined"==typeof atob)return new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0));var n,e=atob(r),t=new Uint8Array(e.length);for(n=0;nt;t++)o[t]=n[t];for(t=0;ta?!1:i.subarray(0,a)},r.sign.keyPair=function(){var r=new Uint8Array(qn),n=new Uint8Array(Xn);return tn(r,n),{publicKey:r,secretKey:n}},r.sign.keyPair.fromSecretKey=function(r){if(ln(r),r.length!==Xn)throw new Error("bad secret key size");var n,e=new Uint8Array(qn);for(n=0;32>n;n++)e[n]=r[32+n];return{publicKey:e,secretKey:r}},r.sign.publicKeyLength=qn,r.sign.secretKeyLength=Xn,r.sign.signatureLength=Vn,r.hash=function(r){ln(r);var n=new Uint8Array(Dn);return Q(n,r,r.length),n},r.hash.hashLength=Dn,r.verify=function(r,n){return ln(r,n),0===r.length||0===n.length?!1:r.length!==n.length?!1:0===a(r,0,n,0,r.length)?!0:!1},r.setPRNG=function(r){gn=r},function(){var n;"undefined"!=typeof window?(window.crypto&&window.crypto.getRandomValues?n=window.crypto:window.msCrypto&&window.msCrypto.getRandomValues&&(n=window.msCrypto),n&&r.setPRNG(function(r,e){var t,o=new Uint8Array(e);for(n.getRandomValues(o),t=0;e>t;t++)r[t]=o[t]})):"undefined"!=typeof require&&(n=require("crypto"),n&&r.setPRNG(function(r,e){var t,o=n.randomBytes(e);for(t=0;e>t;t++)r[t]=o[t]}))}()}("undefined"!=typeof module&&module.exports?module.exports:window.nacl=window.nacl||{}); \ No newline at end of file