From 1ea7e435991fdb7caee81ab51d018abd55704bdc Mon Sep 17 00:00:00 2001 From: Dmitry Chestnykh Date: Tue, 9 Sep 2014 09:49:49 +0200 Subject: [PATCH] Inline ld32 and st32. Makes Salsa20 ~1.1 (FF) - 1.8 (Chrome) faster. --- nacl-fast.js | 223 ++++++++++++++++++++++++++++++++--------------- nacl-fast.min.js | 2 +- 2 files changed, 154 insertions(+), 71 deletions(-) diff --git a/nacl-fast.js b/nacl-fast.js index d84b315e..0e5031af 100644 --- a/nacl-fast.js +++ b/nacl-fast.js @@ -30,18 +30,6 @@ var gf0 = gf(), Y = gf([0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666]), I = gf([0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83]); -function ld32(x, i) { - var u = x[i+3] & 0xff; - u = (u<<8)|(x[i+2] & 0xff); - u = (u<<8)|(x[i+1] & 0xff); - return (u<<8)|(x[i+0] & 0xff); -} - -function st32(x, j, u) { - var i; - for (i = 0; i < 4; i++) { x[j+i] = u & 255; u >>>= 8; } -} - function ts64(x, i, h, l) { x[i] = (h >> 24) & 0xff; x[i+1] = (h >> 16) & 0xff; @@ -67,23 +55,23 @@ function crypto_verify_32(x, xi, y, yi) { return vn(x,xi,y,yi,32); } -function core_salsa20(out, inp, k, c) { - var j0 = ld32(c, 0), - j1 = ld32(k, 0), - j2 = ld32(k, 4), - j3 = ld32(k, 8), - j4 = ld32(k, 12), - j5 = ld32(c, 4), - j6 = ld32(inp, 0), - j7 = ld32(inp, 4), - j8 = ld32(inp, 8), - j9 = ld32(inp, 12), - j10 = ld32(c, 8), - j11 = ld32(k, 16), - j12 = ld32(k, 20), - j13 = ld32(k, 24), - j14 = ld32(k, 28), - j15 = ld32(c, 12); +function core_salsa20(o, p, k, c) { + var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24, + j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24, + j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24, + j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24, + j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24, + j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24, + j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24, + j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24, + j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24, + j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24, + j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24, + j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24, + j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24, + j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24, + j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24, + j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24; var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, @@ -179,41 +167,104 @@ function core_salsa20(out, inp, k, c) { x14 = x14 + j14 | 0; x15 = x15 + j15 | 0; - st32(out, 0, x0); - st32(out, 4, x1); - st32(out, 8, x2); - st32(out, 12, x3); - st32(out, 16, x4); - st32(out, 20, x5); - st32(out, 24, x6); - st32(out, 28, x7); - st32(out, 32, x8); - st32(out, 36, x9); - st32(out, 40, x10); - st32(out, 44, x11); - st32(out, 48, x12); - st32(out, 52, x13); - st32(out, 56, x14); - st32(out, 60, x15); + o[ 0] = x0 >>> 0 & 0xff; + o[ 1] = x0 >>> 8 & 0xff; + o[ 2] = x0 >>> 16 & 0xff; + o[ 3] = x0 >>> 24 & 0xff; + + o[ 4] = x1 >>> 0 & 0xff; + o[ 5] = x1 >>> 8 & 0xff; + o[ 6] = x1 >>> 16 & 0xff; + o[ 7] = x1 >>> 24 & 0xff; + + o[ 8] = x2 >>> 0 & 0xff; + o[ 9] = x2 >>> 8 & 0xff; + o[10] = x2 >>> 16 & 0xff; + o[11] = x2 >>> 24 & 0xff; + + o[12] = x3 >>> 0 & 0xff; + o[13] = x3 >>> 8 & 0xff; + o[14] = x3 >>> 16 & 0xff; + o[15] = x3 >>> 24 & 0xff; + + o[16] = x4 >>> 0 & 0xff; + o[17] = x4 >>> 8 & 0xff; + o[18] = x4 >>> 16 & 0xff; + o[19] = x4 >>> 24 & 0xff; + + o[20] = x5 >>> 0 & 0xff; + o[21] = x5 >>> 8 & 0xff; + o[22] = x5 >>> 16 & 0xff; + o[23] = x5 >>> 24 & 0xff; + + o[24] = x6 >>> 0 & 0xff; + o[25] = x6 >>> 8 & 0xff; + o[26] = x6 >>> 16 & 0xff; + o[27] = x6 >>> 24 & 0xff; + + o[28] = x7 >>> 0 & 0xff; + o[29] = x7 >>> 8 & 0xff; + o[30] = x7 >>> 16 & 0xff; + o[31] = x7 >>> 24 & 0xff; + + o[32] = x8 >>> 0 & 0xff; + o[33] = x8 >>> 8 & 0xff; + o[34] = x8 >>> 16 & 0xff; + o[35] = x8 >>> 24 & 0xff; + + o[36] = x9 >>> 0 & 0xff; + o[37] = x9 >>> 8 & 0xff; + o[38] = x9 >>> 16 & 0xff; + o[39] = x9 >>> 24 & 0xff; + + o[40] = x10 >>> 0 & 0xff; + o[41] = x10 >>> 8 & 0xff; + o[42] = x10 >>> 16 & 0xff; + o[43] = x10 >>> 24 & 0xff; + + o[44] = x11 >>> 0 & 0xff; + o[45] = x11 >>> 8 & 0xff; + o[46] = x11 >>> 16 & 0xff; + o[47] = x11 >>> 24 & 0xff; + + o[48] = x12 >>> 0 & 0xff; + o[49] = x12 >>> 8 & 0xff; + o[50] = x12 >>> 16 & 0xff; + o[51] = x12 >>> 24 & 0xff; + + o[52] = x13 >>> 0 & 0xff; + o[53] = x13 >>> 8 & 0xff; + o[54] = x13 >>> 16 & 0xff; + o[55] = x13 >>> 24 & 0xff; + + o[56] = x14 >>> 0 & 0xff; + o[57] = x14 >>> 8 & 0xff; + o[58] = x14 >>> 16 & 0xff; + o[59] = x14 >>> 24 & 0xff; + + o[60] = x15 >>> 0 & 0xff; + o[61] = x15 >>> 8 & 0xff; + o[62] = x15 >>> 16 & 0xff; + o[63] = x15 >>> 24 & 0xff; } -function core_hsalsa20(out,inp,k,c) { - var j0 = ld32(c, 0), - j1 = ld32(k, 0), - j2 = ld32(k, 4), - j3 = ld32(k, 8), - j4 = ld32(k, 12), - j5 = ld32(c, 4), - j6 = ld32(inp, 0), - j7 = ld32(inp, 4), - j8 = ld32(inp, 8), - j9 = ld32(inp, 12), - j10 = ld32(c, 8), - j11 = ld32(k, 16), - j12 = ld32(k, 20), - j13 = ld32(k, 24), - j14 = ld32(k, 28), - j15 = ld32(c, 12); +function core_hsalsa20(o,p,k,c) { + var j0 = c[ 0] & 0xff | (c[ 1] & 0xff)<<8 | (c[ 2] & 0xff)<<16 | (c[ 3] & 0xff)<<24, + j1 = k[ 0] & 0xff | (k[ 1] & 0xff)<<8 | (k[ 2] & 0xff)<<16 | (k[ 3] & 0xff)<<24, + j2 = k[ 4] & 0xff | (k[ 5] & 0xff)<<8 | (k[ 6] & 0xff)<<16 | (k[ 7] & 0xff)<<24, + j3 = k[ 8] & 0xff | (k[ 9] & 0xff)<<8 | (k[10] & 0xff)<<16 | (k[11] & 0xff)<<24, + j4 = k[12] & 0xff | (k[13] & 0xff)<<8 | (k[14] & 0xff)<<16 | (k[15] & 0xff)<<24, + j5 = c[ 4] & 0xff | (c[ 5] & 0xff)<<8 | (c[ 6] & 0xff)<<16 | (c[ 7] & 0xff)<<24, + j6 = p[ 0] & 0xff | (p[ 1] & 0xff)<<8 | (p[ 2] & 0xff)<<16 | (p[ 3] & 0xff)<<24, + j7 = p[ 4] & 0xff | (p[ 5] & 0xff)<<8 | (p[ 6] & 0xff)<<16 | (p[ 7] & 0xff)<<24, + j8 = p[ 8] & 0xff | (p[ 9] & 0xff)<<8 | (p[10] & 0xff)<<16 | (p[11] & 0xff)<<24, + j9 = p[12] & 0xff | (p[13] & 0xff)<<8 | (p[14] & 0xff)<<16 | (p[15] & 0xff)<<24, + j10 = c[ 8] & 0xff | (c[ 9] & 0xff)<<8 | (c[10] & 0xff)<<16 | (c[11] & 0xff)<<24, + j11 = k[16] & 0xff | (k[17] & 0xff)<<8 | (k[18] & 0xff)<<16 | (k[19] & 0xff)<<24, + j12 = k[20] & 0xff | (k[21] & 0xff)<<8 | (k[22] & 0xff)<<16 | (k[23] & 0xff)<<24, + j13 = k[24] & 0xff | (k[25] & 0xff)<<8 | (k[26] & 0xff)<<16 | (k[27] & 0xff)<<24, + j14 = k[28] & 0xff | (k[29] & 0xff)<<8 | (k[30] & 0xff)<<16 | (k[31] & 0xff)<<24, + j15 = c[12] & 0xff | (c[13] & 0xff)<<8 | (c[14] & 0xff)<<16 | (c[15] & 0xff)<<24; var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, @@ -292,14 +343,46 @@ function core_hsalsa20(out,inp,k,c) { u = x14 + x13 | 0; x15 ^= u<<18 | u>>>(32-18); } - st32(out, 0, x0); - st32(out, 4, x5); - st32(out, 8, x10); - st32(out, 12, x15); - st32(out, 16, x6); - st32(out, 20, x7); - st32(out, 24, x8); - st32(out, 28, x9); + + o[ 0] = x0 >>> 0 & 0xff; + o[ 1] = x0 >>> 8 & 0xff; + o[ 2] = x0 >>> 16 & 0xff; + o[ 3] = x0 >>> 24 & 0xff; + + o[ 4] = x5 >>> 0 & 0xff; + o[ 5] = x5 >>> 8 & 0xff; + o[ 6] = x5 >>> 16 & 0xff; + o[ 7] = x5 >>> 24 & 0xff; + + o[ 8] = x10 >>> 0 & 0xff; + o[ 9] = x10 >>> 8 & 0xff; + o[10] = x10 >>> 16 & 0xff; + o[11] = x10 >>> 24 & 0xff; + + o[12] = x15 >>> 0 & 0xff; + o[13] = x15 >>> 8 & 0xff; + o[14] = x15 >>> 16 & 0xff; + o[15] = x15 >>> 24 & 0xff; + + o[16] = x6 >>> 0 & 0xff; + o[17] = x6 >>> 8 & 0xff; + o[18] = x6 >>> 16 & 0xff; + o[19] = x6 >>> 24 & 0xff; + + o[20] = x7 >>> 0 & 0xff; + o[21] = x7 >>> 8 & 0xff; + o[22] = x7 >>> 16 & 0xff; + o[23] = x7 >>> 24 & 0xff; + + o[24] = x8 >>> 0 & 0xff; + o[25] = x8 >>> 8 & 0xff; + o[26] = x8 >>> 16 & 0xff; + o[27] = x8 >>> 24 & 0xff; + + o[28] = x9 >>> 0 & 0xff; + o[29] = x9 >>> 8 & 0xff; + o[30] = x9 >>> 16 & 0xff; + o[31] = x9 >>> 24 & 0xff; } function crypto_core_salsa20(out,inp,k,c) { diff --git a/nacl-fast.min.js b/nacl-fast.min.js index d5e384b4..74bc22e7 100644 --- a/nacl-fast.min.js +++ b/nacl-fast.min.js @@ -1 +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,a=0;for(i=0;o>i;i++)a|=r[t+i]^n[e+i];return(1&a-1>>>8)-1}function i(r,t,n,e){return o(r,t,n,e,16)}function a(r,t,n,e){return o(r,t,n,e,32)}function f(r,e,o,i){for(var a,f=t(i,0),h=t(o,0),s=t(o,4),u=t(o,8),c=t(o,12),y=t(i,4),w=t(e,0),l=t(e,4),v=t(e,8),p=t(e,12),g=t(i,8),b=t(o,16),A=t(o,20),d=t(o,24),_=t(o,28),U=t(i,12),E=f,x=h,m=s,B=u,S=c,K=y,T=w,Y=l,k=v,L=p,C=g,R=b,z=A,P=d,F=_,N=U,O=0;20>O;O+=2)a=E+z|0,S^=a<<7|a>>>25,a=S+E|0,k^=a<<9|a>>>23,a=k+S|0,z^=a<<13|a>>>19,a=z+k|0,E^=a<<18|a>>>14,a=K+x|0,L^=a<<7|a>>>25,a=L+K|0,P^=a<<9|a>>>23,a=P+L|0,x^=a<<13|a>>>19,a=x+P|0,K^=a<<18|a>>>14,a=C+T|0,F^=a<<7|a>>>25,a=F+C|0,m^=a<<9|a>>>23,a=m+F|0,T^=a<<13|a>>>19,a=T+m|0,C^=a<<18|a>>>14,a=N+R|0,B^=a<<7|a>>>25,a=B+N|0,Y^=a<<9|a>>>23,a=Y+B|0,R^=a<<13|a>>>19,a=R+Y|0,N^=a<<18|a>>>14,a=E+B|0,x^=a<<7|a>>>25,a=x+E|0,m^=a<<9|a>>>23,a=m+x|0,B^=a<<13|a>>>19,a=B+m|0,E^=a<<18|a>>>14,a=K+S|0,T^=a<<7|a>>>25,a=T+K|0,Y^=a<<9|a>>>23,a=Y+T|0,S^=a<<13|a>>>19,a=S+Y|0,K^=a<<18|a>>>14,a=C+L|0,R^=a<<7|a>>>25,a=R+C|0,k^=a<<9|a>>>23,a=k+R|0,L^=a<<13|a>>>19,a=L+k|0,C^=a<<18|a>>>14,a=N+F|0,z^=a<<7|a>>>25,a=z+N|0,P^=a<<9|a>>>23,a=P+z|0,F^=a<<13|a>>>19,a=F+P|0,N^=a<<18|a>>>14;E=E+f|0,x=x+h|0,m=m+s|0,B=B+u|0,S=S+c|0,K=K+y|0,T=T+w|0,Y=Y+l|0,k=k+v|0,L=L+p|0,C=C+g|0,R=R+b|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,L),n(r,40,C),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 a,f=t(i,0),h=t(o,0),s=t(o,4),u=t(o,8),c=t(o,12),y=t(i,4),w=t(e,0),l=t(e,4),v=t(e,8),p=t(e,12),g=t(i,8),b=t(o,16),A=t(o,20),d=t(o,24),_=t(o,28),U=t(i,12),E=f,x=h,m=s,B=u,S=c,K=y,T=w,Y=l,k=v,L=p,C=g,R=b,z=A,P=d,F=_,N=U,O=0;20>O;O+=2)a=E+z|0,S^=a<<7|a>>>25,a=S+E|0,k^=a<<9|a>>>23,a=k+S|0,z^=a<<13|a>>>19,a=z+k|0,E^=a<<18|a>>>14,a=K+x|0,L^=a<<7|a>>>25,a=L+K|0,P^=a<<9|a>>>23,a=P+L|0,x^=a<<13|a>>>19,a=x+P|0,K^=a<<18|a>>>14,a=C+T|0,F^=a<<7|a>>>25,a=F+C|0,m^=a<<9|a>>>23,a=m+F|0,T^=a<<13|a>>>19,a=T+m|0,C^=a<<18|a>>>14,a=N+R|0,B^=a<<7|a>>>25,a=B+N|0,Y^=a<<9|a>>>23,a=Y+B|0,R^=a<<13|a>>>19,a=R+Y|0,N^=a<<18|a>>>14,a=E+B|0,x^=a<<7|a>>>25,a=x+E|0,m^=a<<9|a>>>23,a=m+x|0,B^=a<<13|a>>>19,a=B+m|0,E^=a<<18|a>>>14,a=K+S|0,T^=a<<7|a>>>25,a=T+K|0,Y^=a<<9|a>>>23,a=Y+T|0,S^=a<<13|a>>>19,a=S+Y|0,K^=a<<18|a>>>14,a=C+L|0,R^=a<<7|a>>>25,a=R+C|0,k^=a<<9|a>>>23,a=k+R|0,L^=a<<13|a>>>19,a=L+k|0,C^=a<<18|a>>>14,a=N+F|0,z^=a<<7|a>>>25,a=z+N|0,P^=a<<9|a>>>23,a=P+z|0,F^=a<<13|a>>>19,a=F+P|0,N^=a<<18|a>>>14;n(r,0,E),n(r,4,K),n(r,8,C),n(r,12,N),n(r,16,T),n(r,20,Y),n(r,24,k),n(r,28,L)}function s(r,t,n,e){f(r,t,n,e)}function u(r,t,n,e){h(r,t,n,e)}function c(r,t,n,e,o,i,a){var f,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,a,lt),h=0;64>h;h++)r[t+h]=n[e+h]^c[h];for(f=1,h=8;16>h;h++)f=f+(255&u[h])|0,u[h]=255&f,f>>>=8;o-=64,t+=64,e+=64}if(o>0)for(s(c,u,a,lt),h=0;o>h;h++)r[t+h]=n[e+h]^c[h];return 0}function y(r,t,n,e,o){var i,a,f=new Uint8Array(16),h=new Uint8Array(64);for(a=0;16>a;a++)f[a]=0;for(a=0;8>a;a++)f[a]=e[a];for(;n>=64;){for(s(h,f,o,lt),a=0;64>a;a++)r[t+a]=h[a];for(i=1,a=8;16>a;a++)i=i+(255&f[a])|0,f[a]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(s(h,f,o,lt),a=0;n>a;a++)r[t+a]=h[a];return 0}function w(r,t,n,e,o){var i=new Uint8Array(32);u(i,e,o,lt);for(var a=new Uint8Array(8),f=0;8>f;f++)a[f]=e[f+16];return y(r,t,n,a,i)}function l(r,t,n,e,o,i,a){var f=new Uint8Array(32);u(f,i,a,lt);for(var h=new Uint8Array(8),s=0;8>s;s++)h[s]=i[s+16];return c(r,t,n,e,o,h,f)}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 g(r,t,n,e,o,i){var a=new vt(i);return a.update(n,e,o),a.finish(r,t),0}function b(r,t,n,e,o,a){var f=new Uint8Array(16);return g(f,0,n,e,o,a),i(r,t,f,0)}function A(r,t,n,e,o){var i;if(32>n)return-1;for(l(r,0,t,0,n,e,o),g(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,a=new Uint8Array(32);if(32>n)return-1;if(w(a,0,32,e,o),0!==b(t,16,t,32,n-32,a))return-1;for(l(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(),a=nt();for(n=0;16>n;n++)a[n]=t[n];for(U(a),U(a),U(a),e=0;2>e;e++){for(i[0]=a[0]-65517,n=1;15>n;n++)i[n]=a[n]-65535-(i[n-1]>>16&1),i[n-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(n=0;16>n;n++)r[2*n]=255&a[n],r[2*n+1]=a[n]>>8}function m(r,t){var n=new Uint8Array(32),e=new Uint8Array(32);return x(n,r),x(e,t),a(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 L(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 C(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),a=new Float64Array(80),f=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(a,n),o=0;16>o;o++)h[o]=a[o],u[o]=f[o]=s[o]=0;for(f[0]=u[0]=1,o=254;o>=0;--o)e=i[o>>>3]>>>(7&o)&1,E(f,h,e),E(s,u,e),K(c,f,s),T(f,f,s),K(s,h,u),T(h,h,u),k(u,c),k(y,f),Y(f,s,f),Y(s,h,c),K(c,f,s),T(f,f,s),k(h,f),T(s,u,y),Y(f,s,ht),K(f,f,u),Y(s,s,f),Y(f,u,y),Y(u,h,a),k(h,c),E(f,h,e),E(s,u,e);for(o=0;16>o;o++)a[o+16]=f[o],a[o+32]=s[o],a[o+48]=h[o],a[o+64]=u[o];var w=a.subarray(32),l=a.subarray(16);return L(w,w),Y(l,l,w),x(r,l),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,lt)}function N(r,t,n,e,o,i){var a=new Uint8Array(32);return F(a,o,i),pt(r,t,n,e,a)}function O(r,t,n,e,o,i){var a=new Uint8Array(32);return F(a,o,i),gt(r,t,n,e,a)}function I(r,t,n,e){for(var o,i,a,f,h,s,u,c,y,w,l,v,p,g,b,A,d,_,U,E,x,m,B,S,K,T,Y=new Int32Array(16),k=new Int32Array(16),L=r[0],C=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=L,i=C,a=R,f=z,h=P,s=F,u=N,c=O,y=I,w=M,l=G,v=Z,p=j,g=V,b=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=bt[2*U],m=bt[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=(L>>>28|I<<4)^(I>>>2|L<<30)^(I>>>7|L<<25),m=(I>>>28|L<<4)^(L>>>2|I<<30)^(L>>>7|I<<25),B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,x=L&C^L&R^C&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=f,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,f=65535&K|T<<16,v=65535&B|S<<16,C=o,R=i,z=a,P=f,F=h,N=s,O=u,L=c,M=y,G=w,Z=l,j=v,V=p,q=g,X=b,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=L,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]=L=65535&K|T<<16,t[0]=I=65535&B|S<<16,x=C,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]=C=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),a=new Int32Array(8),f=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,a[0]=4089235720,a[1]=2227873595,a[2]=4271175723,a[3]=1595750129,a[4]=2917565137,a[5]=725511199,a[6]=4215389547,a[7]=327033209,I(i,a,t,n),n%=128,o=0;n>o;o++)f[o]=t[h-n+o];for(f[n]=128,n=256-128*(112>n?1:0),f[n-9]=0,e(f,n-8,h/536870912|0,h<<3),I(i,a,f,n),o=0;8>o;o++)e(r,8*o,i[o],a[o]);return 0}function G(r,t){var n=nt(),e=nt(),o=nt(),i=nt(),a=nt(),f=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(a,e,n),T(f,i,o),K(h,i,o),K(s,e,n),Y(r[0],a,f),Y(r[1],s,h),Y(r[2],h,f),Y(r[3],a,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();L(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],at),_(r[1],ft),_(r[2],ft),_(r[3],at),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],ft),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,a=new Uint8Array(64),f=new Uint8Array(64),h=new Uint8Array(64),s=new Float64Array(64),u=[nt(),nt(),nt(),nt()];M(a,e,32),a[0]&=248,a[31]&=127,a[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]=a[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(f,r,n+64),H(f),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]+=f[o]*a[i];return D(r.subarray(32),s),c}function Q(r,t){var n=nt(),e=nt(),o=nt(),i=nt(),a=nt(),f=nt(),h=nt();return _(r[2],ft),S(r[1],t),k(o,r[1]),Y(i,o,st),T(o,o,r[2]),K(i,r[2],i),k(a,i),k(f,a),Y(h,f,a),Y(n,h,o),Y(n,n,i),C(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],wt),k(e,r[0]),Y(e,e,i),m(e,o)?-1:(B(r[0])===t[31]>>7&&T(r[0],at,r[0]),Y(r[3],r[0],r[1]),0)}function W(r,t,n,e){var o,i,f=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(f,s),n-=64,a(t,0,f,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>>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),a=v(r,8),this.r[4]=255&(i>>>4|a<<12),this.r[5]=a>>>1&8190,f=v(r,10),this.r[6]=8191&(a>>>14|f<<2),h=v(r,12),this.r[7]=8065&(f>>>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,a,f,h,s,u,c,y,w,l=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),a=v(r,t+6),this.h[3]+=8191&(i>>>7|a<<9),f=v(r,t+8),this.h[4]+=8191&(a>>>4|f<<12),this.h[5]+=f>>>1&8191,h=v(r,t+10),this.h[6]+=8191&(f>>>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|l,y=0,c=0;10>y;y++){for(p[y]=c,w=0;10>w;w++)p[y]+=this.h[w]*(y>=w?this.r[y-w]:5*this.r[y+10-w]),4===w&&(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,a=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,a[0]=this.h[0]+5,n=a[0]>>>13,a[0]&=8191,i=1;10>i;i++)a[i]=this.h[i]+n,n=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,e=(a[9]>>>15)-1,i=0;10>i;i++)a[i]&=e;for(e=~e,i=0;10>i;i++)this.h[i]=this.h[i]&e|a[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,gt=d,bt=[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,Lt=64,Ct=32,Rt=64,zt=32,Pt=64;r.lowlevel={crypto_core_hsalsa20:u,crypto_stream_xor:l,crypto_stream:w,crypto_stream_salsa20_xor:c,crypto_stream_salsa20:y,crypto_onetimeauth:g,crypto_onetimeauth_verify:b,crypto_verify_16:i,crypto_verify_32:a,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:Lt,crypto_sign_PUBLICKEYBYTES:Ct,crypto_sign_SECRETKEYBYTES:Rt,crypto_sign_SEEDBYTES:zt,crypto_hash_BYTES:Pt},r.util={},r.util.decodeUTF8=function(r){var t,n=unescape(encodeURIComponent(r)),e=new Uint8Array(n.length);for(t=0;tt;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;te)return null;for(var o=new Uint8Array(e),i=0;ie;e++)o[e]=t[e];for(e=0;e=0},r.sign.keyPair=function(){var r=new Uint8Array(Ct),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");for(var t=new Uint8Array(Ct),n=0;ne;e++)n[e]=r[e];return X(t,n,!0),{publicKey:t,secretKey:n}},r.sign.publicKeyLength=Ct,r.sign.secretKeyLength=Rt,r.sign.seedLength=zt,r.sign.signatureLength=Lt,r.hash=function(r){tt(r);var t=new Uint8Array(Pt);return M(t,r,r.length),t},r.hash.hashLength=Pt,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||{}); \ No newline at end of file +!function(r){"use strict";function t(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 n(r,t,n,e,o){var i,a=0;for(i=0;o>i;i++)a|=r[t+i]^n[e+i];return(1&a-1>>>8)-1}function e(r,t,e,o){return n(r,t,e,o,16)}function o(r,t,e,o){return n(r,t,e,o,32)}function i(r,t,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,a=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,s=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,y=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,w=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,l=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,g=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,b=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,A=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,_=i,U=a,E=f,x=h,m=s,B=u,S=c,K=y,T=w,Y=l,k=p,L=g,C=v,R=b,z=A,P=d,F=0;20>F;F+=2)o=_+C|0,m^=o<<7|o>>>25,o=m+_|0,T^=o<<9|o>>>23,o=T+m|0,C^=o<<13|o>>>19,o=C+T|0,_^=o<<18|o>>>14,o=B+U|0,Y^=o<<7|o>>>25,o=Y+B|0,R^=o<<9|o>>>23,o=R+Y|0,U^=o<<13|o>>>19,o=U+R|0,B^=o<<18|o>>>14,o=k+S|0,z^=o<<7|o>>>25,o=z+k|0,E^=o<<9|o>>>23,o=E+z|0,S^=o<<13|o>>>19,o=S+E|0,k^=o<<18|o>>>14,o=P+L|0,x^=o<<7|o>>>25,o=x+P|0,K^=o<<9|o>>>23,o=K+x|0,L^=o<<13|o>>>19,o=L+K|0,P^=o<<18|o>>>14,o=_+x|0,U^=o<<7|o>>>25,o=U+_|0,E^=o<<9|o>>>23,o=E+U|0,x^=o<<13|o>>>19,o=x+E|0,_^=o<<18|o>>>14,o=B+m|0,S^=o<<7|o>>>25,o=S+B|0,K^=o<<9|o>>>23,o=K+S|0,m^=o<<13|o>>>19,o=m+K|0,B^=o<<18|o>>>14,o=k+Y|0,L^=o<<7|o>>>25,o=L+k|0,T^=o<<9|o>>>23,o=T+L|0,Y^=o<<13|o>>>19,o=Y+T|0,k^=o<<18|o>>>14,o=P+z|0,C^=o<<7|o>>>25,o=C+P|0,R^=o<<9|o>>>23,o=R+C|0,z^=o<<13|o>>>19,o=z+R|0,P^=o<<18|o>>>14;_=_+i|0,U=U+a|0,E=E+f|0,x=x+h|0,m=m+s|0,B=B+u|0,S=S+c|0,K=K+y|0,T=T+w|0,Y=Y+l|0,k=k+p|0,L=L+g|0,C=C+v|0,R=R+b|0,z=z+A|0,P=P+d|0,r[0]=_>>>0&255,r[1]=_>>>8&255,r[2]=_>>>16&255,r[3]=_>>>24&255,r[4]=U>>>0&255,r[5]=U>>>8&255,r[6]=U>>>16&255,r[7]=U>>>24&255,r[8]=E>>>0&255,r[9]=E>>>8&255,r[10]=E>>>16&255,r[11]=E>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=m>>>0&255,r[17]=m>>>8&255,r[18]=m>>>16&255,r[19]=m>>>24&255,r[20]=B>>>0&255,r[21]=B>>>8&255,r[22]=B>>>16&255,r[23]=B>>>24&255,r[24]=S>>>0&255,r[25]=S>>>8&255,r[26]=S>>>16&255,r[27]=S>>>24&255,r[28]=K>>>0&255,r[29]=K>>>8&255,r[30]=K>>>16&255,r[31]=K>>>24&255,r[32]=T>>>0&255,r[33]=T>>>8&255,r[34]=T>>>16&255,r[35]=T>>>24&255,r[36]=Y>>>0&255,r[37]=Y>>>8&255,r[38]=Y>>>16&255,r[39]=Y>>>24&255,r[40]=k>>>0&255,r[41]=k>>>8&255,r[42]=k>>>16&255,r[43]=k>>>24&255,r[44]=L>>>0&255,r[45]=L>>>8&255,r[46]=L>>>16&255,r[47]=L>>>24&255,r[48]=C>>>0&255,r[49]=C>>>8&255,r[50]=C>>>16&255,r[51]=C>>>24&255,r[52]=R>>>0&255,r[53]=R>>>8&255,r[54]=R>>>16&255,r[55]=R>>>24&255,r[56]=z>>>0&255,r[57]=z>>>8&255,r[58]=z>>>16&255,r[59]=z>>>24&255,r[60]=P>>>0&255,r[61]=P>>>8&255,r[62]=P>>>16&255,r[63]=P>>>24&255}function a(r,t,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,a=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,h=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,s=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,y=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,w=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,l=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,p=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,g=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,v=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,b=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,A=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,_=i,U=a,E=f,x=h,m=s,B=u,S=c,K=y,T=w,Y=l,k=p,L=g,C=v,R=b,z=A,P=d,F=0;20>F;F+=2)o=_+C|0,m^=o<<7|o>>>25,o=m+_|0,T^=o<<9|o>>>23,o=T+m|0,C^=o<<13|o>>>19,o=C+T|0,_^=o<<18|o>>>14,o=B+U|0,Y^=o<<7|o>>>25,o=Y+B|0,R^=o<<9|o>>>23,o=R+Y|0,U^=o<<13|o>>>19,o=U+R|0,B^=o<<18|o>>>14,o=k+S|0,z^=o<<7|o>>>25,o=z+k|0,E^=o<<9|o>>>23,o=E+z|0,S^=o<<13|o>>>19,o=S+E|0,k^=o<<18|o>>>14,o=P+L|0,x^=o<<7|o>>>25,o=x+P|0,K^=o<<9|o>>>23,o=K+x|0,L^=o<<13|o>>>19,o=L+K|0,P^=o<<18|o>>>14,o=_+x|0,U^=o<<7|o>>>25,o=U+_|0,E^=o<<9|o>>>23,o=E+U|0,x^=o<<13|o>>>19,o=x+E|0,_^=o<<18|o>>>14,o=B+m|0,S^=o<<7|o>>>25,o=S+B|0,K^=o<<9|o>>>23,o=K+S|0,m^=o<<13|o>>>19,o=m+K|0,B^=o<<18|o>>>14,o=k+Y|0,L^=o<<7|o>>>25,o=L+k|0,T^=o<<9|o>>>23,o=T+L|0,Y^=o<<13|o>>>19,o=Y+T|0,k^=o<<18|o>>>14,o=P+z|0,C^=o<<7|o>>>25,o=C+P|0,R^=o<<9|o>>>23,o=R+C|0,z^=o<<13|o>>>19,o=z+R|0,P^=o<<18|o>>>14;r[0]=_>>>0&255,r[1]=_>>>8&255,r[2]=_>>>16&255,r[3]=_>>>24&255,r[4]=B>>>0&255,r[5]=B>>>8&255,r[6]=B>>>16&255,r[7]=B>>>24&255,r[8]=k>>>0&255,r[9]=k>>>8&255,r[10]=k>>>16&255,r[11]=k>>>24&255,r[12]=P>>>0&255,r[13]=P>>>8&255,r[14]=P>>>16&255,r[15]=P>>>24&255,r[16]=S>>>0&255,r[17]=S>>>8&255,r[18]=S>>>16&255,r[19]=S>>>24&255,r[20]=K>>>0&255,r[21]=K>>>8&255,r[22]=K>>>16&255,r[23]=K>>>24&255,r[24]=T>>>0&255,r[25]=T>>>8&255,r[26]=T>>>16&255,r[27]=T>>>24&255,r[28]=Y>>>0&255,r[29]=Y>>>8&255,r[30]=Y>>>16&255,r[31]=Y>>>24&255}function f(r,t,n,e){i(r,t,n,e)}function h(r,t,n,e){a(r,t,n,e)}function s(r,t,n,e,o,i,a){var h,s,u=new Uint8Array(16),c=new Uint8Array(64);for(s=0;16>s;s++)u[s]=0;for(s=0;8>s;s++)u[s]=i[s];for(;o>=64;){for(f(c,u,a,yt),s=0;64>s;s++)r[t+s]=n[e+s]^c[s];for(h=1,s=8;16>s;s++)h=h+(255&u[s])|0,u[s]=255&h,h>>>=8;o-=64,t+=64,e+=64}if(o>0)for(f(c,u,a,yt),s=0;o>s;s++)r[t+s]=n[e+s]^c[s];return 0}function u(r,t,n,e,o){var i,a,h=new Uint8Array(16),s=new Uint8Array(64);for(a=0;16>a;a++)h[a]=0;for(a=0;8>a;a++)h[a]=e[a];for(;n>=64;){for(f(s,h,o,yt),a=0;64>a;a++)r[t+a]=s[a];for(i=1,a=8;16>a;a++)i=i+(255&h[a])|0,h[a]=255&i,i>>>=8;n-=64,t+=64}if(n>0)for(f(s,h,o,yt),a=0;n>a;a++)r[t+a]=s[a];return 0}function c(r,t,n,e,o){var i=new Uint8Array(32);h(i,e,o,yt);for(var a=new Uint8Array(8),f=0;8>f;f++)a[f]=e[f+16];return u(r,t,n,a,i)}function y(r,t,n,e,o,i,a){var f=new Uint8Array(32);h(f,i,a,yt);for(var u=new Uint8Array(8),c=0;8>c;c++)u[c]=i[c+16];return s(r,t,n,e,o,u,f)}function w(r,t){return 255&r[t]|(255&r[t+1])<<8}function l(r,t,n){r[t]=n>>>0&255,r[t+1]=n>>>8&255}function p(r,t,n,e,o,i){var a=new wt(i);return a.update(n,e,o),a.finish(r,t),0}function g(r,t,n,o,i,a){var f=new Uint8Array(16);return p(f,0,n,o,i,a),e(r,t,f,0)}function v(r,t,n,e,o){var i;if(32>n)return-1;for(y(r,0,t,0,n,e,o),p(r,16,r,32,n-32,r),i=0;16>i;i++)r[i]=0;return 0}function b(r,t,n,e,o){var i,a=new Uint8Array(32);if(32>n)return-1;if(c(a,0,32,e,o),0!==g(t,16,t,32,n-32,a))return-1;for(y(r,0,t,0,n,e,o),i=0;32>i;i++)r[i]=0;return 0}function A(r,t){var n;for(n=0;16>n;n++)r[n]=0|t[n]}function d(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 _(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 U(r,t){var n,e,o,i=rt(),a=rt();for(n=0;16>n;n++)a[n]=t[n];for(d(a),d(a),d(a),e=0;2>e;e++){for(i[0]=a[0]-65517,n=1;15>n;n++)i[n]=a[n]-65535-(i[n-1]>>16&1),i[n-1]&=65535;i[15]=a[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,_(a,i,1-o)}for(n=0;16>n;n++)r[2*n]=255&a[n],r[2*n+1]=a[n]>>8}function E(r,t){var n=new Uint8Array(32),e=new Uint8Array(32);return U(n,r),U(e,t),o(n,0,e,0)}function x(r){var t=new Uint8Array(32);return U(t,r),1&t[0]}function m(r,t){var n;for(n=0;16>n;n++)r[n]=t[2*n]+(t[2*n+1]<<8);r[15]&=32767}function B(r,t,n){var e;for(e=0;16>e;e++)r[e]=t[e]+n[e]|0}function S(r,t,n){var e;for(e=0;16>e;e++)r[e]=t[e]-n[e]|0}function K(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];d(r),d(r)}function T(r,t){K(r,t,t)}function Y(r,t){var n,e=rt();for(n=0;16>n;n++)e[n]=t[n];for(n=253;n>=0;n--)T(e,e),2!==n&&4!==n&&K(e,e,t);for(n=0;16>n;n++)r[n]=e[n]}function k(r,t){var n,e=rt();for(n=0;16>n;n++)e[n]=t[n];for(n=250;n>=0;n--)T(e,e),1!==n&&K(e,e,t);for(n=0;16>n;n++)r[n]=e[n]}function L(r,t,n){var e,o,i=new Uint8Array(32),a=new Float64Array(80),f=rt(),h=rt(),s=rt(),u=rt(),c=rt(),y=rt();for(o=0;31>o;o++)i[o]=t[o];for(i[31]=127&t[31]|64,i[0]&=248,m(a,n),o=0;16>o;o++)h[o]=a[o],u[o]=f[o]=s[o]=0;for(f[0]=u[0]=1,o=254;o>=0;--o)e=i[o>>>3]>>>(7&o)&1,_(f,h,e),_(s,u,e),B(c,f,s),S(f,f,s),B(s,h,u),S(h,h,u),T(u,c),T(y,f),K(f,s,f),K(s,h,c),B(c,f,s),S(f,f,s),T(h,f),S(s,u,y),K(f,s,at),B(f,f,u),K(s,s,f),K(f,u,y),K(u,h,a),T(h,c),_(f,h,e),_(s,u,e);for(o=0;16>o;o++)a[o+16]=f[o],a[o+32]=s[o],a[o+48]=h[o],a[o+64]=u[o];var w=a.subarray(32),l=a.subarray(16);return Y(w,w),K(l,l,w),U(r,l),0}function C(r,t){return L(r,t,et)}function R(r,t){return tt(t,32),C(r,t)}function z(r,t,n){var e=new Uint8Array(32);return L(e,n,t),h(r,nt,e,yt)}function P(r,t,n,e,o,i){var a=new Uint8Array(32);return z(a,o,i),lt(r,t,n,e,a)}function F(r,t,n,e,o,i){var a=new Uint8Array(32);return z(a,o,i),pt(r,t,n,e,a)}function N(r,t,n,e){for(var o,i,a,f,h,s,u,c,y,w,l,p,g,v,b,A,d,_,U,E,x,m,B,S,K,T,Y=new Int32Array(16),k=new Int32Array(16),L=r[0],C=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=L,i=C,a=R,f=z,h=P,s=F,u=N,c=O,y=I,w=M,l=G,p=Z,g=j,v=V,b=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=(L>>>28|I<<4)^(I>>>2|L<<30)^(I>>>7|L<<25),m=(I>>>28|L<<4)^(L>>>2|I<<30)^(L>>>7|I<<25),B+=65535&m,S+=m>>>16,K+=65535&x,T+=x>>>16,x=L&C^L&R^C&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=f,m=p,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,f=65535&K|T<<16,p=65535&B|S<<16,C=o,R=i,z=a,P=f,F=h,N=s,O=u,L=c,M=y,G=w,Z=l,j=p,V=g,q=v,X=b,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=L,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]=L=65535&K|T<<16,t[0]=I=65535&B|S<<16,x=C,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]=C=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 O(r,n,e){var o,i=new Int32Array(8),a=new Int32Array(8),f=new Uint8Array(256),h=e;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,a[0]=4089235720,a[1]=2227873595,a[2]=4271175723,a[3]=1595750129,a[4]=2917565137,a[5]=725511199,a[6]=4215389547,a[7]=327033209,N(i,a,n,e),e%=128,o=0;e>o;o++)f[o]=n[h-e+o];for(f[e]=128,e=256-128*(112>e?1:0),f[e-9]=0,t(f,e-8,h/536870912|0,h<<3),N(i,a,f,e),o=0;8>o;o++)t(r,8*o,i[o],a[o]);return 0}function I(r,t){var n=rt(),e=rt(),o=rt(),i=rt(),a=rt(),f=rt(),h=rt(),s=rt(),u=rt();S(n,r[1],r[0]),S(u,t[1],t[0]),K(n,n,u),B(e,r[0],r[1]),B(u,t[0],t[1]),K(e,e,u),K(o,r[3],t[3]),K(o,o,ht),K(i,r[2],t[2]),B(i,i,i),S(a,e,n),S(f,i,o),B(h,i,o),B(s,e,n),K(r[0],a,f),K(r[1],s,h),K(r[2],h,f),K(r[3],a,s)}function M(r,t,n){var e;for(e=0;4>e;e++)_(r[e],t[e],n)}function G(r,t){var n=rt(),e=rt(),o=rt();Y(o,t[2]),K(n,t[0],o),K(e,t[1],o),U(r,e),r[31]^=x(n)<<7}function Z(r,t,n){var e,o;for(A(r[0],ot),A(r[1],it),A(r[2],it),A(r[3],ot),o=255;o>=0;--o)e=n[o/8|0]>>(7&o)&1,M(r,t,e),I(t,r),I(r,r),M(r,t,e)}function j(r,t){var n=[rt(),rt(),rt(),rt()];A(n[0],st),A(n[1],ut),A(n[2],it),K(n[3],st,ut),Z(r,n,t)}function V(r,t,n){var e,o=new Uint8Array(64),i=[rt(),rt(),rt(),rt()];for(n||tt(t,32),O(o,t,32),o[0]&=248,o[31]&=127,o[31]|=64,j(i,o),G(r,i),e=0;32>e;e++)t[e+32]=r[e];return 0}function q(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]*vt[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)*vt[o],n=t[o]>>8,t[o]&=255;for(o=0;32>o;o++)t[o]-=n*vt[o];for(e=0;32>e;e++)t[e+1]+=t[e]>>8,r[e]=255&t[e]}function X(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;q(r,n)}function D(r,t,n,e){var o,i,a=new Uint8Array(64),f=new Uint8Array(64),h=new Uint8Array(64),s=new Float64Array(64),u=[rt(),rt(),rt(),rt()];O(a,e,32),a[0]&=248,a[31]&=127,a[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]=a[32+o];for(O(h,r.subarray(32),n+32),X(h),j(u,h),G(r,u),o=32;64>o;o++)r[o]=e[o];for(O(f,r,n+64),X(f),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]+=f[o]*a[i];return q(r.subarray(32),s),c}function H(r,t){var n=rt(),e=rt(),o=rt(),i=rt(),a=rt(),f=rt(),h=rt();return A(r[2],it),m(r[1],t),T(o,r[1]),K(i,o,ft),S(o,o,r[2]),B(i,r[2],i),T(a,i),T(f,a),K(h,f,a),K(n,h,o),K(n,n,i),k(n,n),K(n,n,o),K(n,n,i),K(n,n,i),K(r[0],n,i),T(e,r[0]),K(e,e,i),E(e,o)&&K(r[0],r[0],ct),T(e,r[0]),K(e,e,i),E(e,o)?-1:(x(r[0])===t[31]>>7&&S(r[0],ot,r[0]),K(r[3],r[0],r[1]),0)}function J(r,t,n,e){var i,a,f=new Uint8Array(32),h=new Uint8Array(64),s=[rt(),rt(),rt(),rt()],u=[rt(),rt(),rt(),rt()];if(a=-1,64>n)return-1;if(H(u,e))return-1;for(i=0;n>i;i++)r[i]=t[i];for(i=0;32>i;i++)r[i+32]=e[i];if(O(h,r,n),X(h),Z(s,u,h),j(u,t.subarray(32)),I(s,u),G(f,s),n-=64,o(t,0,f,0)){for(i=0;n>i;i++)r[i]=0;return-1}for(i=0;n>i;i++)r[i]=t[i+64];return a=n}function Q(r,t){if(r.length!==bt)throw new Error("bad key size");if(t.length!==At)throw new Error("bad nonce size")}function W(r,t){if(r.length!==xt)throw new Error("bad public key size");if(t.length!==mt)throw new Error("bad secret key size")}function $(){for(var r,t={}.toString,n=0;n>>13|e<<3),o=w(r,4),this.r[2]=7939&(e>>>10|o<<6),i=w(r,6),this.r[3]=8191&(o>>>7|i<<9),a=w(r,8),this.r[4]=255&(i>>>4|a<<12),this.r[5]=a>>>1&8190,f=w(r,10),this.r[6]=8191&(a>>>14|f<<2),h=w(r,12),this.r[7]=8065&(f>>>11|h<<5),s=w(r,14),this.r[8]=8191&(h>>>8|s<<8),this.r[9]=s>>>5&127,t=0;8>t;t++)this.pad[t]=w(r,16+2*t)};wt.prototype.blocks=function(r,t,n){for(var e,o,i,a,f,h,s,u,c,y,l,p=this.fin?0:2048,g=new Uint32Array(10);n>=16;){for(e=w(r,t+0),this.h[0]+=8191&e,o=w(r,t+2),this.h[1]+=8191&(e>>>13|o<<3),i=w(r,t+4),this.h[2]+=8191&(o>>>10|i<<6),a=w(r,t+6),this.h[3]+=8191&(i>>>7|a<<9),f=w(r,t+8),this.h[4]+=8191&(a>>>4|f<<12),this.h[5]+=f>>>1&8191,h=w(r,t+10),this.h[6]+=8191&(f>>>14|h<<2),s=w(r,t+12),this.h[7]+=8191&(h>>>11|s<<5),u=w(r,t+14),this.h[8]+=8191&(s>>>8|u<<8),this.h[9]+=u>>>5|p,y=0,c=0;10>y;y++){for(g[y]=c,l=0;10>l;l++)g[y]+=this.h[l]*(y>=l?this.r[y-l]:5*this.r[y+10-l]),4===l&&(c=g[y]>>>13,g[y]&=8191);c+=g[y]>>>13,g[y]&=8191}for(c=(c<<2)+c|0,c=c+g[0]|0,g[0]=8191&c,c>>>=13,g[1]+=c,y=0;10>y;y++)this.h[y]=g[y];t+=16,n-=16}},wt.prototype.finish=function(r,t){var n,e,o,i,a=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,a[0]=this.h[0]+5,n=a[0]>>>13,a[0]&=8191,i=1;10>i;i++)a[i]=this.h[i]+n,n=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,e=(a[9]>>>15)-1,i=0;10>i;i++)a[i]&=e;for(e=~e,i=0;10>i;i++)this.h[i]=this.h[i]&e|a[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++)l(r,t+2*i,this.h[i])},wt.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 lt=v,pt=b,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],vt=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]),bt=32,At=24,dt=32,_t=16,Ut=32,Et=32,xt=32,mt=32,Bt=32,St=At,Kt=dt,Tt=_t,Yt=64,kt=32,Lt=64,Ct=32,Rt=64;r.lowlevel={crypto_core_hsalsa20:h,crypto_stream_xor:y,crypto_stream:c,crypto_stream_salsa20_xor:s,crypto_stream_salsa20:u,crypto_onetimeauth:p,crypto_onetimeauth_verify:g,crypto_verify_16:e,crypto_verify_32:o,crypto_secretbox:v,crypto_secretbox_open:b,crypto_scalarmult:L,crypto_scalarmult_base:C,crypto_box_beforenm:z,crypto_box_afternm:lt,crypto_box:P,crypto_box_open:F,crypto_box_keypair:R,crypto_hash:O,crypto_sign:D,crypto_sign_keypair:V,crypto_sign_open:J,crypto_secretbox_KEYBYTES:bt,crypto_secretbox_NONCEBYTES:At,crypto_secretbox_ZEROBYTES:dt,crypto_secretbox_BOXZEROBYTES:_t,crypto_scalarmult_BYTES:Ut,crypto_scalarmult_SCALARBYTES:Et,crypto_box_PUBLICKEYBYTES:xt,crypto_box_SECRETKEYBYTES:mt,crypto_box_BEFORENMBYTES:Bt,crypto_box_NONCEBYTES:St,crypto_box_ZEROBYTES:Kt,crypto_box_BOXZEROBYTES:Tt,crypto_sign_BYTES:Yt,crypto_sign_PUBLICKEYBYTES:kt,crypto_sign_SECRETKEYBYTES:Lt,crypto_sign_SEEDBYTES:Ct,crypto_hash_BYTES:Rt},r.util={},r.util.decodeUTF8=function(r){var t,n=unescape(encodeURIComponent(r)),e=new Uint8Array(n.length);for(t=0;tt;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;te)return null;for(var o=new Uint8Array(e),i=0;ie;e++)o[e]=t[e];for(e=0;e=0},r.sign.keyPair=function(){var r=new Uint8Array(kt),t=new Uint8Array(Lt);return V(r,t),{publicKey:r,secretKey:t}},r.sign.keyPair.fromSecretKey=function(r){if($(r),r.length!==Lt)throw new Error("bad secret key size");for(var t=new Uint8Array(kt),n=0;ne;e++)n[e]=r[e];return V(t,n,!0),{publicKey:t,secretKey:n}},r.sign.publicKeyLength=kt,r.sign.secretKeyLength=Lt,r.sign.seedLength=Ct,r.sign.signatureLength=Yt,r.hash=function(r){$(r);var t=new Uint8Array(Rt);return O(t,r,r.length),t},r.hash.hashLength=Rt,r.verify=function(r,t){return $(r,t),0===r.length||0===t.length?!1:r.length!==t.length?!1:0===n(r,0,t,0,r.length)?!0:!1},r.setPRNG=function(r){tt=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||{}); \ No newline at end of file