-
Notifications
You must be signed in to change notification settings - Fork 296
/
nacl-fast.min.js
1 lines (1 loc) · 23.9 KB
/
nacl-fast.min.js
1
!function(r){"use strict";function t(r,t){var n=255&r[t+3];return n=n<<8|255&r[t+2],n=n<<8|255&r[t+1],n<<8|255&r[t+0]}function n(r,t,n){var e;for(e=0;4>e;e++)r[t+e]=255&n,n>>>=8}function e(r,t,n,e){r[t]=n>>24&255,r[t+1]=n>>16&255,r[t+2]=n>>8&255,r[t+3]=255&n,r[t+4]=e>>24&255,r[t+5]=e>>16&255,r[t+6]=e>>8&255,r[t+7]=255&e}function o(r,t,n,e,o){var i,f=0;for(i=0;o>i;i++)f|=r[t+i]^n[e+i];return(1&f-1>>>8)-1}function i(r,t,n,e){return o(r,t,n,e,16)}function f(r,t,n,e){return o(r,t,n,e,32)}function a(r,e,o,i){for(var f,a=t(i,0),h=t(o,0),s=t(o,4),u=t(o,8),c=t(o,12),y=t(i,4),l=t(e,0),w=t(e,4),v=t(e,8),p=t(e,12),b=t(i,8),g=t(o,16),A=t(o,20),d=t(o,24),_=t(o,28),U=t(i,12),E=a,x=h,m=s,B=u,S=c,K=y,T=l,Y=w,k=v,C=p,L=b,R=g,z=A,P=d,F=_,N=U,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=K+x|0,C^=f<<7|f>>>25,f=C+K|0,P^=f<<9|f>>>23,f=P+C|0,x^=f<<13|f>>>19,f=x+P|0,K^=f<<18|f>>>14,f=L+T|0,F^=f<<7|f>>>25,f=F+L|0,m^=f<<9|f>>>23,f=m+F|0,T^=f<<13|f>>>19,f=T+m|0,L^=f<<18|f>>>14,f=N+R|0,B^=f<<7|f>>>25,f=B+N|0,Y^=f<<9|f>>>23,f=Y+B|0,R^=f<<13|f>>>19,f=R+Y|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=K+S|0,T^=f<<7|f>>>25,f=T+K|0,Y^=f<<9|f>>>23,f=Y+T|0,S^=f<<13|f>>>19,f=S+Y|0,K^=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+a|0,x=x+h|0,m=m+s|0,B=B+u|0,S=S+c|0,K=K+y|0,T=T+l|0,Y=Y+w|0,k=k+v|0,C=C+p|0,L=L+b|0,R=R+g|0,z=z+A|0,P=P+d|0,F=F+_|0,N=N+U|0,n(r,0,E),n(r,4,x),n(r,8,m),n(r,12,B),n(r,16,S),n(r,20,K),n(r,24,T),n(r,28,Y),n(r,32,k),n(r,36,C),n(r,40,L),n(r,44,R),n(r,48,z),n(r,52,P),n(r,56,F),n(r,60,N)}function h(r,e,o,i){for(var f,a=t(i,0),h=t(o,0),s=t(o,4),u=t(o,8),c=t(o,12),y=t(i,4),l=t(e,0),w=t(e,4),v=t(e,8),p=t(e,12),b=t(i,8),g=t(o,16),A=t(o,20),d=t(o,24),_=t(o,28),U=t(i,12),E=a,x=h,m=s,B=u,S=c,K=y,T=l,Y=w,k=v,C=p,L=b,R=g,z=A,P=d,F=_,N=U,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=K+x|0,C^=f<<7|f>>>25,f=C+K|0,P^=f<<9|f>>>23,f=P+C|0,x^=f<<13|f>>>19,f=x+P|0,K^=f<<18|f>>>14,f=L+T|0,F^=f<<7|f>>>25,f=F+L|0,m^=f<<9|f>>>23,f=m+F|0,T^=f<<13|f>>>19,f=T+m|0,L^=f<<18|f>>>14,f=N+R|0,B^=f<<7|f>>>25,f=B+N|0,Y^=f<<9|f>>>23,f=Y+B|0,R^=f<<13|f>>>19,f=R+Y|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=K+S|0,T^=f<<7|f>>>25,f=T+K|0,Y^=f<<9|f>>>23,f=Y+T|0,S^=f<<13|f>>>19,f=S+Y|0,K^=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;n(r,0,E),n(r,4,K),n(r,8,L),n(r,12,N),n(r,16,T),n(r,20,Y),n(r,24,k),n(r,28,C)}function s(r,t,n,e){a(r,t,n,e)}function u(r,t,n,e){h(r,t,n,e)}function c(r,t,n,e,o,i,f){var a,h,u=new Uint8Array(16),c=new Uint8Array(64);for(h=0;16>h;h++)u[h]=0;for(h=0;8>h;h++)u[h]=i[h];for(;o>=64;){for(s(c,u,f,wt),h=0;64>h;h++)r[t+h]=n[e+h]^c[h];for(a=1,h=8;16>h;h++)a=a+(255&u[h])|0,u[h]=255&a,a>>>=8;o-=64,t+=64,e+=64}if(o>0)for(s(c,u,f,wt),h=0;o>h;h++)r[t+h]=n[e+h]^c[h];return 0}function y(r,t,n,e,o){var i,f,a=new Uint8Array(16),h=new Uint8Array(64);for(f=0;16>f;f++)a[f]=0;for(f=0;8>f;f++)a[f]=e[f];for(;n>=64;){for(s(h,a,o,wt),f=0;64>f;f++)r[t+f]=h[f];for(i=1,f=8;16>f;f++)i=i+(255&a[f])|0,a[f]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(s(h,a,o,wt),f=0;n>f;f++)r[t+f]=h[f];return 0}function l(r,t,n,e,o){var i=new Uint8Array(32);u(i,e,o,wt);for(var f=new Uint8Array(8),a=0;8>a;a++)f[a]=e[a+16];return y(r,t,n,f,i)}function w(r,t,n,e,o,i,f){var a=new Uint8Array(32);u(a,i,f,wt);for(var h=new Uint8Array(8),s=0;8>s;s++)h[s]=i[s+16];return c(r,t,n,e,o,h,a)}function v(r,t){return 255&r[t]|(255&r[t+1])<<8}function p(r,t,n){r[t]=n>>>0&255,r[t+1]=n>>>8&255}function b(r,t,n,e,o,i){var f=new vt(i);return f.update(n,e,o),f.finish(r,t),0}function g(r,t,n,e,o,f){var a=new Uint8Array(16);return b(a,0,n,e,o,f),i(r,t,a,0)}function A(r,t,n,e,o){var i;if(32>n)return-1;for(w(r,0,t,0,n,e,o),b(r,16,r,32,n-32,r),i=0;16>i;i++)r[i]=0;return 0}function d(r,t,n,e,o){var i,f=new Uint8Array(32);if(32>n)return-1;if(l(f,0,32,e,o),0!==g(t,16,t,32,n-32,f))return-1;for(w(r,0,t,0,n,e,o),i=0;32>i;i++)r[i]=0;return 0}function _(r,t){var n;for(n=0;16>n;n++)r[n]=0|t[n]}function U(r){var t,n;for(n=0;16>n;n++)r[n]+=65536,t=Math.floor(r[n]/65536),r[(n+1)*(15>n?1:0)]+=t-1+37*(t-1)*(15===n?1:0),r[n]-=65536*t}function E(r,t,n){for(var e,o=~(n-1),i=0;16>i;i++)e=o&(r[i]^t[i]),r[i]^=e,t[i]^=e}function x(r,t){var n,e,o,i=nt(),f=nt();for(n=0;16>n;n++)f[n]=t[n];for(U(f),U(f),U(f),e=0;2>e;e++){for(i[0]=f[0]-65517,n=1;15>n;n++)i[n]=f[n]-65535-(i[n-1]>>16&1),i[n-1]&=65535;i[15]=f[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,E(f,i,1-o)}for(n=0;16>n;n++)r[2*n]=255&f[n],r[2*n+1]=f[n]>>8}function m(r,t){var n=new Uint8Array(32),e=new Uint8Array(32);return x(n,r),x(e,t),f(n,0,e,0)}function B(r){var t=new Uint8Array(32);return x(t,r),1&t[0]}function S(r,t){var n;for(n=0;16>n;n++)r[n]=t[2*n]+(t[2*n+1]<<8);r[15]&=32767}function K(r,t,n){var e;for(e=0;16>e;e++)r[e]=t[e]+n[e]|0}function T(r,t,n){var e;for(e=0;16>e;e++)r[e]=t[e]-n[e]|0}function Y(r,t,n){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]+=t[e]*n[o];for(e=0;15>e;e++)i[e]+=38*i[e+16];for(e=0;16>e;e++)r[e]=i[e];U(r),U(r)}function k(r,t){Y(r,t,t)}function C(r,t){var n,e=nt();for(n=0;16>n;n++)e[n]=t[n];for(n=253;n>=0;n--)k(e,e),2!==n&&4!==n&&Y(e,e,t);for(n=0;16>n;n++)r[n]=e[n]}function L(r,t){var n,e=nt();for(n=0;16>n;n++)e[n]=t[n];for(n=250;n>=0;n--)k(e,e),1!==n&&Y(e,e,t);for(n=0;16>n;n++)r[n]=e[n]}function R(r,t,n){var e,o,i=new Uint8Array(32),f=new Float64Array(80),a=nt(),h=nt(),s=nt(),u=nt(),c=nt(),y=nt();for(o=0;31>o;o++)i[o]=t[o];for(i[31]=127&t[31]|64,i[0]&=248,S(f,n),o=0;16>o;o++)h[o]=f[o],u[o]=a[o]=s[o]=0;for(a[0]=u[0]=1,o=254;o>=0;--o)e=i[o>>>3]>>>(7&o)&1,E(a,h,e),E(s,u,e),K(c,a,s),T(a,a,s),K(s,h,u),T(h,h,u),k(u,c),k(y,a),Y(a,s,a),Y(s,h,c),K(c,a,s),T(a,a,s),k(h,a),T(s,u,y),Y(a,s,ht),K(a,a,u),Y(s,s,a),Y(a,u,y),Y(u,h,f),k(h,c),E(a,h,e),E(s,u,e);for(o=0;16>o;o++)f[o+16]=a[o],f[o+32]=s[o],f[o+48]=h[o],f[o+64]=u[o];var l=f.subarray(32),w=f.subarray(16);return C(l,l),Y(w,w,l),x(r,w),0}function z(r,t){return R(r,t,it)}function P(r,t){return et(t,32),z(r,t)}function F(r,t,n){var e=new Uint8Array(32);return R(e,n,t),u(r,ot,e,wt)}function N(r,t,n,e,o,i){var f=new Uint8Array(32);return F(f,o,i),pt(r,t,n,e,f)}function O(r,t,n,e,o,i){var f=new Uint8Array(32);return F(f,o,i),bt(r,t,n,e,f)}function I(r,t,n,e){for(var o,i,f,a,h,s,u,c,y,l,w,v,p,b,g,A,d,_,U,E,x,m,B,S,K,T,Y=new Int32Array(16),k=new Int32Array(16),C=r[0],L=r[1],R=r[2],z=r[3],P=r[4],F=r[5],N=r[6],O=r[7],I=t[0],M=t[1],G=t[2],Z=t[3],j=t[4],V=t[5],q=t[6],X=t[7],D=0;e>=128;){for(U=0;16>U;U++)E=8*U+D,Y[U]=n[E+0]<<24|n[E+1]<<16|n[E+2]<<8|n[E+3],k[U]=n[E+4]<<24|n[E+5]<<16|n[E+6]<<8|n[E+7];for(U=0;80>U;U++)if(o=C,i=L,f=R,a=z,h=P,s=F,u=N,c=O,y=I,l=M,w=G,v=Z,p=j,b=V,g=q,A=X,x=O,m=X,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=(P>>>14|j<<18)^(P>>>18|j<<14)^(j>>>9|P<<23),m=(j>>>14|P<<18)^(j>>>18|P<<14)^(P>>>9|j<<23),B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,x=P&F^~P&N,m=j&V^~j&q,B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,x=gt[2*U],m=gt[2*U+1],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,x=Y[U%16],m=k[U%16],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,d=65535&K|T<<16,_=65535&B|S<<16,x=d,m=_,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=(C>>>28|I<<4)^(I>>>2|C<<30)^(I>>>7|C<<25),m=(I>>>28|C<<4)^(C>>>2|I<<30)^(C>>>7|I<<25),B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,x=C&L^C&R^L&R,m=I&M^I&G^M&G,B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,c=65535&K|T<<16,A=65535&B|S<<16,x=a,m=v,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=d,m=_,B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,a=65535&K|T<<16,v=65535&B|S<<16,L=o,R=i,z=f,P=a,F=h,N=s,O=u,C=c,M=y,G=l,Z=w,j=v,V=p,q=b,X=g,I=A,U%16===15)for(E=0;16>E;E++)x=Y[E],m=k[E],B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=Y[(E+9)%16],m=k[(E+9)%16],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,d=Y[(E+1)%16],_=k[(E+1)%16],x=(d>>>1|_<<31)^(d>>>8|_<<24)^d>>>7,m=(_>>>1|d<<31)^(_>>>8|d<<24)^(_>>>7|d<<25),B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,d=Y[(E+14)%16],_=k[(E+14)%16],x=(d>>>19|_<<13)^(_>>>29|d<<3)^d>>>6,m=(_>>>19|d<<13)^(d>>>29|_<<3)^(_>>>6|d<<26),B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,Y[E]=65535&K|T<<16,k[E]=65535&B|S<<16;x=C,m=I,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=r[0],m=t[0],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,r[0]=C=65535&K|T<<16,t[0]=I=65535&B|S<<16,x=L,m=M,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=r[1],m=t[1],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,r[1]=L=65535&K|T<<16,t[1]=M=65535&B|S<<16,x=R,m=G,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=r[2],m=t[2],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,r[2]=R=65535&K|T<<16,t[2]=G=65535&B|S<<16,x=z,m=Z,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=r[3],m=t[3],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,r[3]=z=65535&K|T<<16,t[3]=Z=65535&B|S<<16,x=P,m=j,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=r[4],m=t[4],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,r[4]=P=65535&K|T<<16,t[4]=j=65535&B|S<<16,x=F,m=V,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=r[5],m=t[5],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,r[5]=F=65535&K|T<<16,t[5]=V=65535&B|S<<16,x=N,m=q,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=r[6],m=t[6],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,r[6]=N=65535&K|T<<16,t[6]=q=65535&B|S<<16,x=O,m=X,B=65535&m,S=m>>>16,K=65535&x,T=x>>>16,x=r[7],m=t[7],B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,S+=B>>>16,K+=S>>>16,T+=K>>>16,r[7]=O=65535&K|T<<16,t[7]=X=65535&B|S<<16,D+=128,e-=128}return e}function M(r,t,n){var o,i=new Int32Array(8),f=new Int32Array(8),a=new Uint8Array(256),h=n;for(i[0]=1779033703,i[1]=3144134277,i[2]=1013904242,i[3]=2773480762,i[4]=1359893119,i[5]=2600822924,i[6]=528734635,i[7]=1541459225,f[0]=4089235720,f[1]=2227873595,f[2]=4271175723,f[3]=1595750129,f[4]=2917565137,f[5]=725511199,f[6]=4215389547,f[7]=327033209,I(i,f,t,n),n%=128,o=0;n>o;o++)a[o]=t[h-n+o];for(a[n]=128,n=256-128*(112>n?1:0),a[n-9]=0,e(a,n-8,h/536870912|0,h<<3),I(i,f,a,n),o=0;8>o;o++)e(r,8*o,i[o],f[o]);return 0}function G(r,t){var n=nt(),e=nt(),o=nt(),i=nt(),f=nt(),a=nt(),h=nt(),s=nt(),u=nt();T(n,r[1],r[0]),T(u,t[1],t[0]),Y(n,n,u),K(e,r[0],r[1]),K(u,t[0],t[1]),Y(e,e,u),Y(o,r[3],t[3]),Y(o,o,ut),Y(i,r[2],t[2]),K(i,i,i),T(f,e,n),T(a,i,o),K(h,i,o),K(s,e,n),Y(r[0],f,a),Y(r[1],s,h),Y(r[2],h,a),Y(r[3],f,s)}function Z(r,t,n){var e;for(e=0;4>e;e++)E(r[e],t[e],n)}function j(r,t){var n=nt(),e=nt(),o=nt();C(o,t[2]),Y(n,t[0],o),Y(e,t[1],o),x(r,e),r[31]^=B(n)<<7}function V(r,t,n){var e,o;for(_(r[0],ft),_(r[1],at),_(r[2],at),_(r[3],ft),o=255;o>=0;--o)e=n[o/8|0]>>(7&o)&1,Z(r,t,e),G(t,r),G(r,r),Z(r,t,e)}function q(r,t){var n=[nt(),nt(),nt(),nt()];_(n[0],ct),_(n[1],yt),_(n[2],at),Y(n[3],ct,yt),V(r,n,t)}function X(r,t,n){var e,o=new Uint8Array(64),i=[nt(),nt(),nt(),nt()];for(n||et(t,32),M(o,t,32),o[0]&=248,o[31]&=127,o[31]|=64,q(i,o),j(r,i),e=0;32>e;e++)t[e+32]=r[e];return 0}function D(r,t){var n,e,o,i;for(e=63;e>=32;--e){for(n=0,o=e-32,i=e-12;i>o;++o)t[o]+=n-16*t[e]*At[o-(e-32)],n=t[o]+128>>8,t[o]-=256*n;t[o]+=n,t[e]=0}for(n=0,o=0;32>o;o++)t[o]+=n-(t[31]>>4)*At[o],n=t[o]>>8,t[o]&=255;for(o=0;32>o;o++)t[o]-=n*At[o];for(e=0;32>e;e++)t[e+1]+=t[e]>>8,r[e]=255&t[e]}function H(r){var t,n=new Float64Array(64);for(t=0;64>t;t++)n[t]=r[t];for(t=0;64>t;t++)r[t]=0;D(r,n)}function J(r,t,n,e){var o,i,f=new Uint8Array(64),a=new Uint8Array(64),h=new Uint8Array(64),s=new Float64Array(64),u=[nt(),nt(),nt(),nt()];M(f,e,32),f[0]&=248,f[31]&=127,f[31]|=64;var c=n+64;for(o=0;n>o;o++)r[64+o]=t[o];for(o=0;32>o;o++)r[32+o]=f[32+o];for(M(h,r.subarray(32),n+32),H(h),q(u,h),j(r,u),o=32;64>o;o++)r[o]=e[o];for(M(a,r,n+64),H(a),o=0;64>o;o++)s[o]=0;for(o=0;32>o;o++)s[o]=h[o];for(o=0;32>o;o++)for(i=0;32>i;i++)s[o+i]+=a[o]*f[i];return D(r.subarray(32),s),c}function Q(r,t){var n=nt(),e=nt(),o=nt(),i=nt(),f=nt(),a=nt(),h=nt();return _(r[2],at),S(r[1],t),k(o,r[1]),Y(i,o,st),T(o,o,r[2]),K(i,r[2],i),k(f,i),k(a,f),Y(h,a,f),Y(n,h,o),Y(n,n,i),L(n,n),Y(n,n,o),Y(n,n,i),Y(n,n,i),Y(r[0],n,i),k(e,r[0]),Y(e,e,i),m(e,o)&&Y(r[0],r[0],lt),k(e,r[0]),Y(e,e,i),m(e,o)?-1:(B(r[0])===t[31]>>7&&T(r[0],ft,r[0]),Y(r[3],r[0],r[1]),0)}function W(r,t,n,e){var o,i,a=new Uint8Array(32),h=new Uint8Array(64),s=[nt(),nt(),nt(),nt()],u=[nt(),nt(),nt(),nt()];if(i=-1,64>n)return-1;if(Q(u,e))return-1;for(o=0;n>o;o++)r[o]=t[o];for(o=0;32>o;o++)r[o+32]=e[o];if(M(h,r,n),H(h),V(s,u,h),q(u,t.subarray(32)),G(s,u),j(a,s),n-=64,f(t,0,a,0)){for(o=0;n>o;o++)r[o]=0;return-1}for(o=0;n>o;o++)r[o]=t[o+64];return i=n}function $(r,t){if(r.length!==dt)throw new Error("bad key size");if(t.length!==_t)throw new Error("bad nonce size")}function rt(r,t){if(r.length!==Bt)throw new Error("bad public key size");if(t.length!==St)throw new Error("bad secret key size")}function tt(){for(var r,t={}.toString,n=0;n<arguments.length;n++)if("[object Uint8Array]"!==(r=t.call(arguments[n])))throw new TypeError("unexpected type "+r+", use Uint8Array")}var nt=function(r){var t,n=new Float64Array(16);if(r)for(t=0;t<r.length;t++)n[t]=r[t];return n},et=function(){throw new Error("no PRNG")},ot=new Uint8Array(16),it=new Uint8Array(32);it[0]=9;var ft=nt(),at=nt([1]),ht=nt([56129,1]),st=nt([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),ut=nt([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),ct=nt([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),yt=nt([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),lt=nt([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]),wt=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]),vt=function(r){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var t,n,e,o,i,f,a,h,s;for(n=v(r,0),this.r[0]=8191&n,e=v(r,2),this.r[1]=8191&(n>>>13|e<<3),o=v(r,4),this.r[2]=7939&(e>>>10|o<<6),i=v(r,6),this.r[3]=8191&(o>>>7|i<<9),f=v(r,8),this.r[4]=255&(i>>>4|f<<12),this.r[5]=f>>>1&8190,a=v(r,10),this.r[6]=8191&(f>>>14|a<<2),h=v(r,12),this.r[7]=8065&(a>>>11|h<<5),s=v(r,14),this.r[8]=8191&(h>>>8|s<<8),this.r[9]=s>>>5&127,t=0;8>t;t++)this.pad[t]=v(r,16+2*t)};vt.prototype.blocks=function(r,t,n){for(var e,o,i,f,a,h,s,u,c,y,l,w=this.fin?0:2048,p=new Uint32Array(10);n>=16;){for(e=v(r,t+0),this.h[0]+=8191&e,o=v(r,t+2),this.h[1]+=8191&(e>>>13|o<<3),i=v(r,t+4),this.h[2]+=8191&(o>>>10|i<<6),f=v(r,t+6),this.h[3]+=8191&(i>>>7|f<<9),a=v(r,t+8),this.h[4]+=8191&(f>>>4|a<<12),this.h[5]+=a>>>1&8191,h=v(r,t+10),this.h[6]+=8191&(a>>>14|h<<2),s=v(r,t+12),this.h[7]+=8191&(h>>>11|s<<5),u=v(r,t+14),this.h[8]+=8191&(s>>>8|u<<8),this.h[9]+=u>>>5|w,y=0,c=0;10>y;y++){for(p[y]=c,l=0;10>l;l++)p[y]+=this.h[l]*(y>=l?this.r[y-l]:5*this.r[y+10-l]),4===l&&(c=p[y]>>>13,p[y]&=8191);c+=p[y]>>>13,p[y]&=8191}for(c=(c<<2)+c|0,c=c+p[0]|0,p[0]=8191&c,c>>>=13,p[1]+=c,y=0;10>y;y++)this.h[y]=p[y];t+=16,n-=16}},vt.prototype.finish=function(r,t){var n,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(n=this.h[1]>>>13,this.h[1]&=8191,i=2;10>i;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,f[0]=this.h[0]+5,n=f[0]>>>13,f[0]&=8191,i=1;10>i;i++)f[i]=this.h[i]+n,n=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++)p(r,t+2*i,this.h[i])},vt.prototype.update=function(r,t,n){var e,o;if(this.leftover){for(o=16-this.leftover,o>n&&(o=n),e=0;o>e;e++)this.buffer[this.leftover+e]=r[t+e];if(n-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(buffer,0,16),this.leftover=0}if(n>=16&&(o=n-n%16,this.blocks(r,t,o),t+=o,n-=o),n){for(e=0;n>e;e++)this.buffer[this.leftover+e]=r[t+e];this.leftover+=n}};var pt=A,bt=d,gt=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],At=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]),dt=32,_t=24,Ut=32,Et=16,xt=32,mt=32,Bt=32,St=32,Kt=32,Tt=_t,Yt=Ut,kt=Et,Ct=64,Lt=32,Rt=64,zt=64;r.lowlevel={crypto_core_hsalsa20:u,crypto_stream_xor:w,crypto_stream:l,crypto_stream_salsa20_xor:c,crypto_stream_salsa20:y,crypto_onetimeauth:b,crypto_onetimeauth_verify:g,crypto_verify_16:i,crypto_verify_32:f,crypto_secretbox:A,crypto_secretbox_open:d,crypto_scalarmult:R,crypto_scalarmult_base:z,crypto_box_beforenm:F,crypto_box_afternm:pt,crypto_box:N,crypto_box_open:O,crypto_box_keypair:P,crypto_hash:M,crypto_sign:J,crypto_sign_keypair:X,crypto_sign_open:W,crypto_secretbox_KEYBYTES:dt,crypto_secretbox_NONCEBYTES:_t,crypto_secretbox_ZEROBYTES:Ut,crypto_secretbox_BOXZEROBYTES:Et,crypto_scalarmult_BYTES:xt,crypto_scalarmult_SCALARBYTES:mt,crypto_box_PUBLICKEYBYTES:Bt,crypto_box_SECRETKEYBYTES:St,crypto_box_BEFORENMBYTES:Kt,crypto_box_NONCEBYTES:Tt,crypto_box_ZEROBYTES:Yt,crypto_box_BOXZEROBYTES:kt,crypto_sign_BYTES:Ct,crypto_sign_PUBLICKEYBYTES:Lt,crypto_sign_SECRETKEYBYTES:Rt,crypto_hash_BYTES:zt},r.util={},r.util.decodeUTF8=function(r){var t,n=unescape(encodeURIComponent(r)),e=new Uint8Array(n.length);for(t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e},r.util.encodeUTF8=function(r){var t,n=[];for(t=0;t<r.length;t++)n.push(String.fromCharCode(r[t]));return decodeURIComponent(escape(n.join("")))},r.util.encodeBase64=function(r){if("undefined"==typeof btoa)return new Buffer(r).toString("base64");var t,n=[],e=r.length;for(t=0;e>t;t++)n.push(String.fromCharCode(r[t]));return btoa(n.join(""))},r.util.decodeBase64=function(r){if("undefined"==typeof atob)return new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0));var t,n=atob(r),e=new Uint8Array(n.length);for(t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e},r.randomBytes=function(r){var t=new Uint8Array(r);return et(t,r),t},r.secretbox=function(r,t,n){tt(r,t,n),$(n,t);for(var e=new Uint8Array(Ut+r.length),o=new Uint8Array(e.length),i=0;i<r.length;i++)e[i+Ut]=r[i];return A(o,e,e.length,t,n),o.subarray(Et)},r.secretbox.open=function(r,t,n){tt(r,t,n),$(n,t);for(var e=new Uint8Array(Et+r.length),o=new Uint8Array(e.length),i=0;i<r.length;i++)e[i+Et]=r[i];return e.length<32?!1:0!==d(o,e,e.length,t,n)?!1:o.subarray(Ut)},r.secretbox.keyLength=dt,r.secretbox.nonceLength=_t,r.secretbox.overheadLength=Et,r.scalarMult=function(r,t){if(tt(r,t),r.length!==mt)throw new Error("bad n size");if(t.length!==xt)throw new Error("bad p size");var n=new Uint8Array(xt);return R(n,r,t),n},r.scalarMult.base=function(r){if(tt(r),r.length!==mt)throw new Error("bad n size");var t=new Uint8Array(xt);return z(t,r),t},r.scalarMult.scalarLength=mt,r.scalarMult.groupElementLength=xt,r.box=function(t,n,e,o){var i=r.box.before(e,o);return r.secretbox(t,n,i)},r.box.before=function(r,t){tt(r,t),rt(r,t);var n=new Uint8Array(Kt);return F(n,r,t),n},r.box.after=r.secretbox,r.box.open=function(t,n,e,o){var i=r.box.before(e,o);return r.secretbox.open(t,n,i)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var r=new Uint8Array(Bt),t=new Uint8Array(St);return P(r,t),{publicKey:r,secretKey:t}},r.box.keyPair.fromSecretKey=function(r){if(tt(r),r.length!==St)throw new Error("bad secret key size");var t=new Uint8Array(Bt);return z(t,r),{publicKey:t,secretKey:r}},r.box.publicKeyLength=Bt,r.box.secretKeyLength=St,r.box.sharedKeyLength=Kt,r.box.nonceLength=Tt,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(r,t){if(tt(r,t),t.length!==Rt)throw new Error("bad secret key size");var n=new Uint8Array(Ct+r.length);return J(n,r,r.length,t),n},r.sign.open=function(r,t){if(2!==arguments.length)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(tt(r,t),t.length!==Lt)throw new Error("bad public key size");var n=new Uint8Array(r.length),e=W(n,r,r.length,t);if(0>e)return null;for(var o=new Uint8Array(e),i=0;i<o.length;i++)o[i]=n[i];return o},r.sign.detached=function(t,n){for(var e=r.sign(t,n),o=new Uint8Array(Ct),i=0;i<o.length;i++)o[i]=e[i];return o},r.sign.detached.verify=function(r,t,n){if(tt(r,t,n),t.length!==Ct)throw new Error("bad signature size");if(n.length!==Lt)throw new Error("bad public key size");var e,o=new Uint8Array(Ct+r.length),i=new Uint8Array(Ct+r.length);for(e=0;Ct>e;e++)o[e]=t[e];for(e=0;e<r.length;e++)o[e+Ct]=r[e];return W(i,o,o.length,n)>=0},r.sign.keyPair=function(){var r=new Uint8Array(Lt),t=new Uint8Array(Rt);return X(r,t),{publicKey:r,secretKey:t}},r.sign.keyPair.fromSecretKey=function(r){if(tt(r),r.length!==Rt)throw new Error("bad secret key size");var t,n=new Uint8Array(Lt);for(t=0;32>t;t++)n[t]=r[32+t];return{publicKey:n,secretKey:r}},r.sign.keyPair.fromSeed=function(r){if(tt(r),32!==r.length)throw new Error("bad seed size");for(var t=new Uint8Array(Lt),n=new Uint8Array(Rt),e=0;32>e;e++)n[e]=r[e];return X(t,n,!0),{publicKey:t,secretKey:n}},r.sign.publicKeyLength=Lt,r.sign.secretKeyLength=Rt,r.sign.signatureLength=Ct,r.hash=function(r){tt(r);var t=new Uint8Array(zt);return M(t,r,r.length),t},r.hash.hashLength=zt,r.verify=function(r,t){return tt(r,t),0===r.length||0===t.length?!1:r.length!==t.length?!1:0===o(r,0,t,0,r.length)?!0:!1},r.setPRNG=function(r){et=r},function(){var t;"undefined"!=typeof window?(window.crypto&&window.crypto.getRandomValues?t=window.crypto:window.msCrypto&&window.msCrypto.getRandomValues&&(t=window.msCrypto),t&&r.setPRNG(function(r,n){var e,o=new Uint8Array(n);for(t.getRandomValues(o),e=0;n>e;e++)r[e]=o[e]})):"undefined"!=typeof require&&(t=require("crypto"),t&&r.setPRNG(function(r,n){var e,o=t.randomBytes(n);for(e=0;n>e;e++)r[e]=o[e]}))}()}("undefined"!=typeof module&&module.exports?module.exports:window.nacl=window.nacl||{});