Comparing version 0.2.0-alpha1 to 0.2.0-alpha2
@@ -1,2 +0,2 @@ | ||
import{sha256 as r}from"js-sha256";import{keccak_256 as t}from"js-sha3";import{isMNID as e}from"mnid";import{ec as n}from"elliptic";import{Buffer as o}from"buffer";import i from"base64url";import a from"did-resolver";import f from"uport-did-resolver";import{encodeBase64Url as h,decodeBase64Url as s,registerNaclDID as u}from"nacl-did";function c(t){return o.from(r.arrayBuffer(t))}function l(r){return"0x"+(e=o.from(r.slice(2),"hex"),o.from(t.buffer(e))).slice(-20).toString("hex");var e}var y=new n("secp256k1");function d(r,t){return void 0===t&&(t=64),r.length===t?r:"0".repeat(t-r.length)+r}var p="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(r,t){return r(t={exports:{}},t.exports),t.exports}var w,g=(w={default:{}})&&w.default||w,b=v(function(r){!function(r){var t=function(r){var t,e=new Float64Array(16);if(r)for(t=0;t<r.length;t++)e[t]=r[t];return e},e=function(){throw new Error("no PRNG")},n=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=t(),a=t([1]),f=t([56129,1]),h=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),s=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),c=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function y(r,t,e,n){r[t]=e>>24&255,r[t+1]=e>>16&255,r[t+2]=e>>8&255,r[t+3]=255&e,r[t+4]=n>>24&255,r[t+5]=n>>16&255,r[t+6]=n>>8&255,r[t+7]=255&n}function d(r,t,e,n,o){var i,a=0;for(i=0;i<o;i++)a|=r[t+i]^e[n+i];return(1&a-1>>>8)-1}function p(r,t,e,n){return d(r,t,e,n,16)}function v(r,t,e,n){return d(r,t,e,n,32)}function w(r,t,e,n){!function(r,t,e,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,h=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,s=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,y=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,d=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&e[16]|(255&e[17])<<8|(255&e[18])<<16|(255&e[19])<<24,w=255&e[20]|(255&e[21])<<8|(255&e[22])<<16|(255&e[23])<<24,g=255&e[24]|(255&e[25])<<8|(255&e[26])<<16|(255&e[27])<<24,b=255&e[28]|(255&e[29])<<8|(255&e[30])<<16|(255&e[31])<<24,m=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,E=i,A=a,U=f,x=h,_=s,S=u,T=c,B=l,M=y,K=d,k=p,P=v,Y=w,j=g,z=b,J=m,L=0;L<20;L+=2)E^=(o=(Y^=(o=(M^=(o=(_^=(o=E+Y|0)<<7|o>>>25)+E|0)<<9|o>>>23)+_|0)<<13|o>>>19)+M|0)<<18|o>>>14,S^=(o=(A^=(o=(j^=(o=(K^=(o=S+A|0)<<7|o>>>25)+S|0)<<9|o>>>23)+K|0)<<13|o>>>19)+j|0)<<18|o>>>14,k^=(o=(T^=(o=(U^=(o=(z^=(o=k+T|0)<<7|o>>>25)+k|0)<<9|o>>>23)+z|0)<<13|o>>>19)+U|0)<<18|o>>>14,J^=(o=(P^=(o=(B^=(o=(x^=(o=J+P|0)<<7|o>>>25)+J|0)<<9|o>>>23)+x|0)<<13|o>>>19)+B|0)<<18|o>>>14,E^=(o=(x^=(o=(U^=(o=(A^=(o=E+x|0)<<7|o>>>25)+E|0)<<9|o>>>23)+A|0)<<13|o>>>19)+U|0)<<18|o>>>14,S^=(o=(_^=(o=(B^=(o=(T^=(o=S+_|0)<<7|o>>>25)+S|0)<<9|o>>>23)+T|0)<<13|o>>>19)+B|0)<<18|o>>>14,k^=(o=(K^=(o=(M^=(o=(P^=(o=k+K|0)<<7|o>>>25)+k|0)<<9|o>>>23)+P|0)<<13|o>>>19)+M|0)<<18|o>>>14,J^=(o=(z^=(o=(j^=(o=(Y^=(o=J+z|0)<<7|o>>>25)+J|0)<<9|o>>>23)+Y|0)<<13|o>>>19)+j|0)<<18|o>>>14;A=A+a|0,U=U+f|0,x=x+h|0,_=_+s|0,S=S+u|0,T=T+c|0,B=B+l|0,M=M+y|0,K=K+d|0,k=k+p|0,P=P+v|0,Y=Y+w|0,j=j+g|0,z=z+b|0,J=J+m|0,r[0]=(E=E+i|0)>>>0&255,r[1]=E>>>8&255,r[2]=E>>>16&255,r[3]=E>>>24&255,r[4]=A>>>0&255,r[5]=A>>>8&255,r[6]=A>>>16&255,r[7]=A>>>24&255,r[8]=U>>>0&255,r[9]=U>>>8&255,r[10]=U>>>16&255,r[11]=U>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=_>>>0&255,r[17]=_>>>8&255,r[18]=_>>>16&255,r[19]=_>>>24&255,r[20]=S>>>0&255,r[21]=S>>>8&255,r[22]=S>>>16&255,r[23]=S>>>24&255,r[24]=T>>>0&255,r[25]=T>>>8&255,r[26]=T>>>16&255,r[27]=T>>>24&255,r[28]=B>>>0&255,r[29]=B>>>8&255,r[30]=B>>>16&255,r[31]=B>>>24&255,r[32]=M>>>0&255,r[33]=M>>>8&255,r[34]=M>>>16&255,r[35]=M>>>24&255,r[36]=K>>>0&255,r[37]=K>>>8&255,r[38]=K>>>16&255,r[39]=K>>>24&255,r[40]=k>>>0&255,r[41]=k>>>8&255,r[42]=k>>>16&255,r[43]=k>>>24&255,r[44]=P>>>0&255,r[45]=P>>>8&255,r[46]=P>>>16&255,r[47]=P>>>24&255,r[48]=Y>>>0&255,r[49]=Y>>>8&255,r[50]=Y>>>16&255,r[51]=Y>>>24&255,r[52]=j>>>0&255,r[53]=j>>>8&255,r[54]=j>>>16&255,r[55]=j>>>24&255,r[56]=z>>>0&255,r[57]=z>>>8&255,r[58]=z>>>16&255,r[59]=z>>>24&255,r[60]=J>>>0&255,r[61]=J>>>8&255,r[62]=J>>>16&255,r[63]=J>>>24&255}(r,t,e,n)}function b(r,t,e,n){!function(r,t,e,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,h=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,s=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,y=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,d=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&e[16]|(255&e[17])<<8|(255&e[18])<<16|(255&e[19])<<24,w=255&e[20]|(255&e[21])<<8|(255&e[22])<<16|(255&e[23])<<24,g=255&e[24]|(255&e[25])<<8|(255&e[26])<<16|(255&e[27])<<24,b=255&e[28]|(255&e[29])<<8|(255&e[30])<<16|(255&e[31])<<24,m=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,E=0;E<20;E+=2)i^=(o=(w^=(o=(y^=(o=(s^=(o=i+w|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+y|0)<<18|o>>>14,u^=(o=(a^=(o=(g^=(o=(d^=(o=u+a|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+g|0)<<18|o>>>14,p^=(o=(c^=(o=(f^=(o=(b^=(o=p+c|0)<<7|o>>>25)+p|0)<<9|o>>>23)+b|0)<<13|o>>>19)+f|0)<<18|o>>>14,m^=(o=(v^=(o=(l^=(o=(h^=(o=m+v|0)<<7|o>>>25)+m|0)<<9|o>>>23)+h|0)<<13|o>>>19)+l|0)<<18|o>>>14,i^=(o=(h^=(o=(f^=(o=(a^=(o=i+h|0)<<7|o>>>25)+i|0)<<9|o>>>23)+a|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(l^=(o=(c^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+c|0)<<13|o>>>19)+l|0)<<18|o>>>14,p^=(o=(d^=(o=(y^=(o=(v^=(o=p+d|0)<<7|o>>>25)+p|0)<<9|o>>>23)+v|0)<<13|o>>>19)+y|0)<<18|o>>>14,m^=(o=(b^=(o=(g^=(o=(w^=(o=m+b|0)<<7|o>>>25)+m|0)<<9|o>>>23)+w|0)<<13|o>>>19)+g|0)<<18|o>>>14;r[0]=i>>>0&255,r[1]=i>>>8&255,r[2]=i>>>16&255,r[3]=i>>>24&255,r[4]=u>>>0&255,r[5]=u>>>8&255,r[6]=u>>>16&255,r[7]=u>>>24&255,r[8]=p>>>0&255,r[9]=p>>>8&255,r[10]=p>>>16&255,r[11]=p>>>24&255,r[12]=m>>>0&255,r[13]=m>>>8&255,r[14]=m>>>16&255,r[15]=m>>>24&255,r[16]=c>>>0&255,r[17]=c>>>8&255,r[18]=c>>>16&255,r[19]=c>>>24&255,r[20]=l>>>0&255,r[21]=l>>>8&255,r[22]=l>>>16&255,r[23]=l>>>24&255,r[24]=y>>>0&255,r[25]=y>>>8&255,r[26]=y>>>16&255,r[27]=y>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255}(r,t,e,n)}var m=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function E(r,t,e,n,o,i,a){var f,h,s=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)s[h]=0;for(h=0;h<8;h++)s[h]=i[h];for(;o>=64;){for(w(u,s,a,m),h=0;h<64;h++)r[t+h]=e[n+h]^u[h];for(f=1,h=8;h<16;h++)s[h]=255&(f=f+(255&s[h])|0),f>>>=8;o-=64,t+=64,n+=64}if(o>0)for(w(u,s,a,m),h=0;h<o;h++)r[t+h]=e[n+h]^u[h];return 0}function A(r,t,e,n,o){var i,a,f=new Uint8Array(16),h=new Uint8Array(64);for(a=0;a<16;a++)f[a]=0;for(a=0;a<8;a++)f[a]=n[a];for(;e>=64;){for(w(h,f,o,m),a=0;a<64;a++)r[t+a]=h[a];for(i=1,a=8;a<16;a++)f[a]=255&(i=i+(255&f[a])|0),i>>>=8;e-=64,t+=64}if(e>0)for(w(h,f,o,m),a=0;a<e;a++)r[t+a]=h[a];return 0}function U(r,t,e,n,o){var i=new Uint8Array(32);b(i,n,o,m);for(var a=new Uint8Array(8),f=0;f<8;f++)a[f]=n[f+16];return A(r,t,e,a,i)}function x(r,t,e,n,o,i,a){var f=new Uint8Array(32);b(f,i,a,m);for(var h=new Uint8Array(8),s=0;s<8;s++)h[s]=i[s+16];return E(r,t,e,n,o,h,f)}var _=function(r){var t,e,n,o,i,a,f,h;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,this.r[0]=8191&(t=255&r[0]|(255&r[1])<<8),this.r[1]=8191&(t>>>13|(e=255&r[2]|(255&r[3])<<8)<<3),this.r[2]=7939&(e>>>10|(n=255&r[4]|(255&r[5])<<8)<<6),this.r[3]=8191&(n>>>7|(o=255&r[6]|(255&r[7])<<8)<<9),this.r[4]=255&(o>>>4|(i=255&r[8]|(255&r[9])<<8)<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|(a=255&r[10]|(255&r[11])<<8)<<2),this.r[7]=8065&(a>>>11|(f=255&r[12]|(255&r[13])<<8)<<5),this.r[8]=8191&(f>>>8|(h=255&r[14]|(255&r[15])<<8)<<8),this.r[9]=h>>>5&127,this.pad[0]=255&r[16]|(255&r[17])<<8,this.pad[1]=255&r[18]|(255&r[19])<<8,this.pad[2]=255&r[20]|(255&r[21])<<8,this.pad[3]=255&r[22]|(255&r[23])<<8,this.pad[4]=255&r[24]|(255&r[25])<<8,this.pad[5]=255&r[26]|(255&r[27])<<8,this.pad[6]=255&r[28]|(255&r[29])<<8,this.pad[7]=255&r[30]|(255&r[31])<<8};function S(r,t,e,n,o,i){var a=new _(i);return a.update(e,n,o),a.finish(r,t),0}function T(r,t,e,n,o,i){var a=new Uint8Array(16);return S(a,0,e,n,o,i),p(r,t,a,0)}function B(r,t,e,n,o){var i;if(e<32)return-1;for(x(r,0,t,0,e,n,o),S(r,16,r,32,e-32,r),i=0;i<16;i++)r[i]=0;return 0}function M(r,t,e,n,o){var i,a=new Uint8Array(32);if(e<32)return-1;if(U(a,0,32,n,o),0!==T(t,16,t,32,e-32,a))return-1;for(x(r,0,t,0,e,n,o),i=0;i<32;i++)r[i]=0;return 0}function K(r,t){var e;for(e=0;e<16;e++)r[e]=0|t[e]}function k(r){var t,e,n=1;for(t=0;t<16;t++)e=r[t]+n+65535,n=Math.floor(e/65536),r[t]=e-65536*n;r[0]+=n-1+37*(n-1)}function P(r,t,e){for(var n,o=~(e-1),i=0;i<16;i++)r[i]^=n=o&(r[i]^t[i]),t[i]^=n}function Y(r,e){var n,o,i,a=t(),f=t();for(n=0;n<16;n++)f[n]=e[n];for(k(f),k(f),k(f),o=0;o<2;o++){for(a[0]=f[0]-65517,n=1;n<15;n++)a[n]=f[n]-65535-(a[n-1]>>16&1),a[n-1]&=65535;a[15]=f[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,P(f,a,1-i)}for(n=0;n<16;n++)r[2*n]=255&f[n],r[2*n+1]=f[n]>>8}function j(r,t){var e=new Uint8Array(32),n=new Uint8Array(32);return Y(e,r),Y(n,t),v(e,0,n,0)}function z(r){var t=new Uint8Array(32);return Y(t,r),1&t[0]}function J(r,t){var e;for(e=0;e<16;e++)r[e]=t[2*e]+(t[2*e+1]<<8);r[15]&=32767}function L(r,t,e){for(var n=0;n<16;n++)r[n]=t[n]+e[n]}function R(r,t,e){for(var n=0;n<16;n++)r[n]=t[n]-e[n]}function I(r,t,e){var n,o,i=0,a=0,f=0,h=0,s=0,u=0,c=0,l=0,y=0,d=0,p=0,v=0,w=0,g=0,b=0,m=0,E=0,A=0,U=0,x=0,_=0,S=0,T=0,B=0,M=0,K=0,k=0,P=0,Y=0,j=0,z=0,J=e[0],L=e[1],R=e[2],I=e[3],N=e[4],O=e[5],W=e[6],C=e[7],D=e[8],F=e[9],Z=e[10],V=e[11],G=e[12],q=e[13],H=e[14],X=e[15];i+=(n=t[0])*J,a+=n*L,f+=n*R,h+=n*I,s+=n*N,u+=n*O,c+=n*W,l+=n*C,y+=n*D,d+=n*F,p+=n*Z,v+=n*V,w+=n*G,g+=n*q,b+=n*H,m+=n*X,a+=(n=t[1])*J,f+=n*L,h+=n*R,s+=n*I,u+=n*N,c+=n*O,l+=n*W,y+=n*C,d+=n*D,p+=n*F,v+=n*Z,w+=n*V,g+=n*G,b+=n*q,m+=n*H,E+=n*X,f+=(n=t[2])*J,h+=n*L,s+=n*R,u+=n*I,c+=n*N,l+=n*O,y+=n*W,d+=n*C,p+=n*D,v+=n*F,w+=n*Z,g+=n*V,b+=n*G,m+=n*q,E+=n*H,A+=n*X,h+=(n=t[3])*J,s+=n*L,u+=n*R,c+=n*I,l+=n*N,y+=n*O,d+=n*W,p+=n*C,v+=n*D,w+=n*F,g+=n*Z,b+=n*V,m+=n*G,E+=n*q,A+=n*H,U+=n*X,s+=(n=t[4])*J,u+=n*L,c+=n*R,l+=n*I,y+=n*N,d+=n*O,p+=n*W,v+=n*C,w+=n*D,g+=n*F,b+=n*Z,m+=n*V,E+=n*G,A+=n*q,U+=n*H,x+=n*X,u+=(n=t[5])*J,c+=n*L,l+=n*R,y+=n*I,d+=n*N,p+=n*O,v+=n*W,w+=n*C,g+=n*D,b+=n*F,m+=n*Z,E+=n*V,A+=n*G,U+=n*q,x+=n*H,_+=n*X,c+=(n=t[6])*J,l+=n*L,y+=n*R,d+=n*I,p+=n*N,v+=n*O,w+=n*W,g+=n*C,b+=n*D,m+=n*F,E+=n*Z,A+=n*V,U+=n*G,x+=n*q,_+=n*H,S+=n*X,l+=(n=t[7])*J,y+=n*L,d+=n*R,p+=n*I,v+=n*N,w+=n*O,g+=n*W,b+=n*C,m+=n*D,E+=n*F,A+=n*Z,U+=n*V,x+=n*G,_+=n*q,S+=n*H,T+=n*X,y+=(n=t[8])*J,d+=n*L,p+=n*R,v+=n*I,w+=n*N,g+=n*O,b+=n*W,m+=n*C,E+=n*D,A+=n*F,U+=n*Z,x+=n*V,_+=n*G,S+=n*q,T+=n*H,B+=n*X,d+=(n=t[9])*J,p+=n*L,v+=n*R,w+=n*I,g+=n*N,b+=n*O,m+=n*W,E+=n*C,A+=n*D,U+=n*F,x+=n*Z,_+=n*V,S+=n*G,T+=n*q,B+=n*H,M+=n*X,p+=(n=t[10])*J,v+=n*L,w+=n*R,g+=n*I,b+=n*N,m+=n*O,E+=n*W,A+=n*C,U+=n*D,x+=n*F,_+=n*Z,S+=n*V,T+=n*G,B+=n*q,M+=n*H,K+=n*X,v+=(n=t[11])*J,w+=n*L,g+=n*R,b+=n*I,m+=n*N,E+=n*O,A+=n*W,U+=n*C,x+=n*D,_+=n*F,S+=n*Z,T+=n*V,B+=n*G,M+=n*q,K+=n*H,k+=n*X,w+=(n=t[12])*J,g+=n*L,b+=n*R,m+=n*I,E+=n*N,A+=n*O,U+=n*W,x+=n*C,_+=n*D,S+=n*F,T+=n*Z,B+=n*V,M+=n*G,K+=n*q,k+=n*H,P+=n*X,g+=(n=t[13])*J,b+=n*L,m+=n*R,E+=n*I,A+=n*N,U+=n*O,x+=n*W,_+=n*C,S+=n*D,T+=n*F,B+=n*Z,M+=n*V,K+=n*G,k+=n*q,P+=n*H,Y+=n*X,b+=(n=t[14])*J,m+=n*L,E+=n*R,A+=n*I,U+=n*N,x+=n*O,_+=n*W,S+=n*C,T+=n*D,B+=n*F,M+=n*Z,K+=n*V,k+=n*G,P+=n*q,Y+=n*H,j+=n*X,m+=(n=t[15])*J,a+=38*(A+=n*R),f+=38*(U+=n*I),h+=38*(x+=n*N),s+=38*(_+=n*O),u+=38*(S+=n*W),c+=38*(T+=n*C),l+=38*(B+=n*D),y+=38*(M+=n*F),d+=38*(K+=n*Z),p+=38*(k+=n*V),v+=38*(P+=n*G),w+=38*(Y+=n*q),g+=38*(j+=n*H),b+=38*(z+=n*X),i=(n=(i+=38*(E+=n*L))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),m=(n=m+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),m=(n=m+o+65535)-65536*(o=Math.floor(n/65536)),r[0]=i+=o-1+37*(o-1),r[1]=a,r[2]=f,r[3]=h,r[4]=s,r[5]=u,r[6]=c,r[7]=l,r[8]=y,r[9]=d,r[10]=p,r[11]=v,r[12]=w,r[13]=g,r[14]=b,r[15]=m}function N(r,t){I(r,t,t)}function O(r,e){var n,o=t();for(n=0;n<16;n++)o[n]=e[n];for(n=253;n>=0;n--)N(o,o),2!==n&&4!==n&&I(o,o,e);for(n=0;n<16;n++)r[n]=o[n]}function W(r,e,n){var o,i,a=new Uint8Array(32),h=new Float64Array(80),s=t(),u=t(),c=t(),l=t(),y=t(),d=t();for(i=0;i<31;i++)a[i]=e[i];for(a[31]=127&e[31]|64,a[0]&=248,J(h,n),i=0;i<16;i++)u[i]=h[i],l[i]=s[i]=c[i]=0;for(s[0]=l[0]=1,i=254;i>=0;--i)P(s,u,o=a[i>>>3]>>>(7&i)&1),P(c,l,o),L(y,s,c),R(s,s,c),L(c,u,l),R(u,u,l),N(l,y),N(d,s),I(s,c,s),I(c,u,y),L(y,s,c),R(s,s,c),N(u,s),R(c,l,d),I(s,c,f),L(s,s,l),I(c,c,s),I(s,l,d),I(l,u,h),N(u,y),P(s,u,o),P(c,l,o);for(i=0;i<16;i++)h[i+16]=s[i],h[i+32]=c[i],h[i+48]=u[i],h[i+64]=l[i];var p=h.subarray(32),v=h.subarray(16);return O(p,p),I(v,v,p),Y(r,v),0}function C(r,t){return W(r,t,o)}function D(r,t){return e(t,32),C(r,t)}function F(r,t,e){var o=new Uint8Array(32);return W(o,e,t),b(r,n,o,m)}_.prototype.blocks=function(r,t,e){for(var n,o,i,a,f,h,s,u,c,l,y,d,p,v,w,g,b,m,E,A=this.fin?0:2048,U=this.h[0],x=this.h[1],_=this.h[2],S=this.h[3],T=this.h[4],B=this.h[5],M=this.h[6],K=this.h[7],k=this.h[8],P=this.h[9],Y=this.r[0],j=this.r[1],z=this.r[2],J=this.r[3],L=this.r[4],R=this.r[5],I=this.r[6],N=this.r[7],O=this.r[8],W=this.r[9];e>=16;)l=c=0,l+=(U+=8191&(n=255&r[t+0]|(255&r[t+1])<<8))*Y,l+=(x+=8191&(n>>>13|(o=255&r[t+2]|(255&r[t+3])<<8)<<3))*(5*W),l+=(_+=8191&(o>>>10|(i=255&r[t+4]|(255&r[t+5])<<8)<<6))*(5*O),l+=(S+=8191&(i>>>7|(a=255&r[t+6]|(255&r[t+7])<<8)<<9))*(5*N),c=(l+=(T+=8191&(a>>>4|(f=255&r[t+8]|(255&r[t+9])<<8)<<12))*(5*I))>>>13,l&=8191,l+=(B+=f>>>1&8191)*(5*R),l+=(M+=8191&(f>>>14|(h=255&r[t+10]|(255&r[t+11])<<8)<<2))*(5*L),l+=(K+=8191&(h>>>11|(s=255&r[t+12]|(255&r[t+13])<<8)<<5))*(5*J),l+=(k+=8191&(s>>>8|(u=255&r[t+14]|(255&r[t+15])<<8)<<8))*(5*z),y=c+=(l+=(P+=u>>>5|A)*(5*j))>>>13,y+=U*j,y+=x*Y,y+=_*(5*W),y+=S*(5*O),c=(y+=T*(5*N))>>>13,y&=8191,y+=B*(5*I),y+=M*(5*R),y+=K*(5*L),y+=k*(5*J),c+=(y+=P*(5*z))>>>13,y&=8191,d=c,d+=U*z,d+=x*j,d+=_*Y,d+=S*(5*W),c=(d+=T*(5*O))>>>13,d&=8191,d+=B*(5*N),d+=M*(5*I),d+=K*(5*R),d+=k*(5*L),p=c+=(d+=P*(5*J))>>>13,p+=U*J,p+=x*z,p+=_*j,p+=S*Y,c=(p+=T*(5*W))>>>13,p&=8191,p+=B*(5*O),p+=M*(5*N),p+=K*(5*I),p+=k*(5*R),v=c+=(p+=P*(5*L))>>>13,v+=U*L,v+=x*J,v+=_*z,v+=S*j,c=(v+=T*Y)>>>13,v&=8191,v+=B*(5*W),v+=M*(5*O),v+=K*(5*N),v+=k*(5*I),w=c+=(v+=P*(5*R))>>>13,w+=U*R,w+=x*L,w+=_*J,w+=S*z,c=(w+=T*j)>>>13,w&=8191,w+=B*Y,w+=M*(5*W),w+=K*(5*O),w+=k*(5*N),g=c+=(w+=P*(5*I))>>>13,g+=U*I,g+=x*R,g+=_*L,g+=S*J,c=(g+=T*z)>>>13,g&=8191,g+=B*j,g+=M*Y,g+=K*(5*W),g+=k*(5*O),b=c+=(g+=P*(5*N))>>>13,b+=U*N,b+=x*I,b+=_*R,b+=S*L,c=(b+=T*J)>>>13,b&=8191,b+=B*z,b+=M*j,b+=K*Y,b+=k*(5*W),m=c+=(b+=P*(5*O))>>>13,m+=U*O,m+=x*N,m+=_*I,m+=S*R,c=(m+=T*L)>>>13,m&=8191,m+=B*J,m+=M*z,m+=K*j,m+=k*Y,E=c+=(m+=P*(5*W))>>>13,E+=U*W,E+=x*O,E+=_*N,E+=S*I,c=(E+=T*R)>>>13,E&=8191,E+=B*L,E+=M*J,E+=K*z,E+=k*j,U=l=8191&(c=(c=((c+=(E+=P*Y)>>>13)<<2)+c|0)+(l&=8191)|0),x=y+=c>>>=13,_=d&=8191,S=p&=8191,T=v&=8191,B=w&=8191,M=g&=8191,K=b&=8191,k=m&=8191,P=E&=8191,t+=16,e-=16;this.h[0]=U,this.h[1]=x,this.h[2]=_,this.h[3]=S,this.h[4]=T,this.h[5]=B,this.h[6]=M,this.h[7]=K,this.h[8]=k,this.h[9]=P},_.prototype.finish=function(r,t){var e,n,o,i,a=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(e=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=e,e=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*e,e=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=e,e=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=e,a[0]=this.h[0]+5,e=a[0]>>>13,a[0]&=8191,i=1;i<10;i++)a[i]=this.h[i]+e,e=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,n=(1^e)-1,i=0;i<10;i++)a[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|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),this.h[0]=65535&(o=this.h[0]+this.pad[0]),i=1;i<8;i++)this.h[i]=65535&(o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0);r[t+0]=this.h[0]>>>0&255,r[t+1]=this.h[0]>>>8&255,r[t+2]=this.h[1]>>>0&255,r[t+3]=this.h[1]>>>8&255,r[t+4]=this.h[2]>>>0&255,r[t+5]=this.h[2]>>>8&255,r[t+6]=this.h[3]>>>0&255,r[t+7]=this.h[3]>>>8&255,r[t+8]=this.h[4]>>>0&255,r[t+9]=this.h[4]>>>8&255,r[t+10]=this.h[5]>>>0&255,r[t+11]=this.h[5]>>>8&255,r[t+12]=this.h[6]>>>0&255,r[t+13]=this.h[6]>>>8&255,r[t+14]=this.h[7]>>>0&255,r[t+15]=this.h[7]>>>8&255},_.prototype.update=function(r,t,e){var n,o;if(this.leftover){for((o=16-this.leftover)>e&&(o=e),n=0;n<o;n++)this.buffer[this.leftover+n]=r[t+n];if(e-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(e>=16&&(this.blocks(r,t,o=e-e%16),t+=o,e-=o),e){for(n=0;n<e;n++)this.buffer[this.leftover+n]=r[t+n];this.leftover+=e}};var Z=B,V=M;var G=[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];function q(r,t,e,n){for(var o,i,a,f,h,s,u,c,l,y,d,p,v,w,g,b,m,E,A,U,x,_,S=new Int32Array(16),T=new Int32Array(16),B=r[0],M=r[1],K=r[2],k=r[3],P=r[4],Y=r[5],j=r[6],z=r[7],J=t[0],L=t[1],R=t[2],I=t[3],N=t[4],O=t[5],W=t[6],C=t[7],D=0;n>=128;){for(g=0;g<16;g++)S[g]=e[(b=8*g+D)+0]<<24|e[b+1]<<16|e[b+2]<<8|e[b+3],T[g]=e[b+4]<<24|e[b+5]<<16|e[b+6]<<8|e[b+7];for(g=0;g<80;g++)if(o=M,i=K,a=P,f=Y,h=j,z,u=L,c=R,l=N,y=O,d=W,C,A=65535&(E=C),U=E>>>16,x=65535&(m=z),_=m>>>16,A+=65535&(E=(N>>>14|P<<18)^(N>>>18|P<<14)^(P>>>9|N<<23)),U+=E>>>16,x+=65535&(m=(P>>>14|N<<18)^(P>>>18|N<<14)^(N>>>9|P<<23)),_+=m>>>16,A+=65535&(E=N&O^~N&W),U+=E>>>16,x+=65535&(m=P&Y^~P&j),_+=m>>>16,A+=65535&(E=G[2*g+1]),U+=E>>>16,x+=65535&(m=G[2*g]),_+=m>>>16,U+=(E=T[g%16])>>>16,x+=65535&(m=S[g%16]),_+=m>>>16,x+=(U+=(A+=65535&E)>>>16)>>>16,A=65535&(E=w=65535&A|U<<16),U=E>>>16,x=65535&(m=v=65535&x|(_+=x>>>16)<<16),_=m>>>16,A+=65535&(E=(J>>>28|B<<4)^(B>>>2|J<<30)^(B>>>7|J<<25)),U+=E>>>16,x+=65535&(m=(B>>>28|J<<4)^(J>>>2|B<<30)^(J>>>7|B<<25)),_+=m>>>16,U+=(E=J&L^J&R^L&R)>>>16,x+=65535&(m=B&M^B&K^M&K),_+=m>>>16,s=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,p=65535&A|U<<16,A=65535&(E=I),U=E>>>16,x=65535&(m=k),_=m>>>16,U+=(E=w)>>>16,x+=65535&(m=v),_+=m>>>16,M=B,K=o,k=i,P=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,Y=a,j=f,z=h,B=s,L=J,R=u,I=c,N=65535&A|U<<16,O=l,W=y,C=d,J=p,g%16==15)for(b=0;b<16;b++)A=65535&(E=T[b]),U=E>>>16,x=65535&(m=S[b]),_=m>>>16,A+=65535&(E=T[(b+9)%16]),U+=E>>>16,x+=65535&(m=S[(b+9)%16]),_+=m>>>16,A+=65535&(E=((w=T[(b+1)%16])>>>1|(v=S[(b+1)%16])<<31)^(w>>>8|v<<24)^(w>>>7|v<<25)),U+=E>>>16,x+=65535&(m=(v>>>1|w<<31)^(v>>>8|w<<24)^v>>>7),_+=m>>>16,U+=(E=((w=T[(b+14)%16])>>>19|(v=S[(b+14)%16])<<13)^(v>>>29|w<<3)^(w>>>6|v<<26))>>>16,x+=65535&(m=(v>>>19|w<<13)^(w>>>29|v<<3)^v>>>6),_+=m>>>16,S[b]=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,T[b]=65535&A|U<<16;A=65535&(E=J),U=E>>>16,x=65535&(m=B),_=m>>>16,U+=(E=t[0])>>>16,x+=65535&(m=r[0]),_+=m>>>16,r[0]=B=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[0]=J=65535&A|U<<16,A=65535&(E=L),U=E>>>16,x=65535&(m=M),_=m>>>16,U+=(E=t[1])>>>16,x+=65535&(m=r[1]),_+=m>>>16,r[1]=M=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[1]=L=65535&A|U<<16,A=65535&(E=R),U=E>>>16,x=65535&(m=K),_=m>>>16,U+=(E=t[2])>>>16,x+=65535&(m=r[2]),_+=m>>>16,r[2]=K=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[2]=R=65535&A|U<<16,A=65535&(E=I),U=E>>>16,x=65535&(m=k),_=m>>>16,U+=(E=t[3])>>>16,x+=65535&(m=r[3]),_+=m>>>16,r[3]=k=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[3]=I=65535&A|U<<16,A=65535&(E=N),U=E>>>16,x=65535&(m=P),_=m>>>16,U+=(E=t[4])>>>16,x+=65535&(m=r[4]),_+=m>>>16,r[4]=P=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[4]=N=65535&A|U<<16,A=65535&(E=O),U=E>>>16,x=65535&(m=Y),_=m>>>16,U+=(E=t[5])>>>16,x+=65535&(m=r[5]),_+=m>>>16,r[5]=Y=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[5]=O=65535&A|U<<16,A=65535&(E=W),U=E>>>16,x=65535&(m=j),_=m>>>16,U+=(E=t[6])>>>16,x+=65535&(m=r[6]),_+=m>>>16,r[6]=j=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[6]=W=65535&A|U<<16,A=65535&(E=C),U=E>>>16,x=65535&(m=z),_=m>>>16,U+=(E=t[7])>>>16,x+=65535&(m=r[7]),_+=m>>>16,r[7]=z=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[7]=C=65535&A|U<<16,D+=128,n-=128}return n}function H(r,t,e){var n,o=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),f=e;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,q(o,i,t,e),e%=128,n=0;n<e;n++)a[n]=t[f-e+n];for(a[e]=128,a[(e=256-128*(e<112?1:0))-9]=0,y(a,e-8,f/536870912|0,f<<3),q(o,i,a,e),n=0;n<8;n++)y(r,8*n,o[n],i[n]);return 0}function X(r,e){var n=t(),o=t(),i=t(),a=t(),f=t(),h=t(),u=t(),c=t(),l=t();R(n,r[1],r[0]),R(l,e[1],e[0]),I(n,n,l),L(o,r[0],r[1]),L(l,e[0],e[1]),I(o,o,l),I(i,r[3],e[3]),I(i,i,s),I(a,r[2],e[2]),L(a,a,a),R(f,o,n),R(h,a,i),L(u,a,i),L(c,o,n),I(r[0],f,h),I(r[1],c,u),I(r[2],u,h),I(r[3],f,c)}function $(r,t,e){var n;for(n=0;n<4;n++)P(r[n],t[n],e)}function Q(r,e){var n=t(),o=t(),i=t();O(i,e[2]),I(n,e[0],i),I(o,e[1],i),Y(r,o),r[31]^=z(n)<<7}function rr(r,t,e){var n,o;for(K(r[0],i),K(r[1],a),K(r[2],a),K(r[3],i),o=255;o>=0;--o)$(r,t,n=e[o/8|0]>>(7&o)&1),X(t,r),X(r,r),$(r,t,n)}function tr(r,e){var n=[t(),t(),t(),t()];K(n[0],u),K(n[1],c),K(n[2],a),I(n[3],u,c),rr(r,n,e)}function er(r,n,o){var i,a=new Uint8Array(64),f=[t(),t(),t(),t()];for(o||e(n,32),H(a,n,32),a[0]&=248,a[31]&=127,a[31]|=64,tr(f,a),Q(r,f),i=0;i<32;i++)n[i+32]=r[i];return 0}var nr=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]);function or(r,t){var e,n,o,i;for(n=63;n>=32;--n){for(e=0,o=n-32,i=n-12;o<i;++o)t[o]+=e-16*t[n]*nr[o-(n-32)],t[o]-=256*(e=t[o]+128>>8);t[o]+=e,t[n]=0}for(e=0,o=0;o<32;o++)t[o]+=e-(t[31]>>4)*nr[o],e=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=e*nr[o];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,r[n]=255&t[n]}function ir(r){var t,e=new Float64Array(64);for(t=0;t<64;t++)e[t]=r[t];for(t=0;t<64;t++)r[t]=0;or(r,e)}function ar(r,e,n,o){var i,a,f=new Uint8Array(64),h=new Uint8Array(64),s=new Uint8Array(64),u=new Float64Array(64),c=[t(),t(),t(),t()];H(f,o,32),f[0]&=248,f[31]&=127,f[31]|=64;var l=n+64;for(i=0;i<n;i++)r[64+i]=e[i];for(i=0;i<32;i++)r[32+i]=f[32+i];for(H(s,r.subarray(32),n+32),ir(s),tr(c,s),Q(r,c),i=32;i<64;i++)r[i]=o[i];for(H(h,r,n+64),ir(h),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=s[i];for(i=0;i<32;i++)for(a=0;a<32;a++)u[i+a]+=h[i]*f[a];return or(r.subarray(32),u),l}function fr(r,e){var n=t(),o=t(),f=t(),s=t(),u=t(),c=t(),y=t();return K(r[2],a),J(r[1],e),N(f,r[1]),I(s,f,h),R(f,f,r[2]),L(s,r[2],s),N(u,s),N(c,u),I(y,c,u),I(n,y,f),I(n,n,s),function(r,e){var n,o=t();for(n=0;n<16;n++)o[n]=e[n];for(n=250;n>=0;n--)N(o,o),1!==n&&I(o,o,e);for(n=0;n<16;n++)r[n]=o[n]}(n,n),I(n,n,f),I(n,n,s),I(n,n,s),I(r[0],n,s),N(o,r[0]),I(o,o,s),j(o,f)&&I(r[0],r[0],l),N(o,r[0]),I(o,o,s),j(o,f)?-1:(z(r[0])===e[31]>>7&&R(r[0],i,r[0]),I(r[3],r[0],r[1]),0)}function hr(r,e,n,o){var i,a=new Uint8Array(32),f=new Uint8Array(64),h=[t(),t(),t(),t()],s=[t(),t(),t(),t()];if(-1,n<64)return-1;if(fr(s,o))return-1;for(i=0;i<n;i++)r[i]=e[i];for(i=0;i<32;i++)r[i+32]=o[i];if(H(f,r,n),ir(f),rr(h,s,f),tr(s,e.subarray(32)),X(h,s),Q(a,h),n-=64,v(e,0,a,0)){for(i=0;i<n;i++)r[i]=0;return-1}for(i=0;i<n;i++)r[i]=e[i+64];return n}var sr=32,ur=24,cr=32,lr=32,yr=ur;function dr(r,t){if(r.length!==sr)throw new Error("bad key size");if(t.length!==ur)throw new Error("bad nonce size")}function pr(){var r,t;for(t=0;t<arguments.length;t++)if("[object Uint8Array]"!==(r=Object.prototype.toString.call(arguments[t])))throw new TypeError("unexpected type "+r+", use Uint8Array")}function vr(r){for(var t=0;t<r.length;t++)r[t]=0}r.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:x,crypto_stream:U,crypto_stream_salsa20_xor:E,crypto_stream_salsa20:A,crypto_onetimeauth:S,crypto_onetimeauth_verify:T,crypto_verify_16:p,crypto_verify_32:v,crypto_secretbox:B,crypto_secretbox_open:M,crypto_scalarmult:W,crypto_scalarmult_base:C,crypto_box_beforenm:F,crypto_box_afternm:Z,crypto_box:function(r,t,e,n,o,i){var a=new Uint8Array(32);return F(a,o,i),Z(r,t,e,n,a)},crypto_box_open:function(r,t,e,n,o,i){var a=new Uint8Array(32);return F(a,o,i),V(r,t,e,n,a)},crypto_box_keypair:D,crypto_hash:H,crypto_sign:ar,crypto_sign_keypair:er,crypto_sign_open:hr,crypto_secretbox_KEYBYTES:sr,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:cr,crypto_box_SECRETKEYBYTES:lr,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:yr,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:64,crypto_sign_PUBLICKEYBYTES:32,crypto_sign_SECRETKEYBYTES:64,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64},r.util||(r.util={},r.util.decodeUTF8=r.util.encodeUTF8=r.util.encodeBase64=r.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),r.randomBytes=function(r){var t=new Uint8Array(r);return e(t,r),t},r.secretbox=function(r,t,e){pr(r,t,e),dr(e,t);for(var n=new Uint8Array(32+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+32]=r[i];return B(o,n,n.length,t,e),o.subarray(16)},r.secretbox.open=function(r,t,e){pr(r,t,e),dr(e,t);for(var n=new Uint8Array(16+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+16]=r[i];return!(n.length<32)&&(0===M(o,n,n.length,t,e)&&o.subarray(32))},r.secretbox.keyLength=sr,r.secretbox.nonceLength=ur,r.secretbox.overheadLength=16,r.scalarMult=function(r,t){if(pr(r,t),32!==r.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var e=new Uint8Array(32);return W(e,r,t),e},r.scalarMult.base=function(r){if(pr(r),32!==r.length)throw new Error("bad n size");var t=new Uint8Array(32);return C(t,r),t},r.scalarMult.scalarLength=32,r.scalarMult.groupElementLength=32,r.box=function(t,e,n,o){var i=r.box.before(n,o);return r.secretbox(t,e,i)},r.box.before=function(r,t){pr(r,t),function(r,t){if(r.length!==cr)throw new Error("bad public key size");if(t.length!==lr)throw new Error("bad secret key size")}(r,t);var e=new Uint8Array(32);return F(e,r,t),e},r.box.after=r.secretbox,r.box.open=function(t,e,n,o){var i=r.box.before(n,o);return r.secretbox.open(t,e,i)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var r=new Uint8Array(cr),t=new Uint8Array(lr);return D(r,t),{publicKey:r,secretKey:t}},r.box.keyPair.fromSecretKey=function(r){if(pr(r),r.length!==lr)throw new Error("bad secret key size");var t=new Uint8Array(cr);return C(t,r),{publicKey:t,secretKey:new Uint8Array(r)}},r.box.publicKeyLength=cr,r.box.secretKeyLength=lr,r.box.sharedKeyLength=32,r.box.nonceLength=yr,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(r,t){if(pr(r,t),64!==t.length)throw new Error("bad secret key size");var e=new Uint8Array(64+r.length);return ar(e,r,r.length,t),e},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(pr(r,t),32!==t.length)throw new Error("bad public key size");var e=new Uint8Array(r.length),n=hr(e,r,r.length,t);if(n<0)return null;for(var o=new Uint8Array(n),i=0;i<o.length;i++)o[i]=e[i];return o},r.sign.detached=function(t,e){for(var n=r.sign(t,e),o=new Uint8Array(64),i=0;i<o.length;i++)o[i]=n[i];return o},r.sign.detached.verify=function(r,t,e){if(pr(r,t,e),64!==t.length)throw new Error("bad signature size");if(32!==e.length)throw new Error("bad public key size");var n,o=new Uint8Array(64+r.length),i=new Uint8Array(64+r.length);for(n=0;n<64;n++)o[n]=t[n];for(n=0;n<r.length;n++)o[n+64]=r[n];return hr(i,o,o.length,e)>=0},r.sign.keyPair=function(){var r=new Uint8Array(32),t=new Uint8Array(64);return er(r,t),{publicKey:r,secretKey:t}},r.sign.keyPair.fromSecretKey=function(r){if(pr(r),64!==r.length)throw new Error("bad secret key size");for(var t=new Uint8Array(32),e=0;e<t.length;e++)t[e]=r[32+e];return{publicKey:t,secretKey:new Uint8Array(r)}},r.sign.keyPair.fromSeed=function(r){if(pr(r),32!==r.length)throw new Error("bad seed size");for(var t=new Uint8Array(32),e=new Uint8Array(64),n=0;n<32;n++)e[n]=r[n];return er(t,e,!0),{publicKey:t,secretKey:e}},r.sign.publicKeyLength=32,r.sign.secretKeyLength=64,r.sign.seedLength=32,r.sign.signatureLength=64,r.hash=function(r){pr(r);var t=new Uint8Array(64);return H(t,r,r.length),t},r.hash.hashLength=64,r.verify=function(r,t){return pr(r,t),0!==r.length&&0!==t.length&&(r.length===t.length&&0===d(r,0,t,0,r.length))},r.setPRNG=function(r){e=r},function(){var t="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){r.setPRNG(function(r,e){var n,o=new Uint8Array(e);for(n=0;n<e;n+=65536)t.getRandomValues(o.subarray(n,n+Math.min(e-n,65536)));for(n=0;n<e;n++)r[n]=o[n];vr(o)})}else(t=g)&&t.randomBytes&&r.setPRNG(function(r,e){var n,o=t.randomBytes(e);for(n=0;n<e;n++)r[n]=o[n];vr(o)})}()}(r.exports?r.exports:self.nacl=self.nacl||{})}),m=v(function(r){var t,e;t=p,e=function(){var r={};function t(r){if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(r))throw new TypeError("invalid encoding")}return r.decodeUTF8=function(r){if("string"!=typeof r)throw new TypeError("expected string");var t,e=unescape(encodeURIComponent(r)),n=new Uint8Array(e.length);for(t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n},r.encodeUTF8=function(r){var t,e=[];for(t=0;t<r.length;t++)e.push(String.fromCharCode(r[t]));return decodeURIComponent(escape(e.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(r.encodeBase64=function(r){return Buffer.from(r).toString("base64")},r.decodeBase64=function(r){return t(r),new Uint8Array(Array.prototype.slice.call(Buffer.from(r,"base64"),0))}):(r.encodeBase64=function(r){return new Buffer(r).toString("base64")},r.decodeBase64=function(r){return t(r),new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0))}):(r.encodeBase64=function(r){var t,e=[],n=r.length;for(t=0;t<n;t++)e.push(String.fromCharCode(r[t]));return btoa(e.join(""))},r.decodeBase64=function(r){t(r);var e,n=atob(r),o=new Uint8Array(n.length);for(e=0;e<n.length;e++)o[e]=n.charCodeAt(e);return o}),r},r.exports?r.exports=e():t.nacl?t.nacl.util=e():(t.nacl={},t.nacl.util=e())});var E=new n("secp256k1");function A(r,t){void 0===t&&(t=!1);var e=i.toBuffer(r);if(e.length!==(t?65:64))throw new Error("wrong signature length");var n={r:e.slice(0,32).toString("hex"),s:e.slice(32,64).toString("hex")};return t&&(n.recoveryParam=e[64]),n}var U={ES256K:function(r,t,e){var n=c(r),o=A(t),i=e.find(function(r){return E.keyFromPublic(r.publicKeyHex,"hex").verify(n,o)});if(!i)throw new Error("Signature invalid for JWT");return i},"ES256K-R":function(r,t,e){var n=A(t,!0),o=c(r),i=E.recoverPubKey(o,n,n.recoveryParam),a=i.encode("hex"),f=i.encode("hex",!0),h=l(a),s=e.find(function(r){var t=r.publicKeyHex;return t===a||t===f||r.ethereumAddress===h});if(!s)throw new Error("Signature invalid for JWT");return s},Ed25519:function(r,t,e){var n=m.decodeUTF8(r),o=s(t),i=e.find(function(r){return b.sign.detached.verify(n,o,m.decodeBase64(r.publicKeyBase64))});if(!i)throw new Error("Signature invalid for JWT");return i}};function x(r){var t=U[r];if(!t)throw new Error("Unsupported algorithm "+r);return t}function _(r){function t(t){var e=t.r,n=t.s,a=t.recoveryParam,f=o.alloc(r?65:64);if(o.from(e,"hex").copy(f,0),o.from(n,"hex").copy(f,32),r){if(void 0===a)throw new Error("Signer did not return a recoveryParam");f[64]=a}return i.encode(f)}return void 0===r&&(r=!1),function(r,e){try{return Promise.resolve(e(r)).then(t)}catch(r){return Promise.reject(r)}}}x.toSignatureObject=A;var S={ES256K:_(),"ES256K-R":_(!0),Ed25519:function(r,t){try{return Promise.resolve(t(r))}catch(r){return Promise.reject(r)}}};f(),u();var T={ES256K:["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],"ES256K-R":["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],Ed25519:["ED25519SignatureVerification"]},B={typ:"JWT"},M="ES256K";function K(r){return i.encode(JSON.stringify(r))}var k=300;function P(r){if(r.match(/^did:/))return r;if(e(r))return"did:uport:"+r;throw new Error("Not a valid DID '"+r+"'")}function Y(r){if(!r)throw new Error("no JWT passed into decodeJWT");var t=r.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(t)return{header:JSON.parse(i.decode(t[1])),payload:JSON.parse(i.decode(t[2])),signature:t[3],data:t[1]+"."+t[2]};throw new Error("Incorrect format JWT")}module.exports={SimpleSigner:function(r){var t=y.keyFromPrivate(r);return function(r){try{var e=t.sign(c(r)),n=e.s,o=e.recoveryParam;return Promise.resolve({r:d(e.r.toString("hex")),s:d(n.toString("hex")),recoveryParam:o})}catch(r){return Promise.reject(r)}}},NaclSigner:function(r){var t=m.decodeBase64(r);return function(r){try{return Promise.resolve(h(b.sign.detached(m.decodeUTF8(r),t)))}catch(r){return Promise.reject(r)}}},verifyJWT:function(r,t){void 0===t&&(t={});try{var n=t.audience?P(t.audience):void 0,o=Y(r),i=o.payload,f=o.header,h=o.signature,s=o.data;return Promise.resolve(function(r,t,e){try{var n=T[r];if(!n||0===n.length)throw new Error("No supported signature types for algorithm "+r);var o=P(t);return Promise.resolve(a(o)).then(function(t){if(!t)throw new Error("Unable to resolve DID document for "+o);var i=!e||(t.authentication||[]).map(function(r){return r.publicKey}),a=(t.publicKey||[]).filter(function(r){var t=r.type,o=r.id;return n.find(function(r){return r===t&&(!e||i.indexOf(o)>=0)})});if(e&&(!a||0===a.length))throw new Error("DID document for "+o+" does not have public keys suitable for authenticationg user");if(!a||0===a.length)throw new Error("DID document for "+o+" does not have public keys for "+r);return{authenticators:a,issuer:o,doc:t}})}catch(r){return Promise.reject(r)}}(f.alg,i.iss,t.auth)).then(function(o){var a,u=o.doc,c=o.authenticators,l=o.issuer,y=x(f.alg)(s,h,c),d=Math.floor(Date.now()/1e3);if(y){if(i.iat&&i.iat>d+k)throw new Error("JWT not valid yet (issued in the future): iat: "+i.iat+" > now: "+d);if(i.exp&&i.exp<=d-k)throw new Error("JWT has expired: exp: "+i.exp+" < now: "+d);if(i.aud)if((a=i.aud)&&(a.match(/^did:/)||e(a))){if(!n)throw new Error("JWT audience is required but your app address has not been configured");if(n!==P(i.aud))throw new Error("JWT audience does not match your DID: aud: "+i.aud+" !== yours: "+n)}else{if(!t.callbackUrl)throw new Error("JWT audience matching your callback url is required but one wasn't passed in");if(i.aud!==t.callbackUrl)throw new Error("JWT audience does not match the callback url: aud: "+i.aud+" !== url: "+t.callbackUrl)}return{payload:i,doc:u,issuer:l,signer:y,jwt:r}}})}catch(r){return Promise.reject(r)}},createJWT:function(r,t){var e=t.issuer,n=t.signer,o=t.alg,i=t.expiresIn;try{if(!n)throw new Error("No Signer functionality has been configured");if(!e)throw new Error("No issuing DID has been configured");var a=Object.assign({},B,{alg:o||M}),f={iat:Math.floor(Date.now()/1e3)};if(i){if("number"!=typeof i)throw new Error("JWT expiresIn is not a number");f.exp=f.iat+Math.floor(i)}var h=[K(a),K(Object.assign({},f,r,{iss:e}))].join("."),s=function(r){var t=S[r];if(!t)throw new Error("Unsupported algorithm "+r);return t}(a.alg);return Promise.resolve(s(h,n)).then(function(r){return[h,r].join(".")})}catch(r){return Promise.reject(r)}},decodeJWT:Y}; | ||
import{sha256 as r}from"js-sha256";import{keccak_256 as t}from"js-sha3";import{isMNID as e}from"mnid";import{ec as n}from"elliptic";import{Buffer as o}from"buffer";import i from"base64url";import a from"did-resolver";import f from"uport-did-resolver";import{encodeBase64Url as h,decodeBase64Url as s,registerNaclDID as u}from"nacl-did";function c(t){return o.from(r.arrayBuffer(t))}function l(r){return"0x"+(e=o.from(r.slice(2),"hex"),o.from(t.buffer(e))).slice(-20).toString("hex");var e}var y=new n("secp256k1");function d(r,t){return void 0===t&&(t=64),r.length===t?r:"0".repeat(t-r.length)+r}var p="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(r,t){return r(t={exports:{}},t.exports),t.exports}var w,g=(w={default:{}})&&w.default||w,b=v(function(r){!function(r){var t=function(r){var t,e=new Float64Array(16);if(r)for(t=0;t<r.length;t++)e[t]=r[t];return e},e=function(){throw new Error("no PRNG")},n=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=t(),a=t([1]),f=t([56129,1]),h=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),s=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),c=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function y(r,t,e,n){r[t]=e>>24&255,r[t+1]=e>>16&255,r[t+2]=e>>8&255,r[t+3]=255&e,r[t+4]=n>>24&255,r[t+5]=n>>16&255,r[t+6]=n>>8&255,r[t+7]=255&n}function d(r,t,e,n,o){var i,a=0;for(i=0;i<o;i++)a|=r[t+i]^e[n+i];return(1&a-1>>>8)-1}function p(r,t,e,n){return d(r,t,e,n,16)}function v(r,t,e,n){return d(r,t,e,n,32)}function w(r,t,e,n){!function(r,t,e,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,h=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,s=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,y=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,d=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&e[16]|(255&e[17])<<8|(255&e[18])<<16|(255&e[19])<<24,w=255&e[20]|(255&e[21])<<8|(255&e[22])<<16|(255&e[23])<<24,g=255&e[24]|(255&e[25])<<8|(255&e[26])<<16|(255&e[27])<<24,b=255&e[28]|(255&e[29])<<8|(255&e[30])<<16|(255&e[31])<<24,m=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,E=i,A=a,U=f,x=h,_=s,S=u,T=c,B=l,M=y,K=d,k=p,P=v,Y=w,j=g,z=b,J=m,L=0;L<20;L+=2)E^=(o=(Y^=(o=(M^=(o=(_^=(o=E+Y|0)<<7|o>>>25)+E|0)<<9|o>>>23)+_|0)<<13|o>>>19)+M|0)<<18|o>>>14,S^=(o=(A^=(o=(j^=(o=(K^=(o=S+A|0)<<7|o>>>25)+S|0)<<9|o>>>23)+K|0)<<13|o>>>19)+j|0)<<18|o>>>14,k^=(o=(T^=(o=(U^=(o=(z^=(o=k+T|0)<<7|o>>>25)+k|0)<<9|o>>>23)+z|0)<<13|o>>>19)+U|0)<<18|o>>>14,J^=(o=(P^=(o=(B^=(o=(x^=(o=J+P|0)<<7|o>>>25)+J|0)<<9|o>>>23)+x|0)<<13|o>>>19)+B|0)<<18|o>>>14,E^=(o=(x^=(o=(U^=(o=(A^=(o=E+x|0)<<7|o>>>25)+E|0)<<9|o>>>23)+A|0)<<13|o>>>19)+U|0)<<18|o>>>14,S^=(o=(_^=(o=(B^=(o=(T^=(o=S+_|0)<<7|o>>>25)+S|0)<<9|o>>>23)+T|0)<<13|o>>>19)+B|0)<<18|o>>>14,k^=(o=(K^=(o=(M^=(o=(P^=(o=k+K|0)<<7|o>>>25)+k|0)<<9|o>>>23)+P|0)<<13|o>>>19)+M|0)<<18|o>>>14,J^=(o=(z^=(o=(j^=(o=(Y^=(o=J+z|0)<<7|o>>>25)+J|0)<<9|o>>>23)+Y|0)<<13|o>>>19)+j|0)<<18|o>>>14;A=A+a|0,U=U+f|0,x=x+h|0,_=_+s|0,S=S+u|0,T=T+c|0,B=B+l|0,M=M+y|0,K=K+d|0,k=k+p|0,P=P+v|0,Y=Y+w|0,j=j+g|0,z=z+b|0,J=J+m|0,r[0]=(E=E+i|0)>>>0&255,r[1]=E>>>8&255,r[2]=E>>>16&255,r[3]=E>>>24&255,r[4]=A>>>0&255,r[5]=A>>>8&255,r[6]=A>>>16&255,r[7]=A>>>24&255,r[8]=U>>>0&255,r[9]=U>>>8&255,r[10]=U>>>16&255,r[11]=U>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=_>>>0&255,r[17]=_>>>8&255,r[18]=_>>>16&255,r[19]=_>>>24&255,r[20]=S>>>0&255,r[21]=S>>>8&255,r[22]=S>>>16&255,r[23]=S>>>24&255,r[24]=T>>>0&255,r[25]=T>>>8&255,r[26]=T>>>16&255,r[27]=T>>>24&255,r[28]=B>>>0&255,r[29]=B>>>8&255,r[30]=B>>>16&255,r[31]=B>>>24&255,r[32]=M>>>0&255,r[33]=M>>>8&255,r[34]=M>>>16&255,r[35]=M>>>24&255,r[36]=K>>>0&255,r[37]=K>>>8&255,r[38]=K>>>16&255,r[39]=K>>>24&255,r[40]=k>>>0&255,r[41]=k>>>8&255,r[42]=k>>>16&255,r[43]=k>>>24&255,r[44]=P>>>0&255,r[45]=P>>>8&255,r[46]=P>>>16&255,r[47]=P>>>24&255,r[48]=Y>>>0&255,r[49]=Y>>>8&255,r[50]=Y>>>16&255,r[51]=Y>>>24&255,r[52]=j>>>0&255,r[53]=j>>>8&255,r[54]=j>>>16&255,r[55]=j>>>24&255,r[56]=z>>>0&255,r[57]=z>>>8&255,r[58]=z>>>16&255,r[59]=z>>>24&255,r[60]=J>>>0&255,r[61]=J>>>8&255,r[62]=J>>>16&255,r[63]=J>>>24&255}(r,t,e,n)}function b(r,t,e,n){!function(r,t,e,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,f=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,h=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,s=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,l=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,y=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,d=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&e[16]|(255&e[17])<<8|(255&e[18])<<16|(255&e[19])<<24,w=255&e[20]|(255&e[21])<<8|(255&e[22])<<16|(255&e[23])<<24,g=255&e[24]|(255&e[25])<<8|(255&e[26])<<16|(255&e[27])<<24,b=255&e[28]|(255&e[29])<<8|(255&e[30])<<16|(255&e[31])<<24,m=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,E=0;E<20;E+=2)i^=(o=(w^=(o=(y^=(o=(s^=(o=i+w|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+y|0)<<18|o>>>14,u^=(o=(a^=(o=(g^=(o=(d^=(o=u+a|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+g|0)<<18|o>>>14,p^=(o=(c^=(o=(f^=(o=(b^=(o=p+c|0)<<7|o>>>25)+p|0)<<9|o>>>23)+b|0)<<13|o>>>19)+f|0)<<18|o>>>14,m^=(o=(v^=(o=(l^=(o=(h^=(o=m+v|0)<<7|o>>>25)+m|0)<<9|o>>>23)+h|0)<<13|o>>>19)+l|0)<<18|o>>>14,i^=(o=(h^=(o=(f^=(o=(a^=(o=i+h|0)<<7|o>>>25)+i|0)<<9|o>>>23)+a|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(l^=(o=(c^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+c|0)<<13|o>>>19)+l|0)<<18|o>>>14,p^=(o=(d^=(o=(y^=(o=(v^=(o=p+d|0)<<7|o>>>25)+p|0)<<9|o>>>23)+v|0)<<13|o>>>19)+y|0)<<18|o>>>14,m^=(o=(b^=(o=(g^=(o=(w^=(o=m+b|0)<<7|o>>>25)+m|0)<<9|o>>>23)+w|0)<<13|o>>>19)+g|0)<<18|o>>>14;r[0]=i>>>0&255,r[1]=i>>>8&255,r[2]=i>>>16&255,r[3]=i>>>24&255,r[4]=u>>>0&255,r[5]=u>>>8&255,r[6]=u>>>16&255,r[7]=u>>>24&255,r[8]=p>>>0&255,r[9]=p>>>8&255,r[10]=p>>>16&255,r[11]=p>>>24&255,r[12]=m>>>0&255,r[13]=m>>>8&255,r[14]=m>>>16&255,r[15]=m>>>24&255,r[16]=c>>>0&255,r[17]=c>>>8&255,r[18]=c>>>16&255,r[19]=c>>>24&255,r[20]=l>>>0&255,r[21]=l>>>8&255,r[22]=l>>>16&255,r[23]=l>>>24&255,r[24]=y>>>0&255,r[25]=y>>>8&255,r[26]=y>>>16&255,r[27]=y>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255}(r,t,e,n)}var m=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function E(r,t,e,n,o,i,a){var f,h,s=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)s[h]=0;for(h=0;h<8;h++)s[h]=i[h];for(;o>=64;){for(w(u,s,a,m),h=0;h<64;h++)r[t+h]=e[n+h]^u[h];for(f=1,h=8;h<16;h++)s[h]=255&(f=f+(255&s[h])|0),f>>>=8;o-=64,t+=64,n+=64}if(o>0)for(w(u,s,a,m),h=0;h<o;h++)r[t+h]=e[n+h]^u[h];return 0}function A(r,t,e,n,o){var i,a,f=new Uint8Array(16),h=new Uint8Array(64);for(a=0;a<16;a++)f[a]=0;for(a=0;a<8;a++)f[a]=n[a];for(;e>=64;){for(w(h,f,o,m),a=0;a<64;a++)r[t+a]=h[a];for(i=1,a=8;a<16;a++)f[a]=255&(i=i+(255&f[a])|0),i>>>=8;e-=64,t+=64}if(e>0)for(w(h,f,o,m),a=0;a<e;a++)r[t+a]=h[a];return 0}function U(r,t,e,n,o){var i=new Uint8Array(32);b(i,n,o,m);for(var a=new Uint8Array(8),f=0;f<8;f++)a[f]=n[f+16];return A(r,t,e,a,i)}function x(r,t,e,n,o,i,a){var f=new Uint8Array(32);b(f,i,a,m);for(var h=new Uint8Array(8),s=0;s<8;s++)h[s]=i[s+16];return E(r,t,e,n,o,h,f)}var _=function(r){var t,e,n,o,i,a,f,h;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,this.r[0]=8191&(t=255&r[0]|(255&r[1])<<8),this.r[1]=8191&(t>>>13|(e=255&r[2]|(255&r[3])<<8)<<3),this.r[2]=7939&(e>>>10|(n=255&r[4]|(255&r[5])<<8)<<6),this.r[3]=8191&(n>>>7|(o=255&r[6]|(255&r[7])<<8)<<9),this.r[4]=255&(o>>>4|(i=255&r[8]|(255&r[9])<<8)<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|(a=255&r[10]|(255&r[11])<<8)<<2),this.r[7]=8065&(a>>>11|(f=255&r[12]|(255&r[13])<<8)<<5),this.r[8]=8191&(f>>>8|(h=255&r[14]|(255&r[15])<<8)<<8),this.r[9]=h>>>5&127,this.pad[0]=255&r[16]|(255&r[17])<<8,this.pad[1]=255&r[18]|(255&r[19])<<8,this.pad[2]=255&r[20]|(255&r[21])<<8,this.pad[3]=255&r[22]|(255&r[23])<<8,this.pad[4]=255&r[24]|(255&r[25])<<8,this.pad[5]=255&r[26]|(255&r[27])<<8,this.pad[6]=255&r[28]|(255&r[29])<<8,this.pad[7]=255&r[30]|(255&r[31])<<8};function S(r,t,e,n,o,i){var a=new _(i);return a.update(e,n,o),a.finish(r,t),0}function T(r,t,e,n,o,i){var a=new Uint8Array(16);return S(a,0,e,n,o,i),p(r,t,a,0)}function B(r,t,e,n,o){var i;if(e<32)return-1;for(x(r,0,t,0,e,n,o),S(r,16,r,32,e-32,r),i=0;i<16;i++)r[i]=0;return 0}function M(r,t,e,n,o){var i,a=new Uint8Array(32);if(e<32)return-1;if(U(a,0,32,n,o),0!==T(t,16,t,32,e-32,a))return-1;for(x(r,0,t,0,e,n,o),i=0;i<32;i++)r[i]=0;return 0}function K(r,t){var e;for(e=0;e<16;e++)r[e]=0|t[e]}function k(r){var t,e,n=1;for(t=0;t<16;t++)e=r[t]+n+65535,n=Math.floor(e/65536),r[t]=e-65536*n;r[0]+=n-1+37*(n-1)}function P(r,t,e){for(var n,o=~(e-1),i=0;i<16;i++)r[i]^=n=o&(r[i]^t[i]),t[i]^=n}function Y(r,e){var n,o,i,a=t(),f=t();for(n=0;n<16;n++)f[n]=e[n];for(k(f),k(f),k(f),o=0;o<2;o++){for(a[0]=f[0]-65517,n=1;n<15;n++)a[n]=f[n]-65535-(a[n-1]>>16&1),a[n-1]&=65535;a[15]=f[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,P(f,a,1-i)}for(n=0;n<16;n++)r[2*n]=255&f[n],r[2*n+1]=f[n]>>8}function j(r,t){var e=new Uint8Array(32),n=new Uint8Array(32);return Y(e,r),Y(n,t),v(e,0,n,0)}function z(r){var t=new Uint8Array(32);return Y(t,r),1&t[0]}function J(r,t){var e;for(e=0;e<16;e++)r[e]=t[2*e]+(t[2*e+1]<<8);r[15]&=32767}function L(r,t,e){for(var n=0;n<16;n++)r[n]=t[n]+e[n]}function R(r,t,e){for(var n=0;n<16;n++)r[n]=t[n]-e[n]}function I(r,t,e){var n,o,i=0,a=0,f=0,h=0,s=0,u=0,c=0,l=0,y=0,d=0,p=0,v=0,w=0,g=0,b=0,m=0,E=0,A=0,U=0,x=0,_=0,S=0,T=0,B=0,M=0,K=0,k=0,P=0,Y=0,j=0,z=0,J=e[0],L=e[1],R=e[2],I=e[3],N=e[4],O=e[5],W=e[6],C=e[7],D=e[8],F=e[9],Z=e[10],V=e[11],G=e[12],q=e[13],H=e[14],X=e[15];i+=(n=t[0])*J,a+=n*L,f+=n*R,h+=n*I,s+=n*N,u+=n*O,c+=n*W,l+=n*C,y+=n*D,d+=n*F,p+=n*Z,v+=n*V,w+=n*G,g+=n*q,b+=n*H,m+=n*X,a+=(n=t[1])*J,f+=n*L,h+=n*R,s+=n*I,u+=n*N,c+=n*O,l+=n*W,y+=n*C,d+=n*D,p+=n*F,v+=n*Z,w+=n*V,g+=n*G,b+=n*q,m+=n*H,E+=n*X,f+=(n=t[2])*J,h+=n*L,s+=n*R,u+=n*I,c+=n*N,l+=n*O,y+=n*W,d+=n*C,p+=n*D,v+=n*F,w+=n*Z,g+=n*V,b+=n*G,m+=n*q,E+=n*H,A+=n*X,h+=(n=t[3])*J,s+=n*L,u+=n*R,c+=n*I,l+=n*N,y+=n*O,d+=n*W,p+=n*C,v+=n*D,w+=n*F,g+=n*Z,b+=n*V,m+=n*G,E+=n*q,A+=n*H,U+=n*X,s+=(n=t[4])*J,u+=n*L,c+=n*R,l+=n*I,y+=n*N,d+=n*O,p+=n*W,v+=n*C,w+=n*D,g+=n*F,b+=n*Z,m+=n*V,E+=n*G,A+=n*q,U+=n*H,x+=n*X,u+=(n=t[5])*J,c+=n*L,l+=n*R,y+=n*I,d+=n*N,p+=n*O,v+=n*W,w+=n*C,g+=n*D,b+=n*F,m+=n*Z,E+=n*V,A+=n*G,U+=n*q,x+=n*H,_+=n*X,c+=(n=t[6])*J,l+=n*L,y+=n*R,d+=n*I,p+=n*N,v+=n*O,w+=n*W,g+=n*C,b+=n*D,m+=n*F,E+=n*Z,A+=n*V,U+=n*G,x+=n*q,_+=n*H,S+=n*X,l+=(n=t[7])*J,y+=n*L,d+=n*R,p+=n*I,v+=n*N,w+=n*O,g+=n*W,b+=n*C,m+=n*D,E+=n*F,A+=n*Z,U+=n*V,x+=n*G,_+=n*q,S+=n*H,T+=n*X,y+=(n=t[8])*J,d+=n*L,p+=n*R,v+=n*I,w+=n*N,g+=n*O,b+=n*W,m+=n*C,E+=n*D,A+=n*F,U+=n*Z,x+=n*V,_+=n*G,S+=n*q,T+=n*H,B+=n*X,d+=(n=t[9])*J,p+=n*L,v+=n*R,w+=n*I,g+=n*N,b+=n*O,m+=n*W,E+=n*C,A+=n*D,U+=n*F,x+=n*Z,_+=n*V,S+=n*G,T+=n*q,B+=n*H,M+=n*X,p+=(n=t[10])*J,v+=n*L,w+=n*R,g+=n*I,b+=n*N,m+=n*O,E+=n*W,A+=n*C,U+=n*D,x+=n*F,_+=n*Z,S+=n*V,T+=n*G,B+=n*q,M+=n*H,K+=n*X,v+=(n=t[11])*J,w+=n*L,g+=n*R,b+=n*I,m+=n*N,E+=n*O,A+=n*W,U+=n*C,x+=n*D,_+=n*F,S+=n*Z,T+=n*V,B+=n*G,M+=n*q,K+=n*H,k+=n*X,w+=(n=t[12])*J,g+=n*L,b+=n*R,m+=n*I,E+=n*N,A+=n*O,U+=n*W,x+=n*C,_+=n*D,S+=n*F,T+=n*Z,B+=n*V,M+=n*G,K+=n*q,k+=n*H,P+=n*X,g+=(n=t[13])*J,b+=n*L,m+=n*R,E+=n*I,A+=n*N,U+=n*O,x+=n*W,_+=n*C,S+=n*D,T+=n*F,B+=n*Z,M+=n*V,K+=n*G,k+=n*q,P+=n*H,Y+=n*X,b+=(n=t[14])*J,m+=n*L,E+=n*R,A+=n*I,U+=n*N,x+=n*O,_+=n*W,S+=n*C,T+=n*D,B+=n*F,M+=n*Z,K+=n*V,k+=n*G,P+=n*q,Y+=n*H,j+=n*X,m+=(n=t[15])*J,a+=38*(A+=n*R),f+=38*(U+=n*I),h+=38*(x+=n*N),s+=38*(_+=n*O),u+=38*(S+=n*W),c+=38*(T+=n*C),l+=38*(B+=n*D),y+=38*(M+=n*F),d+=38*(K+=n*Z),p+=38*(k+=n*V),v+=38*(P+=n*G),w+=38*(Y+=n*q),g+=38*(j+=n*H),b+=38*(z+=n*X),i=(n=(i+=38*(E+=n*L))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),m=(n=m+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),m=(n=m+o+65535)-65536*(o=Math.floor(n/65536)),r[0]=i+=o-1+37*(o-1),r[1]=a,r[2]=f,r[3]=h,r[4]=s,r[5]=u,r[6]=c,r[7]=l,r[8]=y,r[9]=d,r[10]=p,r[11]=v,r[12]=w,r[13]=g,r[14]=b,r[15]=m}function N(r,t){I(r,t,t)}function O(r,e){var n,o=t();for(n=0;n<16;n++)o[n]=e[n];for(n=253;n>=0;n--)N(o,o),2!==n&&4!==n&&I(o,o,e);for(n=0;n<16;n++)r[n]=o[n]}function W(r,e,n){var o,i,a=new Uint8Array(32),h=new Float64Array(80),s=t(),u=t(),c=t(),l=t(),y=t(),d=t();for(i=0;i<31;i++)a[i]=e[i];for(a[31]=127&e[31]|64,a[0]&=248,J(h,n),i=0;i<16;i++)u[i]=h[i],l[i]=s[i]=c[i]=0;for(s[0]=l[0]=1,i=254;i>=0;--i)P(s,u,o=a[i>>>3]>>>(7&i)&1),P(c,l,o),L(y,s,c),R(s,s,c),L(c,u,l),R(u,u,l),N(l,y),N(d,s),I(s,c,s),I(c,u,y),L(y,s,c),R(s,s,c),N(u,s),R(c,l,d),I(s,c,f),L(s,s,l),I(c,c,s),I(s,l,d),I(l,u,h),N(u,y),P(s,u,o),P(c,l,o);for(i=0;i<16;i++)h[i+16]=s[i],h[i+32]=c[i],h[i+48]=u[i],h[i+64]=l[i];var p=h.subarray(32),v=h.subarray(16);return O(p,p),I(v,v,p),Y(r,v),0}function C(r,t){return W(r,t,o)}function D(r,t){return e(t,32),C(r,t)}function F(r,t,e){var o=new Uint8Array(32);return W(o,e,t),b(r,n,o,m)}_.prototype.blocks=function(r,t,e){for(var n,o,i,a,f,h,s,u,c,l,y,d,p,v,w,g,b,m,E,A=this.fin?0:2048,U=this.h[0],x=this.h[1],_=this.h[2],S=this.h[3],T=this.h[4],B=this.h[5],M=this.h[6],K=this.h[7],k=this.h[8],P=this.h[9],Y=this.r[0],j=this.r[1],z=this.r[2],J=this.r[3],L=this.r[4],R=this.r[5],I=this.r[6],N=this.r[7],O=this.r[8],W=this.r[9];e>=16;)l=c=0,l+=(U+=8191&(n=255&r[t+0]|(255&r[t+1])<<8))*Y,l+=(x+=8191&(n>>>13|(o=255&r[t+2]|(255&r[t+3])<<8)<<3))*(5*W),l+=(_+=8191&(o>>>10|(i=255&r[t+4]|(255&r[t+5])<<8)<<6))*(5*O),l+=(S+=8191&(i>>>7|(a=255&r[t+6]|(255&r[t+7])<<8)<<9))*(5*N),c=(l+=(T+=8191&(a>>>4|(f=255&r[t+8]|(255&r[t+9])<<8)<<12))*(5*I))>>>13,l&=8191,l+=(B+=f>>>1&8191)*(5*R),l+=(M+=8191&(f>>>14|(h=255&r[t+10]|(255&r[t+11])<<8)<<2))*(5*L),l+=(K+=8191&(h>>>11|(s=255&r[t+12]|(255&r[t+13])<<8)<<5))*(5*J),l+=(k+=8191&(s>>>8|(u=255&r[t+14]|(255&r[t+15])<<8)<<8))*(5*z),y=c+=(l+=(P+=u>>>5|A)*(5*j))>>>13,y+=U*j,y+=x*Y,y+=_*(5*W),y+=S*(5*O),c=(y+=T*(5*N))>>>13,y&=8191,y+=B*(5*I),y+=M*(5*R),y+=K*(5*L),y+=k*(5*J),c+=(y+=P*(5*z))>>>13,y&=8191,d=c,d+=U*z,d+=x*j,d+=_*Y,d+=S*(5*W),c=(d+=T*(5*O))>>>13,d&=8191,d+=B*(5*N),d+=M*(5*I),d+=K*(5*R),d+=k*(5*L),p=c+=(d+=P*(5*J))>>>13,p+=U*J,p+=x*z,p+=_*j,p+=S*Y,c=(p+=T*(5*W))>>>13,p&=8191,p+=B*(5*O),p+=M*(5*N),p+=K*(5*I),p+=k*(5*R),v=c+=(p+=P*(5*L))>>>13,v+=U*L,v+=x*J,v+=_*z,v+=S*j,c=(v+=T*Y)>>>13,v&=8191,v+=B*(5*W),v+=M*(5*O),v+=K*(5*N),v+=k*(5*I),w=c+=(v+=P*(5*R))>>>13,w+=U*R,w+=x*L,w+=_*J,w+=S*z,c=(w+=T*j)>>>13,w&=8191,w+=B*Y,w+=M*(5*W),w+=K*(5*O),w+=k*(5*N),g=c+=(w+=P*(5*I))>>>13,g+=U*I,g+=x*R,g+=_*L,g+=S*J,c=(g+=T*z)>>>13,g&=8191,g+=B*j,g+=M*Y,g+=K*(5*W),g+=k*(5*O),b=c+=(g+=P*(5*N))>>>13,b+=U*N,b+=x*I,b+=_*R,b+=S*L,c=(b+=T*J)>>>13,b&=8191,b+=B*z,b+=M*j,b+=K*Y,b+=k*(5*W),m=c+=(b+=P*(5*O))>>>13,m+=U*O,m+=x*N,m+=_*I,m+=S*R,c=(m+=T*L)>>>13,m&=8191,m+=B*J,m+=M*z,m+=K*j,m+=k*Y,E=c+=(m+=P*(5*W))>>>13,E+=U*W,E+=x*O,E+=_*N,E+=S*I,c=(E+=T*R)>>>13,E&=8191,E+=B*L,E+=M*J,E+=K*z,E+=k*j,U=l=8191&(c=(c=((c+=(E+=P*Y)>>>13)<<2)+c|0)+(l&=8191)|0),x=y+=c>>>=13,_=d&=8191,S=p&=8191,T=v&=8191,B=w&=8191,M=g&=8191,K=b&=8191,k=m&=8191,P=E&=8191,t+=16,e-=16;this.h[0]=U,this.h[1]=x,this.h[2]=_,this.h[3]=S,this.h[4]=T,this.h[5]=B,this.h[6]=M,this.h[7]=K,this.h[8]=k,this.h[9]=P},_.prototype.finish=function(r,t){var e,n,o,i,a=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(e=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=e,e=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*e,e=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=e,e=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=e,a[0]=this.h[0]+5,e=a[0]>>>13,a[0]&=8191,i=1;i<10;i++)a[i]=this.h[i]+e,e=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,n=(1^e)-1,i=0;i<10;i++)a[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|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),this.h[0]=65535&(o=this.h[0]+this.pad[0]),i=1;i<8;i++)this.h[i]=65535&(o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0);r[t+0]=this.h[0]>>>0&255,r[t+1]=this.h[0]>>>8&255,r[t+2]=this.h[1]>>>0&255,r[t+3]=this.h[1]>>>8&255,r[t+4]=this.h[2]>>>0&255,r[t+5]=this.h[2]>>>8&255,r[t+6]=this.h[3]>>>0&255,r[t+7]=this.h[3]>>>8&255,r[t+8]=this.h[4]>>>0&255,r[t+9]=this.h[4]>>>8&255,r[t+10]=this.h[5]>>>0&255,r[t+11]=this.h[5]>>>8&255,r[t+12]=this.h[6]>>>0&255,r[t+13]=this.h[6]>>>8&255,r[t+14]=this.h[7]>>>0&255,r[t+15]=this.h[7]>>>8&255},_.prototype.update=function(r,t,e){var n,o;if(this.leftover){for((o=16-this.leftover)>e&&(o=e),n=0;n<o;n++)this.buffer[this.leftover+n]=r[t+n];if(e-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(e>=16&&(this.blocks(r,t,o=e-e%16),t+=o,e-=o),e){for(n=0;n<e;n++)this.buffer[this.leftover+n]=r[t+n];this.leftover+=e}};var Z=B,V=M;var G=[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];function q(r,t,e,n){for(var o,i,a,f,h,s,u,c,l,y,d,p,v,w,g,b,m,E,A,U,x,_,S=new Int32Array(16),T=new Int32Array(16),B=r[0],M=r[1],K=r[2],k=r[3],P=r[4],Y=r[5],j=r[6],z=r[7],J=t[0],L=t[1],R=t[2],I=t[3],N=t[4],O=t[5],W=t[6],C=t[7],D=0;n>=128;){for(g=0;g<16;g++)S[g]=e[(b=8*g+D)+0]<<24|e[b+1]<<16|e[b+2]<<8|e[b+3],T[g]=e[b+4]<<24|e[b+5]<<16|e[b+6]<<8|e[b+7];for(g=0;g<80;g++)if(o=M,i=K,a=P,f=Y,h=j,z,u=L,c=R,l=N,y=O,d=W,C,A=65535&(E=C),U=E>>>16,x=65535&(m=z),_=m>>>16,A+=65535&(E=(N>>>14|P<<18)^(N>>>18|P<<14)^(P>>>9|N<<23)),U+=E>>>16,x+=65535&(m=(P>>>14|N<<18)^(P>>>18|N<<14)^(N>>>9|P<<23)),_+=m>>>16,A+=65535&(E=N&O^~N&W),U+=E>>>16,x+=65535&(m=P&Y^~P&j),_+=m>>>16,A+=65535&(E=G[2*g+1]),U+=E>>>16,x+=65535&(m=G[2*g]),_+=m>>>16,U+=(E=T[g%16])>>>16,x+=65535&(m=S[g%16]),_+=m>>>16,x+=(U+=(A+=65535&E)>>>16)>>>16,A=65535&(E=w=65535&A|U<<16),U=E>>>16,x=65535&(m=v=65535&x|(_+=x>>>16)<<16),_=m>>>16,A+=65535&(E=(J>>>28|B<<4)^(B>>>2|J<<30)^(B>>>7|J<<25)),U+=E>>>16,x+=65535&(m=(B>>>28|J<<4)^(J>>>2|B<<30)^(J>>>7|B<<25)),_+=m>>>16,U+=(E=J&L^J&R^L&R)>>>16,x+=65535&(m=B&M^B&K^M&K),_+=m>>>16,s=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,p=65535&A|U<<16,A=65535&(E=I),U=E>>>16,x=65535&(m=k),_=m>>>16,U+=(E=w)>>>16,x+=65535&(m=v),_+=m>>>16,M=B,K=o,k=i,P=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,Y=a,j=f,z=h,B=s,L=J,R=u,I=c,N=65535&A|U<<16,O=l,W=y,C=d,J=p,g%16==15)for(b=0;b<16;b++)A=65535&(E=T[b]),U=E>>>16,x=65535&(m=S[b]),_=m>>>16,A+=65535&(E=T[(b+9)%16]),U+=E>>>16,x+=65535&(m=S[(b+9)%16]),_+=m>>>16,A+=65535&(E=((w=T[(b+1)%16])>>>1|(v=S[(b+1)%16])<<31)^(w>>>8|v<<24)^(w>>>7|v<<25)),U+=E>>>16,x+=65535&(m=(v>>>1|w<<31)^(v>>>8|w<<24)^v>>>7),_+=m>>>16,U+=(E=((w=T[(b+14)%16])>>>19|(v=S[(b+14)%16])<<13)^(v>>>29|w<<3)^(w>>>6|v<<26))>>>16,x+=65535&(m=(v>>>19|w<<13)^(w>>>29|v<<3)^v>>>6),_+=m>>>16,S[b]=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,T[b]=65535&A|U<<16;A=65535&(E=J),U=E>>>16,x=65535&(m=B),_=m>>>16,U+=(E=t[0])>>>16,x+=65535&(m=r[0]),_+=m>>>16,r[0]=B=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[0]=J=65535&A|U<<16,A=65535&(E=L),U=E>>>16,x=65535&(m=M),_=m>>>16,U+=(E=t[1])>>>16,x+=65535&(m=r[1]),_+=m>>>16,r[1]=M=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[1]=L=65535&A|U<<16,A=65535&(E=R),U=E>>>16,x=65535&(m=K),_=m>>>16,U+=(E=t[2])>>>16,x+=65535&(m=r[2]),_+=m>>>16,r[2]=K=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[2]=R=65535&A|U<<16,A=65535&(E=I),U=E>>>16,x=65535&(m=k),_=m>>>16,U+=(E=t[3])>>>16,x+=65535&(m=r[3]),_+=m>>>16,r[3]=k=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[3]=I=65535&A|U<<16,A=65535&(E=N),U=E>>>16,x=65535&(m=P),_=m>>>16,U+=(E=t[4])>>>16,x+=65535&(m=r[4]),_+=m>>>16,r[4]=P=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[4]=N=65535&A|U<<16,A=65535&(E=O),U=E>>>16,x=65535&(m=Y),_=m>>>16,U+=(E=t[5])>>>16,x+=65535&(m=r[5]),_+=m>>>16,r[5]=Y=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[5]=O=65535&A|U<<16,A=65535&(E=W),U=E>>>16,x=65535&(m=j),_=m>>>16,U+=(E=t[6])>>>16,x+=65535&(m=r[6]),_+=m>>>16,r[6]=j=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[6]=W=65535&A|U<<16,A=65535&(E=C),U=E>>>16,x=65535&(m=z),_=m>>>16,U+=(E=t[7])>>>16,x+=65535&(m=r[7]),_+=m>>>16,r[7]=z=65535&(x+=(U+=(A+=65535&E)>>>16)>>>16)|(_+=x>>>16)<<16,t[7]=C=65535&A|U<<16,D+=128,n-=128}return n}function H(r,t,e){var n,o=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),f=e;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,q(o,i,t,e),e%=128,n=0;n<e;n++)a[n]=t[f-e+n];for(a[e]=128,a[(e=256-128*(e<112?1:0))-9]=0,y(a,e-8,f/536870912|0,f<<3),q(o,i,a,e),n=0;n<8;n++)y(r,8*n,o[n],i[n]);return 0}function X(r,e){var n=t(),o=t(),i=t(),a=t(),f=t(),h=t(),u=t(),c=t(),l=t();R(n,r[1],r[0]),R(l,e[1],e[0]),I(n,n,l),L(o,r[0],r[1]),L(l,e[0],e[1]),I(o,o,l),I(i,r[3],e[3]),I(i,i,s),I(a,r[2],e[2]),L(a,a,a),R(f,o,n),R(h,a,i),L(u,a,i),L(c,o,n),I(r[0],f,h),I(r[1],c,u),I(r[2],u,h),I(r[3],f,c)}function $(r,t,e){var n;for(n=0;n<4;n++)P(r[n],t[n],e)}function Q(r,e){var n=t(),o=t(),i=t();O(i,e[2]),I(n,e[0],i),I(o,e[1],i),Y(r,o),r[31]^=z(n)<<7}function rr(r,t,e){var n,o;for(K(r[0],i),K(r[1],a),K(r[2],a),K(r[3],i),o=255;o>=0;--o)$(r,t,n=e[o/8|0]>>(7&o)&1),X(t,r),X(r,r),$(r,t,n)}function tr(r,e){var n=[t(),t(),t(),t()];K(n[0],u),K(n[1],c),K(n[2],a),I(n[3],u,c),rr(r,n,e)}function er(r,n,o){var i,a=new Uint8Array(64),f=[t(),t(),t(),t()];for(o||e(n,32),H(a,n,32),a[0]&=248,a[31]&=127,a[31]|=64,tr(f,a),Q(r,f),i=0;i<32;i++)n[i+32]=r[i];return 0}var nr=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]);function or(r,t){var e,n,o,i;for(n=63;n>=32;--n){for(e=0,o=n-32,i=n-12;o<i;++o)t[o]+=e-16*t[n]*nr[o-(n-32)],t[o]-=256*(e=t[o]+128>>8);t[o]+=e,t[n]=0}for(e=0,o=0;o<32;o++)t[o]+=e-(t[31]>>4)*nr[o],e=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=e*nr[o];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,r[n]=255&t[n]}function ir(r){var t,e=new Float64Array(64);for(t=0;t<64;t++)e[t]=r[t];for(t=0;t<64;t++)r[t]=0;or(r,e)}function ar(r,e,n,o){var i,a,f=new Uint8Array(64),h=new Uint8Array(64),s=new Uint8Array(64),u=new Float64Array(64),c=[t(),t(),t(),t()];H(f,o,32),f[0]&=248,f[31]&=127,f[31]|=64;var l=n+64;for(i=0;i<n;i++)r[64+i]=e[i];for(i=0;i<32;i++)r[32+i]=f[32+i];for(H(s,r.subarray(32),n+32),ir(s),tr(c,s),Q(r,c),i=32;i<64;i++)r[i]=o[i];for(H(h,r,n+64),ir(h),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=s[i];for(i=0;i<32;i++)for(a=0;a<32;a++)u[i+a]+=h[i]*f[a];return or(r.subarray(32),u),l}function fr(r,e){var n=t(),o=t(),f=t(),s=t(),u=t(),c=t(),y=t();return K(r[2],a),J(r[1],e),N(f,r[1]),I(s,f,h),R(f,f,r[2]),L(s,r[2],s),N(u,s),N(c,u),I(y,c,u),I(n,y,f),I(n,n,s),function(r,e){var n,o=t();for(n=0;n<16;n++)o[n]=e[n];for(n=250;n>=0;n--)N(o,o),1!==n&&I(o,o,e);for(n=0;n<16;n++)r[n]=o[n]}(n,n),I(n,n,f),I(n,n,s),I(n,n,s),I(r[0],n,s),N(o,r[0]),I(o,o,s),j(o,f)&&I(r[0],r[0],l),N(o,r[0]),I(o,o,s),j(o,f)?-1:(z(r[0])===e[31]>>7&&R(r[0],i,r[0]),I(r[3],r[0],r[1]),0)}function hr(r,e,n,o){var i,a=new Uint8Array(32),f=new Uint8Array(64),h=[t(),t(),t(),t()],s=[t(),t(),t(),t()];if(-1,n<64)return-1;if(fr(s,o))return-1;for(i=0;i<n;i++)r[i]=e[i];for(i=0;i<32;i++)r[i+32]=o[i];if(H(f,r,n),ir(f),rr(h,s,f),tr(s,e.subarray(32)),X(h,s),Q(a,h),n-=64,v(e,0,a,0)){for(i=0;i<n;i++)r[i]=0;return-1}for(i=0;i<n;i++)r[i]=e[i+64];return n}var sr=32,ur=24,cr=32,lr=32,yr=ur;function dr(r,t){if(r.length!==sr)throw new Error("bad key size");if(t.length!==ur)throw new Error("bad nonce size")}function pr(){var r,t;for(t=0;t<arguments.length;t++)if("[object Uint8Array]"!==(r=Object.prototype.toString.call(arguments[t])))throw new TypeError("unexpected type "+r+", use Uint8Array")}function vr(r){for(var t=0;t<r.length;t++)r[t]=0}r.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:x,crypto_stream:U,crypto_stream_salsa20_xor:E,crypto_stream_salsa20:A,crypto_onetimeauth:S,crypto_onetimeauth_verify:T,crypto_verify_16:p,crypto_verify_32:v,crypto_secretbox:B,crypto_secretbox_open:M,crypto_scalarmult:W,crypto_scalarmult_base:C,crypto_box_beforenm:F,crypto_box_afternm:Z,crypto_box:function(r,t,e,n,o,i){var a=new Uint8Array(32);return F(a,o,i),Z(r,t,e,n,a)},crypto_box_open:function(r,t,e,n,o,i){var a=new Uint8Array(32);return F(a,o,i),V(r,t,e,n,a)},crypto_box_keypair:D,crypto_hash:H,crypto_sign:ar,crypto_sign_keypair:er,crypto_sign_open:hr,crypto_secretbox_KEYBYTES:sr,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:cr,crypto_box_SECRETKEYBYTES:lr,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:yr,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:64,crypto_sign_PUBLICKEYBYTES:32,crypto_sign_SECRETKEYBYTES:64,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64},r.util||(r.util={},r.util.decodeUTF8=r.util.encodeUTF8=r.util.encodeBase64=r.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),r.randomBytes=function(r){var t=new Uint8Array(r);return e(t,r),t},r.secretbox=function(r,t,e){pr(r,t,e),dr(e,t);for(var n=new Uint8Array(32+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+32]=r[i];return B(o,n,n.length,t,e),o.subarray(16)},r.secretbox.open=function(r,t,e){pr(r,t,e),dr(e,t);for(var n=new Uint8Array(16+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+16]=r[i];return!(n.length<32)&&(0===M(o,n,n.length,t,e)&&o.subarray(32))},r.secretbox.keyLength=sr,r.secretbox.nonceLength=ur,r.secretbox.overheadLength=16,r.scalarMult=function(r,t){if(pr(r,t),32!==r.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var e=new Uint8Array(32);return W(e,r,t),e},r.scalarMult.base=function(r){if(pr(r),32!==r.length)throw new Error("bad n size");var t=new Uint8Array(32);return C(t,r),t},r.scalarMult.scalarLength=32,r.scalarMult.groupElementLength=32,r.box=function(t,e,n,o){var i=r.box.before(n,o);return r.secretbox(t,e,i)},r.box.before=function(r,t){pr(r,t),function(r,t){if(r.length!==cr)throw new Error("bad public key size");if(t.length!==lr)throw new Error("bad secret key size")}(r,t);var e=new Uint8Array(32);return F(e,r,t),e},r.box.after=r.secretbox,r.box.open=function(t,e,n,o){var i=r.box.before(n,o);return r.secretbox.open(t,e,i)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var r=new Uint8Array(cr),t=new Uint8Array(lr);return D(r,t),{publicKey:r,secretKey:t}},r.box.keyPair.fromSecretKey=function(r){if(pr(r),r.length!==lr)throw new Error("bad secret key size");var t=new Uint8Array(cr);return C(t,r),{publicKey:t,secretKey:new Uint8Array(r)}},r.box.publicKeyLength=cr,r.box.secretKeyLength=lr,r.box.sharedKeyLength=32,r.box.nonceLength=yr,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(r,t){if(pr(r,t),64!==t.length)throw new Error("bad secret key size");var e=new Uint8Array(64+r.length);return ar(e,r,r.length,t),e},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(pr(r,t),32!==t.length)throw new Error("bad public key size");var e=new Uint8Array(r.length),n=hr(e,r,r.length,t);if(n<0)return null;for(var o=new Uint8Array(n),i=0;i<o.length;i++)o[i]=e[i];return o},r.sign.detached=function(t,e){for(var n=r.sign(t,e),o=new Uint8Array(64),i=0;i<o.length;i++)o[i]=n[i];return o},r.sign.detached.verify=function(r,t,e){if(pr(r,t,e),64!==t.length)throw new Error("bad signature size");if(32!==e.length)throw new Error("bad public key size");var n,o=new Uint8Array(64+r.length),i=new Uint8Array(64+r.length);for(n=0;n<64;n++)o[n]=t[n];for(n=0;n<r.length;n++)o[n+64]=r[n];return hr(i,o,o.length,e)>=0},r.sign.keyPair=function(){var r=new Uint8Array(32),t=new Uint8Array(64);return er(r,t),{publicKey:r,secretKey:t}},r.sign.keyPair.fromSecretKey=function(r){if(pr(r),64!==r.length)throw new Error("bad secret key size");for(var t=new Uint8Array(32),e=0;e<t.length;e++)t[e]=r[32+e];return{publicKey:t,secretKey:new Uint8Array(r)}},r.sign.keyPair.fromSeed=function(r){if(pr(r),32!==r.length)throw new Error("bad seed size");for(var t=new Uint8Array(32),e=new Uint8Array(64),n=0;n<32;n++)e[n]=r[n];return er(t,e,!0),{publicKey:t,secretKey:e}},r.sign.publicKeyLength=32,r.sign.secretKeyLength=64,r.sign.seedLength=32,r.sign.signatureLength=64,r.hash=function(r){pr(r);var t=new Uint8Array(64);return H(t,r,r.length),t},r.hash.hashLength=64,r.verify=function(r,t){return pr(r,t),0!==r.length&&0!==t.length&&(r.length===t.length&&0===d(r,0,t,0,r.length))},r.setPRNG=function(r){e=r},function(){var t="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(t&&t.getRandomValues){r.setPRNG(function(r,e){var n,o=new Uint8Array(e);for(n=0;n<e;n+=65536)t.getRandomValues(o.subarray(n,n+Math.min(e-n,65536)));for(n=0;n<e;n++)r[n]=o[n];vr(o)})}else(t=g)&&t.randomBytes&&r.setPRNG(function(r,e){var n,o=t.randomBytes(e);for(n=0;n<e;n++)r[n]=o[n];vr(o)})}()}(r.exports?r.exports:self.nacl=self.nacl||{})}),m=v(function(r){var t,e;t=p,e=function(){var r={};function t(r){if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(r))throw new TypeError("invalid encoding")}return r.decodeUTF8=function(r){if("string"!=typeof r)throw new TypeError("expected string");var t,e=unescape(encodeURIComponent(r)),n=new Uint8Array(e.length);for(t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n},r.encodeUTF8=function(r){var t,e=[];for(t=0;t<r.length;t++)e.push(String.fromCharCode(r[t]));return decodeURIComponent(escape(e.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(r.encodeBase64=function(r){return Buffer.from(r).toString("base64")},r.decodeBase64=function(r){return t(r),new Uint8Array(Array.prototype.slice.call(Buffer.from(r,"base64"),0))}):(r.encodeBase64=function(r){return new Buffer(r).toString("base64")},r.decodeBase64=function(r){return t(r),new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0))}):(r.encodeBase64=function(r){var t,e=[],n=r.length;for(t=0;t<n;t++)e.push(String.fromCharCode(r[t]));return btoa(e.join(""))},r.decodeBase64=function(r){t(r);var e,n=atob(r),o=new Uint8Array(n.length);for(e=0;e<n.length;e++)o[e]=n.charCodeAt(e);return o}),r},r.exports?r.exports=e():t.nacl?t.nacl.util=e():(t.nacl={},t.nacl.util=e())});var E=new n("secp256k1");function A(r,t){void 0===t&&(t=!1);var e=i.toBuffer(r);if(e.length!==(t?65:64))throw new Error("wrong signature length");var n={r:e.slice(0,32).toString("hex"),s:e.slice(32,64).toString("hex")};return t&&(n.recoveryParam=e[64]),n}var U={ES256K:function(r,t,e){var n=c(r),o=A(t),i=e.find(function(r){return E.keyFromPublic(r.publicKeyHex,"hex").verify(n,o)});if(!i)throw new Error("Signature invalid for JWT");return i},"ES256K-R":function(r,t,e){var n=A(t,!0),o=c(r),i=E.recoverPubKey(o,n,n.recoveryParam),a=i.encode("hex"),f=i.encode("hex",!0),h=l(a),s=e.find(function(r){var t=r.publicKeyHex;return t===a||t===f||r.ethereumAddress===h});if(!s)throw new Error("Signature invalid for JWT");return s},Ed25519:function(r,t,e){var n=m.decodeUTF8(r),o=s(t),i=e.find(function(r){return b.sign.detached.verify(n,o,m.decodeBase64(r.publicKeyBase64))});if(!i)throw new Error("Signature invalid for JWT");return i}};function x(r){var t=U[r];if(!t)throw new Error("Unsupported algorithm "+r);return t}function _(r){function t(t){var e=t.r,n=t.s,a=t.recoveryParam,f=o.alloc(r?65:64);if(o.from(e,"hex").copy(f,0),o.from(n,"hex").copy(f,32),r){if(void 0===a)throw new Error("Signer did not return a recoveryParam");f[64]=a}return i.encode(f)}return void 0===r&&(r=!1),function(r,e){try{return Promise.resolve(e(r)).then(t)}catch(r){return Promise.reject(r)}}}x.toSignatureObject=A;var S={ES256K:_(),"ES256K-R":_(!0),Ed25519:function(r,t){try{return Promise.resolve(t(r))}catch(r){return Promise.reject(r)}}};f(),u();var T={ES256K:["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],"ES256K-R":["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],Ed25519:["ED25519SignatureVerification"]},B={typ:"JWT"},M="ES256K";function K(r){return i.encode(JSON.stringify(r))}var k=300;function P(r){if(r.match(/^did:/))return r;if(e(r))return"did:uport:"+r;throw new Error("Not a valid DID '"+r+"'")}function Y(r){if(!r)throw new Error("no JWT passed into decodeJWT");var t=r.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(t)return{header:JSON.parse(i.decode(t[1])),payload:JSON.parse(i.decode(t[2])),signature:t[3],data:t[1]+"."+t[2]};throw new Error("Incorrect format JWT")}module.exports={SimpleSigner:function(r){var t=y.keyFromPrivate(r);return function(r){try{var e=t.sign(c(r)),n=e.s,o=e.recoveryParam;return Promise.resolve({r:d(e.r.toString("hex")),s:d(n.toString("hex")),recoveryParam:o})}catch(r){return Promise.reject(r)}}},NaclSigner:function(r){var t=m.decodeBase64(r);return function(r){try{return Promise.resolve(h(b.sign.detached(m.decodeUTF8(r),t)))}catch(r){return Promise.reject(r)}}},verifyJWT:function(r,t){void 0===t&&(t={});try{var n=t.audience?P(t.audience):void 0,o=Y(r),i=o.payload,f=o.header,h=o.signature,s=o.data;return Promise.resolve(function(r,t,e){try{var n=T[r];if(!n||0===n.length)throw new Error("No supported signature types for algorithm "+r);var o=P(t);return Promise.resolve(a(o)).then(function(t){if(!t)throw new Error("Unable to resolve DID document for "+o);var i=!e||(t.authentication||[]).map(function(r){return r.publicKey}),a=(t.publicKey||[]).filter(function(r){var t=r.type,o=r.id;return n.find(function(r){return r===t&&(!e||i.indexOf(o)>=0)})});if(e&&(!a||0===a.length))throw new Error("DID document for "+o+" does not have public keys suitable for authenticationg user");if(!a||0===a.length)throw new Error("DID document for "+o+" does not have public keys for "+r);return{authenticators:a,issuer:o,doc:t}})}catch(r){return Promise.reject(r)}}(f.alg,i.iss,t.auth)).then(function(o){var a,u=o.doc,c=o.authenticators,l=o.issuer,y=x(f.alg)(s,h,c),d=Math.floor(Date.now()/1e3);if(y){if(i.iat&&i.iat>d+k)throw new Error("JWT not valid yet (issued in the future): iat: "+i.iat+" > now: "+d);if(i.exp&&i.exp<=d-k)throw new Error("JWT has expired: exp: "+i.exp+" < now: "+d);if(i.aud)if((a=i.aud)&&(a.match(/^did:/)||e(a))){if(!n)throw new Error("JWT audience is required but your app address has not been configured");if(n!==P(i.aud))throw new Error("JWT audience does not match your DID: aud: "+i.aud+" !== yours: "+n)}else{if(!t.callbackUrl)throw new Error("JWT audience matching your callback url is required but one wasn't passed in");if(i.aud!==t.callbackUrl)throw new Error("JWT audience does not match the callback url: aud: "+i.aud+" !== url: "+t.callbackUrl)}return{payload:i,doc:u,issuer:l,signer:y,jwt:r}}})}catch(r){return Promise.reject(r)}},createJWT:function(r,t){var e=t.issuer,n=t.signer,o=t.alg,i=t.expiresIn;try{if(!n)throw new Error("No Signer functionality has been configured");if(!e)throw new Error("No issuing DID has been configured");var a=Object.assign({},B,{alg:o||M}),f={iat:Math.floor(Date.now()/1e3)};if(i){if("number"!=typeof i)throw new Error("JWT expiresIn is not a number");f.exp=f.iat+Math.floor(i)}var h=[K(a),K(Object.assign({},f,r,{iss:e}))].join("."),s=function(r){var t=S[r];if(!t)throw new Error("Unsupported algorithm "+r);return t}(a.alg);return Promise.resolve(s(h,n)).then(function(r){return[h,r].join(".")})}catch(r){return Promise.reject(r)}},decodeJWT:Y,toEthereumAddress:l}; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -1,2 +0,2 @@ | ||
function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}var e=require("js-sha256"),t=require("js-sha3"),n=require("mnid"),o=require("elliptic"),i=require("buffer"),a=r(require("base64url")),f=r(require("did-resolver")),h=r(require("uport-did-resolver")),s=require("nacl-did");function u(r){return i.Buffer.from(e.sha256.arrayBuffer(r))}function c(r){return"0x"+(e=i.Buffer.from(r.slice(2),"hex"),i.Buffer.from(t.keccak_256.buffer(e))).slice(-20).toString("hex");var e}var l=new o.ec("secp256k1");function y(r,e){return void 0===e&&(e=64),r.length===e?r:"0".repeat(e-r.length)+r}var d="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(r,e){return r(e={exports:{}},e.exports),e.exports}var w={},p=v(function(r){!function(r){var e=function(r){var e,t=new Float64Array(16);if(r)for(e=0;e<r.length;e++)t[e]=r[e];return t},t=function(){throw new Error("no PRNG")},n=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=e(),a=e([1]),f=e([56129,1]),h=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),s=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),c=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function y(r,e,t,n){r[e]=t>>24&255,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=255&t,r[e+4]=n>>24&255,r[e+5]=n>>16&255,r[e+6]=n>>8&255,r[e+7]=255&n}function d(r,e,t,n,o){var i,a=0;for(i=0;i<o;i++)a|=r[e+i]^t[n+i];return(1&a-1>>>8)-1}function v(r,e,t,n){return d(r,e,t,n,16)}function p(r,e,t,n){return d(r,e,t,n,32)}function g(r,e,t,n){!function(r,e,t,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,s=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,v=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,w=255&t[16]|(255&t[17])<<8|(255&t[18])<<16|(255&t[19])<<24,p=255&t[20]|(255&t[21])<<8|(255&t[22])<<16|(255&t[23])<<24,g=255&t[24]|(255&t[25])<<8|(255&t[26])<<16|(255&t[27])<<24,b=255&t[28]|(255&t[29])<<8|(255&t[30])<<16|(255&t[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,A=i,U=a,m=f,x=h,_=s,S=u,B=c,T=l,M=y,K=d,k=v,P=w,Y=p,j=g,z=b,D=E,I=0;I<20;I+=2)A^=(o=(Y^=(o=(M^=(o=(_^=(o=A+Y|0)<<7|o>>>25)+A|0)<<9|o>>>23)+_|0)<<13|o>>>19)+M|0)<<18|o>>>14,S^=(o=(U^=(o=(j^=(o=(K^=(o=S+U|0)<<7|o>>>25)+S|0)<<9|o>>>23)+K|0)<<13|o>>>19)+j|0)<<18|o>>>14,k^=(o=(B^=(o=(m^=(o=(z^=(o=k+B|0)<<7|o>>>25)+k|0)<<9|o>>>23)+z|0)<<13|o>>>19)+m|0)<<18|o>>>14,D^=(o=(P^=(o=(T^=(o=(x^=(o=D+P|0)<<7|o>>>25)+D|0)<<9|o>>>23)+x|0)<<13|o>>>19)+T|0)<<18|o>>>14,A^=(o=(x^=(o=(m^=(o=(U^=(o=A+x|0)<<7|o>>>25)+A|0)<<9|o>>>23)+U|0)<<13|o>>>19)+m|0)<<18|o>>>14,S^=(o=(_^=(o=(T^=(o=(B^=(o=S+_|0)<<7|o>>>25)+S|0)<<9|o>>>23)+B|0)<<13|o>>>19)+T|0)<<18|o>>>14,k^=(o=(K^=(o=(M^=(o=(P^=(o=k+K|0)<<7|o>>>25)+k|0)<<9|o>>>23)+P|0)<<13|o>>>19)+M|0)<<18|o>>>14,D^=(o=(z^=(o=(j^=(o=(Y^=(o=D+z|0)<<7|o>>>25)+D|0)<<9|o>>>23)+Y|0)<<13|o>>>19)+j|0)<<18|o>>>14;U=U+a|0,m=m+f|0,x=x+h|0,_=_+s|0,S=S+u|0,B=B+c|0,T=T+l|0,M=M+y|0,K=K+d|0,k=k+v|0,P=P+w|0,Y=Y+p|0,j=j+g|0,z=z+b|0,D=D+E|0,r[0]=(A=A+i|0)>>>0&255,r[1]=A>>>8&255,r[2]=A>>>16&255,r[3]=A>>>24&255,r[4]=U>>>0&255,r[5]=U>>>8&255,r[6]=U>>>16&255,r[7]=U>>>24&255,r[8]=m>>>0&255,r[9]=m>>>8&255,r[10]=m>>>16&255,r[11]=m>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=_>>>0&255,r[17]=_>>>8&255,r[18]=_>>>16&255,r[19]=_>>>24&255,r[20]=S>>>0&255,r[21]=S>>>8&255,r[22]=S>>>16&255,r[23]=S>>>24&255,r[24]=B>>>0&255,r[25]=B>>>8&255,r[26]=B>>>16&255,r[27]=B>>>24&255,r[28]=T>>>0&255,r[29]=T>>>8&255,r[30]=T>>>16&255,r[31]=T>>>24&255,r[32]=M>>>0&255,r[33]=M>>>8&255,r[34]=M>>>16&255,r[35]=M>>>24&255,r[36]=K>>>0&255,r[37]=K>>>8&255,r[38]=K>>>16&255,r[39]=K>>>24&255,r[40]=k>>>0&255,r[41]=k>>>8&255,r[42]=k>>>16&255,r[43]=k>>>24&255,r[44]=P>>>0&255,r[45]=P>>>8&255,r[46]=P>>>16&255,r[47]=P>>>24&255,r[48]=Y>>>0&255,r[49]=Y>>>8&255,r[50]=Y>>>16&255,r[51]=Y>>>24&255,r[52]=j>>>0&255,r[53]=j>>>8&255,r[54]=j>>>16&255,r[55]=j>>>24&255,r[56]=z>>>0&255,r[57]=z>>>8&255,r[58]=z>>>16&255,r[59]=z>>>24&255,r[60]=D>>>0&255,r[61]=D>>>8&255,r[62]=D>>>16&255,r[63]=D>>>24&255}(r,e,t,n)}function b(r,e,t,n){!function(r,e,t,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,s=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,v=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,w=255&t[16]|(255&t[17])<<8|(255&t[18])<<16|(255&t[19])<<24,p=255&t[20]|(255&t[21])<<8|(255&t[22])<<16|(255&t[23])<<24,g=255&t[24]|(255&t[25])<<8|(255&t[26])<<16|(255&t[27])<<24,b=255&t[28]|(255&t[29])<<8|(255&t[30])<<16|(255&t[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,A=0;A<20;A+=2)i^=(o=(p^=(o=(y^=(o=(s^=(o=i+p|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+y|0)<<18|o>>>14,u^=(o=(a^=(o=(g^=(o=(d^=(o=u+a|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+g|0)<<18|o>>>14,v^=(o=(c^=(o=(f^=(o=(b^=(o=v+c|0)<<7|o>>>25)+v|0)<<9|o>>>23)+b|0)<<13|o>>>19)+f|0)<<18|o>>>14,E^=(o=(w^=(o=(l^=(o=(h^=(o=E+w|0)<<7|o>>>25)+E|0)<<9|o>>>23)+h|0)<<13|o>>>19)+l|0)<<18|o>>>14,i^=(o=(h^=(o=(f^=(o=(a^=(o=i+h|0)<<7|o>>>25)+i|0)<<9|o>>>23)+a|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(l^=(o=(c^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+c|0)<<13|o>>>19)+l|0)<<18|o>>>14,v^=(o=(d^=(o=(y^=(o=(w^=(o=v+d|0)<<7|o>>>25)+v|0)<<9|o>>>23)+w|0)<<13|o>>>19)+y|0)<<18|o>>>14,E^=(o=(b^=(o=(g^=(o=(p^=(o=E+b|0)<<7|o>>>25)+E|0)<<9|o>>>23)+p|0)<<13|o>>>19)+g|0)<<18|o>>>14;r[0]=i>>>0&255,r[1]=i>>>8&255,r[2]=i>>>16&255,r[3]=i>>>24&255,r[4]=u>>>0&255,r[5]=u>>>8&255,r[6]=u>>>16&255,r[7]=u>>>24&255,r[8]=v>>>0&255,r[9]=v>>>8&255,r[10]=v>>>16&255,r[11]=v>>>24&255,r[12]=E>>>0&255,r[13]=E>>>8&255,r[14]=E>>>16&255,r[15]=E>>>24&255,r[16]=c>>>0&255,r[17]=c>>>8&255,r[18]=c>>>16&255,r[19]=c>>>24&255,r[20]=l>>>0&255,r[21]=l>>>8&255,r[22]=l>>>16&255,r[23]=l>>>24&255,r[24]=y>>>0&255,r[25]=y>>>8&255,r[26]=y>>>16&255,r[27]=y>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255}(r,e,t,n)}var E=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function A(r,e,t,n,o,i,a){var f,h,s=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)s[h]=0;for(h=0;h<8;h++)s[h]=i[h];for(;o>=64;){for(g(u,s,a,E),h=0;h<64;h++)r[e+h]=t[n+h]^u[h];for(f=1,h=8;h<16;h++)s[h]=255&(f=f+(255&s[h])|0),f>>>=8;o-=64,e+=64,n+=64}if(o>0)for(g(u,s,a,E),h=0;h<o;h++)r[e+h]=t[n+h]^u[h];return 0}function U(r,e,t,n,o){var i,a,f=new Uint8Array(16),h=new Uint8Array(64);for(a=0;a<16;a++)f[a]=0;for(a=0;a<8;a++)f[a]=n[a];for(;t>=64;){for(g(h,f,o,E),a=0;a<64;a++)r[e+a]=h[a];for(i=1,a=8;a<16;a++)f[a]=255&(i=i+(255&f[a])|0),i>>>=8;t-=64,e+=64}if(t>0)for(g(h,f,o,E),a=0;a<t;a++)r[e+a]=h[a];return 0}function m(r,e,t,n,o){var i=new Uint8Array(32);b(i,n,o,E);for(var a=new Uint8Array(8),f=0;f<8;f++)a[f]=n[f+16];return U(r,e,t,a,i)}function x(r,e,t,n,o,i,a){var f=new Uint8Array(32);b(f,i,a,E);for(var h=new Uint8Array(8),s=0;s<8;s++)h[s]=i[s+16];return A(r,e,t,n,o,h,f)}var _=function(r){var e,t,n,o,i,a,f,h;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,this.r[0]=8191&(e=255&r[0]|(255&r[1])<<8),this.r[1]=8191&(e>>>13|(t=255&r[2]|(255&r[3])<<8)<<3),this.r[2]=7939&(t>>>10|(n=255&r[4]|(255&r[5])<<8)<<6),this.r[3]=8191&(n>>>7|(o=255&r[6]|(255&r[7])<<8)<<9),this.r[4]=255&(o>>>4|(i=255&r[8]|(255&r[9])<<8)<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|(a=255&r[10]|(255&r[11])<<8)<<2),this.r[7]=8065&(a>>>11|(f=255&r[12]|(255&r[13])<<8)<<5),this.r[8]=8191&(f>>>8|(h=255&r[14]|(255&r[15])<<8)<<8),this.r[9]=h>>>5&127,this.pad[0]=255&r[16]|(255&r[17])<<8,this.pad[1]=255&r[18]|(255&r[19])<<8,this.pad[2]=255&r[20]|(255&r[21])<<8,this.pad[3]=255&r[22]|(255&r[23])<<8,this.pad[4]=255&r[24]|(255&r[25])<<8,this.pad[5]=255&r[26]|(255&r[27])<<8,this.pad[6]=255&r[28]|(255&r[29])<<8,this.pad[7]=255&r[30]|(255&r[31])<<8};function S(r,e,t,n,o,i){var a=new _(i);return a.update(t,n,o),a.finish(r,e),0}function B(r,e,t,n,o,i){var a=new Uint8Array(16);return S(a,0,t,n,o,i),v(r,e,a,0)}function T(r,e,t,n,o){var i;if(t<32)return-1;for(x(r,0,e,0,t,n,o),S(r,16,r,32,t-32,r),i=0;i<16;i++)r[i]=0;return 0}function M(r,e,t,n,o){var i,a=new Uint8Array(32);if(t<32)return-1;if(m(a,0,32,n,o),0!==B(e,16,e,32,t-32,a))return-1;for(x(r,0,e,0,t,n,o),i=0;i<32;i++)r[i]=0;return 0}function K(r,e){var t;for(t=0;t<16;t++)r[t]=0|e[t]}function k(r){var e,t,n=1;for(e=0;e<16;e++)t=r[e]+n+65535,n=Math.floor(t/65536),r[e]=t-65536*n;r[0]+=n-1+37*(n-1)}function P(r,e,t){for(var n,o=~(t-1),i=0;i<16;i++)r[i]^=n=o&(r[i]^e[i]),e[i]^=n}function Y(r,t){var n,o,i,a=e(),f=e();for(n=0;n<16;n++)f[n]=t[n];for(k(f),k(f),k(f),o=0;o<2;o++){for(a[0]=f[0]-65517,n=1;n<15;n++)a[n]=f[n]-65535-(a[n-1]>>16&1),a[n-1]&=65535;a[15]=f[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,P(f,a,1-i)}for(n=0;n<16;n++)r[2*n]=255&f[n],r[2*n+1]=f[n]>>8}function j(r,e){var t=new Uint8Array(32),n=new Uint8Array(32);return Y(t,r),Y(n,e),p(t,0,n,0)}function z(r){var e=new Uint8Array(32);return Y(e,r),1&e[0]}function D(r,e){var t;for(t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function I(r,e,t){for(var n=0;n<16;n++)r[n]=e[n]+t[n]}function J(r,e,t){for(var n=0;n<16;n++)r[n]=e[n]-t[n]}function N(r,e,t){var n,o,i=0,a=0,f=0,h=0,s=0,u=0,c=0,l=0,y=0,d=0,v=0,w=0,p=0,g=0,b=0,E=0,A=0,U=0,m=0,x=0,_=0,S=0,B=0,T=0,M=0,K=0,k=0,P=0,Y=0,j=0,z=0,D=t[0],I=t[1],J=t[2],N=t[3],L=t[4],R=t[5],O=t[6],W=t[7],C=t[8],F=t[9],q=t[10],Z=t[11],V=t[12],G=t[13],H=t[14],X=t[15];i+=(n=e[0])*D,a+=n*I,f+=n*J,h+=n*N,s+=n*L,u+=n*R,c+=n*O,l+=n*W,y+=n*C,d+=n*F,v+=n*q,w+=n*Z,p+=n*V,g+=n*G,b+=n*H,E+=n*X,a+=(n=e[1])*D,f+=n*I,h+=n*J,s+=n*N,u+=n*L,c+=n*R,l+=n*O,y+=n*W,d+=n*C,v+=n*F,w+=n*q,p+=n*Z,g+=n*V,b+=n*G,E+=n*H,A+=n*X,f+=(n=e[2])*D,h+=n*I,s+=n*J,u+=n*N,c+=n*L,l+=n*R,y+=n*O,d+=n*W,v+=n*C,w+=n*F,p+=n*q,g+=n*Z,b+=n*V,E+=n*G,A+=n*H,U+=n*X,h+=(n=e[3])*D,s+=n*I,u+=n*J,c+=n*N,l+=n*L,y+=n*R,d+=n*O,v+=n*W,w+=n*C,p+=n*F,g+=n*q,b+=n*Z,E+=n*V,A+=n*G,U+=n*H,m+=n*X,s+=(n=e[4])*D,u+=n*I,c+=n*J,l+=n*N,y+=n*L,d+=n*R,v+=n*O,w+=n*W,p+=n*C,g+=n*F,b+=n*q,E+=n*Z,A+=n*V,U+=n*G,m+=n*H,x+=n*X,u+=(n=e[5])*D,c+=n*I,l+=n*J,y+=n*N,d+=n*L,v+=n*R,w+=n*O,p+=n*W,g+=n*C,b+=n*F,E+=n*q,A+=n*Z,U+=n*V,m+=n*G,x+=n*H,_+=n*X,c+=(n=e[6])*D,l+=n*I,y+=n*J,d+=n*N,v+=n*L,w+=n*R,p+=n*O,g+=n*W,b+=n*C,E+=n*F,A+=n*q,U+=n*Z,m+=n*V,x+=n*G,_+=n*H,S+=n*X,l+=(n=e[7])*D,y+=n*I,d+=n*J,v+=n*N,w+=n*L,p+=n*R,g+=n*O,b+=n*W,E+=n*C,A+=n*F,U+=n*q,m+=n*Z,x+=n*V,_+=n*G,S+=n*H,B+=n*X,y+=(n=e[8])*D,d+=n*I,v+=n*J,w+=n*N,p+=n*L,g+=n*R,b+=n*O,E+=n*W,A+=n*C,U+=n*F,m+=n*q,x+=n*Z,_+=n*V,S+=n*G,B+=n*H,T+=n*X,d+=(n=e[9])*D,v+=n*I,w+=n*J,p+=n*N,g+=n*L,b+=n*R,E+=n*O,A+=n*W,U+=n*C,m+=n*F,x+=n*q,_+=n*Z,S+=n*V,B+=n*G,T+=n*H,M+=n*X,v+=(n=e[10])*D,w+=n*I,p+=n*J,g+=n*N,b+=n*L,E+=n*R,A+=n*O,U+=n*W,m+=n*C,x+=n*F,_+=n*q,S+=n*Z,B+=n*V,T+=n*G,M+=n*H,K+=n*X,w+=(n=e[11])*D,p+=n*I,g+=n*J,b+=n*N,E+=n*L,A+=n*R,U+=n*O,m+=n*W,x+=n*C,_+=n*F,S+=n*q,B+=n*Z,T+=n*V,M+=n*G,K+=n*H,k+=n*X,p+=(n=e[12])*D,g+=n*I,b+=n*J,E+=n*N,A+=n*L,U+=n*R,m+=n*O,x+=n*W,_+=n*C,S+=n*F,B+=n*q,T+=n*Z,M+=n*V,K+=n*G,k+=n*H,P+=n*X,g+=(n=e[13])*D,b+=n*I,E+=n*J,A+=n*N,U+=n*L,m+=n*R,x+=n*O,_+=n*W,S+=n*C,B+=n*F,T+=n*q,M+=n*Z,K+=n*V,k+=n*G,P+=n*H,Y+=n*X,b+=(n=e[14])*D,E+=n*I,A+=n*J,U+=n*N,m+=n*L,x+=n*R,_+=n*O,S+=n*W,B+=n*C,T+=n*F,M+=n*q,K+=n*Z,k+=n*V,P+=n*G,Y+=n*H,j+=n*X,E+=(n=e[15])*D,a+=38*(U+=n*J),f+=38*(m+=n*N),h+=38*(x+=n*L),s+=38*(_+=n*R),u+=38*(S+=n*O),c+=38*(B+=n*W),l+=38*(T+=n*C),y+=38*(M+=n*F),d+=38*(K+=n*q),v+=38*(k+=n*Z),w+=38*(P+=n*V),p+=38*(Y+=n*G),g+=38*(j+=n*H),b+=38*(z+=n*X),i=(n=(i+=38*(A+=n*I))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),r[0]=i+=o-1+37*(o-1),r[1]=a,r[2]=f,r[3]=h,r[4]=s,r[5]=u,r[6]=c,r[7]=l,r[8]=y,r[9]=d,r[10]=v,r[11]=w,r[12]=p,r[13]=g,r[14]=b,r[15]=E}function L(r,e){N(r,e,e)}function R(r,t){var n,o=e();for(n=0;n<16;n++)o[n]=t[n];for(n=253;n>=0;n--)L(o,o),2!==n&&4!==n&&N(o,o,t);for(n=0;n<16;n++)r[n]=o[n]}function O(r,t,n){var o,i,a=new Uint8Array(32),h=new Float64Array(80),s=e(),u=e(),c=e(),l=e(),y=e(),d=e();for(i=0;i<31;i++)a[i]=t[i];for(a[31]=127&t[31]|64,a[0]&=248,D(h,n),i=0;i<16;i++)u[i]=h[i],l[i]=s[i]=c[i]=0;for(s[0]=l[0]=1,i=254;i>=0;--i)P(s,u,o=a[i>>>3]>>>(7&i)&1),P(c,l,o),I(y,s,c),J(s,s,c),I(c,u,l),J(u,u,l),L(l,y),L(d,s),N(s,c,s),N(c,u,y),I(y,s,c),J(s,s,c),L(u,s),J(c,l,d),N(s,c,f),I(s,s,l),N(c,c,s),N(s,l,d),N(l,u,h),L(u,y),P(s,u,o),P(c,l,o);for(i=0;i<16;i++)h[i+16]=s[i],h[i+32]=c[i],h[i+48]=u[i],h[i+64]=l[i];var v=h.subarray(32),w=h.subarray(16);return R(v,v),N(w,w,v),Y(r,w),0}function W(r,e){return O(r,e,o)}function C(r,e){return t(e,32),W(r,e)}function F(r,e,t){var o=new Uint8Array(32);return O(o,t,e),b(r,n,o,E)}_.prototype.blocks=function(r,e,t){for(var n,o,i,a,f,h,s,u,c,l,y,d,v,w,p,g,b,E,A,U=this.fin?0:2048,m=this.h[0],x=this.h[1],_=this.h[2],S=this.h[3],B=this.h[4],T=this.h[5],M=this.h[6],K=this.h[7],k=this.h[8],P=this.h[9],Y=this.r[0],j=this.r[1],z=this.r[2],D=this.r[3],I=this.r[4],J=this.r[5],N=this.r[6],L=this.r[7],R=this.r[8],O=this.r[9];t>=16;)l=c=0,l+=(m+=8191&(n=255&r[e+0]|(255&r[e+1])<<8))*Y,l+=(x+=8191&(n>>>13|(o=255&r[e+2]|(255&r[e+3])<<8)<<3))*(5*O),l+=(_+=8191&(o>>>10|(i=255&r[e+4]|(255&r[e+5])<<8)<<6))*(5*R),l+=(S+=8191&(i>>>7|(a=255&r[e+6]|(255&r[e+7])<<8)<<9))*(5*L),c=(l+=(B+=8191&(a>>>4|(f=255&r[e+8]|(255&r[e+9])<<8)<<12))*(5*N))>>>13,l&=8191,l+=(T+=f>>>1&8191)*(5*J),l+=(M+=8191&(f>>>14|(h=255&r[e+10]|(255&r[e+11])<<8)<<2))*(5*I),l+=(K+=8191&(h>>>11|(s=255&r[e+12]|(255&r[e+13])<<8)<<5))*(5*D),l+=(k+=8191&(s>>>8|(u=255&r[e+14]|(255&r[e+15])<<8)<<8))*(5*z),y=c+=(l+=(P+=u>>>5|U)*(5*j))>>>13,y+=m*j,y+=x*Y,y+=_*(5*O),y+=S*(5*R),c=(y+=B*(5*L))>>>13,y&=8191,y+=T*(5*N),y+=M*(5*J),y+=K*(5*I),y+=k*(5*D),c+=(y+=P*(5*z))>>>13,y&=8191,d=c,d+=m*z,d+=x*j,d+=_*Y,d+=S*(5*O),c=(d+=B*(5*R))>>>13,d&=8191,d+=T*(5*L),d+=M*(5*N),d+=K*(5*J),d+=k*(5*I),v=c+=(d+=P*(5*D))>>>13,v+=m*D,v+=x*z,v+=_*j,v+=S*Y,c=(v+=B*(5*O))>>>13,v&=8191,v+=T*(5*R),v+=M*(5*L),v+=K*(5*N),v+=k*(5*J),w=c+=(v+=P*(5*I))>>>13,w+=m*I,w+=x*D,w+=_*z,w+=S*j,c=(w+=B*Y)>>>13,w&=8191,w+=T*(5*O),w+=M*(5*R),w+=K*(5*L),w+=k*(5*N),p=c+=(w+=P*(5*J))>>>13,p+=m*J,p+=x*I,p+=_*D,p+=S*z,c=(p+=B*j)>>>13,p&=8191,p+=T*Y,p+=M*(5*O),p+=K*(5*R),p+=k*(5*L),g=c+=(p+=P*(5*N))>>>13,g+=m*N,g+=x*J,g+=_*I,g+=S*D,c=(g+=B*z)>>>13,g&=8191,g+=T*j,g+=M*Y,g+=K*(5*O),g+=k*(5*R),b=c+=(g+=P*(5*L))>>>13,b+=m*L,b+=x*N,b+=_*J,b+=S*I,c=(b+=B*D)>>>13,b&=8191,b+=T*z,b+=M*j,b+=K*Y,b+=k*(5*O),E=c+=(b+=P*(5*R))>>>13,E+=m*R,E+=x*L,E+=_*N,E+=S*J,c=(E+=B*I)>>>13,E&=8191,E+=T*D,E+=M*z,E+=K*j,E+=k*Y,A=c+=(E+=P*(5*O))>>>13,A+=m*O,A+=x*R,A+=_*L,A+=S*N,c=(A+=B*J)>>>13,A&=8191,A+=T*I,A+=M*D,A+=K*z,A+=k*j,m=l=8191&(c=(c=((c+=(A+=P*Y)>>>13)<<2)+c|0)+(l&=8191)|0),x=y+=c>>>=13,_=d&=8191,S=v&=8191,B=w&=8191,T=p&=8191,M=g&=8191,K=b&=8191,k=E&=8191,P=A&=8191,e+=16,t-=16;this.h[0]=m,this.h[1]=x,this.h[2]=_,this.h[3]=S,this.h[4]=B,this.h[5]=T,this.h[6]=M,this.h[7]=K,this.h[8]=k,this.h[9]=P},_.prototype.finish=function(r,e){var t,n,o,i,a=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;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;i<10;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,a[0]=this.h[0]+5,t=a[0]>>>13,a[0]&=8191,i=1;i<10;i++)a[i]=this.h[i]+t,t=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,n=(1^t)-1,i=0;i<10;i++)a[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|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),this.h[0]=65535&(o=this.h[0]+this.pad[0]),i=1;i<8;i++)this.h[i]=65535&(o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0);r[e+0]=this.h[0]>>>0&255,r[e+1]=this.h[0]>>>8&255,r[e+2]=this.h[1]>>>0&255,r[e+3]=this.h[1]>>>8&255,r[e+4]=this.h[2]>>>0&255,r[e+5]=this.h[2]>>>8&255,r[e+6]=this.h[3]>>>0&255,r[e+7]=this.h[3]>>>8&255,r[e+8]=this.h[4]>>>0&255,r[e+9]=this.h[4]>>>8&255,r[e+10]=this.h[5]>>>0&255,r[e+11]=this.h[5]>>>8&255,r[e+12]=this.h[6]>>>0&255,r[e+13]=this.h[6]>>>8&255,r[e+14]=this.h[7]>>>0&255,r[e+15]=this.h[7]>>>8&255},_.prototype.update=function(r,e,t){var n,o;if(this.leftover){for((o=16-this.leftover)>t&&(o=t),n=0;n<o;n++)this.buffer[this.leftover+n]=r[e+n];if(t-=o,e+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(t>=16&&(this.blocks(r,e,o=t-t%16),e+=o,t-=o),t){for(n=0;n<t;n++)this.buffer[this.leftover+n]=r[e+n];this.leftover+=t}};var q=T,Z=M;var V=[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];function G(r,e,t,n){for(var o,i,a,f,h,s,u,c,l,y,d,v,w,p,g,b,E,A,U,m,x,_,S=new Int32Array(16),B=new Int32Array(16),T=r[0],M=r[1],K=r[2],k=r[3],P=r[4],Y=r[5],j=r[6],z=r[7],D=e[0],I=e[1],J=e[2],N=e[3],L=e[4],R=e[5],O=e[6],W=e[7],C=0;n>=128;){for(g=0;g<16;g++)S[g]=t[(b=8*g+C)+0]<<24|t[b+1]<<16|t[b+2]<<8|t[b+3],B[g]=t[b+4]<<24|t[b+5]<<16|t[b+6]<<8|t[b+7];for(g=0;g<80;g++)if(o=M,i=K,a=P,f=Y,h=j,z,u=I,c=J,l=L,y=R,d=O,W,U=65535&(A=W),m=A>>>16,x=65535&(E=z),_=E>>>16,U+=65535&(A=(L>>>14|P<<18)^(L>>>18|P<<14)^(P>>>9|L<<23)),m+=A>>>16,x+=65535&(E=(P>>>14|L<<18)^(P>>>18|L<<14)^(L>>>9|P<<23)),_+=E>>>16,U+=65535&(A=L&R^~L&O),m+=A>>>16,x+=65535&(E=P&Y^~P&j),_+=E>>>16,U+=65535&(A=V[2*g+1]),m+=A>>>16,x+=65535&(E=V[2*g]),_+=E>>>16,m+=(A=B[g%16])>>>16,x+=65535&(E=S[g%16]),_+=E>>>16,x+=(m+=(U+=65535&A)>>>16)>>>16,U=65535&(A=p=65535&U|m<<16),m=A>>>16,x=65535&(E=w=65535&x|(_+=x>>>16)<<16),_=E>>>16,U+=65535&(A=(D>>>28|T<<4)^(T>>>2|D<<30)^(T>>>7|D<<25)),m+=A>>>16,x+=65535&(E=(T>>>28|D<<4)^(D>>>2|T<<30)^(D>>>7|T<<25)),_+=E>>>16,m+=(A=D&I^D&J^I&J)>>>16,x+=65535&(E=T&M^T&K^M&K),_+=E>>>16,s=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,v=65535&U|m<<16,U=65535&(A=N),m=A>>>16,x=65535&(E=k),_=E>>>16,m+=(A=p)>>>16,x+=65535&(E=w),_+=E>>>16,M=T,K=o,k=i,P=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,Y=a,j=f,z=h,T=s,I=D,J=u,N=c,L=65535&U|m<<16,R=l,O=y,W=d,D=v,g%16==15)for(b=0;b<16;b++)U=65535&(A=B[b]),m=A>>>16,x=65535&(E=S[b]),_=E>>>16,U+=65535&(A=B[(b+9)%16]),m+=A>>>16,x+=65535&(E=S[(b+9)%16]),_+=E>>>16,U+=65535&(A=((p=B[(b+1)%16])>>>1|(w=S[(b+1)%16])<<31)^(p>>>8|w<<24)^(p>>>7|w<<25)),m+=A>>>16,x+=65535&(E=(w>>>1|p<<31)^(w>>>8|p<<24)^w>>>7),_+=E>>>16,m+=(A=((p=B[(b+14)%16])>>>19|(w=S[(b+14)%16])<<13)^(w>>>29|p<<3)^(p>>>6|w<<26))>>>16,x+=65535&(E=(w>>>19|p<<13)^(p>>>29|w<<3)^w>>>6),_+=E>>>16,S[b]=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,B[b]=65535&U|m<<16;U=65535&(A=D),m=A>>>16,x=65535&(E=T),_=E>>>16,m+=(A=e[0])>>>16,x+=65535&(E=r[0]),_+=E>>>16,r[0]=T=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[0]=D=65535&U|m<<16,U=65535&(A=I),m=A>>>16,x=65535&(E=M),_=E>>>16,m+=(A=e[1])>>>16,x+=65535&(E=r[1]),_+=E>>>16,r[1]=M=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[1]=I=65535&U|m<<16,U=65535&(A=J),m=A>>>16,x=65535&(E=K),_=E>>>16,m+=(A=e[2])>>>16,x+=65535&(E=r[2]),_+=E>>>16,r[2]=K=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[2]=J=65535&U|m<<16,U=65535&(A=N),m=A>>>16,x=65535&(E=k),_=E>>>16,m+=(A=e[3])>>>16,x+=65535&(E=r[3]),_+=E>>>16,r[3]=k=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[3]=N=65535&U|m<<16,U=65535&(A=L),m=A>>>16,x=65535&(E=P),_=E>>>16,m+=(A=e[4])>>>16,x+=65535&(E=r[4]),_+=E>>>16,r[4]=P=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[4]=L=65535&U|m<<16,U=65535&(A=R),m=A>>>16,x=65535&(E=Y),_=E>>>16,m+=(A=e[5])>>>16,x+=65535&(E=r[5]),_+=E>>>16,r[5]=Y=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[5]=R=65535&U|m<<16,U=65535&(A=O),m=A>>>16,x=65535&(E=j),_=E>>>16,m+=(A=e[6])>>>16,x+=65535&(E=r[6]),_+=E>>>16,r[6]=j=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[6]=O=65535&U|m<<16,U=65535&(A=W),m=A>>>16,x=65535&(E=z),_=E>>>16,m+=(A=e[7])>>>16,x+=65535&(E=r[7]),_+=E>>>16,r[7]=z=65535&(x+=(m+=(U+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[7]=W=65535&U|m<<16,C+=128,n-=128}return n}function H(r,e,t){var n,o=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),f=t;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,G(o,i,e,t),t%=128,n=0;n<t;n++)a[n]=e[f-t+n];for(a[t]=128,a[(t=256-128*(t<112?1:0))-9]=0,y(a,t-8,f/536870912|0,f<<3),G(o,i,a,t),n=0;n<8;n++)y(r,8*n,o[n],i[n]);return 0}function X(r,t){var n=e(),o=e(),i=e(),a=e(),f=e(),h=e(),u=e(),c=e(),l=e();J(n,r[1],r[0]),J(l,t[1],t[0]),N(n,n,l),I(o,r[0],r[1]),I(l,t[0],t[1]),N(o,o,l),N(i,r[3],t[3]),N(i,i,s),N(a,r[2],t[2]),I(a,a,a),J(f,o,n),J(h,a,i),I(u,a,i),I(c,o,n),N(r[0],f,h),N(r[1],c,u),N(r[2],u,h),N(r[3],f,c)}function $(r,e,t){var n;for(n=0;n<4;n++)P(r[n],e[n],t)}function Q(r,t){var n=e(),o=e(),i=e();R(i,t[2]),N(n,t[0],i),N(o,t[1],i),Y(r,o),r[31]^=z(n)<<7}function rr(r,e,t){var n,o;for(K(r[0],i),K(r[1],a),K(r[2],a),K(r[3],i),o=255;o>=0;--o)$(r,e,n=t[o/8|0]>>(7&o)&1),X(e,r),X(r,r),$(r,e,n)}function er(r,t){var n=[e(),e(),e(),e()];K(n[0],u),K(n[1],c),K(n[2],a),N(n[3],u,c),rr(r,n,t)}function tr(r,n,o){var i,a=new Uint8Array(64),f=[e(),e(),e(),e()];for(o||t(n,32),H(a,n,32),a[0]&=248,a[31]&=127,a[31]|=64,er(f,a),Q(r,f),i=0;i<32;i++)n[i+32]=r[i];return 0}var nr=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]);function or(r,e){var t,n,o,i;for(n=63;n>=32;--n){for(t=0,o=n-32,i=n-12;o<i;++o)e[o]+=t-16*e[n]*nr[o-(n-32)],e[o]-=256*(t=e[o]+128>>8);e[o]+=t,e[n]=0}for(t=0,o=0;o<32;o++)e[o]+=t-(e[31]>>4)*nr[o],t=e[o]>>8,e[o]&=255;for(o=0;o<32;o++)e[o]-=t*nr[o];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,r[n]=255&e[n]}function ir(r){var e,t=new Float64Array(64);for(e=0;e<64;e++)t[e]=r[e];for(e=0;e<64;e++)r[e]=0;or(r,t)}function ar(r,t,n,o){var i,a,f=new Uint8Array(64),h=new Uint8Array(64),s=new Uint8Array(64),u=new Float64Array(64),c=[e(),e(),e(),e()];H(f,o,32),f[0]&=248,f[31]&=127,f[31]|=64;var l=n+64;for(i=0;i<n;i++)r[64+i]=t[i];for(i=0;i<32;i++)r[32+i]=f[32+i];for(H(s,r.subarray(32),n+32),ir(s),er(c,s),Q(r,c),i=32;i<64;i++)r[i]=o[i];for(H(h,r,n+64),ir(h),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=s[i];for(i=0;i<32;i++)for(a=0;a<32;a++)u[i+a]+=h[i]*f[a];return or(r.subarray(32),u),l}function fr(r,t){var n=e(),o=e(),f=e(),s=e(),u=e(),c=e(),y=e();return K(r[2],a),D(r[1],t),L(f,r[1]),N(s,f,h),J(f,f,r[2]),I(s,r[2],s),L(u,s),L(c,u),N(y,c,u),N(n,y,f),N(n,n,s),function(r,t){var n,o=e();for(n=0;n<16;n++)o[n]=t[n];for(n=250;n>=0;n--)L(o,o),1!==n&&N(o,o,t);for(n=0;n<16;n++)r[n]=o[n]}(n,n),N(n,n,f),N(n,n,s),N(n,n,s),N(r[0],n,s),L(o,r[0]),N(o,o,s),j(o,f)&&N(r[0],r[0],l),L(o,r[0]),N(o,o,s),j(o,f)?-1:(z(r[0])===t[31]>>7&&J(r[0],i,r[0]),N(r[3],r[0],r[1]),0)}function hr(r,t,n,o){var i,a=new Uint8Array(32),f=new Uint8Array(64),h=[e(),e(),e(),e()],s=[e(),e(),e(),e()];if(-1,n<64)return-1;if(fr(s,o))return-1;for(i=0;i<n;i++)r[i]=t[i];for(i=0;i<32;i++)r[i+32]=o[i];if(H(f,r,n),ir(f),rr(h,s,f),er(s,t.subarray(32)),X(h,s),Q(a,h),n-=64,p(t,0,a,0)){for(i=0;i<n;i++)r[i]=0;return-1}for(i=0;i<n;i++)r[i]=t[i+64];return n}var sr=32,ur=24,cr=32,lr=32,yr=ur;function dr(r,e){if(r.length!==sr)throw new Error("bad key size");if(e.length!==ur)throw new Error("bad nonce size")}function vr(){var r,e;for(e=0;e<arguments.length;e++)if("[object Uint8Array]"!==(r=Object.prototype.toString.call(arguments[e])))throw new TypeError("unexpected type "+r+", use Uint8Array")}function wr(r){for(var e=0;e<r.length;e++)r[e]=0}r.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:x,crypto_stream:m,crypto_stream_salsa20_xor:A,crypto_stream_salsa20:U,crypto_onetimeauth:S,crypto_onetimeauth_verify:B,crypto_verify_16:v,crypto_verify_32:p,crypto_secretbox:T,crypto_secretbox_open:M,crypto_scalarmult:O,crypto_scalarmult_base:W,crypto_box_beforenm:F,crypto_box_afternm:q,crypto_box:function(r,e,t,n,o,i){var a=new Uint8Array(32);return F(a,o,i),q(r,e,t,n,a)},crypto_box_open:function(r,e,t,n,o,i){var a=new Uint8Array(32);return F(a,o,i),Z(r,e,t,n,a)},crypto_box_keypair:C,crypto_hash:H,crypto_sign:ar,crypto_sign_keypair:tr,crypto_sign_open:hr,crypto_secretbox_KEYBYTES:sr,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:cr,crypto_box_SECRETKEYBYTES:lr,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:yr,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:64,crypto_sign_PUBLICKEYBYTES:32,crypto_sign_SECRETKEYBYTES:64,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64},r.util||(r.util={},r.util.decodeUTF8=r.util.encodeUTF8=r.util.encodeBase64=r.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),r.randomBytes=function(r){var e=new Uint8Array(r);return t(e,r),e},r.secretbox=function(r,e,t){vr(r,e,t),dr(t,e);for(var n=new Uint8Array(32+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+32]=r[i];return T(o,n,n.length,e,t),o.subarray(16)},r.secretbox.open=function(r,e,t){vr(r,e,t),dr(t,e);for(var n=new Uint8Array(16+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+16]=r[i];return!(n.length<32)&&(0===M(o,n,n.length,e,t)&&o.subarray(32))},r.secretbox.keyLength=sr,r.secretbox.nonceLength=ur,r.secretbox.overheadLength=16,r.scalarMult=function(r,e){if(vr(r,e),32!==r.length)throw new Error("bad n size");if(32!==e.length)throw new Error("bad p size");var t=new Uint8Array(32);return O(t,r,e),t},r.scalarMult.base=function(r){if(vr(r),32!==r.length)throw new Error("bad n size");var e=new Uint8Array(32);return W(e,r),e},r.scalarMult.scalarLength=32,r.scalarMult.groupElementLength=32,r.box=function(e,t,n,o){var i=r.box.before(n,o);return r.secretbox(e,t,i)},r.box.before=function(r,e){vr(r,e),function(r,e){if(r.length!==cr)throw new Error("bad public key size");if(e.length!==lr)throw new Error("bad secret key size")}(r,e);var t=new Uint8Array(32);return F(t,r,e),t},r.box.after=r.secretbox,r.box.open=function(e,t,n,o){var i=r.box.before(n,o);return r.secretbox.open(e,t,i)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var r=new Uint8Array(cr),e=new Uint8Array(lr);return C(r,e),{publicKey:r,secretKey:e}},r.box.keyPair.fromSecretKey=function(r){if(vr(r),r.length!==lr)throw new Error("bad secret key size");var e=new Uint8Array(cr);return W(e,r),{publicKey:e,secretKey:new Uint8Array(r)}},r.box.publicKeyLength=cr,r.box.secretKeyLength=lr,r.box.sharedKeyLength=32,r.box.nonceLength=yr,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(r,e){if(vr(r,e),64!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(64+r.length);return ar(t,r,r.length,e),t},r.sign.open=function(r,e){if(2!==arguments.length)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(vr(r,e),32!==e.length)throw new Error("bad public key size");var t=new Uint8Array(r.length),n=hr(t,r,r.length,e);if(n<0)return null;for(var o=new Uint8Array(n),i=0;i<o.length;i++)o[i]=t[i];return o},r.sign.detached=function(e,t){for(var n=r.sign(e,t),o=new Uint8Array(64),i=0;i<o.length;i++)o[i]=n[i];return o},r.sign.detached.verify=function(r,e,t){if(vr(r,e,t),64!==e.length)throw new Error("bad signature size");if(32!==t.length)throw new Error("bad public key size");var n,o=new Uint8Array(64+r.length),i=new Uint8Array(64+r.length);for(n=0;n<64;n++)o[n]=e[n];for(n=0;n<r.length;n++)o[n+64]=r[n];return hr(i,o,o.length,t)>=0},r.sign.keyPair=function(){var r=new Uint8Array(32),e=new Uint8Array(64);return tr(r,e),{publicKey:r,secretKey:e}},r.sign.keyPair.fromSecretKey=function(r){if(vr(r),64!==r.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),t=0;t<e.length;t++)e[t]=r[32+t];return{publicKey:e,secretKey:new Uint8Array(r)}},r.sign.keyPair.fromSeed=function(r){if(vr(r),32!==r.length)throw new Error("bad seed size");for(var e=new Uint8Array(32),t=new Uint8Array(64),n=0;n<32;n++)t[n]=r[n];return tr(e,t,!0),{publicKey:e,secretKey:t}},r.sign.publicKeyLength=32,r.sign.secretKeyLength=64,r.sign.seedLength=32,r.sign.signatureLength=64,r.hash=function(r){vr(r);var e=new Uint8Array(64);return H(e,r,r.length),e},r.hash.hashLength=64,r.verify=function(r,e){return vr(r,e),0!==r.length&&0!==e.length&&(r.length===e.length&&0===d(r,0,e,0,r.length))},r.setPRNG=function(r){t=r},function(){var e="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(e&&e.getRandomValues){r.setPRNG(function(r,t){var n,o=new Uint8Array(t);for(n=0;n<t;n+=65536)e.getRandomValues(o.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)r[n]=o[n];wr(o)})}else(e=w)&&e.randomBytes&&r.setPRNG(function(r,t){var n,o=e.randomBytes(t);for(n=0;n<t;n++)r[n]=o[n];wr(o)})}()}(r.exports?r.exports:self.nacl=self.nacl||{})}),g=v(function(r){var e,t;e=d,t=function(){var r={};function e(r){if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(r))throw new TypeError("invalid encoding")}return r.decodeUTF8=function(r){if("string"!=typeof r)throw new TypeError("expected string");var e,t=unescape(encodeURIComponent(r)),n=new Uint8Array(t.length);for(e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},r.encodeUTF8=function(r){var e,t=[];for(e=0;e<r.length;e++)t.push(String.fromCharCode(r[e]));return decodeURIComponent(escape(t.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(r.encodeBase64=function(r){return Buffer.from(r).toString("base64")},r.decodeBase64=function(r){return e(r),new Uint8Array(Array.prototype.slice.call(Buffer.from(r,"base64"),0))}):(r.encodeBase64=function(r){return new Buffer(r).toString("base64")},r.decodeBase64=function(r){return e(r),new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0))}):(r.encodeBase64=function(r){var e,t=[],n=r.length;for(e=0;e<n;e++)t.push(String.fromCharCode(r[e]));return btoa(t.join(""))},r.decodeBase64=function(r){e(r);var t,n=atob(r),o=new Uint8Array(n.length);for(t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return o}),r},r.exports?r.exports=t():e.nacl?e.nacl.util=t():(e.nacl={},e.nacl.util=t())});var b=new o.ec("secp256k1");function E(r,e){void 0===e&&(e=!1);var t=a.toBuffer(r);if(t.length!==(e?65:64))throw new Error("wrong signature length");var n={r:t.slice(0,32).toString("hex"),s:t.slice(32,64).toString("hex")};return e&&(n.recoveryParam=t[64]),n}var A={ES256K:function(r,e,t){var n=u(r),o=E(e),i=t.find(function(r){return b.keyFromPublic(r.publicKeyHex,"hex").verify(n,o)});if(!i)throw new Error("Signature invalid for JWT");return i},"ES256K-R":function(r,e,t){var n=E(e,!0),o=u(r),i=b.recoverPubKey(o,n,n.recoveryParam),a=i.encode("hex"),f=i.encode("hex",!0),h=c(a),s=t.find(function(r){var e=r.publicKeyHex;return e===a||e===f||r.ethereumAddress===h});if(!s)throw new Error("Signature invalid for JWT");return s},Ed25519:function(r,e,t){var n=g.decodeUTF8(r),o=s.decodeBase64Url(e),i=t.find(function(r){return p.sign.detached.verify(n,o,g.decodeBase64(r.publicKeyBase64))});if(!i)throw new Error("Signature invalid for JWT");return i}};function U(r){var e=A[r];if(!e)throw new Error("Unsupported algorithm "+r);return e}function m(r){function e(e){var t=e.r,n=e.s,o=e.recoveryParam,f=i.Buffer.alloc(r?65:64);if(i.Buffer.from(t,"hex").copy(f,0),i.Buffer.from(n,"hex").copy(f,32),r){if(void 0===o)throw new Error("Signer did not return a recoveryParam");f[64]=o}return a.encode(f)}return void 0===r&&(r=!1),function(r,t){try{return Promise.resolve(t(r)).then(e)}catch(r){return Promise.reject(r)}}}U.toSignatureObject=E;var x={ES256K:m(),"ES256K-R":m(!0),Ed25519:function(r,e){try{return Promise.resolve(e(r))}catch(r){return Promise.reject(r)}}};h(),s.registerNaclDID();var _={ES256K:["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],"ES256K-R":["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],Ed25519:["ED25519SignatureVerification"]},S={typ:"JWT"},B="ES256K";function T(r){return a.encode(JSON.stringify(r))}var M=300;function K(r){if(r.match(/^did:/))return r;if(n.isMNID(r))return"did:uport:"+r;throw new Error("Not a valid DID '"+r+"'")}function k(r){if(!r)throw new Error("no JWT passed into decodeJWT");var e=r.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(e)return{header:JSON.parse(a.decode(e[1])),payload:JSON.parse(a.decode(e[2])),signature:e[3],data:e[1]+"."+e[2]};throw new Error("Incorrect format JWT")}module.exports={SimpleSigner:function(r){var e=l.keyFromPrivate(r);return function(r){try{var t=e.sign(u(r)),n=t.s,o=t.recoveryParam;return Promise.resolve({r:y(t.r.toString("hex")),s:y(n.toString("hex")),recoveryParam:o})}catch(r){return Promise.reject(r)}}},NaclSigner:function(r){var e=g.decodeBase64(r);return function(r){try{return Promise.resolve(s.encodeBase64Url(p.sign.detached(g.decodeUTF8(r),e)))}catch(r){return Promise.reject(r)}}},verifyJWT:function(r,e){void 0===e&&(e={});try{var t=e.audience?K(e.audience):void 0,o=k(r),i=o.payload,a=o.header,h=o.signature,s=o.data;return Promise.resolve(function(r,e,t){try{var n=_[r];if(!n||0===n.length)throw new Error("No supported signature types for algorithm "+r);var o=K(e);return Promise.resolve(f(o)).then(function(e){if(!e)throw new Error("Unable to resolve DID document for "+o);var i=!t||(e.authentication||[]).map(function(r){return r.publicKey}),a=(e.publicKey||[]).filter(function(r){var e=r.type,o=r.id;return n.find(function(r){return r===e&&(!t||i.indexOf(o)>=0)})});if(t&&(!a||0===a.length))throw new Error("DID document for "+o+" does not have public keys suitable for authenticationg user");if(!a||0===a.length)throw new Error("DID document for "+o+" does not have public keys for "+r);return{authenticators:a,issuer:o,doc:e}})}catch(r){return Promise.reject(r)}}(a.alg,i.iss,e.auth)).then(function(o){var f,u=o.doc,c=o.authenticators,l=o.issuer,y=U(a.alg)(s,h,c),d=Math.floor(Date.now()/1e3);if(y){if(i.iat&&i.iat>d+M)throw new Error("JWT not valid yet (issued in the future): iat: "+i.iat+" > now: "+d);if(i.exp&&i.exp<=d-M)throw new Error("JWT has expired: exp: "+i.exp+" < now: "+d);if(i.aud)if((f=i.aud)&&(f.match(/^did:/)||n.isMNID(f))){if(!t)throw new Error("JWT audience is required but your app address has not been configured");if(t!==K(i.aud))throw new Error("JWT audience does not match your DID: aud: "+i.aud+" !== yours: "+t)}else{if(!e.callbackUrl)throw new Error("JWT audience matching your callback url is required but one wasn't passed in");if(i.aud!==e.callbackUrl)throw new Error("JWT audience does not match the callback url: aud: "+i.aud+" !== url: "+e.callbackUrl)}return{payload:i,doc:u,issuer:l,signer:y,jwt:r}}})}catch(r){return Promise.reject(r)}},createJWT:function(r,e){var t=e.issuer,n=e.signer,o=e.alg,i=e.expiresIn;try{if(!n)throw new Error("No Signer functionality has been configured");if(!t)throw new Error("No issuing DID has been configured");var a=Object.assign({},S,{alg:o||B}),f={iat:Math.floor(Date.now()/1e3)};if(i){if("number"!=typeof i)throw new Error("JWT expiresIn is not a number");f.exp=f.iat+Math.floor(i)}var h=[T(a),T(Object.assign({},f,r,{iss:t}))].join("."),s=function(r){var e=x[r];if(!e)throw new Error("Unsupported algorithm "+r);return e}(a.alg);return Promise.resolve(s(h,n)).then(function(r){return[h,r].join(".")})}catch(r){return Promise.reject(r)}},decodeJWT:k}; | ||
function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}var e=require("js-sha256"),t=require("js-sha3"),n=require("mnid"),o=require("elliptic"),i=require("buffer"),a=r(require("base64url")),f=r(require("did-resolver")),h=r(require("uport-did-resolver")),s=require("nacl-did");function u(r){return i.Buffer.from(e.sha256.arrayBuffer(r))}function c(r){return"0x"+(e=i.Buffer.from(r.slice(2),"hex"),i.Buffer.from(t.keccak_256.buffer(e))).slice(-20).toString("hex");var e}var l=new o.ec("secp256k1");function y(r,e){return void 0===e&&(e=64),r.length===e?r:"0".repeat(e-r.length)+r}var d="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function v(r,e){return r(e={exports:{}},e.exports),e.exports}var w={},p=v(function(r){!function(r){var e=function(r){var e,t=new Float64Array(16);if(r)for(e=0;e<r.length;e++)t[e]=r[e];return t},t=function(){throw new Error("no PRNG")},n=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=e(),a=e([1]),f=e([56129,1]),h=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),s=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),c=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function y(r,e,t,n){r[e]=t>>24&255,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=255&t,r[e+4]=n>>24&255,r[e+5]=n>>16&255,r[e+6]=n>>8&255,r[e+7]=255&n}function d(r,e,t,n,o){var i,a=0;for(i=0;i<o;i++)a|=r[e+i]^t[n+i];return(1&a-1>>>8)-1}function v(r,e,t,n){return d(r,e,t,n,16)}function p(r,e,t,n){return d(r,e,t,n,32)}function g(r,e,t,n){!function(r,e,t,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,s=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,v=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,w=255&t[16]|(255&t[17])<<8|(255&t[18])<<16|(255&t[19])<<24,p=255&t[20]|(255&t[21])<<8|(255&t[22])<<16|(255&t[23])<<24,g=255&t[24]|(255&t[25])<<8|(255&t[26])<<16|(255&t[27])<<24,b=255&t[28]|(255&t[29])<<8|(255&t[30])<<16|(255&t[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,A=i,m=a,U=f,x=h,_=s,S=u,B=c,T=l,M=y,K=d,k=v,P=w,Y=p,j=g,z=b,D=E,I=0;I<20;I+=2)A^=(o=(Y^=(o=(M^=(o=(_^=(o=A+Y|0)<<7|o>>>25)+A|0)<<9|o>>>23)+_|0)<<13|o>>>19)+M|0)<<18|o>>>14,S^=(o=(m^=(o=(j^=(o=(K^=(o=S+m|0)<<7|o>>>25)+S|0)<<9|o>>>23)+K|0)<<13|o>>>19)+j|0)<<18|o>>>14,k^=(o=(B^=(o=(U^=(o=(z^=(o=k+B|0)<<7|o>>>25)+k|0)<<9|o>>>23)+z|0)<<13|o>>>19)+U|0)<<18|o>>>14,D^=(o=(P^=(o=(T^=(o=(x^=(o=D+P|0)<<7|o>>>25)+D|0)<<9|o>>>23)+x|0)<<13|o>>>19)+T|0)<<18|o>>>14,A^=(o=(x^=(o=(U^=(o=(m^=(o=A+x|0)<<7|o>>>25)+A|0)<<9|o>>>23)+m|0)<<13|o>>>19)+U|0)<<18|o>>>14,S^=(o=(_^=(o=(T^=(o=(B^=(o=S+_|0)<<7|o>>>25)+S|0)<<9|o>>>23)+B|0)<<13|o>>>19)+T|0)<<18|o>>>14,k^=(o=(K^=(o=(M^=(o=(P^=(o=k+K|0)<<7|o>>>25)+k|0)<<9|o>>>23)+P|0)<<13|o>>>19)+M|0)<<18|o>>>14,D^=(o=(z^=(o=(j^=(o=(Y^=(o=D+z|0)<<7|o>>>25)+D|0)<<9|o>>>23)+Y|0)<<13|o>>>19)+j|0)<<18|o>>>14;m=m+a|0,U=U+f|0,x=x+h|0,_=_+s|0,S=S+u|0,B=B+c|0,T=T+l|0,M=M+y|0,K=K+d|0,k=k+v|0,P=P+w|0,Y=Y+p|0,j=j+g|0,z=z+b|0,D=D+E|0,r[0]=(A=A+i|0)>>>0&255,r[1]=A>>>8&255,r[2]=A>>>16&255,r[3]=A>>>24&255,r[4]=m>>>0&255,r[5]=m>>>8&255,r[6]=m>>>16&255,r[7]=m>>>24&255,r[8]=U>>>0&255,r[9]=U>>>8&255,r[10]=U>>>16&255,r[11]=U>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=_>>>0&255,r[17]=_>>>8&255,r[18]=_>>>16&255,r[19]=_>>>24&255,r[20]=S>>>0&255,r[21]=S>>>8&255,r[22]=S>>>16&255,r[23]=S>>>24&255,r[24]=B>>>0&255,r[25]=B>>>8&255,r[26]=B>>>16&255,r[27]=B>>>24&255,r[28]=T>>>0&255,r[29]=T>>>8&255,r[30]=T>>>16&255,r[31]=T>>>24&255,r[32]=M>>>0&255,r[33]=M>>>8&255,r[34]=M>>>16&255,r[35]=M>>>24&255,r[36]=K>>>0&255,r[37]=K>>>8&255,r[38]=K>>>16&255,r[39]=K>>>24&255,r[40]=k>>>0&255,r[41]=k>>>8&255,r[42]=k>>>16&255,r[43]=k>>>24&255,r[44]=P>>>0&255,r[45]=P>>>8&255,r[46]=P>>>16&255,r[47]=P>>>24&255,r[48]=Y>>>0&255,r[49]=Y>>>8&255,r[50]=Y>>>16&255,r[51]=Y>>>24&255,r[52]=j>>>0&255,r[53]=j>>>8&255,r[54]=j>>>16&255,r[55]=j>>>24&255,r[56]=z>>>0&255,r[57]=z>>>8&255,r[58]=z>>>16&255,r[59]=z>>>24&255,r[60]=D>>>0&255,r[61]=D>>>8&255,r[62]=D>>>16&255,r[63]=D>>>24&255}(r,e,t,n)}function b(r,e,t,n){!function(r,e,t,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,s=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,v=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,w=255&t[16]|(255&t[17])<<8|(255&t[18])<<16|(255&t[19])<<24,p=255&t[20]|(255&t[21])<<8|(255&t[22])<<16|(255&t[23])<<24,g=255&t[24]|(255&t[25])<<8|(255&t[26])<<16|(255&t[27])<<24,b=255&t[28]|(255&t[29])<<8|(255&t[30])<<16|(255&t[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,A=0;A<20;A+=2)i^=(o=(p^=(o=(y^=(o=(s^=(o=i+p|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+y|0)<<18|o>>>14,u^=(o=(a^=(o=(g^=(o=(d^=(o=u+a|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+g|0)<<18|o>>>14,v^=(o=(c^=(o=(f^=(o=(b^=(o=v+c|0)<<7|o>>>25)+v|0)<<9|o>>>23)+b|0)<<13|o>>>19)+f|0)<<18|o>>>14,E^=(o=(w^=(o=(l^=(o=(h^=(o=E+w|0)<<7|o>>>25)+E|0)<<9|o>>>23)+h|0)<<13|o>>>19)+l|0)<<18|o>>>14,i^=(o=(h^=(o=(f^=(o=(a^=(o=i+h|0)<<7|o>>>25)+i|0)<<9|o>>>23)+a|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(l^=(o=(c^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+c|0)<<13|o>>>19)+l|0)<<18|o>>>14,v^=(o=(d^=(o=(y^=(o=(w^=(o=v+d|0)<<7|o>>>25)+v|0)<<9|o>>>23)+w|0)<<13|o>>>19)+y|0)<<18|o>>>14,E^=(o=(b^=(o=(g^=(o=(p^=(o=E+b|0)<<7|o>>>25)+E|0)<<9|o>>>23)+p|0)<<13|o>>>19)+g|0)<<18|o>>>14;r[0]=i>>>0&255,r[1]=i>>>8&255,r[2]=i>>>16&255,r[3]=i>>>24&255,r[4]=u>>>0&255,r[5]=u>>>8&255,r[6]=u>>>16&255,r[7]=u>>>24&255,r[8]=v>>>0&255,r[9]=v>>>8&255,r[10]=v>>>16&255,r[11]=v>>>24&255,r[12]=E>>>0&255,r[13]=E>>>8&255,r[14]=E>>>16&255,r[15]=E>>>24&255,r[16]=c>>>0&255,r[17]=c>>>8&255,r[18]=c>>>16&255,r[19]=c>>>24&255,r[20]=l>>>0&255,r[21]=l>>>8&255,r[22]=l>>>16&255,r[23]=l>>>24&255,r[24]=y>>>0&255,r[25]=y>>>8&255,r[26]=y>>>16&255,r[27]=y>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255}(r,e,t,n)}var E=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function A(r,e,t,n,o,i,a){var f,h,s=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)s[h]=0;for(h=0;h<8;h++)s[h]=i[h];for(;o>=64;){for(g(u,s,a,E),h=0;h<64;h++)r[e+h]=t[n+h]^u[h];for(f=1,h=8;h<16;h++)s[h]=255&(f=f+(255&s[h])|0),f>>>=8;o-=64,e+=64,n+=64}if(o>0)for(g(u,s,a,E),h=0;h<o;h++)r[e+h]=t[n+h]^u[h];return 0}function m(r,e,t,n,o){var i,a,f=new Uint8Array(16),h=new Uint8Array(64);for(a=0;a<16;a++)f[a]=0;for(a=0;a<8;a++)f[a]=n[a];for(;t>=64;){for(g(h,f,o,E),a=0;a<64;a++)r[e+a]=h[a];for(i=1,a=8;a<16;a++)f[a]=255&(i=i+(255&f[a])|0),i>>>=8;t-=64,e+=64}if(t>0)for(g(h,f,o,E),a=0;a<t;a++)r[e+a]=h[a];return 0}function U(r,e,t,n,o){var i=new Uint8Array(32);b(i,n,o,E);for(var a=new Uint8Array(8),f=0;f<8;f++)a[f]=n[f+16];return m(r,e,t,a,i)}function x(r,e,t,n,o,i,a){var f=new Uint8Array(32);b(f,i,a,E);for(var h=new Uint8Array(8),s=0;s<8;s++)h[s]=i[s+16];return A(r,e,t,n,o,h,f)}var _=function(r){var e,t,n,o,i,a,f,h;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,this.r[0]=8191&(e=255&r[0]|(255&r[1])<<8),this.r[1]=8191&(e>>>13|(t=255&r[2]|(255&r[3])<<8)<<3),this.r[2]=7939&(t>>>10|(n=255&r[4]|(255&r[5])<<8)<<6),this.r[3]=8191&(n>>>7|(o=255&r[6]|(255&r[7])<<8)<<9),this.r[4]=255&(o>>>4|(i=255&r[8]|(255&r[9])<<8)<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|(a=255&r[10]|(255&r[11])<<8)<<2),this.r[7]=8065&(a>>>11|(f=255&r[12]|(255&r[13])<<8)<<5),this.r[8]=8191&(f>>>8|(h=255&r[14]|(255&r[15])<<8)<<8),this.r[9]=h>>>5&127,this.pad[0]=255&r[16]|(255&r[17])<<8,this.pad[1]=255&r[18]|(255&r[19])<<8,this.pad[2]=255&r[20]|(255&r[21])<<8,this.pad[3]=255&r[22]|(255&r[23])<<8,this.pad[4]=255&r[24]|(255&r[25])<<8,this.pad[5]=255&r[26]|(255&r[27])<<8,this.pad[6]=255&r[28]|(255&r[29])<<8,this.pad[7]=255&r[30]|(255&r[31])<<8};function S(r,e,t,n,o,i){var a=new _(i);return a.update(t,n,o),a.finish(r,e),0}function B(r,e,t,n,o,i){var a=new Uint8Array(16);return S(a,0,t,n,o,i),v(r,e,a,0)}function T(r,e,t,n,o){var i;if(t<32)return-1;for(x(r,0,e,0,t,n,o),S(r,16,r,32,t-32,r),i=0;i<16;i++)r[i]=0;return 0}function M(r,e,t,n,o){var i,a=new Uint8Array(32);if(t<32)return-1;if(U(a,0,32,n,o),0!==B(e,16,e,32,t-32,a))return-1;for(x(r,0,e,0,t,n,o),i=0;i<32;i++)r[i]=0;return 0}function K(r,e){var t;for(t=0;t<16;t++)r[t]=0|e[t]}function k(r){var e,t,n=1;for(e=0;e<16;e++)t=r[e]+n+65535,n=Math.floor(t/65536),r[e]=t-65536*n;r[0]+=n-1+37*(n-1)}function P(r,e,t){for(var n,o=~(t-1),i=0;i<16;i++)r[i]^=n=o&(r[i]^e[i]),e[i]^=n}function Y(r,t){var n,o,i,a=e(),f=e();for(n=0;n<16;n++)f[n]=t[n];for(k(f),k(f),k(f),o=0;o<2;o++){for(a[0]=f[0]-65517,n=1;n<15;n++)a[n]=f[n]-65535-(a[n-1]>>16&1),a[n-1]&=65535;a[15]=f[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,P(f,a,1-i)}for(n=0;n<16;n++)r[2*n]=255&f[n],r[2*n+1]=f[n]>>8}function j(r,e){var t=new Uint8Array(32),n=new Uint8Array(32);return Y(t,r),Y(n,e),p(t,0,n,0)}function z(r){var e=new Uint8Array(32);return Y(e,r),1&e[0]}function D(r,e){var t;for(t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function I(r,e,t){for(var n=0;n<16;n++)r[n]=e[n]+t[n]}function J(r,e,t){for(var n=0;n<16;n++)r[n]=e[n]-t[n]}function N(r,e,t){var n,o,i=0,a=0,f=0,h=0,s=0,u=0,c=0,l=0,y=0,d=0,v=0,w=0,p=0,g=0,b=0,E=0,A=0,m=0,U=0,x=0,_=0,S=0,B=0,T=0,M=0,K=0,k=0,P=0,Y=0,j=0,z=0,D=t[0],I=t[1],J=t[2],N=t[3],L=t[4],R=t[5],O=t[6],W=t[7],C=t[8],F=t[9],q=t[10],Z=t[11],V=t[12],G=t[13],H=t[14],X=t[15];i+=(n=e[0])*D,a+=n*I,f+=n*J,h+=n*N,s+=n*L,u+=n*R,c+=n*O,l+=n*W,y+=n*C,d+=n*F,v+=n*q,w+=n*Z,p+=n*V,g+=n*G,b+=n*H,E+=n*X,a+=(n=e[1])*D,f+=n*I,h+=n*J,s+=n*N,u+=n*L,c+=n*R,l+=n*O,y+=n*W,d+=n*C,v+=n*F,w+=n*q,p+=n*Z,g+=n*V,b+=n*G,E+=n*H,A+=n*X,f+=(n=e[2])*D,h+=n*I,s+=n*J,u+=n*N,c+=n*L,l+=n*R,y+=n*O,d+=n*W,v+=n*C,w+=n*F,p+=n*q,g+=n*Z,b+=n*V,E+=n*G,A+=n*H,m+=n*X,h+=(n=e[3])*D,s+=n*I,u+=n*J,c+=n*N,l+=n*L,y+=n*R,d+=n*O,v+=n*W,w+=n*C,p+=n*F,g+=n*q,b+=n*Z,E+=n*V,A+=n*G,m+=n*H,U+=n*X,s+=(n=e[4])*D,u+=n*I,c+=n*J,l+=n*N,y+=n*L,d+=n*R,v+=n*O,w+=n*W,p+=n*C,g+=n*F,b+=n*q,E+=n*Z,A+=n*V,m+=n*G,U+=n*H,x+=n*X,u+=(n=e[5])*D,c+=n*I,l+=n*J,y+=n*N,d+=n*L,v+=n*R,w+=n*O,p+=n*W,g+=n*C,b+=n*F,E+=n*q,A+=n*Z,m+=n*V,U+=n*G,x+=n*H,_+=n*X,c+=(n=e[6])*D,l+=n*I,y+=n*J,d+=n*N,v+=n*L,w+=n*R,p+=n*O,g+=n*W,b+=n*C,E+=n*F,A+=n*q,m+=n*Z,U+=n*V,x+=n*G,_+=n*H,S+=n*X,l+=(n=e[7])*D,y+=n*I,d+=n*J,v+=n*N,w+=n*L,p+=n*R,g+=n*O,b+=n*W,E+=n*C,A+=n*F,m+=n*q,U+=n*Z,x+=n*V,_+=n*G,S+=n*H,B+=n*X,y+=(n=e[8])*D,d+=n*I,v+=n*J,w+=n*N,p+=n*L,g+=n*R,b+=n*O,E+=n*W,A+=n*C,m+=n*F,U+=n*q,x+=n*Z,_+=n*V,S+=n*G,B+=n*H,T+=n*X,d+=(n=e[9])*D,v+=n*I,w+=n*J,p+=n*N,g+=n*L,b+=n*R,E+=n*O,A+=n*W,m+=n*C,U+=n*F,x+=n*q,_+=n*Z,S+=n*V,B+=n*G,T+=n*H,M+=n*X,v+=(n=e[10])*D,w+=n*I,p+=n*J,g+=n*N,b+=n*L,E+=n*R,A+=n*O,m+=n*W,U+=n*C,x+=n*F,_+=n*q,S+=n*Z,B+=n*V,T+=n*G,M+=n*H,K+=n*X,w+=(n=e[11])*D,p+=n*I,g+=n*J,b+=n*N,E+=n*L,A+=n*R,m+=n*O,U+=n*W,x+=n*C,_+=n*F,S+=n*q,B+=n*Z,T+=n*V,M+=n*G,K+=n*H,k+=n*X,p+=(n=e[12])*D,g+=n*I,b+=n*J,E+=n*N,A+=n*L,m+=n*R,U+=n*O,x+=n*W,_+=n*C,S+=n*F,B+=n*q,T+=n*Z,M+=n*V,K+=n*G,k+=n*H,P+=n*X,g+=(n=e[13])*D,b+=n*I,E+=n*J,A+=n*N,m+=n*L,U+=n*R,x+=n*O,_+=n*W,S+=n*C,B+=n*F,T+=n*q,M+=n*Z,K+=n*V,k+=n*G,P+=n*H,Y+=n*X,b+=(n=e[14])*D,E+=n*I,A+=n*J,m+=n*N,U+=n*L,x+=n*R,_+=n*O,S+=n*W,B+=n*C,T+=n*F,M+=n*q,K+=n*Z,k+=n*V,P+=n*G,Y+=n*H,j+=n*X,E+=(n=e[15])*D,a+=38*(m+=n*J),f+=38*(U+=n*N),h+=38*(x+=n*L),s+=38*(_+=n*R),u+=38*(S+=n*O),c+=38*(B+=n*W),l+=38*(T+=n*C),y+=38*(M+=n*F),d+=38*(K+=n*q),v+=38*(k+=n*Z),w+=38*(P+=n*V),p+=38*(Y+=n*G),g+=38*(j+=n*H),b+=38*(z+=n*X),i=(n=(i+=38*(A+=n*I))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),r[0]=i+=o-1+37*(o-1),r[1]=a,r[2]=f,r[3]=h,r[4]=s,r[5]=u,r[6]=c,r[7]=l,r[8]=y,r[9]=d,r[10]=v,r[11]=w,r[12]=p,r[13]=g,r[14]=b,r[15]=E}function L(r,e){N(r,e,e)}function R(r,t){var n,o=e();for(n=0;n<16;n++)o[n]=t[n];for(n=253;n>=0;n--)L(o,o),2!==n&&4!==n&&N(o,o,t);for(n=0;n<16;n++)r[n]=o[n]}function O(r,t,n){var o,i,a=new Uint8Array(32),h=new Float64Array(80),s=e(),u=e(),c=e(),l=e(),y=e(),d=e();for(i=0;i<31;i++)a[i]=t[i];for(a[31]=127&t[31]|64,a[0]&=248,D(h,n),i=0;i<16;i++)u[i]=h[i],l[i]=s[i]=c[i]=0;for(s[0]=l[0]=1,i=254;i>=0;--i)P(s,u,o=a[i>>>3]>>>(7&i)&1),P(c,l,o),I(y,s,c),J(s,s,c),I(c,u,l),J(u,u,l),L(l,y),L(d,s),N(s,c,s),N(c,u,y),I(y,s,c),J(s,s,c),L(u,s),J(c,l,d),N(s,c,f),I(s,s,l),N(c,c,s),N(s,l,d),N(l,u,h),L(u,y),P(s,u,o),P(c,l,o);for(i=0;i<16;i++)h[i+16]=s[i],h[i+32]=c[i],h[i+48]=u[i],h[i+64]=l[i];var v=h.subarray(32),w=h.subarray(16);return R(v,v),N(w,w,v),Y(r,w),0}function W(r,e){return O(r,e,o)}function C(r,e){return t(e,32),W(r,e)}function F(r,e,t){var o=new Uint8Array(32);return O(o,t,e),b(r,n,o,E)}_.prototype.blocks=function(r,e,t){for(var n,o,i,a,f,h,s,u,c,l,y,d,v,w,p,g,b,E,A,m=this.fin?0:2048,U=this.h[0],x=this.h[1],_=this.h[2],S=this.h[3],B=this.h[4],T=this.h[5],M=this.h[6],K=this.h[7],k=this.h[8],P=this.h[9],Y=this.r[0],j=this.r[1],z=this.r[2],D=this.r[3],I=this.r[4],J=this.r[5],N=this.r[6],L=this.r[7],R=this.r[8],O=this.r[9];t>=16;)l=c=0,l+=(U+=8191&(n=255&r[e+0]|(255&r[e+1])<<8))*Y,l+=(x+=8191&(n>>>13|(o=255&r[e+2]|(255&r[e+3])<<8)<<3))*(5*O),l+=(_+=8191&(o>>>10|(i=255&r[e+4]|(255&r[e+5])<<8)<<6))*(5*R),l+=(S+=8191&(i>>>7|(a=255&r[e+6]|(255&r[e+7])<<8)<<9))*(5*L),c=(l+=(B+=8191&(a>>>4|(f=255&r[e+8]|(255&r[e+9])<<8)<<12))*(5*N))>>>13,l&=8191,l+=(T+=f>>>1&8191)*(5*J),l+=(M+=8191&(f>>>14|(h=255&r[e+10]|(255&r[e+11])<<8)<<2))*(5*I),l+=(K+=8191&(h>>>11|(s=255&r[e+12]|(255&r[e+13])<<8)<<5))*(5*D),l+=(k+=8191&(s>>>8|(u=255&r[e+14]|(255&r[e+15])<<8)<<8))*(5*z),y=c+=(l+=(P+=u>>>5|m)*(5*j))>>>13,y+=U*j,y+=x*Y,y+=_*(5*O),y+=S*(5*R),c=(y+=B*(5*L))>>>13,y&=8191,y+=T*(5*N),y+=M*(5*J),y+=K*(5*I),y+=k*(5*D),c+=(y+=P*(5*z))>>>13,y&=8191,d=c,d+=U*z,d+=x*j,d+=_*Y,d+=S*(5*O),c=(d+=B*(5*R))>>>13,d&=8191,d+=T*(5*L),d+=M*(5*N),d+=K*(5*J),d+=k*(5*I),v=c+=(d+=P*(5*D))>>>13,v+=U*D,v+=x*z,v+=_*j,v+=S*Y,c=(v+=B*(5*O))>>>13,v&=8191,v+=T*(5*R),v+=M*(5*L),v+=K*(5*N),v+=k*(5*J),w=c+=(v+=P*(5*I))>>>13,w+=U*I,w+=x*D,w+=_*z,w+=S*j,c=(w+=B*Y)>>>13,w&=8191,w+=T*(5*O),w+=M*(5*R),w+=K*(5*L),w+=k*(5*N),p=c+=(w+=P*(5*J))>>>13,p+=U*J,p+=x*I,p+=_*D,p+=S*z,c=(p+=B*j)>>>13,p&=8191,p+=T*Y,p+=M*(5*O),p+=K*(5*R),p+=k*(5*L),g=c+=(p+=P*(5*N))>>>13,g+=U*N,g+=x*J,g+=_*I,g+=S*D,c=(g+=B*z)>>>13,g&=8191,g+=T*j,g+=M*Y,g+=K*(5*O),g+=k*(5*R),b=c+=(g+=P*(5*L))>>>13,b+=U*L,b+=x*N,b+=_*J,b+=S*I,c=(b+=B*D)>>>13,b&=8191,b+=T*z,b+=M*j,b+=K*Y,b+=k*(5*O),E=c+=(b+=P*(5*R))>>>13,E+=U*R,E+=x*L,E+=_*N,E+=S*J,c=(E+=B*I)>>>13,E&=8191,E+=T*D,E+=M*z,E+=K*j,E+=k*Y,A=c+=(E+=P*(5*O))>>>13,A+=U*O,A+=x*R,A+=_*L,A+=S*N,c=(A+=B*J)>>>13,A&=8191,A+=T*I,A+=M*D,A+=K*z,A+=k*j,U=l=8191&(c=(c=((c+=(A+=P*Y)>>>13)<<2)+c|0)+(l&=8191)|0),x=y+=c>>>=13,_=d&=8191,S=v&=8191,B=w&=8191,T=p&=8191,M=g&=8191,K=b&=8191,k=E&=8191,P=A&=8191,e+=16,t-=16;this.h[0]=U,this.h[1]=x,this.h[2]=_,this.h[3]=S,this.h[4]=B,this.h[5]=T,this.h[6]=M,this.h[7]=K,this.h[8]=k,this.h[9]=P},_.prototype.finish=function(r,e){var t,n,o,i,a=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;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;i<10;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,a[0]=this.h[0]+5,t=a[0]>>>13,a[0]&=8191,i=1;i<10;i++)a[i]=this.h[i]+t,t=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,n=(1^t)-1,i=0;i<10;i++)a[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|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),this.h[0]=65535&(o=this.h[0]+this.pad[0]),i=1;i<8;i++)this.h[i]=65535&(o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0);r[e+0]=this.h[0]>>>0&255,r[e+1]=this.h[0]>>>8&255,r[e+2]=this.h[1]>>>0&255,r[e+3]=this.h[1]>>>8&255,r[e+4]=this.h[2]>>>0&255,r[e+5]=this.h[2]>>>8&255,r[e+6]=this.h[3]>>>0&255,r[e+7]=this.h[3]>>>8&255,r[e+8]=this.h[4]>>>0&255,r[e+9]=this.h[4]>>>8&255,r[e+10]=this.h[5]>>>0&255,r[e+11]=this.h[5]>>>8&255,r[e+12]=this.h[6]>>>0&255,r[e+13]=this.h[6]>>>8&255,r[e+14]=this.h[7]>>>0&255,r[e+15]=this.h[7]>>>8&255},_.prototype.update=function(r,e,t){var n,o;if(this.leftover){for((o=16-this.leftover)>t&&(o=t),n=0;n<o;n++)this.buffer[this.leftover+n]=r[e+n];if(t-=o,e+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(t>=16&&(this.blocks(r,e,o=t-t%16),e+=o,t-=o),t){for(n=0;n<t;n++)this.buffer[this.leftover+n]=r[e+n];this.leftover+=t}};var q=T,Z=M;var V=[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];function G(r,e,t,n){for(var o,i,a,f,h,s,u,c,l,y,d,v,w,p,g,b,E,A,m,U,x,_,S=new Int32Array(16),B=new Int32Array(16),T=r[0],M=r[1],K=r[2],k=r[3],P=r[4],Y=r[5],j=r[6],z=r[7],D=e[0],I=e[1],J=e[2],N=e[3],L=e[4],R=e[5],O=e[6],W=e[7],C=0;n>=128;){for(g=0;g<16;g++)S[g]=t[(b=8*g+C)+0]<<24|t[b+1]<<16|t[b+2]<<8|t[b+3],B[g]=t[b+4]<<24|t[b+5]<<16|t[b+6]<<8|t[b+7];for(g=0;g<80;g++)if(o=M,i=K,a=P,f=Y,h=j,z,u=I,c=J,l=L,y=R,d=O,W,m=65535&(A=W),U=A>>>16,x=65535&(E=z),_=E>>>16,m+=65535&(A=(L>>>14|P<<18)^(L>>>18|P<<14)^(P>>>9|L<<23)),U+=A>>>16,x+=65535&(E=(P>>>14|L<<18)^(P>>>18|L<<14)^(L>>>9|P<<23)),_+=E>>>16,m+=65535&(A=L&R^~L&O),U+=A>>>16,x+=65535&(E=P&Y^~P&j),_+=E>>>16,m+=65535&(A=V[2*g+1]),U+=A>>>16,x+=65535&(E=V[2*g]),_+=E>>>16,U+=(A=B[g%16])>>>16,x+=65535&(E=S[g%16]),_+=E>>>16,x+=(U+=(m+=65535&A)>>>16)>>>16,m=65535&(A=p=65535&m|U<<16),U=A>>>16,x=65535&(E=w=65535&x|(_+=x>>>16)<<16),_=E>>>16,m+=65535&(A=(D>>>28|T<<4)^(T>>>2|D<<30)^(T>>>7|D<<25)),U+=A>>>16,x+=65535&(E=(T>>>28|D<<4)^(D>>>2|T<<30)^(D>>>7|T<<25)),_+=E>>>16,U+=(A=D&I^D&J^I&J)>>>16,x+=65535&(E=T&M^T&K^M&K),_+=E>>>16,s=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,v=65535&m|U<<16,m=65535&(A=N),U=A>>>16,x=65535&(E=k),_=E>>>16,U+=(A=p)>>>16,x+=65535&(E=w),_+=E>>>16,M=T,K=o,k=i,P=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,Y=a,j=f,z=h,T=s,I=D,J=u,N=c,L=65535&m|U<<16,R=l,O=y,W=d,D=v,g%16==15)for(b=0;b<16;b++)m=65535&(A=B[b]),U=A>>>16,x=65535&(E=S[b]),_=E>>>16,m+=65535&(A=B[(b+9)%16]),U+=A>>>16,x+=65535&(E=S[(b+9)%16]),_+=E>>>16,m+=65535&(A=((p=B[(b+1)%16])>>>1|(w=S[(b+1)%16])<<31)^(p>>>8|w<<24)^(p>>>7|w<<25)),U+=A>>>16,x+=65535&(E=(w>>>1|p<<31)^(w>>>8|p<<24)^w>>>7),_+=E>>>16,U+=(A=((p=B[(b+14)%16])>>>19|(w=S[(b+14)%16])<<13)^(w>>>29|p<<3)^(p>>>6|w<<26))>>>16,x+=65535&(E=(w>>>19|p<<13)^(p>>>29|w<<3)^w>>>6),_+=E>>>16,S[b]=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,B[b]=65535&m|U<<16;m=65535&(A=D),U=A>>>16,x=65535&(E=T),_=E>>>16,U+=(A=e[0])>>>16,x+=65535&(E=r[0]),_+=E>>>16,r[0]=T=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[0]=D=65535&m|U<<16,m=65535&(A=I),U=A>>>16,x=65535&(E=M),_=E>>>16,U+=(A=e[1])>>>16,x+=65535&(E=r[1]),_+=E>>>16,r[1]=M=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[1]=I=65535&m|U<<16,m=65535&(A=J),U=A>>>16,x=65535&(E=K),_=E>>>16,U+=(A=e[2])>>>16,x+=65535&(E=r[2]),_+=E>>>16,r[2]=K=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[2]=J=65535&m|U<<16,m=65535&(A=N),U=A>>>16,x=65535&(E=k),_=E>>>16,U+=(A=e[3])>>>16,x+=65535&(E=r[3]),_+=E>>>16,r[3]=k=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[3]=N=65535&m|U<<16,m=65535&(A=L),U=A>>>16,x=65535&(E=P),_=E>>>16,U+=(A=e[4])>>>16,x+=65535&(E=r[4]),_+=E>>>16,r[4]=P=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[4]=L=65535&m|U<<16,m=65535&(A=R),U=A>>>16,x=65535&(E=Y),_=E>>>16,U+=(A=e[5])>>>16,x+=65535&(E=r[5]),_+=E>>>16,r[5]=Y=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[5]=R=65535&m|U<<16,m=65535&(A=O),U=A>>>16,x=65535&(E=j),_=E>>>16,U+=(A=e[6])>>>16,x+=65535&(E=r[6]),_+=E>>>16,r[6]=j=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[6]=O=65535&m|U<<16,m=65535&(A=W),U=A>>>16,x=65535&(E=z),_=E>>>16,U+=(A=e[7])>>>16,x+=65535&(E=r[7]),_+=E>>>16,r[7]=z=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[7]=W=65535&m|U<<16,C+=128,n-=128}return n}function H(r,e,t){var n,o=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),f=t;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,G(o,i,e,t),t%=128,n=0;n<t;n++)a[n]=e[f-t+n];for(a[t]=128,a[(t=256-128*(t<112?1:0))-9]=0,y(a,t-8,f/536870912|0,f<<3),G(o,i,a,t),n=0;n<8;n++)y(r,8*n,o[n],i[n]);return 0}function X(r,t){var n=e(),o=e(),i=e(),a=e(),f=e(),h=e(),u=e(),c=e(),l=e();J(n,r[1],r[0]),J(l,t[1],t[0]),N(n,n,l),I(o,r[0],r[1]),I(l,t[0],t[1]),N(o,o,l),N(i,r[3],t[3]),N(i,i,s),N(a,r[2],t[2]),I(a,a,a),J(f,o,n),J(h,a,i),I(u,a,i),I(c,o,n),N(r[0],f,h),N(r[1],c,u),N(r[2],u,h),N(r[3],f,c)}function $(r,e,t){var n;for(n=0;n<4;n++)P(r[n],e[n],t)}function Q(r,t){var n=e(),o=e(),i=e();R(i,t[2]),N(n,t[0],i),N(o,t[1],i),Y(r,o),r[31]^=z(n)<<7}function rr(r,e,t){var n,o;for(K(r[0],i),K(r[1],a),K(r[2],a),K(r[3],i),o=255;o>=0;--o)$(r,e,n=t[o/8|0]>>(7&o)&1),X(e,r),X(r,r),$(r,e,n)}function er(r,t){var n=[e(),e(),e(),e()];K(n[0],u),K(n[1],c),K(n[2],a),N(n[3],u,c),rr(r,n,t)}function tr(r,n,o){var i,a=new Uint8Array(64),f=[e(),e(),e(),e()];for(o||t(n,32),H(a,n,32),a[0]&=248,a[31]&=127,a[31]|=64,er(f,a),Q(r,f),i=0;i<32;i++)n[i+32]=r[i];return 0}var nr=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]);function or(r,e){var t,n,o,i;for(n=63;n>=32;--n){for(t=0,o=n-32,i=n-12;o<i;++o)e[o]+=t-16*e[n]*nr[o-(n-32)],e[o]-=256*(t=e[o]+128>>8);e[o]+=t,e[n]=0}for(t=0,o=0;o<32;o++)e[o]+=t-(e[31]>>4)*nr[o],t=e[o]>>8,e[o]&=255;for(o=0;o<32;o++)e[o]-=t*nr[o];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,r[n]=255&e[n]}function ir(r){var e,t=new Float64Array(64);for(e=0;e<64;e++)t[e]=r[e];for(e=0;e<64;e++)r[e]=0;or(r,t)}function ar(r,t,n,o){var i,a,f=new Uint8Array(64),h=new Uint8Array(64),s=new Uint8Array(64),u=new Float64Array(64),c=[e(),e(),e(),e()];H(f,o,32),f[0]&=248,f[31]&=127,f[31]|=64;var l=n+64;for(i=0;i<n;i++)r[64+i]=t[i];for(i=0;i<32;i++)r[32+i]=f[32+i];for(H(s,r.subarray(32),n+32),ir(s),er(c,s),Q(r,c),i=32;i<64;i++)r[i]=o[i];for(H(h,r,n+64),ir(h),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=s[i];for(i=0;i<32;i++)for(a=0;a<32;a++)u[i+a]+=h[i]*f[a];return or(r.subarray(32),u),l}function fr(r,t){var n=e(),o=e(),f=e(),s=e(),u=e(),c=e(),y=e();return K(r[2],a),D(r[1],t),L(f,r[1]),N(s,f,h),J(f,f,r[2]),I(s,r[2],s),L(u,s),L(c,u),N(y,c,u),N(n,y,f),N(n,n,s),function(r,t){var n,o=e();for(n=0;n<16;n++)o[n]=t[n];for(n=250;n>=0;n--)L(o,o),1!==n&&N(o,o,t);for(n=0;n<16;n++)r[n]=o[n]}(n,n),N(n,n,f),N(n,n,s),N(n,n,s),N(r[0],n,s),L(o,r[0]),N(o,o,s),j(o,f)&&N(r[0],r[0],l),L(o,r[0]),N(o,o,s),j(o,f)?-1:(z(r[0])===t[31]>>7&&J(r[0],i,r[0]),N(r[3],r[0],r[1]),0)}function hr(r,t,n,o){var i,a=new Uint8Array(32),f=new Uint8Array(64),h=[e(),e(),e(),e()],s=[e(),e(),e(),e()];if(-1,n<64)return-1;if(fr(s,o))return-1;for(i=0;i<n;i++)r[i]=t[i];for(i=0;i<32;i++)r[i+32]=o[i];if(H(f,r,n),ir(f),rr(h,s,f),er(s,t.subarray(32)),X(h,s),Q(a,h),n-=64,p(t,0,a,0)){for(i=0;i<n;i++)r[i]=0;return-1}for(i=0;i<n;i++)r[i]=t[i+64];return n}var sr=32,ur=24,cr=32,lr=32,yr=ur;function dr(r,e){if(r.length!==sr)throw new Error("bad key size");if(e.length!==ur)throw new Error("bad nonce size")}function vr(){var r,e;for(e=0;e<arguments.length;e++)if("[object Uint8Array]"!==(r=Object.prototype.toString.call(arguments[e])))throw new TypeError("unexpected type "+r+", use Uint8Array")}function wr(r){for(var e=0;e<r.length;e++)r[e]=0}r.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:x,crypto_stream:U,crypto_stream_salsa20_xor:A,crypto_stream_salsa20:m,crypto_onetimeauth:S,crypto_onetimeauth_verify:B,crypto_verify_16:v,crypto_verify_32:p,crypto_secretbox:T,crypto_secretbox_open:M,crypto_scalarmult:O,crypto_scalarmult_base:W,crypto_box_beforenm:F,crypto_box_afternm:q,crypto_box:function(r,e,t,n,o,i){var a=new Uint8Array(32);return F(a,o,i),q(r,e,t,n,a)},crypto_box_open:function(r,e,t,n,o,i){var a=new Uint8Array(32);return F(a,o,i),Z(r,e,t,n,a)},crypto_box_keypair:C,crypto_hash:H,crypto_sign:ar,crypto_sign_keypair:tr,crypto_sign_open:hr,crypto_secretbox_KEYBYTES:sr,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:cr,crypto_box_SECRETKEYBYTES:lr,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:yr,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:64,crypto_sign_PUBLICKEYBYTES:32,crypto_sign_SECRETKEYBYTES:64,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64},r.util||(r.util={},r.util.decodeUTF8=r.util.encodeUTF8=r.util.encodeBase64=r.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),r.randomBytes=function(r){var e=new Uint8Array(r);return t(e,r),e},r.secretbox=function(r,e,t){vr(r,e,t),dr(t,e);for(var n=new Uint8Array(32+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+32]=r[i];return T(o,n,n.length,e,t),o.subarray(16)},r.secretbox.open=function(r,e,t){vr(r,e,t),dr(t,e);for(var n=new Uint8Array(16+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+16]=r[i];return!(n.length<32)&&(0===M(o,n,n.length,e,t)&&o.subarray(32))},r.secretbox.keyLength=sr,r.secretbox.nonceLength=ur,r.secretbox.overheadLength=16,r.scalarMult=function(r,e){if(vr(r,e),32!==r.length)throw new Error("bad n size");if(32!==e.length)throw new Error("bad p size");var t=new Uint8Array(32);return O(t,r,e),t},r.scalarMult.base=function(r){if(vr(r),32!==r.length)throw new Error("bad n size");var e=new Uint8Array(32);return W(e,r),e},r.scalarMult.scalarLength=32,r.scalarMult.groupElementLength=32,r.box=function(e,t,n,o){var i=r.box.before(n,o);return r.secretbox(e,t,i)},r.box.before=function(r,e){vr(r,e),function(r,e){if(r.length!==cr)throw new Error("bad public key size");if(e.length!==lr)throw new Error("bad secret key size")}(r,e);var t=new Uint8Array(32);return F(t,r,e),t},r.box.after=r.secretbox,r.box.open=function(e,t,n,o){var i=r.box.before(n,o);return r.secretbox.open(e,t,i)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var r=new Uint8Array(cr),e=new Uint8Array(lr);return C(r,e),{publicKey:r,secretKey:e}},r.box.keyPair.fromSecretKey=function(r){if(vr(r),r.length!==lr)throw new Error("bad secret key size");var e=new Uint8Array(cr);return W(e,r),{publicKey:e,secretKey:new Uint8Array(r)}},r.box.publicKeyLength=cr,r.box.secretKeyLength=lr,r.box.sharedKeyLength=32,r.box.nonceLength=yr,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(r,e){if(vr(r,e),64!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(64+r.length);return ar(t,r,r.length,e),t},r.sign.open=function(r,e){if(2!==arguments.length)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(vr(r,e),32!==e.length)throw new Error("bad public key size");var t=new Uint8Array(r.length),n=hr(t,r,r.length,e);if(n<0)return null;for(var o=new Uint8Array(n),i=0;i<o.length;i++)o[i]=t[i];return o},r.sign.detached=function(e,t){for(var n=r.sign(e,t),o=new Uint8Array(64),i=0;i<o.length;i++)o[i]=n[i];return o},r.sign.detached.verify=function(r,e,t){if(vr(r,e,t),64!==e.length)throw new Error("bad signature size");if(32!==t.length)throw new Error("bad public key size");var n,o=new Uint8Array(64+r.length),i=new Uint8Array(64+r.length);for(n=0;n<64;n++)o[n]=e[n];for(n=0;n<r.length;n++)o[n+64]=r[n];return hr(i,o,o.length,t)>=0},r.sign.keyPair=function(){var r=new Uint8Array(32),e=new Uint8Array(64);return tr(r,e),{publicKey:r,secretKey:e}},r.sign.keyPair.fromSecretKey=function(r){if(vr(r),64!==r.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),t=0;t<e.length;t++)e[t]=r[32+t];return{publicKey:e,secretKey:new Uint8Array(r)}},r.sign.keyPair.fromSeed=function(r){if(vr(r),32!==r.length)throw new Error("bad seed size");for(var e=new Uint8Array(32),t=new Uint8Array(64),n=0;n<32;n++)t[n]=r[n];return tr(e,t,!0),{publicKey:e,secretKey:t}},r.sign.publicKeyLength=32,r.sign.secretKeyLength=64,r.sign.seedLength=32,r.sign.signatureLength=64,r.hash=function(r){vr(r);var e=new Uint8Array(64);return H(e,r,r.length),e},r.hash.hashLength=64,r.verify=function(r,e){return vr(r,e),0!==r.length&&0!==e.length&&(r.length===e.length&&0===d(r,0,e,0,r.length))},r.setPRNG=function(r){t=r},function(){var e="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(e&&e.getRandomValues){r.setPRNG(function(r,t){var n,o=new Uint8Array(t);for(n=0;n<t;n+=65536)e.getRandomValues(o.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)r[n]=o[n];wr(o)})}else(e=w)&&e.randomBytes&&r.setPRNG(function(r,t){var n,o=e.randomBytes(t);for(n=0;n<t;n++)r[n]=o[n];wr(o)})}()}(r.exports?r.exports:self.nacl=self.nacl||{})}),g=v(function(r){var e,t;e=d,t=function(){var r={};function e(r){if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(r))throw new TypeError("invalid encoding")}return r.decodeUTF8=function(r){if("string"!=typeof r)throw new TypeError("expected string");var e,t=unescape(encodeURIComponent(r)),n=new Uint8Array(t.length);for(e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},r.encodeUTF8=function(r){var e,t=[];for(e=0;e<r.length;e++)t.push(String.fromCharCode(r[e]));return decodeURIComponent(escape(t.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(r.encodeBase64=function(r){return Buffer.from(r).toString("base64")},r.decodeBase64=function(r){return e(r),new Uint8Array(Array.prototype.slice.call(Buffer.from(r,"base64"),0))}):(r.encodeBase64=function(r){return new Buffer(r).toString("base64")},r.decodeBase64=function(r){return e(r),new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0))}):(r.encodeBase64=function(r){var e,t=[],n=r.length;for(e=0;e<n;e++)t.push(String.fromCharCode(r[e]));return btoa(t.join(""))},r.decodeBase64=function(r){e(r);var t,n=atob(r),o=new Uint8Array(n.length);for(t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return o}),r},r.exports?r.exports=t():e.nacl?e.nacl.util=t():(e.nacl={},e.nacl.util=t())});var b=new o.ec("secp256k1");function E(r,e){void 0===e&&(e=!1);var t=a.toBuffer(r);if(t.length!==(e?65:64))throw new Error("wrong signature length");var n={r:t.slice(0,32).toString("hex"),s:t.slice(32,64).toString("hex")};return e&&(n.recoveryParam=t[64]),n}var A={ES256K:function(r,e,t){var n=u(r),o=E(e),i=t.find(function(r){return b.keyFromPublic(r.publicKeyHex,"hex").verify(n,o)});if(!i)throw new Error("Signature invalid for JWT");return i},"ES256K-R":function(r,e,t){var n=E(e,!0),o=u(r),i=b.recoverPubKey(o,n,n.recoveryParam),a=i.encode("hex"),f=i.encode("hex",!0),h=c(a),s=t.find(function(r){var e=r.publicKeyHex;return e===a||e===f||r.ethereumAddress===h});if(!s)throw new Error("Signature invalid for JWT");return s},Ed25519:function(r,e,t){var n=g.decodeUTF8(r),o=s.decodeBase64Url(e),i=t.find(function(r){return p.sign.detached.verify(n,o,g.decodeBase64(r.publicKeyBase64))});if(!i)throw new Error("Signature invalid for JWT");return i}};function m(r){var e=A[r];if(!e)throw new Error("Unsupported algorithm "+r);return e}function U(r){function e(e){var t=e.r,n=e.s,o=e.recoveryParam,f=i.Buffer.alloc(r?65:64);if(i.Buffer.from(t,"hex").copy(f,0),i.Buffer.from(n,"hex").copy(f,32),r){if(void 0===o)throw new Error("Signer did not return a recoveryParam");f[64]=o}return a.encode(f)}return void 0===r&&(r=!1),function(r,t){try{return Promise.resolve(t(r)).then(e)}catch(r){return Promise.reject(r)}}}m.toSignatureObject=E;var x={ES256K:U(),"ES256K-R":U(!0),Ed25519:function(r,e){try{return Promise.resolve(e(r))}catch(r){return Promise.reject(r)}}};h(),s.registerNaclDID();var _={ES256K:["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],"ES256K-R":["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],Ed25519:["ED25519SignatureVerification"]},S={typ:"JWT"},B="ES256K";function T(r){return a.encode(JSON.stringify(r))}var M=300;function K(r){if(r.match(/^did:/))return r;if(n.isMNID(r))return"did:uport:"+r;throw new Error("Not a valid DID '"+r+"'")}function k(r){if(!r)throw new Error("no JWT passed into decodeJWT");var e=r.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(e)return{header:JSON.parse(a.decode(e[1])),payload:JSON.parse(a.decode(e[2])),signature:e[3],data:e[1]+"."+e[2]};throw new Error("Incorrect format JWT")}module.exports={SimpleSigner:function(r){var e=l.keyFromPrivate(r);return function(r){try{var t=e.sign(u(r)),n=t.s,o=t.recoveryParam;return Promise.resolve({r:y(t.r.toString("hex")),s:y(n.toString("hex")),recoveryParam:o})}catch(r){return Promise.reject(r)}}},NaclSigner:function(r){var e=g.decodeBase64(r);return function(r){try{return Promise.resolve(s.encodeBase64Url(p.sign.detached(g.decodeUTF8(r),e)))}catch(r){return Promise.reject(r)}}},verifyJWT:function(r,e){void 0===e&&(e={});try{var t=e.audience?K(e.audience):void 0,o=k(r),i=o.payload,a=o.header,h=o.signature,s=o.data;return Promise.resolve(function(r,e,t){try{var n=_[r];if(!n||0===n.length)throw new Error("No supported signature types for algorithm "+r);var o=K(e);return Promise.resolve(f(o)).then(function(e){if(!e)throw new Error("Unable to resolve DID document for "+o);var i=!t||(e.authentication||[]).map(function(r){return r.publicKey}),a=(e.publicKey||[]).filter(function(r){var e=r.type,o=r.id;return n.find(function(r){return r===e&&(!t||i.indexOf(o)>=0)})});if(t&&(!a||0===a.length))throw new Error("DID document for "+o+" does not have public keys suitable for authenticationg user");if(!a||0===a.length)throw new Error("DID document for "+o+" does not have public keys for "+r);return{authenticators:a,issuer:o,doc:e}})}catch(r){return Promise.reject(r)}}(a.alg,i.iss,e.auth)).then(function(o){var f,u=o.doc,c=o.authenticators,l=o.issuer,y=m(a.alg)(s,h,c),d=Math.floor(Date.now()/1e3);if(y){if(i.iat&&i.iat>d+M)throw new Error("JWT not valid yet (issued in the future): iat: "+i.iat+" > now: "+d);if(i.exp&&i.exp<=d-M)throw new Error("JWT has expired: exp: "+i.exp+" < now: "+d);if(i.aud)if((f=i.aud)&&(f.match(/^did:/)||n.isMNID(f))){if(!t)throw new Error("JWT audience is required but your app address has not been configured");if(t!==K(i.aud))throw new Error("JWT audience does not match your DID: aud: "+i.aud+" !== yours: "+t)}else{if(!e.callbackUrl)throw new Error("JWT audience matching your callback url is required but one wasn't passed in");if(i.aud!==e.callbackUrl)throw new Error("JWT audience does not match the callback url: aud: "+i.aud+" !== url: "+e.callbackUrl)}return{payload:i,doc:u,issuer:l,signer:y,jwt:r}}})}catch(r){return Promise.reject(r)}},createJWT:function(r,e){var t=e.issuer,n=e.signer,o=e.alg,i=e.expiresIn;try{if(!n)throw new Error("No Signer functionality has been configured");if(!t)throw new Error("No issuing DID has been configured");var a=Object.assign({},S,{alg:o||B}),f={iat:Math.floor(Date.now()/1e3)};if(i){if("number"!=typeof i)throw new Error("JWT expiresIn is not a number");f.exp=f.iat+Math.floor(i)}var h=[T(a),T(Object.assign({},f,r,{iss:t}))].join("."),s=function(r){var e=x[r];if(!e)throw new Error("Unsupported algorithm "+r);return e}(a.alg);return Promise.resolve(s(h,n)).then(function(r){return[h,r].join(".")})}catch(r){return Promise.reject(r)}},decodeJWT:k,toEthereumAddress:c}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("js-sha256"),require("js-sha3"),require("mnid"),require("elliptic"),require("buffer"),require("base64url"),require("did-resolver"),require("uport-did-resolver"),require("nacl-did")):"function"==typeof define&&define.amd?define(["js-sha256","js-sha3","mnid","elliptic","buffer","base64url","did-resolver","uport-did-resolver","nacl-did"],e):e(r.jsSha256,r.jsSha3,r.mnid,r.elliptic,r.buffer,r.base64url,r.resolve,r.registerUport,r.naclDid)}(this,function(r,e,t,n,o,i,a,f,h){function s(e){return o.Buffer.from(r.sha256.arrayBuffer(e))}function u(r){return"0x"+(t=o.Buffer.from(r.slice(2),"hex"),o.Buffer.from(e.keccak_256.buffer(t))).slice(-20).toString("hex");var t}i=i&&i.hasOwnProperty("default")?i.default:i,a=a&&a.hasOwnProperty("default")?a.default:a,f=f&&f.hasOwnProperty("default")?f.default:f;var c=new n.ec("secp256k1");function l(r,e){return void 0===e&&(e=64),r.length===e?r:"0".repeat(e-r.length)+r}var y="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(r,e){return r(e={exports:{}},e.exports),e.exports}var p,v=(p={default:{}})&&p.default||p,w=d(function(r){!function(r){var e=function(r){var e,t=new Float64Array(16);if(r)for(e=0;e<r.length;e++)t[e]=r[e];return t},t=function(){throw new Error("no PRNG")},n=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=e(),a=e([1]),f=e([56129,1]),h=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),s=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),c=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function y(r,e,t,n){r[e]=t>>24&255,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=255&t,r[e+4]=n>>24&255,r[e+5]=n>>16&255,r[e+6]=n>>8&255,r[e+7]=255&n}function d(r,e,t,n,o){var i,a=0;for(i=0;i<o;i++)a|=r[e+i]^t[n+i];return(1&a-1>>>8)-1}function p(r,e,t,n){return d(r,e,t,n,16)}function w(r,e,t,n){return d(r,e,t,n,32)}function g(r,e,t,n){!function(r,e,t,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,s=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&t[16]|(255&t[17])<<8|(255&t[18])<<16|(255&t[19])<<24,w=255&t[20]|(255&t[21])<<8|(255&t[22])<<16|(255&t[23])<<24,g=255&t[24]|(255&t[25])<<8|(255&t[26])<<16|(255&t[27])<<24,b=255&t[28]|(255&t[29])<<8|(255&t[30])<<16|(255&t[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,A=i,m=a,U=f,x=h,_=s,S=u,B=c,T=l,M=y,K=d,k=p,P=v,j=w,Y=g,D=b,z=E,I=0;I<20;I+=2)A^=(o=(j^=(o=(M^=(o=(_^=(o=A+j|0)<<7|o>>>25)+A|0)<<9|o>>>23)+_|0)<<13|o>>>19)+M|0)<<18|o>>>14,S^=(o=(m^=(o=(Y^=(o=(K^=(o=S+m|0)<<7|o>>>25)+S|0)<<9|o>>>23)+K|0)<<13|o>>>19)+Y|0)<<18|o>>>14,k^=(o=(B^=(o=(U^=(o=(D^=(o=k+B|0)<<7|o>>>25)+k|0)<<9|o>>>23)+D|0)<<13|o>>>19)+U|0)<<18|o>>>14,z^=(o=(P^=(o=(T^=(o=(x^=(o=z+P|0)<<7|o>>>25)+z|0)<<9|o>>>23)+x|0)<<13|o>>>19)+T|0)<<18|o>>>14,A^=(o=(x^=(o=(U^=(o=(m^=(o=A+x|0)<<7|o>>>25)+A|0)<<9|o>>>23)+m|0)<<13|o>>>19)+U|0)<<18|o>>>14,S^=(o=(_^=(o=(T^=(o=(B^=(o=S+_|0)<<7|o>>>25)+S|0)<<9|o>>>23)+B|0)<<13|o>>>19)+T|0)<<18|o>>>14,k^=(o=(K^=(o=(M^=(o=(P^=(o=k+K|0)<<7|o>>>25)+k|0)<<9|o>>>23)+P|0)<<13|o>>>19)+M|0)<<18|o>>>14,z^=(o=(D^=(o=(Y^=(o=(j^=(o=z+D|0)<<7|o>>>25)+z|0)<<9|o>>>23)+j|0)<<13|o>>>19)+Y|0)<<18|o>>>14;m=m+a|0,U=U+f|0,x=x+h|0,_=_+s|0,S=S+u|0,B=B+c|0,T=T+l|0,M=M+y|0,K=K+d|0,k=k+p|0,P=P+v|0,j=j+w|0,Y=Y+g|0,D=D+b|0,z=z+E|0,r[0]=(A=A+i|0)>>>0&255,r[1]=A>>>8&255,r[2]=A>>>16&255,r[3]=A>>>24&255,r[4]=m>>>0&255,r[5]=m>>>8&255,r[6]=m>>>16&255,r[7]=m>>>24&255,r[8]=U>>>0&255,r[9]=U>>>8&255,r[10]=U>>>16&255,r[11]=U>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=_>>>0&255,r[17]=_>>>8&255,r[18]=_>>>16&255,r[19]=_>>>24&255,r[20]=S>>>0&255,r[21]=S>>>8&255,r[22]=S>>>16&255,r[23]=S>>>24&255,r[24]=B>>>0&255,r[25]=B>>>8&255,r[26]=B>>>16&255,r[27]=B>>>24&255,r[28]=T>>>0&255,r[29]=T>>>8&255,r[30]=T>>>16&255,r[31]=T>>>24&255,r[32]=M>>>0&255,r[33]=M>>>8&255,r[34]=M>>>16&255,r[35]=M>>>24&255,r[36]=K>>>0&255,r[37]=K>>>8&255,r[38]=K>>>16&255,r[39]=K>>>24&255,r[40]=k>>>0&255,r[41]=k>>>8&255,r[42]=k>>>16&255,r[43]=k>>>24&255,r[44]=P>>>0&255,r[45]=P>>>8&255,r[46]=P>>>16&255,r[47]=P>>>24&255,r[48]=j>>>0&255,r[49]=j>>>8&255,r[50]=j>>>16&255,r[51]=j>>>24&255,r[52]=Y>>>0&255,r[53]=Y>>>8&255,r[54]=Y>>>16&255,r[55]=Y>>>24&255,r[56]=D>>>0&255,r[57]=D>>>8&255,r[58]=D>>>16&255,r[59]=D>>>24&255,r[60]=z>>>0&255,r[61]=z>>>8&255,r[62]=z>>>16&255,r[63]=z>>>24&255}(r,e,t,n)}function b(r,e,t,n){!function(r,e,t,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,s=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&t[16]|(255&t[17])<<8|(255&t[18])<<16|(255&t[19])<<24,w=255&t[20]|(255&t[21])<<8|(255&t[22])<<16|(255&t[23])<<24,g=255&t[24]|(255&t[25])<<8|(255&t[26])<<16|(255&t[27])<<24,b=255&t[28]|(255&t[29])<<8|(255&t[30])<<16|(255&t[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,A=0;A<20;A+=2)i^=(o=(w^=(o=(y^=(o=(s^=(o=i+w|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+y|0)<<18|o>>>14,u^=(o=(a^=(o=(g^=(o=(d^=(o=u+a|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+g|0)<<18|o>>>14,p^=(o=(c^=(o=(f^=(o=(b^=(o=p+c|0)<<7|o>>>25)+p|0)<<9|o>>>23)+b|0)<<13|o>>>19)+f|0)<<18|o>>>14,E^=(o=(v^=(o=(l^=(o=(h^=(o=E+v|0)<<7|o>>>25)+E|0)<<9|o>>>23)+h|0)<<13|o>>>19)+l|0)<<18|o>>>14,i^=(o=(h^=(o=(f^=(o=(a^=(o=i+h|0)<<7|o>>>25)+i|0)<<9|o>>>23)+a|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(l^=(o=(c^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+c|0)<<13|o>>>19)+l|0)<<18|o>>>14,p^=(o=(d^=(o=(y^=(o=(v^=(o=p+d|0)<<7|o>>>25)+p|0)<<9|o>>>23)+v|0)<<13|o>>>19)+y|0)<<18|o>>>14,E^=(o=(b^=(o=(g^=(o=(w^=(o=E+b|0)<<7|o>>>25)+E|0)<<9|o>>>23)+w|0)<<13|o>>>19)+g|0)<<18|o>>>14;r[0]=i>>>0&255,r[1]=i>>>8&255,r[2]=i>>>16&255,r[3]=i>>>24&255,r[4]=u>>>0&255,r[5]=u>>>8&255,r[6]=u>>>16&255,r[7]=u>>>24&255,r[8]=p>>>0&255,r[9]=p>>>8&255,r[10]=p>>>16&255,r[11]=p>>>24&255,r[12]=E>>>0&255,r[13]=E>>>8&255,r[14]=E>>>16&255,r[15]=E>>>24&255,r[16]=c>>>0&255,r[17]=c>>>8&255,r[18]=c>>>16&255,r[19]=c>>>24&255,r[20]=l>>>0&255,r[21]=l>>>8&255,r[22]=l>>>16&255,r[23]=l>>>24&255,r[24]=y>>>0&255,r[25]=y>>>8&255,r[26]=y>>>16&255,r[27]=y>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255}(r,e,t,n)}var E=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function A(r,e,t,n,o,i,a){var f,h,s=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)s[h]=0;for(h=0;h<8;h++)s[h]=i[h];for(;o>=64;){for(g(u,s,a,E),h=0;h<64;h++)r[e+h]=t[n+h]^u[h];for(f=1,h=8;h<16;h++)s[h]=255&(f=f+(255&s[h])|0),f>>>=8;o-=64,e+=64,n+=64}if(o>0)for(g(u,s,a,E),h=0;h<o;h++)r[e+h]=t[n+h]^u[h];return 0}function m(r,e,t,n,o){var i,a,f=new Uint8Array(16),h=new Uint8Array(64);for(a=0;a<16;a++)f[a]=0;for(a=0;a<8;a++)f[a]=n[a];for(;t>=64;){for(g(h,f,o,E),a=0;a<64;a++)r[e+a]=h[a];for(i=1,a=8;a<16;a++)f[a]=255&(i=i+(255&f[a])|0),i>>>=8;t-=64,e+=64}if(t>0)for(g(h,f,o,E),a=0;a<t;a++)r[e+a]=h[a];return 0}function U(r,e,t,n,o){var i=new Uint8Array(32);b(i,n,o,E);for(var a=new Uint8Array(8),f=0;f<8;f++)a[f]=n[f+16];return m(r,e,t,a,i)}function x(r,e,t,n,o,i,a){var f=new Uint8Array(32);b(f,i,a,E);for(var h=new Uint8Array(8),s=0;s<8;s++)h[s]=i[s+16];return A(r,e,t,n,o,h,f)}var _=function(r){var e,t,n,o,i,a,f,h;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,this.r[0]=8191&(e=255&r[0]|(255&r[1])<<8),this.r[1]=8191&(e>>>13|(t=255&r[2]|(255&r[3])<<8)<<3),this.r[2]=7939&(t>>>10|(n=255&r[4]|(255&r[5])<<8)<<6),this.r[3]=8191&(n>>>7|(o=255&r[6]|(255&r[7])<<8)<<9),this.r[4]=255&(o>>>4|(i=255&r[8]|(255&r[9])<<8)<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|(a=255&r[10]|(255&r[11])<<8)<<2),this.r[7]=8065&(a>>>11|(f=255&r[12]|(255&r[13])<<8)<<5),this.r[8]=8191&(f>>>8|(h=255&r[14]|(255&r[15])<<8)<<8),this.r[9]=h>>>5&127,this.pad[0]=255&r[16]|(255&r[17])<<8,this.pad[1]=255&r[18]|(255&r[19])<<8,this.pad[2]=255&r[20]|(255&r[21])<<8,this.pad[3]=255&r[22]|(255&r[23])<<8,this.pad[4]=255&r[24]|(255&r[25])<<8,this.pad[5]=255&r[26]|(255&r[27])<<8,this.pad[6]=255&r[28]|(255&r[29])<<8,this.pad[7]=255&r[30]|(255&r[31])<<8};function S(r,e,t,n,o,i){var a=new _(i);return a.update(t,n,o),a.finish(r,e),0}function B(r,e,t,n,o,i){var a=new Uint8Array(16);return S(a,0,t,n,o,i),p(r,e,a,0)}function T(r,e,t,n,o){var i;if(t<32)return-1;for(x(r,0,e,0,t,n,o),S(r,16,r,32,t-32,r),i=0;i<16;i++)r[i]=0;return 0}function M(r,e,t,n,o){var i,a=new Uint8Array(32);if(t<32)return-1;if(U(a,0,32,n,o),0!==B(e,16,e,32,t-32,a))return-1;for(x(r,0,e,0,t,n,o),i=0;i<32;i++)r[i]=0;return 0}function K(r,e){var t;for(t=0;t<16;t++)r[t]=0|e[t]}function k(r){var e,t,n=1;for(e=0;e<16;e++)t=r[e]+n+65535,n=Math.floor(t/65536),r[e]=t-65536*n;r[0]+=n-1+37*(n-1)}function P(r,e,t){for(var n,o=~(t-1),i=0;i<16;i++)r[i]^=n=o&(r[i]^e[i]),e[i]^=n}function j(r,t){var n,o,i,a=e(),f=e();for(n=0;n<16;n++)f[n]=t[n];for(k(f),k(f),k(f),o=0;o<2;o++){for(a[0]=f[0]-65517,n=1;n<15;n++)a[n]=f[n]-65535-(a[n-1]>>16&1),a[n-1]&=65535;a[15]=f[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,P(f,a,1-i)}for(n=0;n<16;n++)r[2*n]=255&f[n],r[2*n+1]=f[n]>>8}function Y(r,e){var t=new Uint8Array(32),n=new Uint8Array(32);return j(t,r),j(n,e),w(t,0,n,0)}function D(r){var e=new Uint8Array(32);return j(e,r),1&e[0]}function z(r,e){var t;for(t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function I(r,e,t){for(var n=0;n<16;n++)r[n]=e[n]+t[n]}function J(r,e,t){for(var n=0;n<16;n++)r[n]=e[n]-t[n]}function N(r,e,t){var n,o,i=0,a=0,f=0,h=0,s=0,u=0,c=0,l=0,y=0,d=0,p=0,v=0,w=0,g=0,b=0,E=0,A=0,m=0,U=0,x=0,_=0,S=0,B=0,T=0,M=0,K=0,k=0,P=0,j=0,Y=0,D=0,z=t[0],I=t[1],J=t[2],N=t[3],O=t[4],L=t[5],R=t[6],W=t[7],C=t[8],F=t[9],q=t[10],Z=t[11],V=t[12],G=t[13],H=t[14],X=t[15];i+=(n=e[0])*z,a+=n*I,f+=n*J,h+=n*N,s+=n*O,u+=n*L,c+=n*R,l+=n*W,y+=n*C,d+=n*F,p+=n*q,v+=n*Z,w+=n*V,g+=n*G,b+=n*H,E+=n*X,a+=(n=e[1])*z,f+=n*I,h+=n*J,s+=n*N,u+=n*O,c+=n*L,l+=n*R,y+=n*W,d+=n*C,p+=n*F,v+=n*q,w+=n*Z,g+=n*V,b+=n*G,E+=n*H,A+=n*X,f+=(n=e[2])*z,h+=n*I,s+=n*J,u+=n*N,c+=n*O,l+=n*L,y+=n*R,d+=n*W,p+=n*C,v+=n*F,w+=n*q,g+=n*Z,b+=n*V,E+=n*G,A+=n*H,m+=n*X,h+=(n=e[3])*z,s+=n*I,u+=n*J,c+=n*N,l+=n*O,y+=n*L,d+=n*R,p+=n*W,v+=n*C,w+=n*F,g+=n*q,b+=n*Z,E+=n*V,A+=n*G,m+=n*H,U+=n*X,s+=(n=e[4])*z,u+=n*I,c+=n*J,l+=n*N,y+=n*O,d+=n*L,p+=n*R,v+=n*W,w+=n*C,g+=n*F,b+=n*q,E+=n*Z,A+=n*V,m+=n*G,U+=n*H,x+=n*X,u+=(n=e[5])*z,c+=n*I,l+=n*J,y+=n*N,d+=n*O,p+=n*L,v+=n*R,w+=n*W,g+=n*C,b+=n*F,E+=n*q,A+=n*Z,m+=n*V,U+=n*G,x+=n*H,_+=n*X,c+=(n=e[6])*z,l+=n*I,y+=n*J,d+=n*N,p+=n*O,v+=n*L,w+=n*R,g+=n*W,b+=n*C,E+=n*F,A+=n*q,m+=n*Z,U+=n*V,x+=n*G,_+=n*H,S+=n*X,l+=(n=e[7])*z,y+=n*I,d+=n*J,p+=n*N,v+=n*O,w+=n*L,g+=n*R,b+=n*W,E+=n*C,A+=n*F,m+=n*q,U+=n*Z,x+=n*V,_+=n*G,S+=n*H,B+=n*X,y+=(n=e[8])*z,d+=n*I,p+=n*J,v+=n*N,w+=n*O,g+=n*L,b+=n*R,E+=n*W,A+=n*C,m+=n*F,U+=n*q,x+=n*Z,_+=n*V,S+=n*G,B+=n*H,T+=n*X,d+=(n=e[9])*z,p+=n*I,v+=n*J,w+=n*N,g+=n*O,b+=n*L,E+=n*R,A+=n*W,m+=n*C,U+=n*F,x+=n*q,_+=n*Z,S+=n*V,B+=n*G,T+=n*H,M+=n*X,p+=(n=e[10])*z,v+=n*I,w+=n*J,g+=n*N,b+=n*O,E+=n*L,A+=n*R,m+=n*W,U+=n*C,x+=n*F,_+=n*q,S+=n*Z,B+=n*V,T+=n*G,M+=n*H,K+=n*X,v+=(n=e[11])*z,w+=n*I,g+=n*J,b+=n*N,E+=n*O,A+=n*L,m+=n*R,U+=n*W,x+=n*C,_+=n*F,S+=n*q,B+=n*Z,T+=n*V,M+=n*G,K+=n*H,k+=n*X,w+=(n=e[12])*z,g+=n*I,b+=n*J,E+=n*N,A+=n*O,m+=n*L,U+=n*R,x+=n*W,_+=n*C,S+=n*F,B+=n*q,T+=n*Z,M+=n*V,K+=n*G,k+=n*H,P+=n*X,g+=(n=e[13])*z,b+=n*I,E+=n*J,A+=n*N,m+=n*O,U+=n*L,x+=n*R,_+=n*W,S+=n*C,B+=n*F,T+=n*q,M+=n*Z,K+=n*V,k+=n*G,P+=n*H,j+=n*X,b+=(n=e[14])*z,E+=n*I,A+=n*J,m+=n*N,U+=n*O,x+=n*L,_+=n*R,S+=n*W,B+=n*C,T+=n*F,M+=n*q,K+=n*Z,k+=n*V,P+=n*G,j+=n*H,Y+=n*X,E+=(n=e[15])*z,a+=38*(m+=n*J),f+=38*(U+=n*N),h+=38*(x+=n*O),s+=38*(_+=n*L),u+=38*(S+=n*R),c+=38*(B+=n*W),l+=38*(T+=n*C),y+=38*(M+=n*F),d+=38*(K+=n*q),p+=38*(k+=n*Z),v+=38*(P+=n*V),w+=38*(j+=n*G),g+=38*(Y+=n*H),b+=38*(D+=n*X),i=(n=(i+=38*(A+=n*I))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),r[0]=i+=o-1+37*(o-1),r[1]=a,r[2]=f,r[3]=h,r[4]=s,r[5]=u,r[6]=c,r[7]=l,r[8]=y,r[9]=d,r[10]=p,r[11]=v,r[12]=w,r[13]=g,r[14]=b,r[15]=E}function O(r,e){N(r,e,e)}function L(r,t){var n,o=e();for(n=0;n<16;n++)o[n]=t[n];for(n=253;n>=0;n--)O(o,o),2!==n&&4!==n&&N(o,o,t);for(n=0;n<16;n++)r[n]=o[n]}function R(r,t,n){var o,i,a=new Uint8Array(32),h=new Float64Array(80),s=e(),u=e(),c=e(),l=e(),y=e(),d=e();for(i=0;i<31;i++)a[i]=t[i];for(a[31]=127&t[31]|64,a[0]&=248,z(h,n),i=0;i<16;i++)u[i]=h[i],l[i]=s[i]=c[i]=0;for(s[0]=l[0]=1,i=254;i>=0;--i)P(s,u,o=a[i>>>3]>>>(7&i)&1),P(c,l,o),I(y,s,c),J(s,s,c),I(c,u,l),J(u,u,l),O(l,y),O(d,s),N(s,c,s),N(c,u,y),I(y,s,c),J(s,s,c),O(u,s),J(c,l,d),N(s,c,f),I(s,s,l),N(c,c,s),N(s,l,d),N(l,u,h),O(u,y),P(s,u,o),P(c,l,o);for(i=0;i<16;i++)h[i+16]=s[i],h[i+32]=c[i],h[i+48]=u[i],h[i+64]=l[i];var p=h.subarray(32),v=h.subarray(16);return L(p,p),N(v,v,p),j(r,v),0}function W(r,e){return R(r,e,o)}function C(r,e){return t(e,32),W(r,e)}function F(r,e,t){var o=new Uint8Array(32);return R(o,t,e),b(r,n,o,E)}_.prototype.blocks=function(r,e,t){for(var n,o,i,a,f,h,s,u,c,l,y,d,p,v,w,g,b,E,A,m=this.fin?0:2048,U=this.h[0],x=this.h[1],_=this.h[2],S=this.h[3],B=this.h[4],T=this.h[5],M=this.h[6],K=this.h[7],k=this.h[8],P=this.h[9],j=this.r[0],Y=this.r[1],D=this.r[2],z=this.r[3],I=this.r[4],J=this.r[5],N=this.r[6],O=this.r[7],L=this.r[8],R=this.r[9];t>=16;)l=c=0,l+=(U+=8191&(n=255&r[e+0]|(255&r[e+1])<<8))*j,l+=(x+=8191&(n>>>13|(o=255&r[e+2]|(255&r[e+3])<<8)<<3))*(5*R),l+=(_+=8191&(o>>>10|(i=255&r[e+4]|(255&r[e+5])<<8)<<6))*(5*L),l+=(S+=8191&(i>>>7|(a=255&r[e+6]|(255&r[e+7])<<8)<<9))*(5*O),c=(l+=(B+=8191&(a>>>4|(f=255&r[e+8]|(255&r[e+9])<<8)<<12))*(5*N))>>>13,l&=8191,l+=(T+=f>>>1&8191)*(5*J),l+=(M+=8191&(f>>>14|(h=255&r[e+10]|(255&r[e+11])<<8)<<2))*(5*I),l+=(K+=8191&(h>>>11|(s=255&r[e+12]|(255&r[e+13])<<8)<<5))*(5*z),l+=(k+=8191&(s>>>8|(u=255&r[e+14]|(255&r[e+15])<<8)<<8))*(5*D),y=c+=(l+=(P+=u>>>5|m)*(5*Y))>>>13,y+=U*Y,y+=x*j,y+=_*(5*R),y+=S*(5*L),c=(y+=B*(5*O))>>>13,y&=8191,y+=T*(5*N),y+=M*(5*J),y+=K*(5*I),y+=k*(5*z),c+=(y+=P*(5*D))>>>13,y&=8191,d=c,d+=U*D,d+=x*Y,d+=_*j,d+=S*(5*R),c=(d+=B*(5*L))>>>13,d&=8191,d+=T*(5*O),d+=M*(5*N),d+=K*(5*J),d+=k*(5*I),p=c+=(d+=P*(5*z))>>>13,p+=U*z,p+=x*D,p+=_*Y,p+=S*j,c=(p+=B*(5*R))>>>13,p&=8191,p+=T*(5*L),p+=M*(5*O),p+=K*(5*N),p+=k*(5*J),v=c+=(p+=P*(5*I))>>>13,v+=U*I,v+=x*z,v+=_*D,v+=S*Y,c=(v+=B*j)>>>13,v&=8191,v+=T*(5*R),v+=M*(5*L),v+=K*(5*O),v+=k*(5*N),w=c+=(v+=P*(5*J))>>>13,w+=U*J,w+=x*I,w+=_*z,w+=S*D,c=(w+=B*Y)>>>13,w&=8191,w+=T*j,w+=M*(5*R),w+=K*(5*L),w+=k*(5*O),g=c+=(w+=P*(5*N))>>>13,g+=U*N,g+=x*J,g+=_*I,g+=S*z,c=(g+=B*D)>>>13,g&=8191,g+=T*Y,g+=M*j,g+=K*(5*R),g+=k*(5*L),b=c+=(g+=P*(5*O))>>>13,b+=U*O,b+=x*N,b+=_*J,b+=S*I,c=(b+=B*z)>>>13,b&=8191,b+=T*D,b+=M*Y,b+=K*j,b+=k*(5*R),E=c+=(b+=P*(5*L))>>>13,E+=U*L,E+=x*O,E+=_*N,E+=S*J,c=(E+=B*I)>>>13,E&=8191,E+=T*z,E+=M*D,E+=K*Y,E+=k*j,A=c+=(E+=P*(5*R))>>>13,A+=U*R,A+=x*L,A+=_*O,A+=S*N,c=(A+=B*J)>>>13,A&=8191,A+=T*I,A+=M*z,A+=K*D,A+=k*Y,U=l=8191&(c=(c=((c+=(A+=P*j)>>>13)<<2)+c|0)+(l&=8191)|0),x=y+=c>>>=13,_=d&=8191,S=p&=8191,B=v&=8191,T=w&=8191,M=g&=8191,K=b&=8191,k=E&=8191,P=A&=8191,e+=16,t-=16;this.h[0]=U,this.h[1]=x,this.h[2]=_,this.h[3]=S,this.h[4]=B,this.h[5]=T,this.h[6]=M,this.h[7]=K,this.h[8]=k,this.h[9]=P},_.prototype.finish=function(r,e){var t,n,o,i,a=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;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;i<10;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,a[0]=this.h[0]+5,t=a[0]>>>13,a[0]&=8191,i=1;i<10;i++)a[i]=this.h[i]+t,t=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,n=(1^t)-1,i=0;i<10;i++)a[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|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),this.h[0]=65535&(o=this.h[0]+this.pad[0]),i=1;i<8;i++)this.h[i]=65535&(o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0);r[e+0]=this.h[0]>>>0&255,r[e+1]=this.h[0]>>>8&255,r[e+2]=this.h[1]>>>0&255,r[e+3]=this.h[1]>>>8&255,r[e+4]=this.h[2]>>>0&255,r[e+5]=this.h[2]>>>8&255,r[e+6]=this.h[3]>>>0&255,r[e+7]=this.h[3]>>>8&255,r[e+8]=this.h[4]>>>0&255,r[e+9]=this.h[4]>>>8&255,r[e+10]=this.h[5]>>>0&255,r[e+11]=this.h[5]>>>8&255,r[e+12]=this.h[6]>>>0&255,r[e+13]=this.h[6]>>>8&255,r[e+14]=this.h[7]>>>0&255,r[e+15]=this.h[7]>>>8&255},_.prototype.update=function(r,e,t){var n,o;if(this.leftover){for((o=16-this.leftover)>t&&(o=t),n=0;n<o;n++)this.buffer[this.leftover+n]=r[e+n];if(t-=o,e+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(t>=16&&(this.blocks(r,e,o=t-t%16),e+=o,t-=o),t){for(n=0;n<t;n++)this.buffer[this.leftover+n]=r[e+n];this.leftover+=t}};var q=T,Z=M;var V=[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];function G(r,e,t,n){for(var o,i,a,f,h,s,u,c,l,y,d,p,v,w,g,b,E,A,m,U,x,_,S=new Int32Array(16),B=new Int32Array(16),T=r[0],M=r[1],K=r[2],k=r[3],P=r[4],j=r[5],Y=r[6],D=r[7],z=e[0],I=e[1],J=e[2],N=e[3],O=e[4],L=e[5],R=e[6],W=e[7],C=0;n>=128;){for(g=0;g<16;g++)S[g]=t[(b=8*g+C)+0]<<24|t[b+1]<<16|t[b+2]<<8|t[b+3],B[g]=t[b+4]<<24|t[b+5]<<16|t[b+6]<<8|t[b+7];for(g=0;g<80;g++)if(o=M,i=K,a=P,f=j,h=Y,D,u=I,c=J,l=O,y=L,d=R,W,m=65535&(A=W),U=A>>>16,x=65535&(E=D),_=E>>>16,m+=65535&(A=(O>>>14|P<<18)^(O>>>18|P<<14)^(P>>>9|O<<23)),U+=A>>>16,x+=65535&(E=(P>>>14|O<<18)^(P>>>18|O<<14)^(O>>>9|P<<23)),_+=E>>>16,m+=65535&(A=O&L^~O&R),U+=A>>>16,x+=65535&(E=P&j^~P&Y),_+=E>>>16,m+=65535&(A=V[2*g+1]),U+=A>>>16,x+=65535&(E=V[2*g]),_+=E>>>16,U+=(A=B[g%16])>>>16,x+=65535&(E=S[g%16]),_+=E>>>16,x+=(U+=(m+=65535&A)>>>16)>>>16,m=65535&(A=w=65535&m|U<<16),U=A>>>16,x=65535&(E=v=65535&x|(_+=x>>>16)<<16),_=E>>>16,m+=65535&(A=(z>>>28|T<<4)^(T>>>2|z<<30)^(T>>>7|z<<25)),U+=A>>>16,x+=65535&(E=(T>>>28|z<<4)^(z>>>2|T<<30)^(z>>>7|T<<25)),_+=E>>>16,U+=(A=z&I^z&J^I&J)>>>16,x+=65535&(E=T&M^T&K^M&K),_+=E>>>16,s=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,p=65535&m|U<<16,m=65535&(A=N),U=A>>>16,x=65535&(E=k),_=E>>>16,U+=(A=w)>>>16,x+=65535&(E=v),_+=E>>>16,M=T,K=o,k=i,P=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,j=a,Y=f,D=h,T=s,I=z,J=u,N=c,O=65535&m|U<<16,L=l,R=y,W=d,z=p,g%16==15)for(b=0;b<16;b++)m=65535&(A=B[b]),U=A>>>16,x=65535&(E=S[b]),_=E>>>16,m+=65535&(A=B[(b+9)%16]),U+=A>>>16,x+=65535&(E=S[(b+9)%16]),_+=E>>>16,m+=65535&(A=((w=B[(b+1)%16])>>>1|(v=S[(b+1)%16])<<31)^(w>>>8|v<<24)^(w>>>7|v<<25)),U+=A>>>16,x+=65535&(E=(v>>>1|w<<31)^(v>>>8|w<<24)^v>>>7),_+=E>>>16,U+=(A=((w=B[(b+14)%16])>>>19|(v=S[(b+14)%16])<<13)^(v>>>29|w<<3)^(w>>>6|v<<26))>>>16,x+=65535&(E=(v>>>19|w<<13)^(w>>>29|v<<3)^v>>>6),_+=E>>>16,S[b]=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,B[b]=65535&m|U<<16;m=65535&(A=z),U=A>>>16,x=65535&(E=T),_=E>>>16,U+=(A=e[0])>>>16,x+=65535&(E=r[0]),_+=E>>>16,r[0]=T=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[0]=z=65535&m|U<<16,m=65535&(A=I),U=A>>>16,x=65535&(E=M),_=E>>>16,U+=(A=e[1])>>>16,x+=65535&(E=r[1]),_+=E>>>16,r[1]=M=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[1]=I=65535&m|U<<16,m=65535&(A=J),U=A>>>16,x=65535&(E=K),_=E>>>16,U+=(A=e[2])>>>16,x+=65535&(E=r[2]),_+=E>>>16,r[2]=K=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[2]=J=65535&m|U<<16,m=65535&(A=N),U=A>>>16,x=65535&(E=k),_=E>>>16,U+=(A=e[3])>>>16,x+=65535&(E=r[3]),_+=E>>>16,r[3]=k=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[3]=N=65535&m|U<<16,m=65535&(A=O),U=A>>>16,x=65535&(E=P),_=E>>>16,U+=(A=e[4])>>>16,x+=65535&(E=r[4]),_+=E>>>16,r[4]=P=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[4]=O=65535&m|U<<16,m=65535&(A=L),U=A>>>16,x=65535&(E=j),_=E>>>16,U+=(A=e[5])>>>16,x+=65535&(E=r[5]),_+=E>>>16,r[5]=j=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[5]=L=65535&m|U<<16,m=65535&(A=R),U=A>>>16,x=65535&(E=Y),_=E>>>16,U+=(A=e[6])>>>16,x+=65535&(E=r[6]),_+=E>>>16,r[6]=Y=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[6]=R=65535&m|U<<16,m=65535&(A=W),U=A>>>16,x=65535&(E=D),_=E>>>16,U+=(A=e[7])>>>16,x+=65535&(E=r[7]),_+=E>>>16,r[7]=D=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[7]=W=65535&m|U<<16,C+=128,n-=128}return n}function H(r,e,t){var n,o=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),f=t;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,G(o,i,e,t),t%=128,n=0;n<t;n++)a[n]=e[f-t+n];for(a[t]=128,a[(t=256-128*(t<112?1:0))-9]=0,y(a,t-8,f/536870912|0,f<<3),G(o,i,a,t),n=0;n<8;n++)y(r,8*n,o[n],i[n]);return 0}function X(r,t){var n=e(),o=e(),i=e(),a=e(),f=e(),h=e(),u=e(),c=e(),l=e();J(n,r[1],r[0]),J(l,t[1],t[0]),N(n,n,l),I(o,r[0],r[1]),I(l,t[0],t[1]),N(o,o,l),N(i,r[3],t[3]),N(i,i,s),N(a,r[2],t[2]),I(a,a,a),J(f,o,n),J(h,a,i),I(u,a,i),I(c,o,n),N(r[0],f,h),N(r[1],c,u),N(r[2],u,h),N(r[3],f,c)}function $(r,e,t){var n;for(n=0;n<4;n++)P(r[n],e[n],t)}function Q(r,t){var n=e(),o=e(),i=e();L(i,t[2]),N(n,t[0],i),N(o,t[1],i),j(r,o),r[31]^=D(n)<<7}function rr(r,e,t){var n,o;for(K(r[0],i),K(r[1],a),K(r[2],a),K(r[3],i),o=255;o>=0;--o)$(r,e,n=t[o/8|0]>>(7&o)&1),X(e,r),X(r,r),$(r,e,n)}function er(r,t){var n=[e(),e(),e(),e()];K(n[0],u),K(n[1],c),K(n[2],a),N(n[3],u,c),rr(r,n,t)}function tr(r,n,o){var i,a=new Uint8Array(64),f=[e(),e(),e(),e()];for(o||t(n,32),H(a,n,32),a[0]&=248,a[31]&=127,a[31]|=64,er(f,a),Q(r,f),i=0;i<32;i++)n[i+32]=r[i];return 0}var nr=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]);function or(r,e){var t,n,o,i;for(n=63;n>=32;--n){for(t=0,o=n-32,i=n-12;o<i;++o)e[o]+=t-16*e[n]*nr[o-(n-32)],e[o]-=256*(t=e[o]+128>>8);e[o]+=t,e[n]=0}for(t=0,o=0;o<32;o++)e[o]+=t-(e[31]>>4)*nr[o],t=e[o]>>8,e[o]&=255;for(o=0;o<32;o++)e[o]-=t*nr[o];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,r[n]=255&e[n]}function ir(r){var e,t=new Float64Array(64);for(e=0;e<64;e++)t[e]=r[e];for(e=0;e<64;e++)r[e]=0;or(r,t)}function ar(r,t,n,o){var i,a,f=new Uint8Array(64),h=new Uint8Array(64),s=new Uint8Array(64),u=new Float64Array(64),c=[e(),e(),e(),e()];H(f,o,32),f[0]&=248,f[31]&=127,f[31]|=64;var l=n+64;for(i=0;i<n;i++)r[64+i]=t[i];for(i=0;i<32;i++)r[32+i]=f[32+i];for(H(s,r.subarray(32),n+32),ir(s),er(c,s),Q(r,c),i=32;i<64;i++)r[i]=o[i];for(H(h,r,n+64),ir(h),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=s[i];for(i=0;i<32;i++)for(a=0;a<32;a++)u[i+a]+=h[i]*f[a];return or(r.subarray(32),u),l}function fr(r,t){var n=e(),o=e(),f=e(),s=e(),u=e(),c=e(),y=e();return K(r[2],a),z(r[1],t),O(f,r[1]),N(s,f,h),J(f,f,r[2]),I(s,r[2],s),O(u,s),O(c,u),N(y,c,u),N(n,y,f),N(n,n,s),function(r,t){var n,o=e();for(n=0;n<16;n++)o[n]=t[n];for(n=250;n>=0;n--)O(o,o),1!==n&&N(o,o,t);for(n=0;n<16;n++)r[n]=o[n]}(n,n),N(n,n,f),N(n,n,s),N(n,n,s),N(r[0],n,s),O(o,r[0]),N(o,o,s),Y(o,f)&&N(r[0],r[0],l),O(o,r[0]),N(o,o,s),Y(o,f)?-1:(D(r[0])===t[31]>>7&&J(r[0],i,r[0]),N(r[3],r[0],r[1]),0)}function hr(r,t,n,o){var i,a=new Uint8Array(32),f=new Uint8Array(64),h=[e(),e(),e(),e()],s=[e(),e(),e(),e()];if(-1,n<64)return-1;if(fr(s,o))return-1;for(i=0;i<n;i++)r[i]=t[i];for(i=0;i<32;i++)r[i+32]=o[i];if(H(f,r,n),ir(f),rr(h,s,f),er(s,t.subarray(32)),X(h,s),Q(a,h),n-=64,w(t,0,a,0)){for(i=0;i<n;i++)r[i]=0;return-1}for(i=0;i<n;i++)r[i]=t[i+64];return n}var sr=32,ur=24,cr=32,lr=32,yr=ur;function dr(r,e){if(r.length!==sr)throw new Error("bad key size");if(e.length!==ur)throw new Error("bad nonce size")}function pr(){var r,e;for(e=0;e<arguments.length;e++)if("[object Uint8Array]"!==(r=Object.prototype.toString.call(arguments[e])))throw new TypeError("unexpected type "+r+", use Uint8Array")}function vr(r){for(var e=0;e<r.length;e++)r[e]=0}r.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:x,crypto_stream:U,crypto_stream_salsa20_xor:A,crypto_stream_salsa20:m,crypto_onetimeauth:S,crypto_onetimeauth_verify:B,crypto_verify_16:p,crypto_verify_32:w,crypto_secretbox:T,crypto_secretbox_open:M,crypto_scalarmult:R,crypto_scalarmult_base:W,crypto_box_beforenm:F,crypto_box_afternm:q,crypto_box:function(r,e,t,n,o,i){var a=new Uint8Array(32);return F(a,o,i),q(r,e,t,n,a)},crypto_box_open:function(r,e,t,n,o,i){var a=new Uint8Array(32);return F(a,o,i),Z(r,e,t,n,a)},crypto_box_keypair:C,crypto_hash:H,crypto_sign:ar,crypto_sign_keypair:tr,crypto_sign_open:hr,crypto_secretbox_KEYBYTES:sr,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:cr,crypto_box_SECRETKEYBYTES:lr,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:yr,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:64,crypto_sign_PUBLICKEYBYTES:32,crypto_sign_SECRETKEYBYTES:64,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64},r.util||(r.util={},r.util.decodeUTF8=r.util.encodeUTF8=r.util.encodeBase64=r.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),r.randomBytes=function(r){var e=new Uint8Array(r);return t(e,r),e},r.secretbox=function(r,e,t){pr(r,e,t),dr(t,e);for(var n=new Uint8Array(32+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+32]=r[i];return T(o,n,n.length,e,t),o.subarray(16)},r.secretbox.open=function(r,e,t){pr(r,e,t),dr(t,e);for(var n=new Uint8Array(16+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+16]=r[i];return!(n.length<32)&&(0===M(o,n,n.length,e,t)&&o.subarray(32))},r.secretbox.keyLength=sr,r.secretbox.nonceLength=ur,r.secretbox.overheadLength=16,r.scalarMult=function(r,e){if(pr(r,e),32!==r.length)throw new Error("bad n size");if(32!==e.length)throw new Error("bad p size");var t=new Uint8Array(32);return R(t,r,e),t},r.scalarMult.base=function(r){if(pr(r),32!==r.length)throw new Error("bad n size");var e=new Uint8Array(32);return W(e,r),e},r.scalarMult.scalarLength=32,r.scalarMult.groupElementLength=32,r.box=function(e,t,n,o){var i=r.box.before(n,o);return r.secretbox(e,t,i)},r.box.before=function(r,e){pr(r,e),function(r,e){if(r.length!==cr)throw new Error("bad public key size");if(e.length!==lr)throw new Error("bad secret key size")}(r,e);var t=new Uint8Array(32);return F(t,r,e),t},r.box.after=r.secretbox,r.box.open=function(e,t,n,o){var i=r.box.before(n,o);return r.secretbox.open(e,t,i)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var r=new Uint8Array(cr),e=new Uint8Array(lr);return C(r,e),{publicKey:r,secretKey:e}},r.box.keyPair.fromSecretKey=function(r){if(pr(r),r.length!==lr)throw new Error("bad secret key size");var e=new Uint8Array(cr);return W(e,r),{publicKey:e,secretKey:new Uint8Array(r)}},r.box.publicKeyLength=cr,r.box.secretKeyLength=lr,r.box.sharedKeyLength=32,r.box.nonceLength=yr,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(r,e){if(pr(r,e),64!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(64+r.length);return ar(t,r,r.length,e),t},r.sign.open=function(r,e){if(2!==arguments.length)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(pr(r,e),32!==e.length)throw new Error("bad public key size");var t=new Uint8Array(r.length),n=hr(t,r,r.length,e);if(n<0)return null;for(var o=new Uint8Array(n),i=0;i<o.length;i++)o[i]=t[i];return o},r.sign.detached=function(e,t){for(var n=r.sign(e,t),o=new Uint8Array(64),i=0;i<o.length;i++)o[i]=n[i];return o},r.sign.detached.verify=function(r,e,t){if(pr(r,e,t),64!==e.length)throw new Error("bad signature size");if(32!==t.length)throw new Error("bad public key size");var n,o=new Uint8Array(64+r.length),i=new Uint8Array(64+r.length);for(n=0;n<64;n++)o[n]=e[n];for(n=0;n<r.length;n++)o[n+64]=r[n];return hr(i,o,o.length,t)>=0},r.sign.keyPair=function(){var r=new Uint8Array(32),e=new Uint8Array(64);return tr(r,e),{publicKey:r,secretKey:e}},r.sign.keyPair.fromSecretKey=function(r){if(pr(r),64!==r.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),t=0;t<e.length;t++)e[t]=r[32+t];return{publicKey:e,secretKey:new Uint8Array(r)}},r.sign.keyPair.fromSeed=function(r){if(pr(r),32!==r.length)throw new Error("bad seed size");for(var e=new Uint8Array(32),t=new Uint8Array(64),n=0;n<32;n++)t[n]=r[n];return tr(e,t,!0),{publicKey:e,secretKey:t}},r.sign.publicKeyLength=32,r.sign.secretKeyLength=64,r.sign.seedLength=32,r.sign.signatureLength=64,r.hash=function(r){pr(r);var e=new Uint8Array(64);return H(e,r,r.length),e},r.hash.hashLength=64,r.verify=function(r,e){return pr(r,e),0!==r.length&&0!==e.length&&(r.length===e.length&&0===d(r,0,e,0,r.length))},r.setPRNG=function(r){t=r},function(){var e="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(e&&e.getRandomValues){r.setPRNG(function(r,t){var n,o=new Uint8Array(t);for(n=0;n<t;n+=65536)e.getRandomValues(o.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)r[n]=o[n];vr(o)})}else(e=v)&&e.randomBytes&&r.setPRNG(function(r,t){var n,o=e.randomBytes(t);for(n=0;n<t;n++)r[n]=o[n];vr(o)})}()}(r.exports?r.exports:self.nacl=self.nacl||{})}),g=d(function(r){var e,t;e=y,t=function(){var r={};function e(r){if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(r))throw new TypeError("invalid encoding")}return r.decodeUTF8=function(r){if("string"!=typeof r)throw new TypeError("expected string");var e,t=unescape(encodeURIComponent(r)),n=new Uint8Array(t.length);for(e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},r.encodeUTF8=function(r){var e,t=[];for(e=0;e<r.length;e++)t.push(String.fromCharCode(r[e]));return decodeURIComponent(escape(t.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(r.encodeBase64=function(r){return Buffer.from(r).toString("base64")},r.decodeBase64=function(r){return e(r),new Uint8Array(Array.prototype.slice.call(Buffer.from(r,"base64"),0))}):(r.encodeBase64=function(r){return new Buffer(r).toString("base64")},r.decodeBase64=function(r){return e(r),new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0))}):(r.encodeBase64=function(r){var e,t=[],n=r.length;for(e=0;e<n;e++)t.push(String.fromCharCode(r[e]));return btoa(t.join(""))},r.decodeBase64=function(r){e(r);var t,n=atob(r),o=new Uint8Array(n.length);for(t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return o}),r},r.exports?r.exports=t():e.nacl?e.nacl.util=t():(e.nacl={},e.nacl.util=t())});var b=new n.ec("secp256k1");function E(r,e){void 0===e&&(e=!1);var t=i.toBuffer(r);if(t.length!==(e?65:64))throw new Error("wrong signature length");var n={r:t.slice(0,32).toString("hex"),s:t.slice(32,64).toString("hex")};return e&&(n.recoveryParam=t[64]),n}var A={ES256K:function(r,e,t){var n=s(r),o=E(e),i=t.find(function(r){return b.keyFromPublic(r.publicKeyHex,"hex").verify(n,o)});if(!i)throw new Error("Signature invalid for JWT");return i},"ES256K-R":function(r,e,t){var n=E(e,!0),o=s(r),i=b.recoverPubKey(o,n,n.recoveryParam),a=i.encode("hex"),f=i.encode("hex",!0),h=u(a),c=t.find(function(r){var e=r.publicKeyHex;return e===a||e===f||r.ethereumAddress===h});if(!c)throw new Error("Signature invalid for JWT");return c},Ed25519:function(r,e,t){var n=g.decodeUTF8(r),o=h.decodeBase64Url(e),i=t.find(function(r){return w.sign.detached.verify(n,o,g.decodeBase64(r.publicKeyBase64))});if(!i)throw new Error("Signature invalid for JWT");return i}};function m(r){var e=A[r];if(!e)throw new Error("Unsupported algorithm "+r);return e}function U(r){function e(e){var t=e.r,n=e.s,a=e.recoveryParam,f=o.Buffer.alloc(r?65:64);if(o.Buffer.from(t,"hex").copy(f,0),o.Buffer.from(n,"hex").copy(f,32),r){if(void 0===a)throw new Error("Signer did not return a recoveryParam");f[64]=a}return i.encode(f)}return void 0===r&&(r=!1),function(r,t){try{return Promise.resolve(t(r)).then(e)}catch(r){return Promise.reject(r)}}}m.toSignatureObject=E;var x={ES256K:U(),"ES256K-R":U(!0),Ed25519:function(r,e){try{return Promise.resolve(e(r))}catch(r){return Promise.reject(r)}}};f(),h.registerNaclDID();var _={ES256K:["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],"ES256K-R":["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],Ed25519:["ED25519SignatureVerification"]},S={typ:"JWT"},B="ES256K";function T(r){return i.encode(JSON.stringify(r))}var M=300;function K(r){if(r.match(/^did:/))return r;if(t.isMNID(r))return"did:uport:"+r;throw new Error("Not a valid DID '"+r+"'")}function k(r){if(!r)throw new Error("no JWT passed into decodeJWT");var e=r.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(e)return{header:JSON.parse(i.decode(e[1])),payload:JSON.parse(i.decode(e[2])),signature:e[3],data:e[1]+"."+e[2]};throw new Error("Incorrect format JWT")}module.exports={SimpleSigner:function(r){var e=c.keyFromPrivate(r);return function(r){try{var t=e.sign(s(r)),n=t.s,o=t.recoveryParam;return Promise.resolve({r:l(t.r.toString("hex")),s:l(n.toString("hex")),recoveryParam:o})}catch(r){return Promise.reject(r)}}},NaclSigner:function(r){var e=g.decodeBase64(r);return function(r){try{return Promise.resolve(h.encodeBase64Url(w.sign.detached(g.decodeUTF8(r),e)))}catch(r){return Promise.reject(r)}}},verifyJWT:function(r,e){void 0===e&&(e={});try{var n=e.audience?K(e.audience):void 0,o=k(r),i=o.payload,f=o.header,h=o.signature,s=o.data;return Promise.resolve(function(r,e,t){try{var n=_[r];if(!n||0===n.length)throw new Error("No supported signature types for algorithm "+r);var o=K(e);return Promise.resolve(a(o)).then(function(e){if(!e)throw new Error("Unable to resolve DID document for "+o);var i=!t||(e.authentication||[]).map(function(r){return r.publicKey}),a=(e.publicKey||[]).filter(function(r){var e=r.type,o=r.id;return n.find(function(r){return r===e&&(!t||i.indexOf(o)>=0)})});if(t&&(!a||0===a.length))throw new Error("DID document for "+o+" does not have public keys suitable for authenticationg user");if(!a||0===a.length)throw new Error("DID document for "+o+" does not have public keys for "+r);return{authenticators:a,issuer:o,doc:e}})}catch(r){return Promise.reject(r)}}(f.alg,i.iss,e.auth)).then(function(o){var a,u=o.doc,c=o.authenticators,l=o.issuer,y=m(f.alg)(s,h,c),d=Math.floor(Date.now()/1e3);if(y){if(i.iat&&i.iat>d+M)throw new Error("JWT not valid yet (issued in the future): iat: "+i.iat+" > now: "+d);if(i.exp&&i.exp<=d-M)throw new Error("JWT has expired: exp: "+i.exp+" < now: "+d);if(i.aud)if((a=i.aud)&&(a.match(/^did:/)||t.isMNID(a))){if(!n)throw new Error("JWT audience is required but your app address has not been configured");if(n!==K(i.aud))throw new Error("JWT audience does not match your DID: aud: "+i.aud+" !== yours: "+n)}else{if(!e.callbackUrl)throw new Error("JWT audience matching your callback url is required but one wasn't passed in");if(i.aud!==e.callbackUrl)throw new Error("JWT audience does not match the callback url: aud: "+i.aud+" !== url: "+e.callbackUrl)}return{payload:i,doc:u,issuer:l,signer:y,jwt:r}}})}catch(r){return Promise.reject(r)}},createJWT:function(r,e){var t=e.issuer,n=e.signer,o=e.alg,i=e.expiresIn;try{if(!n)throw new Error("No Signer functionality has been configured");if(!t)throw new Error("No issuing DID has been configured");var a=Object.assign({},S,{alg:o||B}),f={iat:Math.floor(Date.now()/1e3)};if(i){if("number"!=typeof i)throw new Error("JWT expiresIn is not a number");f.exp=f.iat+Math.floor(i)}var h=[T(a),T(Object.assign({},f,r,{iss:t}))].join("."),s=function(r){var e=x[r];if(!e)throw new Error("Unsupported algorithm "+r);return e}(a.alg);return Promise.resolve(s(h,n)).then(function(r){return[h,r].join(".")})}catch(r){return Promise.reject(r)}},decodeJWT:k}}); | ||
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("js-sha256"),require("js-sha3"),require("mnid"),require("elliptic"),require("buffer"),require("base64url"),require("did-resolver"),require("uport-did-resolver"),require("nacl-did")):"function"==typeof define&&define.amd?define(["js-sha256","js-sha3","mnid","elliptic","buffer","base64url","did-resolver","uport-did-resolver","nacl-did"],e):e(r.jsSha256,r.jsSha3,r.mnid,r.elliptic,r.buffer,r.base64url,r.resolve,r.registerUport,r.naclDid)}(this,function(r,e,t,n,o,i,a,f,h){function s(e){return o.Buffer.from(r.sha256.arrayBuffer(e))}function u(r){return"0x"+(t=o.Buffer.from(r.slice(2),"hex"),o.Buffer.from(e.keccak_256.buffer(t))).slice(-20).toString("hex");var t}i=i&&i.hasOwnProperty("default")?i.default:i,a=a&&a.hasOwnProperty("default")?a.default:a,f=f&&f.hasOwnProperty("default")?f.default:f;var c=new n.ec("secp256k1");function l(r,e){return void 0===e&&(e=64),r.length===e?r:"0".repeat(e-r.length)+r}var y="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(r,e){return r(e={exports:{}},e.exports),e.exports}var p,v=(p={default:{}})&&p.default||p,w=d(function(r){!function(r){var e=function(r){var e,t=new Float64Array(16);if(r)for(e=0;e<r.length;e++)t[e]=r[e];return t},t=function(){throw new Error("no PRNG")},n=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=e(),a=e([1]),f=e([56129,1]),h=e([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),s=e([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=e([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),c=e([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=e([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function y(r,e,t,n){r[e]=t>>24&255,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=255&t,r[e+4]=n>>24&255,r[e+5]=n>>16&255,r[e+6]=n>>8&255,r[e+7]=255&n}function d(r,e,t,n,o){var i,a=0;for(i=0;i<o;i++)a|=r[e+i]^t[n+i];return(1&a-1>>>8)-1}function p(r,e,t,n){return d(r,e,t,n,16)}function w(r,e,t,n){return d(r,e,t,n,32)}function g(r,e,t,n){!function(r,e,t,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,s=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&t[16]|(255&t[17])<<8|(255&t[18])<<16|(255&t[19])<<24,w=255&t[20]|(255&t[21])<<8|(255&t[22])<<16|(255&t[23])<<24,g=255&t[24]|(255&t[25])<<8|(255&t[26])<<16|(255&t[27])<<24,b=255&t[28]|(255&t[29])<<8|(255&t[30])<<16|(255&t[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,A=i,m=a,U=f,x=h,_=s,S=u,B=c,T=l,M=y,K=d,k=p,P=v,j=w,Y=g,D=b,z=E,I=0;I<20;I+=2)A^=(o=(j^=(o=(M^=(o=(_^=(o=A+j|0)<<7|o>>>25)+A|0)<<9|o>>>23)+_|0)<<13|o>>>19)+M|0)<<18|o>>>14,S^=(o=(m^=(o=(Y^=(o=(K^=(o=S+m|0)<<7|o>>>25)+S|0)<<9|o>>>23)+K|0)<<13|o>>>19)+Y|0)<<18|o>>>14,k^=(o=(B^=(o=(U^=(o=(D^=(o=k+B|0)<<7|o>>>25)+k|0)<<9|o>>>23)+D|0)<<13|o>>>19)+U|0)<<18|o>>>14,z^=(o=(P^=(o=(T^=(o=(x^=(o=z+P|0)<<7|o>>>25)+z|0)<<9|o>>>23)+x|0)<<13|o>>>19)+T|0)<<18|o>>>14,A^=(o=(x^=(o=(U^=(o=(m^=(o=A+x|0)<<7|o>>>25)+A|0)<<9|o>>>23)+m|0)<<13|o>>>19)+U|0)<<18|o>>>14,S^=(o=(_^=(o=(T^=(o=(B^=(o=S+_|0)<<7|o>>>25)+S|0)<<9|o>>>23)+B|0)<<13|o>>>19)+T|0)<<18|o>>>14,k^=(o=(K^=(o=(M^=(o=(P^=(o=k+K|0)<<7|o>>>25)+k|0)<<9|o>>>23)+P|0)<<13|o>>>19)+M|0)<<18|o>>>14,z^=(o=(D^=(o=(Y^=(o=(j^=(o=z+D|0)<<7|o>>>25)+z|0)<<9|o>>>23)+j|0)<<13|o>>>19)+Y|0)<<18|o>>>14;m=m+a|0,U=U+f|0,x=x+h|0,_=_+s|0,S=S+u|0,B=B+c|0,T=T+l|0,M=M+y|0,K=K+d|0,k=k+p|0,P=P+v|0,j=j+w|0,Y=Y+g|0,D=D+b|0,z=z+E|0,r[0]=(A=A+i|0)>>>0&255,r[1]=A>>>8&255,r[2]=A>>>16&255,r[3]=A>>>24&255,r[4]=m>>>0&255,r[5]=m>>>8&255,r[6]=m>>>16&255,r[7]=m>>>24&255,r[8]=U>>>0&255,r[9]=U>>>8&255,r[10]=U>>>16&255,r[11]=U>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=_>>>0&255,r[17]=_>>>8&255,r[18]=_>>>16&255,r[19]=_>>>24&255,r[20]=S>>>0&255,r[21]=S>>>8&255,r[22]=S>>>16&255,r[23]=S>>>24&255,r[24]=B>>>0&255,r[25]=B>>>8&255,r[26]=B>>>16&255,r[27]=B>>>24&255,r[28]=T>>>0&255,r[29]=T>>>8&255,r[30]=T>>>16&255,r[31]=T>>>24&255,r[32]=M>>>0&255,r[33]=M>>>8&255,r[34]=M>>>16&255,r[35]=M>>>24&255,r[36]=K>>>0&255,r[37]=K>>>8&255,r[38]=K>>>16&255,r[39]=K>>>24&255,r[40]=k>>>0&255,r[41]=k>>>8&255,r[42]=k>>>16&255,r[43]=k>>>24&255,r[44]=P>>>0&255,r[45]=P>>>8&255,r[46]=P>>>16&255,r[47]=P>>>24&255,r[48]=j>>>0&255,r[49]=j>>>8&255,r[50]=j>>>16&255,r[51]=j>>>24&255,r[52]=Y>>>0&255,r[53]=Y>>>8&255,r[54]=Y>>>16&255,r[55]=Y>>>24&255,r[56]=D>>>0&255,r[57]=D>>>8&255,r[58]=D>>>16&255,r[59]=D>>>24&255,r[60]=z>>>0&255,r[61]=z>>>8&255,r[62]=z>>>16&255,r[63]=z>>>24&255}(r,e,t,n)}function b(r,e,t,n){!function(r,e,t,n){for(var o,i=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,f=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,h=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,s=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,l=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,y=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,d=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,v=255&t[16]|(255&t[17])<<8|(255&t[18])<<16|(255&t[19])<<24,w=255&t[20]|(255&t[21])<<8|(255&t[22])<<16|(255&t[23])<<24,g=255&t[24]|(255&t[25])<<8|(255&t[26])<<16|(255&t[27])<<24,b=255&t[28]|(255&t[29])<<8|(255&t[30])<<16|(255&t[31])<<24,E=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,A=0;A<20;A+=2)i^=(o=(w^=(o=(y^=(o=(s^=(o=i+w|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+y|0)<<18|o>>>14,u^=(o=(a^=(o=(g^=(o=(d^=(o=u+a|0)<<7|o>>>25)+u|0)<<9|o>>>23)+d|0)<<13|o>>>19)+g|0)<<18|o>>>14,p^=(o=(c^=(o=(f^=(o=(b^=(o=p+c|0)<<7|o>>>25)+p|0)<<9|o>>>23)+b|0)<<13|o>>>19)+f|0)<<18|o>>>14,E^=(o=(v^=(o=(l^=(o=(h^=(o=E+v|0)<<7|o>>>25)+E|0)<<9|o>>>23)+h|0)<<13|o>>>19)+l|0)<<18|o>>>14,i^=(o=(h^=(o=(f^=(o=(a^=(o=i+h|0)<<7|o>>>25)+i|0)<<9|o>>>23)+a|0)<<13|o>>>19)+f|0)<<18|o>>>14,u^=(o=(s^=(o=(l^=(o=(c^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+c|0)<<13|o>>>19)+l|0)<<18|o>>>14,p^=(o=(d^=(o=(y^=(o=(v^=(o=p+d|0)<<7|o>>>25)+p|0)<<9|o>>>23)+v|0)<<13|o>>>19)+y|0)<<18|o>>>14,E^=(o=(b^=(o=(g^=(o=(w^=(o=E+b|0)<<7|o>>>25)+E|0)<<9|o>>>23)+w|0)<<13|o>>>19)+g|0)<<18|o>>>14;r[0]=i>>>0&255,r[1]=i>>>8&255,r[2]=i>>>16&255,r[3]=i>>>24&255,r[4]=u>>>0&255,r[5]=u>>>8&255,r[6]=u>>>16&255,r[7]=u>>>24&255,r[8]=p>>>0&255,r[9]=p>>>8&255,r[10]=p>>>16&255,r[11]=p>>>24&255,r[12]=E>>>0&255,r[13]=E>>>8&255,r[14]=E>>>16&255,r[15]=E>>>24&255,r[16]=c>>>0&255,r[17]=c>>>8&255,r[18]=c>>>16&255,r[19]=c>>>24&255,r[20]=l>>>0&255,r[21]=l>>>8&255,r[22]=l>>>16&255,r[23]=l>>>24&255,r[24]=y>>>0&255,r[25]=y>>>8&255,r[26]=y>>>16&255,r[27]=y>>>24&255,r[28]=d>>>0&255,r[29]=d>>>8&255,r[30]=d>>>16&255,r[31]=d>>>24&255}(r,e,t,n)}var E=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function A(r,e,t,n,o,i,a){var f,h,s=new Uint8Array(16),u=new Uint8Array(64);for(h=0;h<16;h++)s[h]=0;for(h=0;h<8;h++)s[h]=i[h];for(;o>=64;){for(g(u,s,a,E),h=0;h<64;h++)r[e+h]=t[n+h]^u[h];for(f=1,h=8;h<16;h++)s[h]=255&(f=f+(255&s[h])|0),f>>>=8;o-=64,e+=64,n+=64}if(o>0)for(g(u,s,a,E),h=0;h<o;h++)r[e+h]=t[n+h]^u[h];return 0}function m(r,e,t,n,o){var i,a,f=new Uint8Array(16),h=new Uint8Array(64);for(a=0;a<16;a++)f[a]=0;for(a=0;a<8;a++)f[a]=n[a];for(;t>=64;){for(g(h,f,o,E),a=0;a<64;a++)r[e+a]=h[a];for(i=1,a=8;a<16;a++)f[a]=255&(i=i+(255&f[a])|0),i>>>=8;t-=64,e+=64}if(t>0)for(g(h,f,o,E),a=0;a<t;a++)r[e+a]=h[a];return 0}function U(r,e,t,n,o){var i=new Uint8Array(32);b(i,n,o,E);for(var a=new Uint8Array(8),f=0;f<8;f++)a[f]=n[f+16];return m(r,e,t,a,i)}function x(r,e,t,n,o,i,a){var f=new Uint8Array(32);b(f,i,a,E);for(var h=new Uint8Array(8),s=0;s<8;s++)h[s]=i[s+16];return A(r,e,t,n,o,h,f)}var _=function(r){var e,t,n,o,i,a,f,h;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,this.r[0]=8191&(e=255&r[0]|(255&r[1])<<8),this.r[1]=8191&(e>>>13|(t=255&r[2]|(255&r[3])<<8)<<3),this.r[2]=7939&(t>>>10|(n=255&r[4]|(255&r[5])<<8)<<6),this.r[3]=8191&(n>>>7|(o=255&r[6]|(255&r[7])<<8)<<9),this.r[4]=255&(o>>>4|(i=255&r[8]|(255&r[9])<<8)<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|(a=255&r[10]|(255&r[11])<<8)<<2),this.r[7]=8065&(a>>>11|(f=255&r[12]|(255&r[13])<<8)<<5),this.r[8]=8191&(f>>>8|(h=255&r[14]|(255&r[15])<<8)<<8),this.r[9]=h>>>5&127,this.pad[0]=255&r[16]|(255&r[17])<<8,this.pad[1]=255&r[18]|(255&r[19])<<8,this.pad[2]=255&r[20]|(255&r[21])<<8,this.pad[3]=255&r[22]|(255&r[23])<<8,this.pad[4]=255&r[24]|(255&r[25])<<8,this.pad[5]=255&r[26]|(255&r[27])<<8,this.pad[6]=255&r[28]|(255&r[29])<<8,this.pad[7]=255&r[30]|(255&r[31])<<8};function S(r,e,t,n,o,i){var a=new _(i);return a.update(t,n,o),a.finish(r,e),0}function B(r,e,t,n,o,i){var a=new Uint8Array(16);return S(a,0,t,n,o,i),p(r,e,a,0)}function T(r,e,t,n,o){var i;if(t<32)return-1;for(x(r,0,e,0,t,n,o),S(r,16,r,32,t-32,r),i=0;i<16;i++)r[i]=0;return 0}function M(r,e,t,n,o){var i,a=new Uint8Array(32);if(t<32)return-1;if(U(a,0,32,n,o),0!==B(e,16,e,32,t-32,a))return-1;for(x(r,0,e,0,t,n,o),i=0;i<32;i++)r[i]=0;return 0}function K(r,e){var t;for(t=0;t<16;t++)r[t]=0|e[t]}function k(r){var e,t,n=1;for(e=0;e<16;e++)t=r[e]+n+65535,n=Math.floor(t/65536),r[e]=t-65536*n;r[0]+=n-1+37*(n-1)}function P(r,e,t){for(var n,o=~(t-1),i=0;i<16;i++)r[i]^=n=o&(r[i]^e[i]),e[i]^=n}function j(r,t){var n,o,i,a=e(),f=e();for(n=0;n<16;n++)f[n]=t[n];for(k(f),k(f),k(f),o=0;o<2;o++){for(a[0]=f[0]-65517,n=1;n<15;n++)a[n]=f[n]-65535-(a[n-1]>>16&1),a[n-1]&=65535;a[15]=f[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,P(f,a,1-i)}for(n=0;n<16;n++)r[2*n]=255&f[n],r[2*n+1]=f[n]>>8}function Y(r,e){var t=new Uint8Array(32),n=new Uint8Array(32);return j(t,r),j(n,e),w(t,0,n,0)}function D(r){var e=new Uint8Array(32);return j(e,r),1&e[0]}function z(r,e){var t;for(t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function I(r,e,t){for(var n=0;n<16;n++)r[n]=e[n]+t[n]}function J(r,e,t){for(var n=0;n<16;n++)r[n]=e[n]-t[n]}function N(r,e,t){var n,o,i=0,a=0,f=0,h=0,s=0,u=0,c=0,l=0,y=0,d=0,p=0,v=0,w=0,g=0,b=0,E=0,A=0,m=0,U=0,x=0,_=0,S=0,B=0,T=0,M=0,K=0,k=0,P=0,j=0,Y=0,D=0,z=t[0],I=t[1],J=t[2],N=t[3],O=t[4],L=t[5],R=t[6],W=t[7],C=t[8],F=t[9],q=t[10],Z=t[11],V=t[12],G=t[13],H=t[14],X=t[15];i+=(n=e[0])*z,a+=n*I,f+=n*J,h+=n*N,s+=n*O,u+=n*L,c+=n*R,l+=n*W,y+=n*C,d+=n*F,p+=n*q,v+=n*Z,w+=n*V,g+=n*G,b+=n*H,E+=n*X,a+=(n=e[1])*z,f+=n*I,h+=n*J,s+=n*N,u+=n*O,c+=n*L,l+=n*R,y+=n*W,d+=n*C,p+=n*F,v+=n*q,w+=n*Z,g+=n*V,b+=n*G,E+=n*H,A+=n*X,f+=(n=e[2])*z,h+=n*I,s+=n*J,u+=n*N,c+=n*O,l+=n*L,y+=n*R,d+=n*W,p+=n*C,v+=n*F,w+=n*q,g+=n*Z,b+=n*V,E+=n*G,A+=n*H,m+=n*X,h+=(n=e[3])*z,s+=n*I,u+=n*J,c+=n*N,l+=n*O,y+=n*L,d+=n*R,p+=n*W,v+=n*C,w+=n*F,g+=n*q,b+=n*Z,E+=n*V,A+=n*G,m+=n*H,U+=n*X,s+=(n=e[4])*z,u+=n*I,c+=n*J,l+=n*N,y+=n*O,d+=n*L,p+=n*R,v+=n*W,w+=n*C,g+=n*F,b+=n*q,E+=n*Z,A+=n*V,m+=n*G,U+=n*H,x+=n*X,u+=(n=e[5])*z,c+=n*I,l+=n*J,y+=n*N,d+=n*O,p+=n*L,v+=n*R,w+=n*W,g+=n*C,b+=n*F,E+=n*q,A+=n*Z,m+=n*V,U+=n*G,x+=n*H,_+=n*X,c+=(n=e[6])*z,l+=n*I,y+=n*J,d+=n*N,p+=n*O,v+=n*L,w+=n*R,g+=n*W,b+=n*C,E+=n*F,A+=n*q,m+=n*Z,U+=n*V,x+=n*G,_+=n*H,S+=n*X,l+=(n=e[7])*z,y+=n*I,d+=n*J,p+=n*N,v+=n*O,w+=n*L,g+=n*R,b+=n*W,E+=n*C,A+=n*F,m+=n*q,U+=n*Z,x+=n*V,_+=n*G,S+=n*H,B+=n*X,y+=(n=e[8])*z,d+=n*I,p+=n*J,v+=n*N,w+=n*O,g+=n*L,b+=n*R,E+=n*W,A+=n*C,m+=n*F,U+=n*q,x+=n*Z,_+=n*V,S+=n*G,B+=n*H,T+=n*X,d+=(n=e[9])*z,p+=n*I,v+=n*J,w+=n*N,g+=n*O,b+=n*L,E+=n*R,A+=n*W,m+=n*C,U+=n*F,x+=n*q,_+=n*Z,S+=n*V,B+=n*G,T+=n*H,M+=n*X,p+=(n=e[10])*z,v+=n*I,w+=n*J,g+=n*N,b+=n*O,E+=n*L,A+=n*R,m+=n*W,U+=n*C,x+=n*F,_+=n*q,S+=n*Z,B+=n*V,T+=n*G,M+=n*H,K+=n*X,v+=(n=e[11])*z,w+=n*I,g+=n*J,b+=n*N,E+=n*O,A+=n*L,m+=n*R,U+=n*W,x+=n*C,_+=n*F,S+=n*q,B+=n*Z,T+=n*V,M+=n*G,K+=n*H,k+=n*X,w+=(n=e[12])*z,g+=n*I,b+=n*J,E+=n*N,A+=n*O,m+=n*L,U+=n*R,x+=n*W,_+=n*C,S+=n*F,B+=n*q,T+=n*Z,M+=n*V,K+=n*G,k+=n*H,P+=n*X,g+=(n=e[13])*z,b+=n*I,E+=n*J,A+=n*N,m+=n*O,U+=n*L,x+=n*R,_+=n*W,S+=n*C,B+=n*F,T+=n*q,M+=n*Z,K+=n*V,k+=n*G,P+=n*H,j+=n*X,b+=(n=e[14])*z,E+=n*I,A+=n*J,m+=n*N,U+=n*O,x+=n*L,_+=n*R,S+=n*W,B+=n*C,T+=n*F,M+=n*q,K+=n*Z,k+=n*V,P+=n*G,j+=n*H,Y+=n*X,E+=(n=e[15])*z,a+=38*(m+=n*J),f+=38*(U+=n*N),h+=38*(x+=n*O),s+=38*(_+=n*L),u+=38*(S+=n*R),c+=38*(B+=n*W),l+=38*(T+=n*C),y+=38*(M+=n*F),d+=38*(K+=n*q),p+=38*(k+=n*Z),v+=38*(P+=n*V),w+=38*(j+=n*G),g+=38*(Y+=n*H),b+=38*(D+=n*X),i=(n=(i+=38*(A+=n*I))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),i=(n=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(n/65536)),a=(n=a+o+65535)-65536*(o=Math.floor(n/65536)),f=(n=f+o+65535)-65536*(o=Math.floor(n/65536)),h=(n=h+o+65535)-65536*(o=Math.floor(n/65536)),s=(n=s+o+65535)-65536*(o=Math.floor(n/65536)),u=(n=u+o+65535)-65536*(o=Math.floor(n/65536)),c=(n=c+o+65535)-65536*(o=Math.floor(n/65536)),l=(n=l+o+65535)-65536*(o=Math.floor(n/65536)),y=(n=y+o+65535)-65536*(o=Math.floor(n/65536)),d=(n=d+o+65535)-65536*(o=Math.floor(n/65536)),p=(n=p+o+65535)-65536*(o=Math.floor(n/65536)),v=(n=v+o+65535)-65536*(o=Math.floor(n/65536)),w=(n=w+o+65535)-65536*(o=Math.floor(n/65536)),g=(n=g+o+65535)-65536*(o=Math.floor(n/65536)),b=(n=b+o+65535)-65536*(o=Math.floor(n/65536)),E=(n=E+o+65535)-65536*(o=Math.floor(n/65536)),r[0]=i+=o-1+37*(o-1),r[1]=a,r[2]=f,r[3]=h,r[4]=s,r[5]=u,r[6]=c,r[7]=l,r[8]=y,r[9]=d,r[10]=p,r[11]=v,r[12]=w,r[13]=g,r[14]=b,r[15]=E}function O(r,e){N(r,e,e)}function L(r,t){var n,o=e();for(n=0;n<16;n++)o[n]=t[n];for(n=253;n>=0;n--)O(o,o),2!==n&&4!==n&&N(o,o,t);for(n=0;n<16;n++)r[n]=o[n]}function R(r,t,n){var o,i,a=new Uint8Array(32),h=new Float64Array(80),s=e(),u=e(),c=e(),l=e(),y=e(),d=e();for(i=0;i<31;i++)a[i]=t[i];for(a[31]=127&t[31]|64,a[0]&=248,z(h,n),i=0;i<16;i++)u[i]=h[i],l[i]=s[i]=c[i]=0;for(s[0]=l[0]=1,i=254;i>=0;--i)P(s,u,o=a[i>>>3]>>>(7&i)&1),P(c,l,o),I(y,s,c),J(s,s,c),I(c,u,l),J(u,u,l),O(l,y),O(d,s),N(s,c,s),N(c,u,y),I(y,s,c),J(s,s,c),O(u,s),J(c,l,d),N(s,c,f),I(s,s,l),N(c,c,s),N(s,l,d),N(l,u,h),O(u,y),P(s,u,o),P(c,l,o);for(i=0;i<16;i++)h[i+16]=s[i],h[i+32]=c[i],h[i+48]=u[i],h[i+64]=l[i];var p=h.subarray(32),v=h.subarray(16);return L(p,p),N(v,v,p),j(r,v),0}function W(r,e){return R(r,e,o)}function C(r,e){return t(e,32),W(r,e)}function F(r,e,t){var o=new Uint8Array(32);return R(o,t,e),b(r,n,o,E)}_.prototype.blocks=function(r,e,t){for(var n,o,i,a,f,h,s,u,c,l,y,d,p,v,w,g,b,E,A,m=this.fin?0:2048,U=this.h[0],x=this.h[1],_=this.h[2],S=this.h[3],B=this.h[4],T=this.h[5],M=this.h[6],K=this.h[7],k=this.h[8],P=this.h[9],j=this.r[0],Y=this.r[1],D=this.r[2],z=this.r[3],I=this.r[4],J=this.r[5],N=this.r[6],O=this.r[7],L=this.r[8],R=this.r[9];t>=16;)l=c=0,l+=(U+=8191&(n=255&r[e+0]|(255&r[e+1])<<8))*j,l+=(x+=8191&(n>>>13|(o=255&r[e+2]|(255&r[e+3])<<8)<<3))*(5*R),l+=(_+=8191&(o>>>10|(i=255&r[e+4]|(255&r[e+5])<<8)<<6))*(5*L),l+=(S+=8191&(i>>>7|(a=255&r[e+6]|(255&r[e+7])<<8)<<9))*(5*O),c=(l+=(B+=8191&(a>>>4|(f=255&r[e+8]|(255&r[e+9])<<8)<<12))*(5*N))>>>13,l&=8191,l+=(T+=f>>>1&8191)*(5*J),l+=(M+=8191&(f>>>14|(h=255&r[e+10]|(255&r[e+11])<<8)<<2))*(5*I),l+=(K+=8191&(h>>>11|(s=255&r[e+12]|(255&r[e+13])<<8)<<5))*(5*z),l+=(k+=8191&(s>>>8|(u=255&r[e+14]|(255&r[e+15])<<8)<<8))*(5*D),y=c+=(l+=(P+=u>>>5|m)*(5*Y))>>>13,y+=U*Y,y+=x*j,y+=_*(5*R),y+=S*(5*L),c=(y+=B*(5*O))>>>13,y&=8191,y+=T*(5*N),y+=M*(5*J),y+=K*(5*I),y+=k*(5*z),c+=(y+=P*(5*D))>>>13,y&=8191,d=c,d+=U*D,d+=x*Y,d+=_*j,d+=S*(5*R),c=(d+=B*(5*L))>>>13,d&=8191,d+=T*(5*O),d+=M*(5*N),d+=K*(5*J),d+=k*(5*I),p=c+=(d+=P*(5*z))>>>13,p+=U*z,p+=x*D,p+=_*Y,p+=S*j,c=(p+=B*(5*R))>>>13,p&=8191,p+=T*(5*L),p+=M*(5*O),p+=K*(5*N),p+=k*(5*J),v=c+=(p+=P*(5*I))>>>13,v+=U*I,v+=x*z,v+=_*D,v+=S*Y,c=(v+=B*j)>>>13,v&=8191,v+=T*(5*R),v+=M*(5*L),v+=K*(5*O),v+=k*(5*N),w=c+=(v+=P*(5*J))>>>13,w+=U*J,w+=x*I,w+=_*z,w+=S*D,c=(w+=B*Y)>>>13,w&=8191,w+=T*j,w+=M*(5*R),w+=K*(5*L),w+=k*(5*O),g=c+=(w+=P*(5*N))>>>13,g+=U*N,g+=x*J,g+=_*I,g+=S*z,c=(g+=B*D)>>>13,g&=8191,g+=T*Y,g+=M*j,g+=K*(5*R),g+=k*(5*L),b=c+=(g+=P*(5*O))>>>13,b+=U*O,b+=x*N,b+=_*J,b+=S*I,c=(b+=B*z)>>>13,b&=8191,b+=T*D,b+=M*Y,b+=K*j,b+=k*(5*R),E=c+=(b+=P*(5*L))>>>13,E+=U*L,E+=x*O,E+=_*N,E+=S*J,c=(E+=B*I)>>>13,E&=8191,E+=T*z,E+=M*D,E+=K*Y,E+=k*j,A=c+=(E+=P*(5*R))>>>13,A+=U*R,A+=x*L,A+=_*O,A+=S*N,c=(A+=B*J)>>>13,A&=8191,A+=T*I,A+=M*z,A+=K*D,A+=k*Y,U=l=8191&(c=(c=((c+=(A+=P*j)>>>13)<<2)+c|0)+(l&=8191)|0),x=y+=c>>>=13,_=d&=8191,S=p&=8191,B=v&=8191,T=w&=8191,M=g&=8191,K=b&=8191,k=E&=8191,P=A&=8191,e+=16,t-=16;this.h[0]=U,this.h[1]=x,this.h[2]=_,this.h[3]=S,this.h[4]=B,this.h[5]=T,this.h[6]=M,this.h[7]=K,this.h[8]=k,this.h[9]=P},_.prototype.finish=function(r,e){var t,n,o,i,a=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;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;i<10;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,a[0]=this.h[0]+5,t=a[0]>>>13,a[0]&=8191,i=1;i<10;i++)a[i]=this.h[i]+t,t=a[i]>>>13,a[i]&=8191;for(a[9]-=8192,n=(1^t)-1,i=0;i<10;i++)a[i]&=n;for(n=~n,i=0;i<10;i++)this.h[i]=this.h[i]&n|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),this.h[0]=65535&(o=this.h[0]+this.pad[0]),i=1;i<8;i++)this.h[i]=65535&(o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0);r[e+0]=this.h[0]>>>0&255,r[e+1]=this.h[0]>>>8&255,r[e+2]=this.h[1]>>>0&255,r[e+3]=this.h[1]>>>8&255,r[e+4]=this.h[2]>>>0&255,r[e+5]=this.h[2]>>>8&255,r[e+6]=this.h[3]>>>0&255,r[e+7]=this.h[3]>>>8&255,r[e+8]=this.h[4]>>>0&255,r[e+9]=this.h[4]>>>8&255,r[e+10]=this.h[5]>>>0&255,r[e+11]=this.h[5]>>>8&255,r[e+12]=this.h[6]>>>0&255,r[e+13]=this.h[6]>>>8&255,r[e+14]=this.h[7]>>>0&255,r[e+15]=this.h[7]>>>8&255},_.prototype.update=function(r,e,t){var n,o;if(this.leftover){for((o=16-this.leftover)>t&&(o=t),n=0;n<o;n++)this.buffer[this.leftover+n]=r[e+n];if(t-=o,e+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(t>=16&&(this.blocks(r,e,o=t-t%16),e+=o,t-=o),t){for(n=0;n<t;n++)this.buffer[this.leftover+n]=r[e+n];this.leftover+=t}};var q=T,Z=M;var V=[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];function G(r,e,t,n){for(var o,i,a,f,h,s,u,c,l,y,d,p,v,w,g,b,E,A,m,U,x,_,S=new Int32Array(16),B=new Int32Array(16),T=r[0],M=r[1],K=r[2],k=r[3],P=r[4],j=r[5],Y=r[6],D=r[7],z=e[0],I=e[1],J=e[2],N=e[3],O=e[4],L=e[5],R=e[6],W=e[7],C=0;n>=128;){for(g=0;g<16;g++)S[g]=t[(b=8*g+C)+0]<<24|t[b+1]<<16|t[b+2]<<8|t[b+3],B[g]=t[b+4]<<24|t[b+5]<<16|t[b+6]<<8|t[b+7];for(g=0;g<80;g++)if(o=M,i=K,a=P,f=j,h=Y,D,u=I,c=J,l=O,y=L,d=R,W,m=65535&(A=W),U=A>>>16,x=65535&(E=D),_=E>>>16,m+=65535&(A=(O>>>14|P<<18)^(O>>>18|P<<14)^(P>>>9|O<<23)),U+=A>>>16,x+=65535&(E=(P>>>14|O<<18)^(P>>>18|O<<14)^(O>>>9|P<<23)),_+=E>>>16,m+=65535&(A=O&L^~O&R),U+=A>>>16,x+=65535&(E=P&j^~P&Y),_+=E>>>16,m+=65535&(A=V[2*g+1]),U+=A>>>16,x+=65535&(E=V[2*g]),_+=E>>>16,U+=(A=B[g%16])>>>16,x+=65535&(E=S[g%16]),_+=E>>>16,x+=(U+=(m+=65535&A)>>>16)>>>16,m=65535&(A=w=65535&m|U<<16),U=A>>>16,x=65535&(E=v=65535&x|(_+=x>>>16)<<16),_=E>>>16,m+=65535&(A=(z>>>28|T<<4)^(T>>>2|z<<30)^(T>>>7|z<<25)),U+=A>>>16,x+=65535&(E=(T>>>28|z<<4)^(z>>>2|T<<30)^(z>>>7|T<<25)),_+=E>>>16,U+=(A=z&I^z&J^I&J)>>>16,x+=65535&(E=T&M^T&K^M&K),_+=E>>>16,s=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,p=65535&m|U<<16,m=65535&(A=N),U=A>>>16,x=65535&(E=k),_=E>>>16,U+=(A=w)>>>16,x+=65535&(E=v),_+=E>>>16,M=T,K=o,k=i,P=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,j=a,Y=f,D=h,T=s,I=z,J=u,N=c,O=65535&m|U<<16,L=l,R=y,W=d,z=p,g%16==15)for(b=0;b<16;b++)m=65535&(A=B[b]),U=A>>>16,x=65535&(E=S[b]),_=E>>>16,m+=65535&(A=B[(b+9)%16]),U+=A>>>16,x+=65535&(E=S[(b+9)%16]),_+=E>>>16,m+=65535&(A=((w=B[(b+1)%16])>>>1|(v=S[(b+1)%16])<<31)^(w>>>8|v<<24)^(w>>>7|v<<25)),U+=A>>>16,x+=65535&(E=(v>>>1|w<<31)^(v>>>8|w<<24)^v>>>7),_+=E>>>16,U+=(A=((w=B[(b+14)%16])>>>19|(v=S[(b+14)%16])<<13)^(v>>>29|w<<3)^(w>>>6|v<<26))>>>16,x+=65535&(E=(v>>>19|w<<13)^(w>>>29|v<<3)^v>>>6),_+=E>>>16,S[b]=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,B[b]=65535&m|U<<16;m=65535&(A=z),U=A>>>16,x=65535&(E=T),_=E>>>16,U+=(A=e[0])>>>16,x+=65535&(E=r[0]),_+=E>>>16,r[0]=T=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[0]=z=65535&m|U<<16,m=65535&(A=I),U=A>>>16,x=65535&(E=M),_=E>>>16,U+=(A=e[1])>>>16,x+=65535&(E=r[1]),_+=E>>>16,r[1]=M=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[1]=I=65535&m|U<<16,m=65535&(A=J),U=A>>>16,x=65535&(E=K),_=E>>>16,U+=(A=e[2])>>>16,x+=65535&(E=r[2]),_+=E>>>16,r[2]=K=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[2]=J=65535&m|U<<16,m=65535&(A=N),U=A>>>16,x=65535&(E=k),_=E>>>16,U+=(A=e[3])>>>16,x+=65535&(E=r[3]),_+=E>>>16,r[3]=k=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[3]=N=65535&m|U<<16,m=65535&(A=O),U=A>>>16,x=65535&(E=P),_=E>>>16,U+=(A=e[4])>>>16,x+=65535&(E=r[4]),_+=E>>>16,r[4]=P=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[4]=O=65535&m|U<<16,m=65535&(A=L),U=A>>>16,x=65535&(E=j),_=E>>>16,U+=(A=e[5])>>>16,x+=65535&(E=r[5]),_+=E>>>16,r[5]=j=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[5]=L=65535&m|U<<16,m=65535&(A=R),U=A>>>16,x=65535&(E=Y),_=E>>>16,U+=(A=e[6])>>>16,x+=65535&(E=r[6]),_+=E>>>16,r[6]=Y=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[6]=R=65535&m|U<<16,m=65535&(A=W),U=A>>>16,x=65535&(E=D),_=E>>>16,U+=(A=e[7])>>>16,x+=65535&(E=r[7]),_+=E>>>16,r[7]=D=65535&(x+=(U+=(m+=65535&A)>>>16)>>>16)|(_+=x>>>16)<<16,e[7]=W=65535&m|U<<16,C+=128,n-=128}return n}function H(r,e,t){var n,o=new Int32Array(8),i=new Int32Array(8),a=new Uint8Array(256),f=t;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,G(o,i,e,t),t%=128,n=0;n<t;n++)a[n]=e[f-t+n];for(a[t]=128,a[(t=256-128*(t<112?1:0))-9]=0,y(a,t-8,f/536870912|0,f<<3),G(o,i,a,t),n=0;n<8;n++)y(r,8*n,o[n],i[n]);return 0}function X(r,t){var n=e(),o=e(),i=e(),a=e(),f=e(),h=e(),u=e(),c=e(),l=e();J(n,r[1],r[0]),J(l,t[1],t[0]),N(n,n,l),I(o,r[0],r[1]),I(l,t[0],t[1]),N(o,o,l),N(i,r[3],t[3]),N(i,i,s),N(a,r[2],t[2]),I(a,a,a),J(f,o,n),J(h,a,i),I(u,a,i),I(c,o,n),N(r[0],f,h),N(r[1],c,u),N(r[2],u,h),N(r[3],f,c)}function $(r,e,t){var n;for(n=0;n<4;n++)P(r[n],e[n],t)}function Q(r,t){var n=e(),o=e(),i=e();L(i,t[2]),N(n,t[0],i),N(o,t[1],i),j(r,o),r[31]^=D(n)<<7}function rr(r,e,t){var n,o;for(K(r[0],i),K(r[1],a),K(r[2],a),K(r[3],i),o=255;o>=0;--o)$(r,e,n=t[o/8|0]>>(7&o)&1),X(e,r),X(r,r),$(r,e,n)}function er(r,t){var n=[e(),e(),e(),e()];K(n[0],u),K(n[1],c),K(n[2],a),N(n[3],u,c),rr(r,n,t)}function tr(r,n,o){var i,a=new Uint8Array(64),f=[e(),e(),e(),e()];for(o||t(n,32),H(a,n,32),a[0]&=248,a[31]&=127,a[31]|=64,er(f,a),Q(r,f),i=0;i<32;i++)n[i+32]=r[i];return 0}var nr=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]);function or(r,e){var t,n,o,i;for(n=63;n>=32;--n){for(t=0,o=n-32,i=n-12;o<i;++o)e[o]+=t-16*e[n]*nr[o-(n-32)],e[o]-=256*(t=e[o]+128>>8);e[o]+=t,e[n]=0}for(t=0,o=0;o<32;o++)e[o]+=t-(e[31]>>4)*nr[o],t=e[o]>>8,e[o]&=255;for(o=0;o<32;o++)e[o]-=t*nr[o];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,r[n]=255&e[n]}function ir(r){var e,t=new Float64Array(64);for(e=0;e<64;e++)t[e]=r[e];for(e=0;e<64;e++)r[e]=0;or(r,t)}function ar(r,t,n,o){var i,a,f=new Uint8Array(64),h=new Uint8Array(64),s=new Uint8Array(64),u=new Float64Array(64),c=[e(),e(),e(),e()];H(f,o,32),f[0]&=248,f[31]&=127,f[31]|=64;var l=n+64;for(i=0;i<n;i++)r[64+i]=t[i];for(i=0;i<32;i++)r[32+i]=f[32+i];for(H(s,r.subarray(32),n+32),ir(s),er(c,s),Q(r,c),i=32;i<64;i++)r[i]=o[i];for(H(h,r,n+64),ir(h),i=0;i<64;i++)u[i]=0;for(i=0;i<32;i++)u[i]=s[i];for(i=0;i<32;i++)for(a=0;a<32;a++)u[i+a]+=h[i]*f[a];return or(r.subarray(32),u),l}function fr(r,t){var n=e(),o=e(),f=e(),s=e(),u=e(),c=e(),y=e();return K(r[2],a),z(r[1],t),O(f,r[1]),N(s,f,h),J(f,f,r[2]),I(s,r[2],s),O(u,s),O(c,u),N(y,c,u),N(n,y,f),N(n,n,s),function(r,t){var n,o=e();for(n=0;n<16;n++)o[n]=t[n];for(n=250;n>=0;n--)O(o,o),1!==n&&N(o,o,t);for(n=0;n<16;n++)r[n]=o[n]}(n,n),N(n,n,f),N(n,n,s),N(n,n,s),N(r[0],n,s),O(o,r[0]),N(o,o,s),Y(o,f)&&N(r[0],r[0],l),O(o,r[0]),N(o,o,s),Y(o,f)?-1:(D(r[0])===t[31]>>7&&J(r[0],i,r[0]),N(r[3],r[0],r[1]),0)}function hr(r,t,n,o){var i,a=new Uint8Array(32),f=new Uint8Array(64),h=[e(),e(),e(),e()],s=[e(),e(),e(),e()];if(-1,n<64)return-1;if(fr(s,o))return-1;for(i=0;i<n;i++)r[i]=t[i];for(i=0;i<32;i++)r[i+32]=o[i];if(H(f,r,n),ir(f),rr(h,s,f),er(s,t.subarray(32)),X(h,s),Q(a,h),n-=64,w(t,0,a,0)){for(i=0;i<n;i++)r[i]=0;return-1}for(i=0;i<n;i++)r[i]=t[i+64];return n}var sr=32,ur=24,cr=32,lr=32,yr=ur;function dr(r,e){if(r.length!==sr)throw new Error("bad key size");if(e.length!==ur)throw new Error("bad nonce size")}function pr(){var r,e;for(e=0;e<arguments.length;e++)if("[object Uint8Array]"!==(r=Object.prototype.toString.call(arguments[e])))throw new TypeError("unexpected type "+r+", use Uint8Array")}function vr(r){for(var e=0;e<r.length;e++)r[e]=0}r.lowlevel={crypto_core_hsalsa20:b,crypto_stream_xor:x,crypto_stream:U,crypto_stream_salsa20_xor:A,crypto_stream_salsa20:m,crypto_onetimeauth:S,crypto_onetimeauth_verify:B,crypto_verify_16:p,crypto_verify_32:w,crypto_secretbox:T,crypto_secretbox_open:M,crypto_scalarmult:R,crypto_scalarmult_base:W,crypto_box_beforenm:F,crypto_box_afternm:q,crypto_box:function(r,e,t,n,o,i){var a=new Uint8Array(32);return F(a,o,i),q(r,e,t,n,a)},crypto_box_open:function(r,e,t,n,o,i){var a=new Uint8Array(32);return F(a,o,i),Z(r,e,t,n,a)},crypto_box_keypair:C,crypto_hash:H,crypto_sign:ar,crypto_sign_keypair:tr,crypto_sign_open:hr,crypto_secretbox_KEYBYTES:sr,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:cr,crypto_box_SECRETKEYBYTES:lr,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:yr,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:64,crypto_sign_PUBLICKEYBYTES:32,crypto_sign_SECRETKEYBYTES:64,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64},r.util||(r.util={},r.util.decodeUTF8=r.util.encodeUTF8=r.util.encodeBase64=r.util.decodeBase64=function(){throw new Error("nacl.util moved into separate package: https://github.com/dchest/tweetnacl-util-js")}),r.randomBytes=function(r){var e=new Uint8Array(r);return t(e,r),e},r.secretbox=function(r,e,t){pr(r,e,t),dr(t,e);for(var n=new Uint8Array(32+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+32]=r[i];return T(o,n,n.length,e,t),o.subarray(16)},r.secretbox.open=function(r,e,t){pr(r,e,t),dr(t,e);for(var n=new Uint8Array(16+r.length),o=new Uint8Array(n.length),i=0;i<r.length;i++)n[i+16]=r[i];return!(n.length<32)&&(0===M(o,n,n.length,e,t)&&o.subarray(32))},r.secretbox.keyLength=sr,r.secretbox.nonceLength=ur,r.secretbox.overheadLength=16,r.scalarMult=function(r,e){if(pr(r,e),32!==r.length)throw new Error("bad n size");if(32!==e.length)throw new Error("bad p size");var t=new Uint8Array(32);return R(t,r,e),t},r.scalarMult.base=function(r){if(pr(r),32!==r.length)throw new Error("bad n size");var e=new Uint8Array(32);return W(e,r),e},r.scalarMult.scalarLength=32,r.scalarMult.groupElementLength=32,r.box=function(e,t,n,o){var i=r.box.before(n,o);return r.secretbox(e,t,i)},r.box.before=function(r,e){pr(r,e),function(r,e){if(r.length!==cr)throw new Error("bad public key size");if(e.length!==lr)throw new Error("bad secret key size")}(r,e);var t=new Uint8Array(32);return F(t,r,e),t},r.box.after=r.secretbox,r.box.open=function(e,t,n,o){var i=r.box.before(n,o);return r.secretbox.open(e,t,i)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var r=new Uint8Array(cr),e=new Uint8Array(lr);return C(r,e),{publicKey:r,secretKey:e}},r.box.keyPair.fromSecretKey=function(r){if(pr(r),r.length!==lr)throw new Error("bad secret key size");var e=new Uint8Array(cr);return W(e,r),{publicKey:e,secretKey:new Uint8Array(r)}},r.box.publicKeyLength=cr,r.box.secretKeyLength=lr,r.box.sharedKeyLength=32,r.box.nonceLength=yr,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(r,e){if(pr(r,e),64!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(64+r.length);return ar(t,r,r.length,e),t},r.sign.open=function(r,e){if(2!==arguments.length)throw new Error("nacl.sign.open accepts 2 arguments; did you mean to use nacl.sign.detached.verify?");if(pr(r,e),32!==e.length)throw new Error("bad public key size");var t=new Uint8Array(r.length),n=hr(t,r,r.length,e);if(n<0)return null;for(var o=new Uint8Array(n),i=0;i<o.length;i++)o[i]=t[i];return o},r.sign.detached=function(e,t){for(var n=r.sign(e,t),o=new Uint8Array(64),i=0;i<o.length;i++)o[i]=n[i];return o},r.sign.detached.verify=function(r,e,t){if(pr(r,e,t),64!==e.length)throw new Error("bad signature size");if(32!==t.length)throw new Error("bad public key size");var n,o=new Uint8Array(64+r.length),i=new Uint8Array(64+r.length);for(n=0;n<64;n++)o[n]=e[n];for(n=0;n<r.length;n++)o[n+64]=r[n];return hr(i,o,o.length,t)>=0},r.sign.keyPair=function(){var r=new Uint8Array(32),e=new Uint8Array(64);return tr(r,e),{publicKey:r,secretKey:e}},r.sign.keyPair.fromSecretKey=function(r){if(pr(r),64!==r.length)throw new Error("bad secret key size");for(var e=new Uint8Array(32),t=0;t<e.length;t++)e[t]=r[32+t];return{publicKey:e,secretKey:new Uint8Array(r)}},r.sign.keyPair.fromSeed=function(r){if(pr(r),32!==r.length)throw new Error("bad seed size");for(var e=new Uint8Array(32),t=new Uint8Array(64),n=0;n<32;n++)t[n]=r[n];return tr(e,t,!0),{publicKey:e,secretKey:t}},r.sign.publicKeyLength=32,r.sign.secretKeyLength=64,r.sign.seedLength=32,r.sign.signatureLength=64,r.hash=function(r){pr(r);var e=new Uint8Array(64);return H(e,r,r.length),e},r.hash.hashLength=64,r.verify=function(r,e){return pr(r,e),0!==r.length&&0!==e.length&&(r.length===e.length&&0===d(r,0,e,0,r.length))},r.setPRNG=function(r){t=r},function(){var e="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(e&&e.getRandomValues){r.setPRNG(function(r,t){var n,o=new Uint8Array(t);for(n=0;n<t;n+=65536)e.getRandomValues(o.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)r[n]=o[n];vr(o)})}else(e=v)&&e.randomBytes&&r.setPRNG(function(r,t){var n,o=e.randomBytes(t);for(n=0;n<t;n++)r[n]=o[n];vr(o)})}()}(r.exports?r.exports:self.nacl=self.nacl||{})}),g=d(function(r){var e,t;e=y,t=function(){var r={};function e(r){if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(r))throw new TypeError("invalid encoding")}return r.decodeUTF8=function(r){if("string"!=typeof r)throw new TypeError("expected string");var e,t=unescape(encodeURIComponent(r)),n=new Uint8Array(t.length);for(e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},r.encodeUTF8=function(r){var e,t=[];for(e=0;e<r.length;e++)t.push(String.fromCharCode(r[e]));return decodeURIComponent(escape(t.join("")))},"undefined"==typeof atob?void 0!==Buffer.from?(r.encodeBase64=function(r){return Buffer.from(r).toString("base64")},r.decodeBase64=function(r){return e(r),new Uint8Array(Array.prototype.slice.call(Buffer.from(r,"base64"),0))}):(r.encodeBase64=function(r){return new Buffer(r).toString("base64")},r.decodeBase64=function(r){return e(r),new Uint8Array(Array.prototype.slice.call(new Buffer(r,"base64"),0))}):(r.encodeBase64=function(r){var e,t=[],n=r.length;for(e=0;e<n;e++)t.push(String.fromCharCode(r[e]));return btoa(t.join(""))},r.decodeBase64=function(r){e(r);var t,n=atob(r),o=new Uint8Array(n.length);for(t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return o}),r},r.exports?r.exports=t():e.nacl?e.nacl.util=t():(e.nacl={},e.nacl.util=t())});var b=new n.ec("secp256k1");function E(r,e){void 0===e&&(e=!1);var t=i.toBuffer(r);if(t.length!==(e?65:64))throw new Error("wrong signature length");var n={r:t.slice(0,32).toString("hex"),s:t.slice(32,64).toString("hex")};return e&&(n.recoveryParam=t[64]),n}var A={ES256K:function(r,e,t){var n=s(r),o=E(e),i=t.find(function(r){return b.keyFromPublic(r.publicKeyHex,"hex").verify(n,o)});if(!i)throw new Error("Signature invalid for JWT");return i},"ES256K-R":function(r,e,t){var n=E(e,!0),o=s(r),i=b.recoverPubKey(o,n,n.recoveryParam),a=i.encode("hex"),f=i.encode("hex",!0),h=u(a),c=t.find(function(r){var e=r.publicKeyHex;return e===a||e===f||r.ethereumAddress===h});if(!c)throw new Error("Signature invalid for JWT");return c},Ed25519:function(r,e,t){var n=g.decodeUTF8(r),o=h.decodeBase64Url(e),i=t.find(function(r){return w.sign.detached.verify(n,o,g.decodeBase64(r.publicKeyBase64))});if(!i)throw new Error("Signature invalid for JWT");return i}};function m(r){var e=A[r];if(!e)throw new Error("Unsupported algorithm "+r);return e}function U(r){function e(e){var t=e.r,n=e.s,a=e.recoveryParam,f=o.Buffer.alloc(r?65:64);if(o.Buffer.from(t,"hex").copy(f,0),o.Buffer.from(n,"hex").copy(f,32),r){if(void 0===a)throw new Error("Signer did not return a recoveryParam");f[64]=a}return i.encode(f)}return void 0===r&&(r=!1),function(r,t){try{return Promise.resolve(t(r)).then(e)}catch(r){return Promise.reject(r)}}}m.toSignatureObject=E;var x={ES256K:U(),"ES256K-R":U(!0),Ed25519:function(r,e){try{return Promise.resolve(e(r))}catch(r){return Promise.reject(r)}}};f(),h.registerNaclDID();var _={ES256K:["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],"ES256K-R":["Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1"],Ed25519:["ED25519SignatureVerification"]},S={typ:"JWT"},B="ES256K";function T(r){return i.encode(JSON.stringify(r))}var M=300;function K(r){if(r.match(/^did:/))return r;if(t.isMNID(r))return"did:uport:"+r;throw new Error("Not a valid DID '"+r+"'")}function k(r){if(!r)throw new Error("no JWT passed into decodeJWT");var e=r.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(e)return{header:JSON.parse(i.decode(e[1])),payload:JSON.parse(i.decode(e[2])),signature:e[3],data:e[1]+"."+e[2]};throw new Error("Incorrect format JWT")}module.exports={SimpleSigner:function(r){var e=c.keyFromPrivate(r);return function(r){try{var t=e.sign(s(r)),n=t.s,o=t.recoveryParam;return Promise.resolve({r:l(t.r.toString("hex")),s:l(n.toString("hex")),recoveryParam:o})}catch(r){return Promise.reject(r)}}},NaclSigner:function(r){var e=g.decodeBase64(r);return function(r){try{return Promise.resolve(h.encodeBase64Url(w.sign.detached(g.decodeUTF8(r),e)))}catch(r){return Promise.reject(r)}}},verifyJWT:function(r,e){void 0===e&&(e={});try{var n=e.audience?K(e.audience):void 0,o=k(r),i=o.payload,f=o.header,h=o.signature,s=o.data;return Promise.resolve(function(r,e,t){try{var n=_[r];if(!n||0===n.length)throw new Error("No supported signature types for algorithm "+r);var o=K(e);return Promise.resolve(a(o)).then(function(e){if(!e)throw new Error("Unable to resolve DID document for "+o);var i=!t||(e.authentication||[]).map(function(r){return r.publicKey}),a=(e.publicKey||[]).filter(function(r){var e=r.type,o=r.id;return n.find(function(r){return r===e&&(!t||i.indexOf(o)>=0)})});if(t&&(!a||0===a.length))throw new Error("DID document for "+o+" does not have public keys suitable for authenticationg user");if(!a||0===a.length)throw new Error("DID document for "+o+" does not have public keys for "+r);return{authenticators:a,issuer:o,doc:e}})}catch(r){return Promise.reject(r)}}(f.alg,i.iss,e.auth)).then(function(o){var a,u=o.doc,c=o.authenticators,l=o.issuer,y=m(f.alg)(s,h,c),d=Math.floor(Date.now()/1e3);if(y){if(i.iat&&i.iat>d+M)throw new Error("JWT not valid yet (issued in the future): iat: "+i.iat+" > now: "+d);if(i.exp&&i.exp<=d-M)throw new Error("JWT has expired: exp: "+i.exp+" < now: "+d);if(i.aud)if((a=i.aud)&&(a.match(/^did:/)||t.isMNID(a))){if(!n)throw new Error("JWT audience is required but your app address has not been configured");if(n!==K(i.aud))throw new Error("JWT audience does not match your DID: aud: "+i.aud+" !== yours: "+n)}else{if(!e.callbackUrl)throw new Error("JWT audience matching your callback url is required but one wasn't passed in");if(i.aud!==e.callbackUrl)throw new Error("JWT audience does not match the callback url: aud: "+i.aud+" !== url: "+e.callbackUrl)}return{payload:i,doc:u,issuer:l,signer:y,jwt:r}}})}catch(r){return Promise.reject(r)}},createJWT:function(r,e){var t=e.issuer,n=e.signer,o=e.alg,i=e.expiresIn;try{if(!n)throw new Error("No Signer functionality has been configured");if(!t)throw new Error("No issuing DID has been configured");var a=Object.assign({},S,{alg:o||B}),f={iat:Math.floor(Date.now()/1e3)};if(i){if("number"!=typeof i)throw new Error("JWT expiresIn is not a number");f.exp=f.iat+Math.floor(i)}var h=[T(a),T(Object.assign({},f,r,{iss:t}))].join("."),s=function(r){var e=x[r];if(!e)throw new Error("Unsupported algorithm "+r);return e}(a.alg);return Promise.resolve(s(h,n)).then(function(r){return[h,r].join(".")})}catch(r){return Promise.reject(r)}},decodeJWT:k,toEthereumAddress:u}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "did-jwt", | ||
"version": "0.2.0-alpha1", | ||
"version": "0.2.0-alpha2", | ||
"description": "Library for Signing and Verifying JWTs compatible uPort and DID standards", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
import SimpleSigner from './SimpleSigner' | ||
import NaclSigner from './NaclSigner' | ||
import { toEthereumAddress } from './Digest' | ||
import { verifyJWT, createJWT, decodeJWT } from './JWT' | ||
module.exports = { SimpleSigner, NaclSigner, verifyJWT, createJWT, decodeJWT } | ||
module.exports = { SimpleSigner, NaclSigner, verifyJWT, createJWT, decodeJWT, toEthereumAddress } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
633097
1402
0