libsodium-wrappers
Advanced tools
Comparing version 0.7.2 to 0.7.3
@@ -1,1 +0,1 @@ | ||
!function(e){function t(e,t){"use strict";function r(e){if("function"==typeof TextEncoder)return new TextEncoder("utf-8").encode(e);e=unescape(encodeURIComponent(e));for(var t=new Uint8Array(e.length),r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function a(e){if("function"==typeof TextDecoder)return new TextDecoder("utf-8",{fatal:!0}).decode(e);var t=Math.ceil(e.length/8192);if(t<=1)try{return decodeURIComponent(escape(String.fromCharCode.apply(null,e)))}catch(e){throw new TypeError("The encoded data was not valid.")}for(var r="",n=0,_=0;_<t;_++){var s=Array.prototype.slice.call(e,8192*_+n,8192*(_+1)+n);if(0!=s.length){var c,h=s.length,o=0;do{var p=s[--h];p>=240?(o=4,c=!0):p>=224?(o=3,c=!0):p>=192?(o=2,c=!0):p<128&&(o=1,c=!0)}while(!c);for(var y=o-(s.length-h),i=0;i<y;i++)n--,s.pop();r+=a(s)}}return r}function n(e){e=f(null,e,"input");for(var t,r,a,n="",_=0;_<e.length;_++)a=87+(r=15&e[_])+(r-10>>8&-39)<<8|87+(t=e[_]>>>4)+(t-10>>8&-39),n+=String.fromCharCode(255&a)+String.fromCharCode(a>>>8);return n}function _(e){if(void 0==e)return Et.URLSAFE_NO_PADDING;if(e!==Et.ORIGINAL&&e!==Et.ORIGINAL_NO_PADDING&&e!==Et.URLSAFE&&e!=Et.URLSAFE_NO_PADDING)throw new Error("unsupported base64 variant");return e}function s(e,t){t=_(t),e=f(n,e,"input");var r,n=[],s=0|Math.floor(e.length/3),c=e.length-3*s,h=4*s+(0!==c?0==(2&t)?4:2+(c>>>1):0),o=new y(h+1),p=i(e);return n.push(p),n.push(o.address),0===kt._sodium_bin2base64(o.address,o.length,p,e.length,t)&&v(n,"conversion failed"),o.length=h,r=a(o.to_Uint8Array()),d(n),r}function c(){return["uint8array","text","hex","base64"]}function h(e,t){var r=t||xt;if(!o(r))throw new Error(r+" output format is not available");if(e instanceof y){if("uint8array"===r)return e.to_Uint8Array();if("text"===r)return a(e.to_Uint8Array());if("hex"===r)return n(e.to_Uint8Array());if("base64"===r)return s(e.to_Uint8Array(),Et.URLSAFE_NO_PADDING);throw new Error('What is output format "'+r+'"?')}if("object"==typeof e){for(var _=Object.keys(e),c={},p=0;p<_.length;p++)c[_[p]]=h(e[_[p]],r);return c}if("string"==typeof e)return e;throw new TypeError("Cannot format output")}function o(e){for(var t=c(),r=0;r<t.length;r++)if(t[r]===e)return!0;return!1}function p(e){if(e){if("string"!=typeof e)throw new TypeError("When defined, the output format must be a string");if(!o(e))throw new Error(e+" is not a supported output format")}}function y(e){this.length=e,this.address=u(e)}function i(e){var t=u(e.length);return kt.HEAPU8.set(e,t),t}function u(e){var t=kt._malloc(e);if(0===t)throw{message:"_malloc() failed",length:e};return t}function l(e){kt._free(e)}function d(e){if(e)for(var t=0;t<e.length;t++)l(e[t])}function v(e,t){throw d(e),new Error(t)}function g(e,t){throw d(e),new TypeError(t)}function b(e,t,r){void 0==t&&g(e,r+" cannot be null or undefined")}function f(e,t,a){return b(e,t,a),t instanceof Uint8Array?t:"string"==typeof t?r(t):void g(e,"unsupported input type for "+a)}function m(e,t,r,a,n,_){var s=[];p(_);var c=null;void 0!=e&&(c=i(e=f(s,e,"secret_nonce")),e.length,s.push(c));var o=i(t=f(s,t,"ciphertext")),u=t.length;s.push(o);var l=null,b=0;void 0!=r&&(l=i(r=f(s,r,"additional_data")),b=r.length,s.push(l)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=i(a),s.push(m),n=f(s,n,"key");var x,w=0|kt._crypto_aead_chacha20poly1305_keybytes();n.length!==w&&g(s,"invalid key length"),x=i(n),s.push(x);var E=new y(u-kt._crypto_aead_chacha20poly1305_abytes()|0),T=E.address;if(s.push(T),0===kt._crypto_aead_chacha20poly1305_decrypt(T,null,c,o,u,0,l,b,0,m,x)){var S=h(E,_);return d(s),S}v(s,"incorrect usage")}function k(e,t,r,a,n,_,s){var c=[];p(s);var o=null;void 0!=e&&(o=i(e=f(c,e,"secret_nonce")),e.length,c.push(o));var u=i(t=f(c,t,"ciphertext")),l=t.length;c.push(u),r=f(c,r,"mac");var b,m=0|kt._crypto_box_macbytes();r.length!==m&&g(c,"invalid mac length"),b=i(r),c.push(b);var k=null,x=0;void 0!=a&&(k=i(a=f(c,a,"additional_data")),x=a.length,c.push(k)),n=f(c,n,"public_nonce");var w,E=0|kt._crypto_aead_chacha20poly1305_npubbytes();n.length!==E&&g(c,"invalid public_nonce length"),w=i(n),c.push(w),_=f(c,_,"key");var T,S=0|kt._crypto_aead_chacha20poly1305_keybytes();_.length!==S&&g(c,"invalid key length"),T=i(_),c.push(T);var Y=new y(0|l),K=Y.address;if(c.push(K),0===kt._crypto_aead_chacha20poly1305_decrypt_detached(K,o,u,l,0,b,k,x,0,w,T)){var A=h(Y,s);return d(c),A}v(c,"incorrect usage")}function x(e,t,r,a,n,_){var s=[];p(_);var c=i(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=i(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=i(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=i(a),s.push(m),n=f(s,n,"key");var x,w=0|kt._crypto_aead_chacha20poly1305_keybytes();n.length!==w&&g(s,"invalid key length"),x=i(n),s.push(x);var E=new y(o+kt._crypto_aead_chacha20poly1305_abytes()|0),T=E.address;if(s.push(T),0===kt._crypto_aead_chacha20poly1305_encrypt(T,null,c,o,0,u,l,0,b,m,x)){var S=h(E,_);return d(s),S}v(s,"incorrect usage")}function w(e,t,r,a,n,_){var s=[];p(_);var c=i(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=i(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=i(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=i(a),s.push(m),n=f(s,n,"key");var x,w=0|kt._crypto_aead_chacha20poly1305_keybytes();n.length!==w&&g(s,"invalid key length"),x=i(n),s.push(x);var E=new y(0|o),T=E.address;s.push(T);var S=new y(0|kt._crypto_aead_chacha20poly1305_abytes()),Y=S.address;if(s.push(Y),0===kt._crypto_aead_chacha20poly1305_encrypt_detached(T,Y,null,c,o,0,u,l,0,b,m,x)){var K=h({ciphertext:E,mac:S},_);return d(s),K}v(s,"incorrect usage")}function E(e,t,r,a,n,_){var s=[];p(_);var c=null;void 0!=e&&(c=i(e=f(s,e,"secret_nonce")),e.length,s.push(c));var o=i(t=f(s,t,"ciphertext")),u=t.length;s.push(o);var l=null,b=0;void 0!=r&&(l=i(r=f(s,r,"additional_data")),b=r.length,s.push(l)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=i(a),s.push(m),n=f(s,n,"key");var x,w=0|kt._crypto_aead_chacha20poly1305_ietf_keybytes();n.length!==w&&g(s,"invalid key length"),x=i(n),s.push(x);var E=new y(u-kt._crypto_aead_chacha20poly1305_ietf_abytes()|0),T=E.address;if(s.push(T),0===kt._crypto_aead_chacha20poly1305_ietf_decrypt(T,null,c,o,u,0,l,b,0,m,x)){var S=h(E,_);return d(s),S}v(s,"incorrect usage")}function T(e,t,r,a,n,_,s){var c=[];p(s);var o=null;void 0!=e&&(o=i(e=f(c,e,"secret_nonce")),e.length,c.push(o));var u=i(t=f(c,t,"ciphertext")),l=t.length;c.push(u),r=f(c,r,"mac");var b,m=0|kt._crypto_box_macbytes();r.length!==m&&g(c,"invalid mac length"),b=i(r),c.push(b);var k=null,x=0;void 0!=a&&(k=i(a=f(c,a,"additional_data")),x=a.length,c.push(k)),n=f(c,n,"public_nonce");var w,E=0|kt._crypto_aead_chacha20poly1305_ietf_npubbytes();n.length!==E&&g(c,"invalid public_nonce length"),w=i(n),c.push(w),_=f(c,_,"key");var T,S=0|kt._crypto_aead_chacha20poly1305_ietf_keybytes();_.length!==S&&g(c,"invalid key length"),T=i(_),c.push(T);var Y=new y(0|l),K=Y.address;if(c.push(K),0===kt._crypto_aead_chacha20poly1305_ietf_decrypt_detached(K,o,u,l,0,b,k,x,0,w,T)){var A=h(Y,s);return d(c),A}v(c,"incorrect usage")}function S(e,t,r,a,n,_){var s=[];p(_);var c=i(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=i(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=i(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=i(a),s.push(m),n=f(s,n,"key");var x,w=0|kt._crypto_aead_chacha20poly1305_ietf_keybytes();n.length!==w&&g(s,"invalid key length"),x=i(n),s.push(x);var E=new y(o+kt._crypto_aead_chacha20poly1305_ietf_abytes()|0),T=E.address;if(s.push(T),0===kt._crypto_aead_chacha20poly1305_ietf_encrypt(T,null,c,o,0,u,l,0,b,m,x)){var S=h(E,_);return d(s),S}v(s,"incorrect usage")}function Y(e,t,r,a,n,_){var s=[];p(_);var c=i(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=i(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=i(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=i(a),s.push(m),n=f(s,n,"key");var x,w=0|kt._crypto_aead_chacha20poly1305_ietf_keybytes();n.length!==w&&g(s,"invalid key length"),x=i(n),s.push(x);var E=new y(0|o),T=E.address;s.push(T);var S=new y(0|kt._crypto_aead_chacha20poly1305_ietf_abytes()),Y=S.address;if(s.push(Y),0===kt._crypto_aead_chacha20poly1305_ietf_encrypt_detached(T,Y,null,c,o,0,u,l,0,b,m,x)){var K=h({ciphertext:E,mac:S},_);return d(s),K}v(s,"incorrect usage")}function K(e){var t=[];p(e);var r=new y(0|kt._crypto_aead_chacha20poly1305_ietf_keybytes()),a=r.address;t.push(a),kt._crypto_aead_chacha20poly1305_ietf_keygen(a);var n=h(r,e);return d(t),n}function A(e){var t=[];p(e);var r=new y(0|kt._crypto_aead_chacha20poly1305_keybytes()),a=r.address;t.push(a),kt._crypto_aead_chacha20poly1305_keygen(a);var n=h(r,e);return d(t),n}function I(e,t,r,a,n,_){var s=[];p(_);var c=null;void 0!=e&&(c=i(e=f(s,e,"secret_nonce")),e.length,s.push(c));var o=i(t=f(s,t,"ciphertext")),u=t.length;s.push(o);var l=null,b=0;void 0!=r&&(l=i(r=f(s,r,"additional_data")),b=r.length,s.push(l)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_xchacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=i(a),s.push(m),n=f(s,n,"key");var x,w=0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes();n.length!==w&&g(s,"invalid key length"),x=i(n),s.push(x);var E=new y(u-kt._crypto_aead_xchacha20poly1305_ietf_abytes()|0),T=E.address;if(s.push(T),0===kt._crypto_aead_xchacha20poly1305_ietf_decrypt(T,null,c,o,u,0,l,b,0,m,x)){var S=h(E,_);return d(s),S}v(s,"incorrect usage")}function B(e,t,r,a,n,_,s){var c=[];p(s);var o=null;void 0!=e&&(o=i(e=f(c,e,"secret_nonce")),e.length,c.push(o));var u=i(t=f(c,t,"ciphertext")),l=t.length;c.push(u),r=f(c,r,"mac");var b,m=0|kt._crypto_box_macbytes();r.length!==m&&g(c,"invalid mac length"),b=i(r),c.push(b);var k=null,x=0;void 0!=a&&(k=i(a=f(c,a,"additional_data")),x=a.length,c.push(k)),n=f(c,n,"public_nonce");var w,E=0|kt._crypto_aead_xchacha20poly1305_ietf_npubbytes();n.length!==E&&g(c,"invalid public_nonce length"),w=i(n),c.push(w),_=f(c,_,"key");var T,S=0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes();_.length!==S&&g(c,"invalid key length"),T=i(_),c.push(T);var Y=new y(0|l),K=Y.address;if(c.push(K),0===kt._crypto_aead_xchacha20poly1305_ietf_decrypt_detached(K,o,u,l,0,b,k,x,0,w,T)){var A=h(Y,s);return d(c),A}v(c,"incorrect usage")}function M(e,t,r,a,n,_){var s=[];p(_);var c=i(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=i(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=i(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_xchacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=i(a),s.push(m),n=f(s,n,"key");var x,w=0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes();n.length!==w&&g(s,"invalid key length"),x=i(n),s.push(x);var E=new y(o+kt._crypto_aead_xchacha20poly1305_ietf_abytes()|0),T=E.address;if(s.push(T),0===kt._crypto_aead_xchacha20poly1305_ietf_encrypt(T,null,c,o,0,u,l,0,b,m,x)){var S=h(E,_);return d(s),S}v(s,"incorrect usage")}function L(e,t,r,a,n,_){var s=[];p(_);var c=i(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=i(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=i(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_xchacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=i(a),s.push(m),n=f(s,n,"key");var x,w=0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes();n.length!==w&&g(s,"invalid key length"),x=i(n),s.push(x);var E=new y(0|o),T=E.address;s.push(T);var S=new y(0|kt._crypto_aead_xchacha20poly1305_ietf_abytes()),Y=S.address;if(s.push(Y),0===kt._crypto_aead_xchacha20poly1305_ietf_encrypt_detached(T,Y,null,c,o,0,u,l,0,b,m,x)){var K=h({ciphertext:E,mac:S},_);return d(s),K}v(s,"incorrect usage")}function N(e){var t=[];p(e);var r=new y(0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes()),a=r.address;t.push(a),kt._crypto_aead_xchacha20poly1305_ietf_keygen(a);var n=h(r,e);return d(t),n}function U(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_auth_keybytes();t.length!==c&&g(a,"invalid key length"),s=i(t),a.push(s);var o=new y(0|kt._crypto_auth_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_auth(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function R(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_auth_hmacsha256_keybytes();t.length!==c&&g(a,"invalid key length"),s=i(t),a.push(s);var o=new y(0|kt._crypto_auth_hmacsha256_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_auth_hmacsha256(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function O(e){var t=[];p(e);var r=new y(0|kt._crypto_auth_hmacsha256_keybytes()),a=r.address;t.push(a),kt._crypto_auth_hmacsha256_keygen(a);var n=h(r,e);return d(t),n}function P(e,t,r){var a=[];e=f(a,e,"tag");var n,_=0|kt._crypto_auth_hmacsha256_bytes();e.length!==_&&g(a,"invalid tag length"),n=i(e),a.push(n);var s=i(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"key");var h,o=0|kt._crypto_auth_hmacsha256_keybytes();r.length!==o&&g(a,"invalid key length"),h=i(r),a.push(h);var p=0===(0|kt._crypto_auth_hmacsha256_verify(n,s,c,0,h));return d(a),p}function C(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_auth_hmacsha512_keybytes();t.length!==c&&g(a,"invalid key length"),s=i(t),a.push(s);var o=new y(0|kt._crypto_auth_hmacsha512_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_auth_hmacsha512(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function D(e){var t=[];p(e);var r=new y(0|kt._crypto_auth_hmacsha512_keybytes()),a=r.address;t.push(a),kt._crypto_auth_hmacsha512_keygen(a);var n=h(r,e);return d(t),n}function G(e,t,r){var a=[];e=f(a,e,"tag");var n,_=0|kt._crypto_auth_hmacsha512_bytes();e.length!==_&&g(a,"invalid tag length"),n=i(e),a.push(n);var s=i(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"key");var h,o=0|kt._crypto_auth_hmacsha512_keybytes();r.length!==o&&g(a,"invalid key length"),h=i(r),a.push(h);var p=0===(0|kt._crypto_auth_hmacsha512_verify(n,s,c,0,h));return d(a),p}function V(e){var t=[];p(e);var r=new y(0|kt._crypto_auth_keybytes()),a=r.address;t.push(a),kt._crypto_auth_keygen(a);var n=h(r,e);return d(t),n}function F(e,t,r){var a=[];e=f(a,e,"tag");var n,_=0|kt._crypto_auth_bytes();e.length!==_&&g(a,"invalid tag length"),n=i(e),a.push(n);var s=i(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"key");var h,o=0|kt._crypto_auth_keybytes();r.length!==o&&g(a,"invalid key length"),h=i(r),a.push(h);var p=0===(0|kt._crypto_auth_verify(n,s,c,0,h));return d(a),p}function X(e,t,r){var a=[];p(r),e=f(a,e,"publicKey");var n,_=0|kt._crypto_box_publickeybytes();e.length!==_&&g(a,"invalid publicKey length"),n=i(e),a.push(n),t=f(a,t,"privateKey");var s,c=0|kt._crypto_box_secretkeybytes();t.length!==c&&g(a,"invalid privateKey length"),s=i(t),a.push(s);var o=new y(0|kt._crypto_box_beforenmbytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_box_beforenm(u,n,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function H(e,t,r,a,n){var _=[];p(n);var s=i(e=f(_,e,"message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_box_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=i(t),_.push(o),r=f(_,r,"publicKey");var l,b=0|kt._crypto_box_publickeybytes();r.length!==b&&g(_,"invalid publicKey length"),l=i(r),_.push(l),a=f(_,a,"privateKey");var m,k=0|kt._crypto_box_secretkeybytes();a.length!==k&&g(_,"invalid privateKey length"),m=i(a),_.push(m);var x=new y(0|c),w=x.address;_.push(w);var E=new y(0|kt._crypto_box_macbytes()),T=E.address;if(_.push(T),0==(0|kt._crypto_box_detached(w,T,s,c,0,o,l,m))){var S=h({ciphertext:x,mac:E},n);return d(_),S}v(_,"incorrect usage")}function j(e,t,r,a,n){var _=[];p(n);var s=i(e=f(_,e,"message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_box_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=i(t),_.push(o),r=f(_,r,"publicKey");var l,b=0|kt._crypto_box_publickeybytes();r.length!==b&&g(_,"invalid publicKey length"),l=i(r),_.push(l),a=f(_,a,"privateKey");var m,k=0|kt._crypto_box_secretkeybytes();a.length!==k&&g(_,"invalid privateKey length"),m=i(a),_.push(m);var x=new y(c+kt._crypto_box_macbytes()|0),w=x.address;if(_.push(w),0==(0|kt._crypto_box_easy(w,s,c,0,o,l,m))){var E=h(x,n);return d(_),E}v(_,"incorrect usage")}function z(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_box_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=i(t),n.push(c),r=f(n,r,"sharedKey");var u,l=0|kt._crypto_box_beforenmbytes();r.length!==l&&g(n,"invalid sharedKey length"),u=i(r),n.push(u);var b=new y(s+kt._crypto_box_macbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_box_easy_afternm(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"incorrect usage")}function W(e){var t=[];p(e);var r=new y(0|kt._crypto_box_publickeybytes()),a=r.address;t.push(a);var n=new y(0|kt._crypto_box_secretkeybytes()),_=n.address;if(t.push(_),0==(0|kt._crypto_box_keypair(a,_))){var s={publicKey:h(r,e),privateKey:h(n,e),keyType:"x25519"};return d(t),s}v(t,"incorrect usage")}function J(e,t,r,a,n,_){var s=[];p(_);var c=i(e=f(s,e,"ciphertext")),o=e.length;s.push(c),t=f(s,t,"mac");var u,l=0|kt._crypto_box_macbytes();t.length!==l&&g(s,"invalid mac length"),u=i(t),s.push(u),r=f(s,r,"nonce");var b,m=0|kt._crypto_box_noncebytes();r.length!==m&&g(s,"invalid nonce length"),b=i(r),s.push(b),a=f(s,a,"publicKey");var k,x=0|kt._crypto_box_publickeybytes();a.length!==x&&g(s,"invalid publicKey length"),k=i(a),s.push(k),n=f(s,n,"privateKey");var w,E=0|kt._crypto_box_secretkeybytes();n.length!==E&&g(s,"invalid privateKey length"),w=i(n),s.push(w);var T=new y(0|o),S=T.address;if(s.push(S),0==(0|kt._crypto_box_open_detached(S,c,u,o,0,b,k,w))){var Y=h(T,_);return d(s),Y}v(s,"incorrect usage")}function q(e,t,r,a,n){var _=[];p(n);var s=i(e=f(_,e,"ciphertext")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_box_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=i(t),_.push(o),r=f(_,r,"publicKey");var l,b=0|kt._crypto_box_publickeybytes();r.length!==b&&g(_,"invalid publicKey length"),l=i(r),_.push(l),a=f(_,a,"privateKey");var m,k=0|kt._crypto_box_secretkeybytes();a.length!==k&&g(_,"invalid privateKey length"),m=i(a),_.push(m);var x=new y(c-kt._crypto_box_macbytes()|0),w=x.address;if(_.push(w),0==(0|kt._crypto_box_open_easy(w,s,c,0,o,l,m))){var E=h(x,n);return d(_),E}v(_,"incorrect usage")}function Q(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"ciphertext")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_box_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=i(t),n.push(c),r=f(n,r,"sharedKey");var u,l=0|kt._crypto_box_beforenmbytes();r.length!==l&&g(n,"invalid sharedKey length"),u=i(r),n.push(u);var b=new y(s-kt._crypto_box_macbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_box_open_easy_afternm(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"incorrect usage")}function Z(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"publicKey");var s,c=0|kt._crypto_box_publickeybytes();t.length!==c&&g(a,"invalid publicKey length"),s=i(t),a.push(s);var o=new y(_+kt._crypto_box_sealbytes()|0),u=o.address;if(a.push(u),0==(0|kt._crypto_box_seal(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function $(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"ciphertext")),s=e.length;n.push(_),t=f(n,t,"publicKey");var c,o=0|kt._crypto_box_publickeybytes();t.length!==o&&g(n,"invalid publicKey length"),c=i(t),n.push(c),r=f(n,r,"privateKey");var u,l=0|kt._crypto_box_secretkeybytes();r.length!==l&&g(n,"invalid privateKey length"),u=i(r),n.push(u);var b=new y(s-kt._crypto_box_sealbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_box_seal_open(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"incorrect usage")}function ee(e,t){var r=[];p(t),e=f(r,e,"seed");var a,n=0|kt._crypto_box_seedbytes();e.length!==n&&g(r,"invalid seed length"),a=i(e),r.push(a);var _=new y(0|kt._crypto_box_publickeybytes()),s=_.address;r.push(s);var c=new y(0|kt._crypto_box_secretkeybytes()),o=c.address;if(r.push(o),0==(0|kt._crypto_box_seed_keypair(s,o,a))){var u={publicKey:h(_,t),privateKey:h(c,t),keyType:"x25519"};return d(r),u}v(r,"incorrect usage")}function te(e,t,r,a){var n=[];p(a),b(n,e,"hash_length"),("number"!=typeof e||(0|e)!==e||e<0)&&g(n,"hash_length must be an unsigned integer");var _=i(t=f(n,t,"message")),s=t.length;n.push(_);var c=null,o=0;void 0!=r&&(c=i(r=f(n,r,"key")),o=r.length,n.push(c));var u=new y(e=0|e),l=u.address;if(n.push(l),0==(0|kt._crypto_generichash(l,e,_,s,0,c,o))){var m=h(u,a);return d(n),m}v(n,"incorrect usage")}function re(e,t,r){var a=[];p(r),b(a,e,"state_address"),b(a,t,"hash_length"),("number"!=typeof t||(0|t)!==t||t<0)&&g(a,"hash_length must be an unsigned integer");var n=new y(t=0|t),_=n.address;if(a.push(_),0==(0|kt._crypto_generichash_final(e,_,t))){var s=(kt._free(e),h(n,r));return d(a),s}v(a,"incorrect usage")}function ae(e,t,r){var a=[];p(r);var n=null,_=0;void 0!=e&&(n=i(e=f(a,e,"key")),_=e.length,a.push(n)),b(a,t,"hash_length"),("number"!=typeof t||(0|t)!==t||t<0)&&g(a,"hash_length must be an unsigned integer");var s=new y(357).address;if(0==(0|kt._crypto_generichash_init(s,n,_,t))){var c=s;return d(a),c}v(a,"incorrect usage")}function ne(e){var t=[];p(e);var r=new y(0|kt._crypto_generichash_keybytes()),a=r.address;t.push(a),kt._crypto_generichash_keygen(a);var n=h(r,e);return d(t),n}function _e(e,t,r){var a=[];p(r),b(a,e,"state_address");var n=i(t=f(a,t,"message_chunk")),_=t.length;a.push(n),0!=(0|kt._crypto_generichash_update(e,n,_))?v(a,"incorrect usage"):d(a)}function se(e,t){var r=[];p(t);var a=i(e=f(r,e,"message")),n=e.length;r.push(a);var _=new y(0|kt._crypto_hash_bytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_hash(s,a,n,0))){var c=h(_,t);return d(r),c}v(r,"incorrect usage")}function ce(e,t){var r=[];p(t);var a=i(e=f(r,e,"message")),n=e.length;r.push(a);var _=new y(0|kt._crypto_hash_sha256_bytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_hash_sha256(s,a,n,0))){var c=h(_,t);return d(r),c}v(r,"incorrect usage")}function he(e,t){var r=[];p(t);var a=i(e=f(r,e,"message")),n=e.length;r.push(a);var _=new y(0|kt._crypto_hash_sha512_bytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_hash_sha512(s,a,n,0))){var c=h(_,t);return d(r),c}v(r,"incorrect usage")}function oe(e,t,a,n,_){var s=[];p(_),b(s,e,"subkey_len"),("number"!=typeof e||(0|e)!==e||e<0)&&g(s,"subkey_len must be an unsigned integer"),b(s,t,"subkey_id"),("number"!=typeof t||(0|t)!==t||t<0)&&g(s,"subkey_id must be an unsigned integer");var c=i(a=r(a+"\0"));a.length;s.push(c),n=f(s,n,"key");var o,u=0|kt._crypto_kdf_keybytes();n.length!==u&&g(s,"invalid key length"),o=i(n),s.push(o);var l=new y(0|e),v=l.address;s.push(v),kt._crypto_kdf_derive_from_key(v,e,t,0,c,o);var m=h(l,_);return d(s),m}function pe(e){var t=[];p(e);var r=new y(0|kt._crypto_kdf_keybytes()),a=r.address;t.push(a),kt._crypto_kdf_keygen(a);var n=h(r,e);return d(t),n}function ye(e,t,r,a){var n=[];p(a),e=f(n,e,"clientPublicKey");var _,s=0|kt._crypto_kx_publickeybytes();e.length!==s&&g(n,"invalid clientPublicKey length"),_=i(e),n.push(_),t=f(n,t,"clientSecretKey");var c,o=0|kt._crypto_kx_secretkeybytes();t.length!==o&&g(n,"invalid clientSecretKey length"),c=i(t),n.push(c),r=f(n,r,"serverPublicKey");var u,l=0|kt._crypto_kx_publickeybytes();r.length!==l&&g(n,"invalid serverPublicKey length"),u=i(r),n.push(u);var b=new y(0|kt._crypto_kx_sessionkeybytes()),m=b.address;n.push(m);var k=new y(0|kt._crypto_kx_sessionkeybytes()),x=k.address;if(n.push(x),0==(0|kt._crypto_kx_client_session_keys(m,x,_,c,u))){var w=h({sharedRx:b,sharedTx:k},a);return d(n),w}v(n,"incorrect usage")}function ie(e){var t=[];p(e);var r=new y(0|kt._crypto_kx_publickeybytes()),a=r.address;t.push(a);var n=new y(0|kt._crypto_kx_secretkeybytes()),_=n.address;if(t.push(_),0==(0|kt._crypto_kx_keypair(a,_))){var s={publicKey:h(r,e),privateKey:h(n,e),keyType:"x25519"};return d(t),s}v(t,"incorrect usage")}function ue(e,t){var r=[];p(t),e=f(r,e,"seed");var a,n=0|kt._crypto_kx_seedbytes();e.length!==n&&g(r,"invalid seed length"),a=i(e),r.push(a);var _=new y(0|kt._crypto_kx_publickeybytes()),s=_.address;r.push(s);var c=new y(0|kt._crypto_kx_secretkeybytes()),o=c.address;if(r.push(o),0==(0|kt._crypto_kx_seed_keypair(s,o,a))){var u={publicKey:h(_,t),privateKey:h(c,t),keyType:"x25519"};return d(r),u}v(r,"incorrect usage")}function le(e,t,r,a){var n=[];p(a),e=f(n,e,"serverPublicKey");var _,s=0|kt._crypto_kx_publickeybytes();e.length!==s&&g(n,"invalid serverPublicKey length"),_=i(e),n.push(_),t=f(n,t,"serverSecretKey");var c,o=0|kt._crypto_kx_secretkeybytes();t.length!==o&&g(n,"invalid serverSecretKey length"),c=i(t),n.push(c),r=f(n,r,"clientPublicKey");var u,l=0|kt._crypto_kx_publickeybytes();r.length!==l&&g(n,"invalid clientPublicKey length"),u=i(r),n.push(u);var b=new y(0|kt._crypto_kx_sessionkeybytes()),m=b.address;n.push(m);var k=new y(0|kt._crypto_kx_sessionkeybytes()),x=k.address;if(n.push(x),0==(0|kt._crypto_kx_server_session_keys(m,x,_,c,u))){var w=h({sharedRx:b,sharedTx:k},a);return d(n),w}v(n,"incorrect usage")}function de(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_onetimeauth_keybytes();t.length!==c&&g(a,"invalid key length"),s=i(t),a.push(s);var o=new y(0|kt._crypto_onetimeauth_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_onetimeauth(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function ve(e,t){var r=[];p(t),b(r,e,"state_address");var a=new y(0|kt._crypto_onetimeauth_bytes()),n=a.address;if(r.push(n),0==(0|kt._crypto_onetimeauth_final(e,n))){var _=(kt._free(e),h(a,t));return d(r),_}v(r,"incorrect usage")}function ge(e,t){var r=[];p(t);var a=null;void 0!=e&&(a=i(e=f(r,e,"key")),e.length,r.push(a));var n=new y(144).address;if(0==(0|kt._crypto_onetimeauth_init(n,a))){var _=n;return d(r),_}v(r,"incorrect usage")}function be(e){var t=[];p(e);var r=new y(0|kt._crypto_onetimeauth_keybytes()),a=r.address;t.push(a),kt._crypto_onetimeauth_keygen(a);var n=h(r,e);return d(t),n}function fe(e,t,r){var a=[];p(r),b(a,e,"state_address");var n=i(t=f(a,t,"message_chunk")),_=t.length;a.push(n),0!=(0|kt._crypto_onetimeauth_update(e,n,_))?v(a,"incorrect usage"):d(a)}function me(e,t,r){var a=[];e=f(a,e,"hash");var n,_=0|kt._crypto_onetimeauth_bytes();e.length!==_&&g(a,"invalid hash length"),n=i(e),a.push(n);var s=i(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"key");var h,o=0|kt._crypto_onetimeauth_keybytes();r.length!==o&&g(a,"invalid key length"),h=i(r),a.push(h);var p=0===(0|kt._crypto_onetimeauth_verify(n,s,c,0,h));return d(a),p}function ke(e,t,r,a,n,_,s){var c=[];p(s),b(c,e,"keyLength"),("number"!=typeof e||(0|e)!==e||e<0)&&g(c,"keyLength must be an unsigned integer");var o=i(t=f(c,t,"password")),u=t.length;c.push(o),r=f(c,r,"salt");var l,m=0|kt._crypto_pwhash_saltbytes();r.length!==m&&g(c,"invalid salt length"),l=i(r),c.push(l),b(c,a,"opsLimit"),("number"!=typeof a||(0|a)!==a||a<0)&&g(c,"opsLimit must be an unsigned integer"),b(c,n,"memLimit"),("number"!=typeof n||(0|n)!==n||n<0)&&g(c,"memLimit must be an unsigned integer"),b(c,_,"algorithm"),("number"!=typeof _||(0|_)!==_||_<0)&&g(c,"algorithm must be an unsigned integer");var k=new y(0|e),x=k.address;if(c.push(x),0==(0|kt._crypto_pwhash(x,e,0,o,u,0,l,a,0,n,_))){var w=h(k,s);return d(c),w}v(c,"incorrect usage")}function xe(e,t,r,a,n,_){var s=[];p(_),b(s,e,"keyLength"),("number"!=typeof e||(0|e)!==e||e<0)&&g(s,"keyLength must be an unsigned integer");var c=i(t=f(s,t,"password")),o=t.length;s.push(c),r=f(s,r,"salt");var u,l=0|kt._crypto_pwhash_scryptsalsa208sha256_saltbytes();r.length!==l&&g(s,"invalid salt length"),u=i(r),s.push(u),b(s,a,"opsLimit"),("number"!=typeof a||(0|a)!==a||a<0)&&g(s,"opsLimit must be an unsigned integer"),b(s,n,"memLimit"),("number"!=typeof n||(0|n)!==n||n<0)&&g(s,"memLimit must be an unsigned integer");var m=new y(0|e),k=m.address;if(s.push(k),0==(0|kt._crypto_pwhash_scryptsalsa208sha256(k,e,0,c,o,0,u,a,0,n))){var x=h(m,_);return d(s),x}v(s,"incorrect usage")}function we(e,t,r,a,n,_,s){var c=[];p(s);var o=i(e=f(c,e,"password")),u=e.length;c.push(o);var l=i(t=f(c,t,"salt")),m=t.length;c.push(l),b(c,r,"opsLimit"),("number"!=typeof r||(0|r)!==r||r<0)&&g(c,"opsLimit must be an unsigned integer"),b(c,a,"r"),("number"!=typeof a||(0|a)!==a||a<0)&&g(c,"r must be an unsigned integer"),b(c,n,"p"),("number"!=typeof n||(0|n)!==n||n<0)&&g(c,"p must be an unsigned integer"),b(c,_,"keyLength"),("number"!=typeof _||(0|_)!==_||_<0)&&g(c,"keyLength must be an unsigned integer");var k=new y(0|_),x=k.address;if(c.push(x),0==(0|kt._crypto_pwhash_scryptsalsa208sha256_ll(o,u,l,m,r,0,a,n,x,_))){var w=h(k,s);return d(c),w}v(c,"incorrect usage")}function Ee(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"password")),s=e.length;n.push(_),b(n,t,"opsLimit"),("number"!=typeof t||(0|t)!==t||t<0)&&g(n,"opsLimit must be an unsigned integer"),b(n,r,"memLimit"),("number"!=typeof r||(0|r)!==r||r<0)&&g(n,"memLimit must be an unsigned integer");var c=new y(0|kt._crypto_pwhash_scryptsalsa208sha256_strbytes()).address;if(n.push(c),0==(0|kt._crypto_pwhash_scryptsalsa208sha256_str(c,_,s,0,t,0,r))){var h=kt.Pointer_stringify(c);return d(n),h}v(n,"incorrect usage")}function Te(e,t,a){var n=[];p(a);var _=i(e=r(e+"\0"));e.length;n.push(_);var s=i(t=f(n,t,"password")),c=t.length;n.push(s);var h=0===(0|kt._crypto_pwhash_scryptsalsa208sha256_str_verify(_,s,c,0));return d(n),h}function Se(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"password")),s=e.length;n.push(_),b(n,t,"opsLimit"),("number"!=typeof t||(0|t)!==t||t<0)&&g(n,"opsLimit must be an unsigned integer"),b(n,r,"memLimit"),("number"!=typeof r||(0|r)!==r||r<0)&&g(n,"memLimit must be an unsigned integer");var c=new y(0|kt._crypto_pwhash_strbytes()).address;if(n.push(c),0==(0|kt._crypto_pwhash_str(c,_,s,0,t,0,r))){var h=kt.Pointer_stringify(c);return d(n),h}v(n,"incorrect usage")}function Ye(e,t,a){var n=[];p(a);var _=i(e=r(e+"\0"));e.length;n.push(_);var s=i(t=f(n,t,"password")),c=t.length;n.push(s);var h=0===(0|kt._crypto_pwhash_str_verify(_,s,c,0));return d(n),h}function Ke(e,t,r){var a=[];p(r),e=f(a,e,"privateKey");var n,_=0|kt._crypto_scalarmult_scalarbytes();e.length!==_&&g(a,"invalid privateKey length"),n=i(e),a.push(n),t=f(a,t,"publicKey");var s,c=0|kt._crypto_scalarmult_scalarbytes();t.length!==c&&g(a,"invalid publicKey length"),s=i(t),a.push(s);var o=new y(0|kt._crypto_scalarmult_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_scalarmult(u,n,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function Ae(e,t){var r=[];p(t),e=f(r,e,"privateKey");var a,n=0|kt._crypto_scalarmult_scalarbytes();e.length!==n&&g(r,"invalid privateKey length"),a=i(e),r.push(a);var _=new y(0|kt._crypto_scalarmult_scalarbytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_scalarmult_base(s,a))){var c=h(_,t);return d(r),c}v(r,"incorrect usage")}function Ie(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_secretbox_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=i(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_secretbox_keybytes();r.length!==l&&g(n,"invalid key length"),u=i(r),n.push(u);var b=new y(0|s),m=b.address;n.push(m);var k=new y(0|kt._crypto_secretbox_macbytes()),x=k.address;if(n.push(x),0==(0|kt._crypto_secretbox_detached(m,x,_,s,0,c,u))){var w=h({mac:k,cipher:b},a);return d(n),w}v(n,"incorrect usage")}function Be(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_secretbox_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=i(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_secretbox_keybytes();r.length!==l&&g(n,"invalid key length"),u=i(r),n.push(u);var b=new y(s+kt._crypto_secretbox_macbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_secretbox_easy(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"incorrect usage")}function Me(e){var t=[];p(e);var r=new y(0|kt._crypto_secretbox_keybytes()),a=r.address;t.push(a),kt._crypto_secretbox_keygen(a);var n=h(r,e);return d(t),n}function Le(e,t,r,a,n){var _=[];p(n);var s=i(e=f(_,e,"ciphertext")),c=e.length;_.push(s),t=f(_,t,"mac");var o,u=0|kt._crypto_secretbox_macbytes();t.length!==u&&g(_,"invalid mac length"),o=i(t),_.push(o),r=f(_,r,"nonce");var l,b=0|kt._crypto_secretbox_noncebytes();r.length!==b&&g(_,"invalid nonce length"),l=i(r),_.push(l),a=f(_,a,"key");var m,k=0|kt._crypto_secretbox_keybytes();a.length!==k&&g(_,"invalid key length"),m=i(a),_.push(m);var x=new y(0|c),w=x.address;if(_.push(w),0==(0|kt._crypto_secretbox_open_detached(w,s,o,c,0,l,m))){var E=h(x,n);return d(_),E}v(_,"incorrect usage")}function Ne(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"ciphertext")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_secretbox_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=i(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_secretbox_keybytes();r.length!==l&&g(n,"invalid key length"),u=i(r),n.push(u);var b=new y(s-kt._crypto_secretbox_macbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_secretbox_open_easy(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"incorrect usage")}function Ue(e,t,r){var a=[];p(r),e=f(a,e,"header");var n,_=0|kt._crypto_secretstream_xchacha20poly1305_headerbytes();e.length!==_&&g(a,"invalid header length"),n=i(e),a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_secretstream_xchacha20poly1305_keybytes();t.length!==c&&g(a,"invalid key length"),s=i(t),a.push(s);var h=new y(52).address;if(0==(0|kt._crypto_secretstream_xchacha20poly1305_init_pull(h,n,s))){var o=h;return d(a),o}v(a,"incorrect usage")}function Re(e,t){var r=[];p(t),e=f(r,e,"key");var a,n=0|kt._crypto_secretstream_xchacha20poly1305_keybytes();e.length!==n&&g(r,"invalid key length"),a=i(e),r.push(a);var _=new y(52).address,s=new y(0|kt._crypto_secretstream_xchacha20poly1305_headerbytes()),c=s.address;if(r.push(c),0==(0|kt._crypto_secretstream_xchacha20poly1305_init_push(_,c,a))){var o={state:_,header:h(s,t)};return d(r),o}v(r,"incorrect usage")}function Oe(e){var t=[];p(e);var r=new y(0|kt._crypto_secretstream_xchacha20poly1305_keybytes()),a=r.address;t.push(a),kt._crypto_secretstream_xchacha20poly1305_keygen(a);var n=h(r,e);return d(t),n}function Pe(e,t,r,a){var n=[];p(a),b(n,e,"state_address");var _=i(t=f(n,t,"cipher")),s=t.length;n.push(_);var c=null,o=0;void 0!=r&&(r=f(n,r,"ad"),c=i(r),o=r.length,n.push(c));var l=new y(s-kt._crypto_secretstream_xchacha20poly1305_abytes()|0),v=l.address;n.push(v);var g=(g=function(){var t=u(1);return n.push(t),0===kt._crypto_secretstream_xchacha20poly1305_pull(e,v,0,t,_,s,0,c,o)&&{tag:kt.HEAPU8[t],message:l}}())&&{message:h(g.message,a),tag:g.tag};return d(n),g}function Ce(e,t,r,a,n){var _=[];p(n),b(_,e,"state_address");var s=i(t=f(_,t,"message_chunk")),c=t.length;_.push(s);var o=null,u=0;void 0!=r&&(o=i(r=f(_,r,"ad")),u=r.length,_.push(o)),b(_,a,"tag"),("number"!=typeof a||(0|a)!==a||a<0)&&g(_,"tag must be an unsigned integer");var l=new y(c+kt._crypto_secretstream_xchacha20poly1305_abytes()|0),m=l.address;if(_.push(m),0==(0|kt._crypto_secretstream_xchacha20poly1305_push(e,m,0,s,c,0,o,u,0,a))){var k=h(l,n);return d(_),k}v(_,"incorrect usage")}function De(e,t){var r=[];p(t),b(r,e,"state_address"),kt._crypto_secretstream_xchacha20poly1305_rekey(e);return d(r),!0}function Ge(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_shorthash_keybytes();t.length!==c&&g(a,"invalid key length"),s=i(t),a.push(s);var o=new y(0|kt._crypto_shorthash_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_shorthash(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function Ve(e){var t=[];p(e);var r=new y(0|kt._crypto_shorthash_keybytes()),a=r.address;t.push(a),kt._crypto_shorthash_keygen(a);var n=h(r,e);return d(t),n}function Fe(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_shorthash_siphashx24_keybytes();t.length!==c&&g(a,"invalid key length"),s=i(t),a.push(s);var o=new y(0|kt._crypto_shorthash_siphashx24_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_shorthash_siphashx24(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function Xe(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"privateKey");var s,c=0|kt._crypto_sign_secretkeybytes();t.length!==c&&g(a,"invalid privateKey length"),s=i(t),a.push(s);var o=new y(e.length+kt._crypto_sign_bytes()|0),u=o.address;if(a.push(u),0==(0|kt._crypto_sign(u,null,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function He(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"privateKey");var s,c=0|kt._crypto_sign_secretkeybytes();t.length!==c&&g(a,"invalid privateKey length"),s=i(t),a.push(s);var o=new y(0|kt._crypto_sign_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_sign_detached(u,null,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function je(e,t){var r=[];p(t),e=f(r,e,"edPk");var a,n=0|kt._crypto_sign_publickeybytes();e.length!==n&&g(r,"invalid edPk length"),a=i(e),r.push(a);var _=new y(0|kt._crypto_scalarmult_scalarbytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_sign_ed25519_pk_to_curve25519(s,a))){var c=h(_,t);return d(r),c}v(r,"incorrect usage")}function ze(e,t){var r=[];p(t),e=f(r,e,"edSk");var a,n=0|kt._crypto_sign_secretkeybytes();e.length!==n&&g(r,"invalid edSk length"),a=i(e),r.push(a);var _=new y(0|kt._crypto_scalarmult_scalarbytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_sign_ed25519_sk_to_curve25519(s,a))){var c=h(_,t);return d(r),c}v(r,"incorrect usage")}function We(e,t){var r=[];p(t),e=f(r,e,"privateKey");var a,n=0|kt._crypto_sign_secretkeybytes();e.length!==n&&g(r,"invalid privateKey length"),a=i(e),r.push(a);var _=new y(0|kt._crypto_sign_publickeybytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_sign_ed25519_sk_to_pk(s,a))){var c=h(_,t);return d(r),c}v(r,"incorrect usage")}function Je(e,t){var r=[];p(t),e=f(r,e,"privateKey");var a,n=0|kt._crypto_sign_secretkeybytes();e.length!==n&&g(r,"invalid privateKey length"),a=i(e),r.push(a);var _=new y(0|kt._crypto_sign_seedbytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_sign_ed25519_sk_to_seed(s,a))){var c=h(_,t);return d(r),c}v(r,"incorrect usage")}function qe(e,t,r){var a=[];p(r),b(a,e,"state_address"),t=f(a,t,"privateKey");var n,_=0|kt._crypto_sign_secretkeybytes();t.length!==_&&g(a,"invalid privateKey length"),n=i(t),a.push(n);var s=new y(0|kt._crypto_sign_bytes()),c=s.address;if(a.push(c),0==(0|kt._crypto_sign_final_create(e,c,null,n))){var o=(kt._free(e),h(s,r));return d(a),o}v(a,"incorrect usage")}function Qe(e,t,r,a){var n=[];p(a),b(n,e,"state_address"),t=f(n,t,"signature");var _,s=0|kt._crypto_sign_bytes();t.length!==s&&g(n,"invalid signature length"),_=i(t),n.push(_),r=f(n,r,"publicKey");var c,h=0|kt._crypto_sign_publickeybytes();r.length!==h&&g(n,"invalid publicKey length"),c=i(r),n.push(c);var o=0===(0|kt._crypto_sign_final_verify(e,_,c));return d(n),o}function Ze(e){var t=[];p(e);var r=new y(208).address;if(0==(0|kt._crypto_sign_init(r))){var a=r;return d(t),a}v(t,"incorrect usage")}function $e(e){var t=[];p(e);var r=new y(0|kt._crypto_sign_publickeybytes()),a=r.address;t.push(a);var n=new y(0|kt._crypto_sign_secretkeybytes()),_=n.address;if(t.push(_),0==(0|kt._crypto_sign_keypair(a,_))){var s={publicKey:h(r,e),privateKey:h(n,e),keyType:"ed25519"};return d(t),s}v(t,"incorrect usage")}function et(e,t,r){var a=[];p(r);var n=i(e=f(a,e,"signedMessage")),_=e.length;a.push(n),t=f(a,t,"publicKey");var s,c=0|kt._crypto_sign_publickeybytes();t.length!==c&&g(a,"invalid publicKey length"),s=i(t),a.push(s);var o=new y(_-kt._crypto_sign_bytes()|0),u=o.address;if(a.push(u),0==(0|kt._crypto_sign_open(u,null,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect usage")}function tt(e,t){var r=[];p(t),e=f(r,e,"seed");var a,n=0|kt._crypto_sign_seedbytes();e.length!==n&&g(r,"invalid seed length"),a=i(e),r.push(a);var _=new y(0|kt._crypto_sign_publickeybytes()),s=_.address;r.push(s);var c=new y(0|kt._crypto_sign_secretkeybytes()),o=c.address;if(r.push(o),0==(0|kt._crypto_sign_seed_keypair(s,o,a))){var u={publicKey:h(_,t),privateKey:h(c,t),keyType:"ed25519"};return d(r),u}v(r,"incorrect usage")}function rt(e,t,r){var a=[];p(r),b(a,e,"state_address");var n=i(t=f(a,t,"message_chunk")),_=t.length;a.push(n),0!=(0|kt._crypto_sign_update(e,n,_))?v(a,"incorrect usage"):d(a)}function at(e,t,r){var a=[];e=f(a,e,"signature");var n,_=0|kt._crypto_sign_bytes();e.length!==_&&g(a,"invalid signature length"),n=i(e),a.push(n);var s=i(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"publicKey");var h,o=0|kt._crypto_sign_publickeybytes();r.length!==o&&g(a,"invalid publicKey length"),h=i(r),a.push(h);var p=0===(0|kt._crypto_sign_verify_detached(n,s,c,0,h));return d(a),p}function nt(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"input_message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_stream_chacha20_ietf_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=i(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_stream_chacha20_ietf_keybytes();r.length!==l&&g(n,"invalid key length"),u=i(r),n.push(u);var b=new y(0|s),m=b.address;if(n.push(m),0===kt._crypto_stream_chacha20_ietf_xor(m,_,s,0,c,u)){var k=h(b,a);return d(n),k}v(n,"incorrect usage")}function _t(e,t,r,a,n){var _=[];p(n);var s=i(e=f(_,e,"input_message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_stream_chacha20_ietf_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=i(t),_.push(o),b(_,r,"nonce_increment"),("number"!=typeof r||(0|r)!==r||r<0)&&g(_,"nonce_increment must be an unsigned integer"),a=f(_,a,"key");var l,m=0|kt._crypto_stream_chacha20_ietf_keybytes();a.length!==m&&g(_,"invalid key length"),l=i(a),_.push(l);var k=new y(0|c),x=k.address;if(_.push(x),0===kt._crypto_stream_chacha20_ietf_xor_ic(x,s,c,0,o,r,0,l)){var w=h(k,n);return d(_),w}v(_,"incorrect usage")}function st(e){var t=[];p(e);var r=new y(0|kt._crypto_stream_chacha20_keybytes()),a=r.address;t.push(a),kt._crypto_stream_chacha20_keygen(a);var n=h(r,e);return d(t),n}function ct(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"input_message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_stream_chacha20_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=i(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_stream_chacha20_keybytes();r.length!==l&&g(n,"invalid key length"),u=i(r),n.push(u);var b=new y(0|s),m=b.address;if(n.push(m),0===kt._crypto_stream_chacha20_xor(m,_,s,0,c,u)){var k=h(b,a);return d(n),k}v(n,"incorrect usage")}function ht(e,t,r,a,n){var _=[];p(n);var s=i(e=f(_,e,"input_message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_stream_chacha20_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=i(t),_.push(o),b(_,r,"nonce_increment"),("number"!=typeof r||(0|r)!==r||r<0)&&g(_,"nonce_increment must be an unsigned integer"),a=f(_,a,"key");var l,m=0|kt._crypto_stream_chacha20_keybytes();a.length!==m&&g(_,"invalid key length"),l=i(a),_.push(l);var k=new y(0|c),x=k.address;if(_.push(x),0===kt._crypto_stream_chacha20_xor_ic(x,s,c,0,o,r,0,l)){var w=h(k,n);return d(_),w}v(_,"incorrect usage")}function ot(e){var t=[];p(e);var r=new y(0|kt._crypto_stream_keybytes()),a=r.address;t.push(a),kt._crypto_stream_keygen(a);var n=h(r,e);return d(t),n}function pt(e){var t=[];p(e);var r=new y(0|kt._crypto_stream_xchacha20_keybytes()),a=r.address;t.push(a),kt._crypto_stream_xchacha20_keygen(a);var n=h(r,e);return d(t),n}function yt(e,t,r,a){var n=[];p(a);var _=i(e=f(n,e,"input_message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_stream_xchacha20_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=i(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_stream_xchacha20_keybytes();r.length!==l&&g(n,"invalid key length"),u=i(r),n.push(u);var b=new y(0|s),m=b.address;if(n.push(m),0===kt._crypto_stream_xchacha20_xor(m,_,s,0,c,u)){var k=h(b,a);return d(n),k}v(n,"incorrect usage")}function it(e,t,r,a,n){var _=[];p(n);var s=i(e=f(_,e,"input_message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_stream_xchacha20_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=i(t),_.push(o),b(_,r,"nonce_increment"),("number"!=typeof r||(0|r)!==r||r<0)&&g(_,"nonce_increment must be an unsigned integer"),a=f(_,a,"key");var l,m=0|kt._crypto_stream_xchacha20_keybytes();a.length!==m&&g(_,"invalid key length"),l=i(a),_.push(l);var k=new y(0|c),x=k.address;if(_.push(x),0===kt._crypto_stream_xchacha20_xor_ic(x,s,c,0,o,r,0,l)){var w=h(k,n);return d(_),w}v(_,"incorrect usage")}function ut(e,t){var r=[];p(t),b(r,e,"length"),("number"!=typeof e||(0|e)!==e||e<0)&&g(r,"length must be an unsigned integer");var a=new y(0|e),n=a.address;r.push(n),kt._randombytes_buf(n,e);var _=h(a,t);return d(r),_}function lt(e,t,r){var a=[];p(r),b(a,e,"length"),("number"!=typeof e||(0|e)!==e||e<0)&&g(a,"length must be an unsigned integer"),t=f(a,t,"seed");var n,_=0|kt._randombytes_seedbytes();t.length!==_&&g(a,"invalid seed length"),n=i(t),a.push(n);var s=new y(0|e),c=s.address;a.push(c),kt._randombytes_buf_deterministic(c,e,0,t);var o=h(s,r);return d(a),o}function dt(e){p(e),kt._randombytes_close()}function vt(e){var t=[];p(e);var r=kt._randombytes_random()>>>0;return d(t),r}function gt(e,t){var r=[];p(t);for(var a=kt._malloc(24),n=0;n<6;n++)kt.setValue(a+4*n,kt.Runtime.addFunction(e[["implementation_name","random","stir","uniform","buf","close"][n]]),"i32");0!=(0|kt._randombytes_set_implementation(a))?v(r,"incorrect usage"):d(r)}function bt(e){p(e),kt._randombytes_stir()}function ft(e,t){var r=[];p(t),b(r,e,"upper_bound"),("number"!=typeof e||(0|e)!==e||e<0)&&g(r,"upper_bound must be an unsigned integer");var a=kt._randombytes_uniform(e)>>>0;return d(r),a}function mt(){var e=[],t=kt._sodium_version_string(),r=kt.Pointer_stringify(t);return d(e),r}var kt,xt="uint8array",wt=t.ready.then(function(){if(0!==(kt=t)._sodium_init())throw new Error("libsodium was not correctly initialized.");for(var r=["crypto_aead_chacha20poly1305_decrypt","crypto_aead_chacha20poly1305_decrypt_detached","crypto_aead_chacha20poly1305_encrypt","crypto_aead_chacha20poly1305_encrypt_detached","crypto_aead_chacha20poly1305_ietf_decrypt","crypto_aead_chacha20poly1305_ietf_decrypt_detached","crypto_aead_chacha20poly1305_ietf_encrypt","crypto_aead_chacha20poly1305_ietf_encrypt_detached","crypto_aead_chacha20poly1305_ietf_keygen","crypto_aead_chacha20poly1305_keygen","crypto_aead_xchacha20poly1305_ietf_decrypt","crypto_aead_xchacha20poly1305_ietf_decrypt_detached","crypto_aead_xchacha20poly1305_ietf_encrypt","crypto_aead_xchacha20poly1305_ietf_encrypt_detached","crypto_aead_xchacha20poly1305_ietf_keygen","crypto_auth","crypto_auth_hmacsha256","crypto_auth_hmacsha256_keygen","crypto_auth_hmacsha256_verify","crypto_auth_hmacsha512","crypto_auth_hmacsha512_keygen","crypto_auth_hmacsha512_verify","crypto_auth_keygen","crypto_auth_verify","crypto_box_beforenm","crypto_box_detached","crypto_box_easy","crypto_box_easy_afternm","crypto_box_keypair","crypto_box_open_detached","crypto_box_open_easy","crypto_box_open_easy_afternm","crypto_box_seal","crypto_box_seal_open","crypto_box_seed_keypair","crypto_generichash","crypto_generichash_final","crypto_generichash_init","crypto_generichash_keygen","crypto_generichash_update","crypto_hash","crypto_hash_sha256","crypto_hash_sha512","crypto_kdf_derive_from_key","crypto_kdf_keygen","crypto_kx_client_session_keys","crypto_kx_keypair","crypto_kx_seed_keypair","crypto_kx_server_session_keys","crypto_onetimeauth","crypto_onetimeauth_final","crypto_onetimeauth_init","crypto_onetimeauth_keygen","crypto_onetimeauth_update","crypto_onetimeauth_verify","crypto_pwhash","crypto_pwhash_scryptsalsa208sha256","crypto_pwhash_scryptsalsa208sha256_ll","crypto_pwhash_scryptsalsa208sha256_str","crypto_pwhash_scryptsalsa208sha256_str_verify","crypto_pwhash_str","crypto_pwhash_str_verify","crypto_scalarmult","crypto_scalarmult_base","crypto_secretbox_detached","crypto_secretbox_easy","crypto_secretbox_keygen","crypto_secretbox_open_detached","crypto_secretbox_open_easy","crypto_secretstream_xchacha20poly1305_init_pull","crypto_secretstream_xchacha20poly1305_init_push","crypto_secretstream_xchacha20poly1305_keygen","crypto_secretstream_xchacha20poly1305_pull","crypto_secretstream_xchacha20poly1305_push","crypto_secretstream_xchacha20poly1305_rekey","crypto_shorthash","crypto_shorthash_keygen","crypto_shorthash_siphashx24","crypto_sign","crypto_sign_detached","crypto_sign_ed25519_pk_to_curve25519","crypto_sign_ed25519_sk_to_curve25519","crypto_sign_ed25519_sk_to_pk","crypto_sign_ed25519_sk_to_seed","crypto_sign_final_create","crypto_sign_final_verify","crypto_sign_init","crypto_sign_keypair","crypto_sign_open","crypto_sign_seed_keypair","crypto_sign_update","crypto_sign_verify_detached","crypto_stream_chacha20_ietf_xor","crypto_stream_chacha20_ietf_xor_ic","crypto_stream_chacha20_keygen","crypto_stream_chacha20_xor","crypto_stream_chacha20_xor_ic","crypto_stream_keygen","crypto_stream_xchacha20_keygen","crypto_stream_xchacha20_xor","crypto_stream_xchacha20_xor_ic","randombytes_buf","randombytes_buf_deterministic","randombytes_close","randombytes_random","randombytes_set_implementation","randombytes_stir","randombytes_uniform","sodium_version_string"],a=[m,k,x,w,E,T,S,Y,K,A,I,B,M,L,N,U,R,O,P,C,D,G,V,F,X,H,j,z,W,J,q,Q,Z,$,ee,te,re,ae,ne,_e,se,ce,he,oe,pe,ye,ie,ue,le,de,ve,ge,be,fe,me,ke,xe,we,Ee,Te,Se,Ye,Ke,Ae,Ie,Be,Me,Le,Ne,Ue,Re,Oe,Pe,Ce,De,Ge,Ve,Fe,Xe,He,je,ze,We,Je,qe,Qe,Ze,$e,et,tt,rt,at,nt,_t,st,ct,ht,ot,pt,yt,it,ut,lt,dt,vt,gt,bt,ft,mt],n=0;n<a.length;n++)"function"==typeof kt["_"+r[n]]&&(e[r[n]]=a[n]);for(var _=["SODIUM_LIBRARY_VERSION_MAJOR","SODIUM_LIBRARY_VERSION_MINOR","crypto_aead_chacha20poly1305_ABYTES","crypto_aead_chacha20poly1305_KEYBYTES","crypto_aead_chacha20poly1305_NPUBBYTES","crypto_aead_chacha20poly1305_NSECBYTES","crypto_aead_chacha20poly1305_ietf_ABYTES","crypto_aead_chacha20poly1305_ietf_KEYBYTES","crypto_aead_chacha20poly1305_ietf_NPUBBYTES","crypto_aead_chacha20poly1305_ietf_NSECBYTES","crypto_aead_xchacha20poly1305_ietf_ABYTES","crypto_aead_xchacha20poly1305_ietf_KEYBYTES","crypto_aead_xchacha20poly1305_ietf_NPUBBYTES","crypto_aead_xchacha20poly1305_ietf_NSECBYTES","crypto_auth_BYTES","crypto_auth_KEYBYTES","crypto_auth_hmacsha256_BYTES","crypto_auth_hmacsha256_KEYBYTES","crypto_auth_hmacsha512_BYTES","crypto_auth_hmacsha512_KEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_MACBYTES","crypto_box_NONCEBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SEALBYTES","crypto_box_SECRETKEYBYTES","crypto_box_SEEDBYTES","crypto_generichash_BYTES","crypto_generichash_BYTES_MAX","crypto_generichash_BYTES_MIN","crypto_generichash_KEYBYTES","crypto_generichash_KEYBYTES_MAX","crypto_generichash_KEYBYTES_MIN","crypto_hash_BYTES","crypto_kdf_BYTES_MAX","crypto_kdf_BYTES_MIN","crypto_kdf_CONTEXTBYTES","crypto_kdf_KEYBYTES","crypto_kx_PUBLICKEYBYTES","crypto_kx_SECRETKEYBYTES","crypto_kx_SEEDBYTES","crypto_kx_SESSSIONKEYBYTES","crypto_onetimeauth_BYTES","crypto_onetimeauth_KEYBYTES","crypto_pwhash_ALG_ARGON2I13","crypto_pwhash_ALG_DEFAULT","crypto_pwhash_BYTES_MAX","crypto_pwhash_BYTES_MIN","crypto_pwhash_MEMLIMIT_INTERACTIVE","crypto_pwhash_MEMLIMIT_MAX","crypto_pwhash_MEMLIMIT_MIN","crypto_pwhash_MEMLIMIT_MODERATE","crypto_pwhash_MEMLIMIT_SENSITIVE","crypto_pwhash_OPSLIMIT_INTERACTIVE","crypto_pwhash_OPSLIMIT_MAX","crypto_pwhash_OPSLIMIT_MIN","crypto_pwhash_OPSLIMIT_MODERATE","crypto_pwhash_OPSLIMIT_SENSITIVE","crypto_pwhash_PASSWD_MAX","crypto_pwhash_PASSWD_MIN","crypto_pwhash_SALTBYTES","crypto_pwhash_STRBYTES","crypto_pwhash_STR_VERIFY","crypto_pwhash_scryptsalsa208sha256_BYTES_MAX","crypto_pwhash_scryptsalsa208sha256_BYTES_MIN","crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE","crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX","crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN","crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE","crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE","crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX","crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN","crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE","crypto_pwhash_scryptsalsa208sha256_SALTBYTES","crypto_pwhash_scryptsalsa208sha256_STRBYTES","crypto_pwhash_scryptsalsa208sha256_STR_VERIFY","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_secretbox_KEYBYTES","crypto_secretbox_MACBYTES","crypto_secretbox_NONCEBYTES","crypto_secretstream_xchacha20poly1305_ABYTES","crypto_secretstream_xchacha20poly1305_HEADERBYTES","crypto_secretstream_xchacha20poly1305_KEYBYTES","crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX","crypto_secretstream_xchacha20poly1305_NPUBBYTES","crypto_secretstream_xchacha20poly1305_TAG_FINAL","crypto_secretstream_xchacha20poly1305_TAG_MESSAGE","crypto_secretstream_xchacha20poly1305_TAG_PUSH","crypto_secretstream_xchacha20poly1305_TAG_REKEY","crypto_shorthash_BYTES","crypto_shorthash_KEYBYTES","crypto_shorthash_siphashx24_BYTES","crypto_shorthash_siphashx24_KEYBYTES","crypto_sign_BYTES","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_stream_chacha20_KEYBYTES","crypto_stream_chacha20_NONCEBYTES","crypto_stream_chacha20_ietf_KEYBYTES","crypto_stream_chacha20_ietf_NONCEBYTES","crypto_stream_xchacha20_ietf_KEYBYTES","crypto_stream_xchacha20_ietf_NONCEBYTES","randombytes_SEEDBYTES"],n=0;n<_.length;n++)"function"==typeof(c=kt["_"+_[n].toLowerCase()])&&(e[_[n]]=0|c());for(var s=["SODIUM_VERSION_STRING","crypto_pwhash_STRPREFIX","crypto_pwhash_scryptsalsa208sha256_STRPREFIX"],n=0;n<s.length;n++){var c=kt["_"+s[n].toLowerCase()];"function"==typeof c&&(e[s[n]]=kt.Pointer_stringify(c()))}}),Et={ORIGINAL:1,ORIGINAL_NO_PADDING:3,URLSAFE:5,URLSAFE_NO_PADDING:7};return y.prototype.to_Uint8Array=function(){var e=new Uint8Array(this.length);return e.set(kt.HEAPU8.subarray(this.address,this.address+this.length)),e},e.add=function(e,t){if(!(e instanceof Uint8Array&&t instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can added");var r=e.length,a=0,n=0;if(t.length!=e.length)throw new TypeError("Arguments must have the same length");for(n=0;n<r;n++)a>>=8,a+=e[n]+t[r],e[n]=255&a},e.base64_variants=Et,e.compare=function(e,t){if(!(e instanceof Uint8Array&&t instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be compared");if(e.length!==t.length)throw new TypeError("Only instances of identical length can be compared");for(var r=0,a=1,n=e.length;n-- >0;)r|=t[n]-e[n]>>8&a,a&=(t[n]^e[n])-1>>8;return r+r+a-1},e.from_base64=function(e,t){t=_(t);var r,a=[],n=new y(3*(e=f(a,e,"input")).length/4),s=i(e),c=u(4),h=u(4);return a.push(s),a.push(n.address),a.push(n.result_bin_len_p),a.push(n.b64_end_p),0!==kt._sodium_base642bin(n.address,n.length,s,e.length,0,c,h,t)&&v(a,"invalid input"),kt.getValue(h,"i32")-s!==e.length&&v(a,"incomplete input"),n.length=kt.getValue(c,"i32"),r=n.to_Uint8Array(),d(a),r},e.from_hex=function(e){var t,r=[],a=new y((e=f(r,e,"input")).length/2),n=i(e),_=u(4);return r.push(n),r.push(a.address),r.push(a.hex_end_p),0!==kt._sodium_hex2bin(a.address,a.length,n,e.length,0,0,_)&&v(r,"invalid input"),kt.getValue(_,"i32")-n!==e.length&&v(r,"incomplete input"),t=a.to_Uint8Array(),d(r),t},e.from_string=r,e.increment=function(e){if(!(e instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be incremented");for(var t=256,r=0,a=e.length;r<a;r++)t>>=8,t+=e[r],e[r]=255&t},e.is_zero=function(e){if(!(e instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be checked");for(var t=0,r=0,a=e.length;r<a;r++)t|=e[r];return 0===t},e.libsodium=t,e.memcmp=function(e,t){if(!(e instanceof Uint8Array&&t instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be compared");if(e.length!==t.length)throw new TypeError("Only instances of identical length can be compared");for(var r=0,a=0,n=e.length;a<n;a++)r|=e[a]^t[a];return 0===r},e.memzero=function(e){if(!(e instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be wiped");for(var t=0,r=e.length;t<r;t++)e[t]=0},e.output_formats=c,e.pad=function(e,t){if(!(e instanceof Uint8Array))throw new TypeError("buffer must be a Uint8Array");if((t|=0)<=0)throw new Error("block size must be > 0");var r,a=[],n=u(4),_=1,s=0,c=0|e.length,h=new y(c+t);a.push(n),a.push(h.address);for(var o=h.address,p=h.address+c+t;o<p;o++)kt.HEAPU8[o]=e[s],s+=_=1&~((65535&((c-=_)>>>48|c>>>32|c>>>16|c))-1>>16);return 0!==kt._sodium_pad(n,h.address,e.length,t,h.length)&&v(a,"internal error"),h.length=kt.getValue(n,"i32"),r=h.to_Uint8Array(),d(a),r},e.unpad=function(e,t){if(!(e instanceof Uint8Array))throw new TypeError("buffer must be a Uint8Array");if((t|=0)<=0)throw new Error("block size must be > 0");var r=[],a=i(e),n=u(4);return r.push(a),r.push(n),0!==kt._sodium_unpad(n,a,e.length,t)&&v(r,"unsupported/invalid padding"),e=new Uint8Array(e),e=e.subarray(0,kt.getValue(n,"i32")),d(r),e},e.ready=wt,e.symbols=function(){return Object.keys(e).sort()},e.to_base64=s,e.to_hex=n,e.to_string=a,e}var r="object"==typeof e.sodium&&"function"==typeof e.sodium.onload?e.sodium.onload:null;"function"==typeof define&&define.amd?define(["exports","libsodium"],t):"object"==typeof exports&&"string"!=typeof exports.nodeName?t(exports,require("libsodium")):e.sodium=t(e.commonJsStrict={},e.libsodium),r&&e.sodium.ready.then(function(){r(e.sodium)})}(this); | ||
!function(e){function t(e,t){"use strict";function r(e){if("function"==typeof TextEncoder)return new TextEncoder("utf-8").encode(e);e=unescape(encodeURIComponent(e));for(var t=new Uint8Array(e.length),r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}function a(e){if("function"==typeof TextDecoder)return new TextDecoder("utf-8",{fatal:!0}).decode(e);var t=Math.ceil(e.length/8192);if(t<=1)try{return decodeURIComponent(escape(String.fromCharCode.apply(null,e)))}catch(e){throw new TypeError("The encoded data was not valid.")}for(var r="",n=0,_=0;_<t;_++){var s=Array.prototype.slice.call(e,8192*_+n,8192*(_+1)+n);if(0!=s.length){var c,h=s.length,o=0;do{var p=s[--h];p>=240?(o=4,c=!0):p>=224?(o=3,c=!0):p>=192?(o=2,c=!0):p<128&&(o=1,c=!0)}while(!c);for(var i=o-(s.length-h),y=0;y<i;y++)n--,s.pop();r+=a(s)}}return r}function n(e){e=f(null,e,"input");for(var t,r,a,n="",_=0;_<e.length;_++)a=87+(r=15&e[_])+(r-10>>8&-39)<<8|87+(t=e[_]>>>4)+(t-10>>8&-39),n+=String.fromCharCode(255&a)+String.fromCharCode(a>>>8);return n}function _(e){if(void 0==e)return wt.URLSAFE_NO_PADDING;if(e!==wt.ORIGINAL&&e!==wt.ORIGINAL_NO_PADDING&&e!==wt.URLSAFE&&e!=wt.URLSAFE_NO_PADDING)throw new Error("unsupported base64 variant");return e}function s(e,t){t=_(t),e=f(n,e,"input");var r,n=[],s=0|Math.floor(e.length/3),c=e.length-3*s,h=4*s+(0!==c?0==(2&t)?4:2+(c>>>1):0),o=new i(h+1),p=y(e);return n.push(p),n.push(o.address),0===kt._sodium_bin2base64(o.address,o.length,p,e.length,t)&&v(n,"conversion failed"),o.length=h,r=a(o.to_Uint8Array()),d(n),r}function c(){return["uint8array","text","hex","base64"]}function h(e,t){var r=t||xt;if(!o(r))throw new Error(r+" output format is not available");if(e instanceof i){if("uint8array"===r)return e.to_Uint8Array();if("text"===r)return a(e.to_Uint8Array());if("hex"===r)return n(e.to_Uint8Array());if("base64"===r)return s(e.to_Uint8Array(),wt.URLSAFE_NO_PADDING);throw new Error('What is output format "'+r+'"?')}if("object"==typeof e){for(var _=Object.keys(e),c={},p=0;p<_.length;p++)c[_[p]]=h(e[_[p]],r);return c}if("string"==typeof e)return e;throw new TypeError("Cannot format output")}function o(e){for(var t=c(),r=0;r<t.length;r++)if(t[r]===e)return!0;return!1}function p(e){if(e){if("string"!=typeof e)throw new TypeError("When defined, the output format must be a string");if(!o(e))throw new Error(e+" is not a supported output format")}}function i(e){this.length=e,this.address=u(e)}function y(e){var t=u(e.length);return kt.HEAPU8.set(e,t),t}function u(e){var t=kt._malloc(e);if(0===t)throw{message:"_malloc() failed",length:e};return t}function l(e){kt._free(e)}function d(e){if(e)for(var t=0;t<e.length;t++)l(e[t])}function v(e,t){throw d(e),new Error(t)}function g(e,t){throw d(e),new TypeError(t)}function b(e,t,r){void 0==t&&g(e,r+" cannot be null or undefined")}function f(e,t,a){return b(e,t,a),t instanceof Uint8Array?t:"string"==typeof t?r(t):void g(e,"unsupported input type for "+a)}function m(e,t,r,a,n,_){var s=[];p(_);var c=null;void 0!=e&&(c=y(e=f(s,e,"secret_nonce")),e.length,s.push(c));var o=y(t=f(s,t,"ciphertext")),u=t.length;s.push(o);var l=null,b=0;void 0!=r&&(l=y(r=f(s,r,"additional_data")),b=r.length,s.push(l)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=y(a),s.push(m),n=f(s,n,"key");var x,E=0|kt._crypto_aead_chacha20poly1305_keybytes();n.length!==E&&g(s,"invalid key length"),x=y(n),s.push(x);var w=new i(u-kt._crypto_aead_chacha20poly1305_abytes()|0),S=w.address;if(s.push(S),0===kt._crypto_aead_chacha20poly1305_decrypt(S,null,c,o,u,0,l,b,0,m,x)){var T=h(w,_);return d(s),T}v(s,"invalid usage")}function k(e,t,r,a,n,_,s){var c=[];p(s);var o=null;void 0!=e&&(o=y(e=f(c,e,"secret_nonce")),e.length,c.push(o));var u=y(t=f(c,t,"ciphertext")),l=t.length;c.push(u),r=f(c,r,"mac");var b,m=0|kt._crypto_box_macbytes();r.length!==m&&g(c,"invalid mac length"),b=y(r),c.push(b);var k=null,x=0;void 0!=a&&(k=y(a=f(c,a,"additional_data")),x=a.length,c.push(k)),n=f(c,n,"public_nonce");var E,w=0|kt._crypto_aead_chacha20poly1305_npubbytes();n.length!==w&&g(c,"invalid public_nonce length"),E=y(n),c.push(E),_=f(c,_,"key");var S,T=0|kt._crypto_aead_chacha20poly1305_keybytes();_.length!==T&&g(c,"invalid key length"),S=y(_),c.push(S);var Y=new i(0|l),A=Y.address;if(c.push(A),0===kt._crypto_aead_chacha20poly1305_decrypt_detached(A,o,u,l,0,b,k,x,0,E,S)){var K=h(Y,s);return d(c),K}v(c,"invalid usage")}function x(e,t,r,a,n,_){var s=[];p(_);var c=y(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=y(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=y(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=y(a),s.push(m),n=f(s,n,"key");var x,E=0|kt._crypto_aead_chacha20poly1305_keybytes();n.length!==E&&g(s,"invalid key length"),x=y(n),s.push(x);var w=new i(o+kt._crypto_aead_chacha20poly1305_abytes()|0),S=w.address;if(s.push(S),0===kt._crypto_aead_chacha20poly1305_encrypt(S,null,c,o,0,u,l,0,b,m,x)){var T=h(w,_);return d(s),T}v(s,"invalid usage")}function E(e,t,r,a,n,_){var s=[];p(_);var c=y(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=y(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=y(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=y(a),s.push(m),n=f(s,n,"key");var x,E=0|kt._crypto_aead_chacha20poly1305_keybytes();n.length!==E&&g(s,"invalid key length"),x=y(n),s.push(x);var w=new i(0|o),S=w.address;s.push(S);var T=new i(0|kt._crypto_aead_chacha20poly1305_abytes()),Y=T.address;if(s.push(Y),0===kt._crypto_aead_chacha20poly1305_encrypt_detached(S,Y,null,c,o,0,u,l,0,b,m,x)){var A=h({ciphertext:w,mac:T},_);return d(s),A}v(s,"invalid usage")}function w(e,t,r,a,n,_){var s=[];p(_);var c=null;void 0!=e&&(c=y(e=f(s,e,"secret_nonce")),e.length,s.push(c));var o=y(t=f(s,t,"ciphertext")),u=t.length;s.push(o);var l=null,b=0;void 0!=r&&(l=y(r=f(s,r,"additional_data")),b=r.length,s.push(l)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=y(a),s.push(m),n=f(s,n,"key");var x,E=0|kt._crypto_aead_chacha20poly1305_ietf_keybytes();n.length!==E&&g(s,"invalid key length"),x=y(n),s.push(x);var w=new i(u-kt._crypto_aead_chacha20poly1305_ietf_abytes()|0),S=w.address;if(s.push(S),0===kt._crypto_aead_chacha20poly1305_ietf_decrypt(S,null,c,o,u,0,l,b,0,m,x)){var T=h(w,_);return d(s),T}v(s,"invalid usage")}function S(e,t,r,a,n,_,s){var c=[];p(s);var o=null;void 0!=e&&(o=y(e=f(c,e,"secret_nonce")),e.length,c.push(o));var u=y(t=f(c,t,"ciphertext")),l=t.length;c.push(u),r=f(c,r,"mac");var b,m=0|kt._crypto_box_macbytes();r.length!==m&&g(c,"invalid mac length"),b=y(r),c.push(b);var k=null,x=0;void 0!=a&&(k=y(a=f(c,a,"additional_data")),x=a.length,c.push(k)),n=f(c,n,"public_nonce");var E,w=0|kt._crypto_aead_chacha20poly1305_ietf_npubbytes();n.length!==w&&g(c,"invalid public_nonce length"),E=y(n),c.push(E),_=f(c,_,"key");var S,T=0|kt._crypto_aead_chacha20poly1305_ietf_keybytes();_.length!==T&&g(c,"invalid key length"),S=y(_),c.push(S);var Y=new i(0|l),A=Y.address;if(c.push(A),0===kt._crypto_aead_chacha20poly1305_ietf_decrypt_detached(A,o,u,l,0,b,k,x,0,E,S)){var K=h(Y,s);return d(c),K}v(c,"invalid usage")}function T(e,t,r,a,n,_){var s=[];p(_);var c=y(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=y(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=y(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=y(a),s.push(m),n=f(s,n,"key");var x,E=0|kt._crypto_aead_chacha20poly1305_ietf_keybytes();n.length!==E&&g(s,"invalid key length"),x=y(n),s.push(x);var w=new i(o+kt._crypto_aead_chacha20poly1305_ietf_abytes()|0),S=w.address;if(s.push(S),0===kt._crypto_aead_chacha20poly1305_ietf_encrypt(S,null,c,o,0,u,l,0,b,m,x)){var T=h(w,_);return d(s),T}v(s,"invalid usage")}function Y(e,t,r,a,n,_){var s=[];p(_);var c=y(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=y(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=y(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_chacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=y(a),s.push(m),n=f(s,n,"key");var x,E=0|kt._crypto_aead_chacha20poly1305_ietf_keybytes();n.length!==E&&g(s,"invalid key length"),x=y(n),s.push(x);var w=new i(0|o),S=w.address;s.push(S);var T=new i(0|kt._crypto_aead_chacha20poly1305_ietf_abytes()),Y=T.address;if(s.push(Y),0===kt._crypto_aead_chacha20poly1305_ietf_encrypt_detached(S,Y,null,c,o,0,u,l,0,b,m,x)){var A=h({ciphertext:w,mac:T},_);return d(s),A}v(s,"invalid usage")}function A(e){var t=[];p(e);var r=new i(0|kt._crypto_aead_chacha20poly1305_ietf_keybytes()),a=r.address;t.push(a),kt._crypto_aead_chacha20poly1305_ietf_keygen(a);var n=h(r,e);return d(t),n}function K(e){var t=[];p(e);var r=new i(0|kt._crypto_aead_chacha20poly1305_keybytes()),a=r.address;t.push(a),kt._crypto_aead_chacha20poly1305_keygen(a);var n=h(r,e);return d(t),n}function B(e,t,r,a,n,_){var s=[];p(_);var c=null;void 0!=e&&(c=y(e=f(s,e,"secret_nonce")),e.length,s.push(c));var o=y(t=f(s,t,"ciphertext")),u=t.length;s.push(o);var l=null,b=0;void 0!=r&&(l=y(r=f(s,r,"additional_data")),b=r.length,s.push(l)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_xchacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=y(a),s.push(m),n=f(s,n,"key");var x,E=0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes();n.length!==E&&g(s,"invalid key length"),x=y(n),s.push(x);var w=new i(u-kt._crypto_aead_xchacha20poly1305_ietf_abytes()|0),S=w.address;if(s.push(S),0===kt._crypto_aead_xchacha20poly1305_ietf_decrypt(S,null,c,o,u,0,l,b,0,m,x)){var T=h(w,_);return d(s),T}v(s,"invalid usage")}function I(e,t,r,a,n,_,s){var c=[];p(s);var o=null;void 0!=e&&(o=y(e=f(c,e,"secret_nonce")),e.length,c.push(o));var u=y(t=f(c,t,"ciphertext")),l=t.length;c.push(u),r=f(c,r,"mac");var b,m=0|kt._crypto_box_macbytes();r.length!==m&&g(c,"invalid mac length"),b=y(r),c.push(b);var k=null,x=0;void 0!=a&&(k=y(a=f(c,a,"additional_data")),x=a.length,c.push(k)),n=f(c,n,"public_nonce");var E,w=0|kt._crypto_aead_xchacha20poly1305_ietf_npubbytes();n.length!==w&&g(c,"invalid public_nonce length"),E=y(n),c.push(E),_=f(c,_,"key");var S,T=0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes();_.length!==T&&g(c,"invalid key length"),S=y(_),c.push(S);var Y=new i(0|l),A=Y.address;if(c.push(A),0===kt._crypto_aead_xchacha20poly1305_ietf_decrypt_detached(A,o,u,l,0,b,k,x,0,E,S)){var K=h(Y,s);return d(c),K}v(c,"invalid usage")}function M(e,t,r,a,n,_){var s=[];p(_);var c=y(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=y(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=y(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_xchacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=y(a),s.push(m),n=f(s,n,"key");var x,E=0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes();n.length!==E&&g(s,"invalid key length"),x=y(n),s.push(x);var w=new i(o+kt._crypto_aead_xchacha20poly1305_ietf_abytes()|0),S=w.address;if(s.push(S),0===kt._crypto_aead_xchacha20poly1305_ietf_encrypt(S,null,c,o,0,u,l,0,b,m,x)){var T=h(w,_);return d(s),T}v(s,"invalid usage")}function L(e,t,r,a,n,_){var s=[];p(_);var c=y(e=f(s,e,"message")),o=e.length;s.push(c);var u=null,l=0;void 0!=t&&(u=y(t=f(s,t,"additional_data")),l=t.length,s.push(u));var b=null;void 0!=r&&(b=y(r=f(s,r,"secret_nonce")),r.length,s.push(b)),a=f(s,a,"public_nonce");var m,k=0|kt._crypto_aead_xchacha20poly1305_ietf_npubbytes();a.length!==k&&g(s,"invalid public_nonce length"),m=y(a),s.push(m),n=f(s,n,"key");var x,E=0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes();n.length!==E&&g(s,"invalid key length"),x=y(n),s.push(x);var w=new i(0|o),S=w.address;s.push(S);var T=new i(0|kt._crypto_aead_xchacha20poly1305_ietf_abytes()),Y=T.address;if(s.push(Y),0===kt._crypto_aead_xchacha20poly1305_ietf_encrypt_detached(S,Y,null,c,o,0,u,l,0,b,m,x)){var A=h({ciphertext:w,mac:T},_);return d(s),A}v(s,"invalid usage")}function N(e){var t=[];p(e);var r=new i(0|kt._crypto_aead_xchacha20poly1305_ietf_keybytes()),a=r.address;t.push(a),kt._crypto_aead_xchacha20poly1305_ietf_keygen(a);var n=h(r,e);return d(t),n}function U(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_auth_keybytes();t.length!==c&&g(a,"invalid key length"),s=y(t),a.push(s);var o=new i(0|kt._crypto_auth_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_auth(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function O(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_auth_hmacsha256_keybytes();t.length!==c&&g(a,"invalid key length"),s=y(t),a.push(s);var o=new i(0|kt._crypto_auth_hmacsha256_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_auth_hmacsha256(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function R(e){var t=[];p(e);var r=new i(0|kt._crypto_auth_hmacsha256_keybytes()),a=r.address;t.push(a),kt._crypto_auth_hmacsha256_keygen(a);var n=h(r,e);return d(t),n}function P(e,t,r){var a=[];e=f(a,e,"tag");var n,_=0|kt._crypto_auth_hmacsha256_bytes();e.length!==_&&g(a,"invalid tag length"),n=y(e),a.push(n);var s=y(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"key");var h,o=0|kt._crypto_auth_hmacsha256_keybytes();r.length!==o&&g(a,"invalid key length"),h=y(r),a.push(h);var p=0==(0|kt._crypto_auth_hmacsha256_verify(n,s,c,0,h));return d(a),p}function C(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_auth_hmacsha512_keybytes();t.length!==c&&g(a,"invalid key length"),s=y(t),a.push(s);var o=new i(0|kt._crypto_auth_hmacsha512_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_auth_hmacsha512(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function G(e){var t=[];p(e);var r=new i(0|kt._crypto_auth_hmacsha512_keybytes()),a=r.address;t.push(a),kt._crypto_auth_hmacsha512_keygen(a);var n=h(r,e);return d(t),n}function D(e,t,r){var a=[];e=f(a,e,"tag");var n,_=0|kt._crypto_auth_hmacsha512_bytes();e.length!==_&&g(a,"invalid tag length"),n=y(e),a.push(n);var s=y(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"key");var h,o=0|kt._crypto_auth_hmacsha512_keybytes();r.length!==o&&g(a,"invalid key length"),h=y(r),a.push(h);var p=0==(0|kt._crypto_auth_hmacsha512_verify(n,s,c,0,h));return d(a),p}function X(e){var t=[];p(e);var r=new i(0|kt._crypto_auth_keybytes()),a=r.address;t.push(a),kt._crypto_auth_keygen(a);var n=h(r,e);return d(t),n}function V(e,t,r){var a=[];e=f(a,e,"tag");var n,_=0|kt._crypto_auth_bytes();e.length!==_&&g(a,"invalid tag length"),n=y(e),a.push(n);var s=y(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"key");var h,o=0|kt._crypto_auth_keybytes();r.length!==o&&g(a,"invalid key length"),h=y(r),a.push(h);var p=0==(0|kt._crypto_auth_verify(n,s,c,0,h));return d(a),p}function F(e,t,r){var a=[];p(r),e=f(a,e,"publicKey");var n,_=0|kt._crypto_box_publickeybytes();e.length!==_&&g(a,"invalid publicKey length"),n=y(e),a.push(n),t=f(a,t,"privateKey");var s,c=0|kt._crypto_box_secretkeybytes();t.length!==c&&g(a,"invalid privateKey length"),s=y(t),a.push(s);var o=new i(0|kt._crypto_box_beforenmbytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_box_beforenm(u,n,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function H(e,t,r,a,n){var _=[];p(n);var s=y(e=f(_,e,"message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_box_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=y(t),_.push(o),r=f(_,r,"publicKey");var l,b=0|kt._crypto_box_publickeybytes();r.length!==b&&g(_,"invalid publicKey length"),l=y(r),_.push(l),a=f(_,a,"privateKey");var m,k=0|kt._crypto_box_secretkeybytes();a.length!==k&&g(_,"invalid privateKey length"),m=y(a),_.push(m);var x=new i(0|c),E=x.address;_.push(E);var w=new i(0|kt._crypto_box_macbytes()),S=w.address;if(_.push(S),0==(0|kt._crypto_box_detached(E,S,s,c,0,o,l,m))){var T=h({ciphertext:x,mac:w},n);return d(_),T}v(_,"invalid usage")}function j(e,t,r,a,n){var _=[];p(n);var s=y(e=f(_,e,"message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_box_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=y(t),_.push(o),r=f(_,r,"publicKey");var l,b=0|kt._crypto_box_publickeybytes();r.length!==b&&g(_,"invalid publicKey length"),l=y(r),_.push(l),a=f(_,a,"privateKey");var m,k=0|kt._crypto_box_secretkeybytes();a.length!==k&&g(_,"invalid privateKey length"),m=y(a),_.push(m);var x=new i(c+kt._crypto_box_macbytes()|0),E=x.address;if(_.push(E),0==(0|kt._crypto_box_easy(E,s,c,0,o,l,m))){var w=h(x,n);return d(_),w}v(_,"invalid usage")}function z(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_box_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=y(t),n.push(c),r=f(n,r,"sharedKey");var u,l=0|kt._crypto_box_beforenmbytes();r.length!==l&&g(n,"invalid sharedKey length"),u=y(r),n.push(u);var b=new i(s+kt._crypto_box_macbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_box_easy_afternm(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"invalid usage")}function W(e){var t=[];p(e);var r=new i(0|kt._crypto_box_publickeybytes()),a=r.address;t.push(a);var n=new i(0|kt._crypto_box_secretkeybytes()),_=n.address;if(t.push(_),0==(0|kt._crypto_box_keypair(a,_))){var s={publicKey:h(r,e),privateKey:h(n,e),keyType:"x25519"};return d(t),s}v(t,"internal error")}function J(e,t,r,a,n,_){var s=[];p(_);var c=y(e=f(s,e,"ciphertext")),o=e.length;s.push(c),t=f(s,t,"mac");var u,l=0|kt._crypto_box_macbytes();t.length!==l&&g(s,"invalid mac length"),u=y(t),s.push(u),r=f(s,r,"nonce");var b,m=0|kt._crypto_box_noncebytes();r.length!==m&&g(s,"invalid nonce length"),b=y(r),s.push(b),a=f(s,a,"publicKey");var k,x=0|kt._crypto_box_publickeybytes();a.length!==x&&g(s,"invalid publicKey length"),k=y(a),s.push(k),n=f(s,n,"privateKey");var E,w=0|kt._crypto_box_secretkeybytes();n.length!==w&&g(s,"invalid privateKey length"),E=y(n),s.push(E);var S=new i(0|o),T=S.address;if(s.push(T),0==(0|kt._crypto_box_open_detached(T,c,u,o,0,b,k,E))){var Y=h(S,_);return d(s),Y}v(s,"incorrect key pair for the given ciphertext")}function q(e,t,r,a,n){var _=[];p(n);var s=y(e=f(_,e,"ciphertext")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_box_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=y(t),_.push(o),r=f(_,r,"publicKey");var l,b=0|kt._crypto_box_publickeybytes();r.length!==b&&g(_,"invalid publicKey length"),l=y(r),_.push(l),a=f(_,a,"privateKey");var m,k=0|kt._crypto_box_secretkeybytes();a.length!==k&&g(_,"invalid privateKey length"),m=y(a),_.push(m);var x=new i(c-kt._crypto_box_macbytes()|0),E=x.address;if(_.push(E),0==(0|kt._crypto_box_open_easy(E,s,c,0,o,l,m))){var w=h(x,n);return d(_),w}v(_,"incorrect key pair for the given ciphertext")}function Q(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"ciphertext")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_box_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=y(t),n.push(c),r=f(n,r,"sharedKey");var u,l=0|kt._crypto_box_beforenmbytes();r.length!==l&&g(n,"invalid sharedKey length"),u=y(r),n.push(u);var b=new i(s-kt._crypto_box_macbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_box_open_easy_afternm(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"incorrect secret key for the given ciphertext")}function Z(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"publicKey");var s,c=0|kt._crypto_box_publickeybytes();t.length!==c&&g(a,"invalid publicKey length"),s=y(t),a.push(s);var o=new i(_+kt._crypto_box_sealbytes()|0),u=o.address;if(a.push(u),0==(0|kt._crypto_box_seal(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function $(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"ciphertext")),s=e.length;n.push(_),t=f(n,t,"publicKey");var c,o=0|kt._crypto_box_publickeybytes();t.length!==o&&g(n,"invalid publicKey length"),c=y(t),n.push(c),r=f(n,r,"privateKey");var u,l=0|kt._crypto_box_secretkeybytes();r.length!==l&&g(n,"invalid privateKey length"),u=y(r),n.push(u);var b=new i(s-kt._crypto_box_sealbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_box_seal_open(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"incorrect key pair for the given ciphertext")}function ee(e,t){var r=[];p(t),e=f(r,e,"seed");var a,n=0|kt._crypto_box_seedbytes();e.length!==n&&g(r,"invalid seed length"),a=y(e),r.push(a);var _=new i(0|kt._crypto_box_publickeybytes()),s=_.address;r.push(s);var c=new i(0|kt._crypto_box_secretkeybytes()),o=c.address;if(r.push(o),0==(0|kt._crypto_box_seed_keypair(s,o,a))){var u={publicKey:h(_,t),privateKey:h(c,t),keyType:"x25519"};return d(r),u}v(r,"invalid usage")}function te(e,t,r,a){var n=[];p(a),b(n,e,"hash_length"),("number"!=typeof e||(0|e)!==e||e<0)&&g(n,"hash_length must be an unsigned integer");var _=y(t=f(n,t,"message")),s=t.length;n.push(_);var c=null,o=0;void 0!=r&&(c=y(r=f(n,r,"key")),o=r.length,n.push(c));var u=new i(e|=0),l=u.address;if(n.push(l),0==(0|kt._crypto_generichash(l,e,_,s,0,c,o))){var m=h(u,a);return d(n),m}v(n,"invalid usage")}function re(e,t,r){var a=[];p(r),b(a,e,"state_address"),b(a,t,"hash_length"),("number"!=typeof t||(0|t)!==t||t<0)&&g(a,"hash_length must be an unsigned integer");var n=new i(t|=0),_=n.address;if(a.push(_),0==(0|kt._crypto_generichash_final(e,_,t))){var s=(kt._free(e),h(n,r));return d(a),s}v(a,"invalid usage")}function ae(e,t,r){var a=[];p(r);var n=null,_=0;void 0!=e&&(n=y(e=f(a,e,"key")),_=e.length,a.push(n)),b(a,t,"hash_length"),("number"!=typeof t||(0|t)!==t||t<0)&&g(a,"hash_length must be an unsigned integer");var s=new i(357).address;if(0==(0|kt._crypto_generichash_init(s,n,_,t))){var c=s;return d(a),c}v(a,"invalid usage")}function ne(e){var t=[];p(e);var r=new i(0|kt._crypto_generichash_keybytes()),a=r.address;t.push(a),kt._crypto_generichash_keygen(a);var n=h(r,e);return d(t),n}function _e(e,t,r){var a=[];p(r),b(a,e,"state_address");var n=y(t=f(a,t,"message_chunk")),_=t.length;a.push(n),0!=(0|kt._crypto_generichash_update(e,n,_))&&v(a,"invalid usage"),d(a)}function se(e,t){var r=[];p(t);var a=y(e=f(r,e,"message")),n=e.length;r.push(a);var _=new i(0|kt._crypto_hash_bytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_hash(s,a,n,0))){var c=h(_,t);return d(r),c}v(r,"invalid usage")}function ce(e,t){var r=[];p(t);var a=y(e=f(r,e,"message")),n=e.length;r.push(a);var _=new i(0|kt._crypto_hash_sha256_bytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_hash_sha256(s,a,n,0))){var c=h(_,t);return d(r),c}v(r,"invalid usage")}function he(e,t){var r=[];p(t);var a=y(e=f(r,e,"message")),n=e.length;r.push(a);var _=new i(0|kt._crypto_hash_sha512_bytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_hash_sha512(s,a,n,0))){var c=h(_,t);return d(r),c}v(r,"invalid usage")}function oe(e,t,a,n,_){var s=[];p(_),b(s,e,"subkey_len"),("number"!=typeof e||(0|e)!==e||e<0)&&g(s,"subkey_len must be an unsigned integer"),b(s,t,"subkey_id"),("number"!=typeof t||(0|t)!==t||t<0)&&g(s,"subkey_id must be an unsigned integer");var c=y(a=r(a+"\0"));a.length,s.push(c),n=f(s,n,"key");var o,u=0|kt._crypto_kdf_keybytes();n.length!==u&&g(s,"invalid key length"),o=y(n),s.push(o);var l=new i(0|e),v=l.address;s.push(v),kt._crypto_kdf_derive_from_key(v,e,t,0,c,o);var m=h(l,_);return d(s),m}function pe(e){var t=[];p(e);var r=new i(0|kt._crypto_kdf_keybytes()),a=r.address;t.push(a),kt._crypto_kdf_keygen(a);var n=h(r,e);return d(t),n}function ie(e,t,r,a){var n=[];p(a),e=f(n,e,"clientPublicKey");var _,s=0|kt._crypto_kx_publickeybytes();e.length!==s&&g(n,"invalid clientPublicKey length"),_=y(e),n.push(_),t=f(n,t,"clientSecretKey");var c,o=0|kt._crypto_kx_secretkeybytes();t.length!==o&&g(n,"invalid clientSecretKey length"),c=y(t),n.push(c),r=f(n,r,"serverPublicKey");var u,l=0|kt._crypto_kx_publickeybytes();r.length!==l&&g(n,"invalid serverPublicKey length"),u=y(r),n.push(u);var b=new i(0|kt._crypto_kx_sessionkeybytes()),m=b.address;n.push(m);var k=new i(0|kt._crypto_kx_sessionkeybytes()),x=k.address;if(n.push(x),0==(0|kt._crypto_kx_client_session_keys(m,x,_,c,u))){var E=h({sharedRx:b,sharedTx:k},a);return d(n),E}v(n,"invalid usage")}function ye(e){var t=[];p(e);var r=new i(0|kt._crypto_kx_publickeybytes()),a=r.address;t.push(a);var n=new i(0|kt._crypto_kx_secretkeybytes()),_=n.address;if(t.push(_),0==(0|kt._crypto_kx_keypair(a,_))){var s={publicKey:h(r,e),privateKey:h(n,e),keyType:"x25519"};return d(t),s}v(t,"internal error")}function ue(e,t){var r=[];p(t),e=f(r,e,"seed");var a,n=0|kt._crypto_kx_seedbytes();e.length!==n&&g(r,"invalid seed length"),a=y(e),r.push(a);var _=new i(0|kt._crypto_kx_publickeybytes()),s=_.address;r.push(s);var c=new i(0|kt._crypto_kx_secretkeybytes()),o=c.address;if(r.push(o),0==(0|kt._crypto_kx_seed_keypair(s,o,a))){var u={publicKey:h(_,t),privateKey:h(c,t),keyType:"x25519"};return d(r),u}v(r,"internal error")}function le(e,t,r,a){var n=[];p(a),e=f(n,e,"serverPublicKey");var _,s=0|kt._crypto_kx_publickeybytes();e.length!==s&&g(n,"invalid serverPublicKey length"),_=y(e),n.push(_),t=f(n,t,"serverSecretKey");var c,o=0|kt._crypto_kx_secretkeybytes();t.length!==o&&g(n,"invalid serverSecretKey length"),c=y(t),n.push(c),r=f(n,r,"clientPublicKey");var u,l=0|kt._crypto_kx_publickeybytes();r.length!==l&&g(n,"invalid clientPublicKey length"),u=y(r),n.push(u);var b=new i(0|kt._crypto_kx_sessionkeybytes()),m=b.address;n.push(m);var k=new i(0|kt._crypto_kx_sessionkeybytes()),x=k.address;if(n.push(x),0==(0|kt._crypto_kx_server_session_keys(m,x,_,c,u))){var E=h({sharedRx:b,sharedTx:k},a);return d(n),E}v(n,"invalid usage")}function de(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_onetimeauth_keybytes();t.length!==c&&g(a,"invalid key length"),s=y(t),a.push(s);var o=new i(0|kt._crypto_onetimeauth_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_onetimeauth(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function ve(e,t){var r=[];p(t),b(r,e,"state_address");var a=new i(0|kt._crypto_onetimeauth_bytes()),n=a.address;if(r.push(n),0==(0|kt._crypto_onetimeauth_final(e,n))){var _=(kt._free(e),h(a,t));return d(r),_}v(r,"invalid usage")}function ge(e,t){var r=[];p(t);var a=null;void 0!=e&&(a=y(e=f(r,e,"key")),e.length,r.push(a));var n=new i(144).address;if(0==(0|kt._crypto_onetimeauth_init(n,a))){var _=n;return d(r),_}v(r,"invalid usage")}function be(e){var t=[];p(e);var r=new i(0|kt._crypto_onetimeauth_keybytes()),a=r.address;t.push(a),kt._crypto_onetimeauth_keygen(a);var n=h(r,e);return d(t),n}function fe(e,t,r){var a=[];p(r),b(a,e,"state_address");var n=y(t=f(a,t,"message_chunk")),_=t.length;a.push(n),0!=(0|kt._crypto_onetimeauth_update(e,n,_))&&v(a,"invalid usage"),d(a)}function me(e,t,r){var a=[];e=f(a,e,"hash");var n,_=0|kt._crypto_onetimeauth_bytes();e.length!==_&&g(a,"invalid hash length"),n=y(e),a.push(n);var s=y(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"key");var h,o=0|kt._crypto_onetimeauth_keybytes();r.length!==o&&g(a,"invalid key length"),h=y(r),a.push(h);var p=0==(0|kt._crypto_onetimeauth_verify(n,s,c,0,h));return d(a),p}function ke(e,t,r,a,n,_,s){var c=[];p(s),b(c,e,"keyLength"),("number"!=typeof e||(0|e)!==e||e<0)&&g(c,"keyLength must be an unsigned integer");var o=y(t=f(c,t,"password")),u=t.length;c.push(o),r=f(c,r,"salt");var l,m=0|kt._crypto_pwhash_saltbytes();r.length!==m&&g(c,"invalid salt length"),l=y(r),c.push(l),b(c,a,"opsLimit"),("number"!=typeof a||(0|a)!==a||a<0)&&g(c,"opsLimit must be an unsigned integer"),b(c,n,"memLimit"),("number"!=typeof n||(0|n)!==n||n<0)&&g(c,"memLimit must be an unsigned integer"),b(c,_,"algorithm"),("number"!=typeof _||(0|_)!==_||_<0)&&g(c,"algorithm must be an unsigned integer");var k=new i(0|e),x=k.address;if(c.push(x),0==(0|kt._crypto_pwhash(x,e,0,o,u,0,l,a,0,n,_))){var E=h(k,s);return d(c),E}v(c,"invalid usage")}function xe(e,t,r,a,n,_){var s=[];p(_),b(s,e,"keyLength"),("number"!=typeof e||(0|e)!==e||e<0)&&g(s,"keyLength must be an unsigned integer");var c=y(t=f(s,t,"password")),o=t.length;s.push(c),r=f(s,r,"salt");var u,l=0|kt._crypto_pwhash_scryptsalsa208sha256_saltbytes();r.length!==l&&g(s,"invalid salt length"),u=y(r),s.push(u),b(s,a,"opsLimit"),("number"!=typeof a||(0|a)!==a||a<0)&&g(s,"opsLimit must be an unsigned integer"),b(s,n,"memLimit"),("number"!=typeof n||(0|n)!==n||n<0)&&g(s,"memLimit must be an unsigned integer");var m=new i(0|e),k=m.address;if(s.push(k),0==(0|kt._crypto_pwhash_scryptsalsa208sha256(k,e,0,c,o,0,u,a,0,n))){var x=h(m,_);return d(s),x}v(s,"invalid usage")}function Ee(e,t,r,a,n,_,s){var c=[];p(s);var o=y(e=f(c,e,"password")),u=e.length;c.push(o);var l=y(t=f(c,t,"salt")),m=t.length;c.push(l),b(c,r,"opsLimit"),("number"!=typeof r||(0|r)!==r||r<0)&&g(c,"opsLimit must be an unsigned integer"),b(c,a,"r"),("number"!=typeof a||(0|a)!==a||a<0)&&g(c,"r must be an unsigned integer"),b(c,n,"p"),("number"!=typeof n||(0|n)!==n||n<0)&&g(c,"p must be an unsigned integer"),b(c,_,"keyLength"),("number"!=typeof _||(0|_)!==_||_<0)&&g(c,"keyLength must be an unsigned integer");var k=new i(0|_),x=k.address;if(c.push(x),0==(0|kt._crypto_pwhash_scryptsalsa208sha256_ll(o,u,l,m,r,0,a,n,x,_))){var E=h(k,s);return d(c),E}v(c,"invalid usage")}function we(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"password")),s=e.length;n.push(_),b(n,t,"opsLimit"),("number"!=typeof t||(0|t)!==t||t<0)&&g(n,"opsLimit must be an unsigned integer"),b(n,r,"memLimit"),("number"!=typeof r||(0|r)!==r||r<0)&&g(n,"memLimit must be an unsigned integer");var c=new i(0|kt._crypto_pwhash_scryptsalsa208sha256_strbytes()).address;if(n.push(c),0==(0|kt._crypto_pwhash_scryptsalsa208sha256_str(c,_,s,0,t,0,r))){var h=kt.Pointer_stringify(c);return d(n),h}v(n,"invalid usage")}function Se(e,t,a){var n=[];p(a);var _=y(e=r(e+"\0"));e.length,n.push(_);var s=y(t=f(n,t,"password")),c=t.length;n.push(s);var h=0==(0|kt._crypto_pwhash_scryptsalsa208sha256_str_verify(_,s,c,0));return d(n),h}function Te(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"password")),s=e.length;n.push(_),b(n,t,"opsLimit"),("number"!=typeof t||(0|t)!==t||t<0)&&g(n,"opsLimit must be an unsigned integer"),b(n,r,"memLimit"),("number"!=typeof r||(0|r)!==r||r<0)&&g(n,"memLimit must be an unsigned integer");var c=new i(0|kt._crypto_pwhash_strbytes()).address;if(n.push(c),0==(0|kt._crypto_pwhash_str(c,_,s,0,t,0,r))){var h=kt.Pointer_stringify(c);return d(n),h}v(n,"invalid usage")}function Ye(e,t,a){var n=[];p(a);var _=y(e=r(e+"\0"));e.length,n.push(_);var s=y(t=f(n,t,"password")),c=t.length;n.push(s);var h=0==(0|kt._crypto_pwhash_str_verify(_,s,c,0));return d(n),h}function Ae(e,t,r){var a=[];p(r),e=f(a,e,"privateKey");var n,_=0|kt._crypto_scalarmult_scalarbytes();e.length!==_&&g(a,"invalid privateKey length"),n=y(e),a.push(n),t=f(a,t,"publicKey");var s,c=0|kt._crypto_scalarmult_scalarbytes();t.length!==c&&g(a,"invalid publicKey length"),s=y(t),a.push(s);var o=new i(0|kt._crypto_scalarmult_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_scalarmult(u,n,s))){var l=h(o,r);return d(a),l}v(a,"weak public key")}function Ke(e,t){var r=[];p(t),e=f(r,e,"privateKey");var a,n=0|kt._crypto_scalarmult_scalarbytes();e.length!==n&&g(r,"invalid privateKey length"),a=y(e),r.push(a);var _=new i(0|kt._crypto_scalarmult_scalarbytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_scalarmult_base(s,a))){var c=h(_,t);return d(r),c}v(r,"insecure scalar")}function Be(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_secretbox_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=y(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_secretbox_keybytes();r.length!==l&&g(n,"invalid key length"),u=y(r),n.push(u);var b=new i(0|s),m=b.address;n.push(m);var k=new i(0|kt._crypto_secretbox_macbytes()),x=k.address;if(n.push(x),0==(0|kt._crypto_secretbox_detached(m,x,_,s,0,c,u))){var E=h({mac:k,cipher:b},a);return d(n),E}v(n,"invalid usage")}function Ie(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_secretbox_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=y(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_secretbox_keybytes();r.length!==l&&g(n,"invalid key length"),u=y(r),n.push(u);var b=new i(s+kt._crypto_secretbox_macbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_secretbox_easy(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"invalid usage")}function Me(e){var t=[];p(e);var r=new i(0|kt._crypto_secretbox_keybytes()),a=r.address;t.push(a),kt._crypto_secretbox_keygen(a);var n=h(r,e);return d(t),n}function Le(e,t,r,a,n){var _=[];p(n);var s=y(e=f(_,e,"ciphertext")),c=e.length;_.push(s),t=f(_,t,"mac");var o,u=0|kt._crypto_secretbox_macbytes();t.length!==u&&g(_,"invalid mac length"),o=y(t),_.push(o),r=f(_,r,"nonce");var l,b=0|kt._crypto_secretbox_noncebytes();r.length!==b&&g(_,"invalid nonce length"),l=y(r),_.push(l),a=f(_,a,"key");var m,k=0|kt._crypto_secretbox_keybytes();a.length!==k&&g(_,"invalid key length"),m=y(a),_.push(m);var x=new i(0|c),E=x.address;if(_.push(E),0==(0|kt._crypto_secretbox_open_detached(E,s,o,c,0,l,m))){var w=h(x,n);return d(_),w}v(_,"wrong secret key for the given ciphertext")}function Ne(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"ciphertext")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_secretbox_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=y(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_secretbox_keybytes();r.length!==l&&g(n,"invalid key length"),u=y(r),n.push(u);var b=new i(s-kt._crypto_secretbox_macbytes()|0),m=b.address;if(n.push(m),0==(0|kt._crypto_secretbox_open_easy(m,_,s,0,c,u))){var k=h(b,a);return d(n),k}v(n,"wrong secret key for the given ciphertext")}function Ue(e,t,r){var a=[];p(r),e=f(a,e,"header");var n,_=0|kt._crypto_secretstream_xchacha20poly1305_headerbytes();e.length!==_&&g(a,"invalid header length"),n=y(e),a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_secretstream_xchacha20poly1305_keybytes();t.length!==c&&g(a,"invalid key length"),s=y(t),a.push(s);var h=new i(52).address;if(0==(0|kt._crypto_secretstream_xchacha20poly1305_init_pull(h,n,s))){var o=h;return d(a),o}v(a,"invalid usage")}function Oe(e,t){var r=[];p(t),e=f(r,e,"key");var a,n=0|kt._crypto_secretstream_xchacha20poly1305_keybytes();e.length!==n&&g(r,"invalid key length"),a=y(e),r.push(a);var _=new i(52).address,s=new i(0|kt._crypto_secretstream_xchacha20poly1305_headerbytes()),c=s.address;if(r.push(c),0==(0|kt._crypto_secretstream_xchacha20poly1305_init_push(_,c,a))){var o={state:_,header:h(s,t)};return d(r),o}v(r,"invalid usage")}function Re(e){var t=[];p(e);var r=new i(0|kt._crypto_secretstream_xchacha20poly1305_keybytes()),a=r.address;t.push(a),kt._crypto_secretstream_xchacha20poly1305_keygen(a);var n=h(r,e);return d(t),n}function Pe(e,t,r,a){var n=[];p(a),b(n,e,"state_address");var _=y(t=f(n,t,"cipher")),s=t.length;n.push(_);var c=null,o=0;void 0!=r&&(r=f(n,r,"ad"),c=y(r),o=r.length,n.push(c));var l=new i(s-kt._crypto_secretstream_xchacha20poly1305_abytes()|0),v=l.address;n.push(v);var g=(g=function(){var t=u(1);return n.push(t),0===kt._crypto_secretstream_xchacha20poly1305_pull(e,v,0,t,_,s,0,c,o)&&{tag:kt.HEAPU8[t],message:l}}())&&{message:h(g.message,a),tag:g.tag};return d(n),g}function Ce(e,t,r,a,n){var _=[];p(n),b(_,e,"state_address");var s=y(t=f(_,t,"message_chunk")),c=t.length;_.push(s);var o=null,u=0;void 0!=r&&(o=y(r=f(_,r,"ad")),u=r.length,_.push(o)),b(_,a,"tag"),("number"!=typeof a||(0|a)!==a||a<0)&&g(_,"tag must be an unsigned integer");var l=new i(c+kt._crypto_secretstream_xchacha20poly1305_abytes()|0),m=l.address;if(_.push(m),0==(0|kt._crypto_secretstream_xchacha20poly1305_push(e,m,0,s,c,0,o,u,0,a))){var k=h(l,n);return d(_),k}v(_,"invalid usage")}function Ge(e,t){var r=[];return p(t),b(r,e,"state_address"),kt._crypto_secretstream_xchacha20poly1305_rekey(e),d(r),!0}function De(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_shorthash_keybytes();t.length!==c&&g(a,"invalid key length"),s=y(t),a.push(s);var o=new i(0|kt._crypto_shorthash_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_shorthash(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function Xe(e){var t=[];p(e);var r=new i(0|kt._crypto_shorthash_keybytes()),a=r.address;t.push(a),kt._crypto_shorthash_keygen(a);var n=h(r,e);return d(t),n}function Ve(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"key");var s,c=0|kt._crypto_shorthash_siphashx24_keybytes();t.length!==c&&g(a,"invalid key length"),s=y(t),a.push(s);var o=new i(0|kt._crypto_shorthash_siphashx24_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_shorthash_siphashx24(u,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function Fe(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"privateKey");var s,c=0|kt._crypto_sign_secretkeybytes();t.length!==c&&g(a,"invalid privateKey length"),s=y(t),a.push(s);var o=new i(e.length+kt._crypto_sign_bytes()|0),u=o.address;if(a.push(u),0==(0|kt._crypto_sign(u,null,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function He(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"message")),_=e.length;a.push(n),t=f(a,t,"privateKey");var s,c=0|kt._crypto_sign_secretkeybytes();t.length!==c&&g(a,"invalid privateKey length"),s=y(t),a.push(s);var o=new i(0|kt._crypto_sign_bytes()),u=o.address;if(a.push(u),0==(0|kt._crypto_sign_detached(u,null,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"invalid usage")}function je(e,t){var r=[];p(t),e=f(r,e,"edPk");var a,n=0|kt._crypto_sign_publickeybytes();e.length!==n&&g(r,"invalid edPk length"),a=y(e),r.push(a);var _=new i(0|kt._crypto_scalarmult_scalarbytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_sign_ed25519_pk_to_curve25519(s,a))){var c=h(_,t);return d(r),c}v(r,"invalid key")}function ze(e,t){var r=[];p(t),e=f(r,e,"edSk");var a,n=0|kt._crypto_sign_secretkeybytes();e.length!==n&&g(r,"invalid edSk length"),a=y(e),r.push(a);var _=new i(0|kt._crypto_scalarmult_scalarbytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_sign_ed25519_sk_to_curve25519(s,a))){var c=h(_,t);return d(r),c}v(r,"invalid key")}function We(e,t){var r=[];p(t),e=f(r,e,"privateKey");var a,n=0|kt._crypto_sign_secretkeybytes();e.length!==n&&g(r,"invalid privateKey length"),a=y(e),r.push(a);var _=new i(0|kt._crypto_sign_publickeybytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_sign_ed25519_sk_to_pk(s,a))){var c=h(_,t);return d(r),c}v(r,"invalid key")}function Je(e,t){var r=[];p(t),e=f(r,e,"privateKey");var a,n=0|kt._crypto_sign_secretkeybytes();e.length!==n&&g(r,"invalid privateKey length"),a=y(e),r.push(a);var _=new i(0|kt._crypto_sign_seedbytes()),s=_.address;if(r.push(s),0==(0|kt._crypto_sign_ed25519_sk_to_seed(s,a))){var c=h(_,t);return d(r),c}v(r,"invalid key")}function qe(e,t,r){var a=[];p(r),b(a,e,"state_address"),t=f(a,t,"privateKey");var n,_=0|kt._crypto_sign_secretkeybytes();t.length!==_&&g(a,"invalid privateKey length"),n=y(t),a.push(n);var s=new i(0|kt._crypto_sign_bytes()),c=s.address;if(a.push(c),0==(0|kt._crypto_sign_final_create(e,c,null,n))){var o=(kt._free(e),h(s,r));return d(a),o}v(a,"invalid usage")}function Qe(e,t,r,a){var n=[];p(a),b(n,e,"state_address"),t=f(n,t,"signature");var _,s=0|kt._crypto_sign_bytes();t.length!==s&&g(n,"invalid signature length"),_=y(t),n.push(_),r=f(n,r,"publicKey");var c,h=0|kt._crypto_sign_publickeybytes();r.length!==h&&g(n,"invalid publicKey length"),c=y(r),n.push(c);var o=0==(0|kt._crypto_sign_final_verify(e,_,c));return d(n),o}function Ze(e){var t=[];p(e);var r=new i(208).address;if(0==(0|kt._crypto_sign_init(r))){var a=r;return d(t),a}v(t,"internal error")}function $e(e){var t=[];p(e);var r=new i(0|kt._crypto_sign_publickeybytes()),a=r.address;t.push(a);var n=new i(0|kt._crypto_sign_secretkeybytes()),_=n.address;if(t.push(_),0==(0|kt._crypto_sign_keypair(a,_))){var s={publicKey:h(r,e),privateKey:h(n,e),keyType:"ed25519"};return d(t),s}v(t,"internal error")}function et(e,t,r){var a=[];p(r);var n=y(e=f(a,e,"signedMessage")),_=e.length;a.push(n),t=f(a,t,"publicKey");var s,c=0|kt._crypto_sign_publickeybytes();t.length!==c&&g(a,"invalid publicKey length"),s=y(t),a.push(s);var o=new i(_-kt._crypto_sign_bytes()|0),u=o.address;if(a.push(u),0==(0|kt._crypto_sign_open(u,null,n,_,0,s))){var l=h(o,r);return d(a),l}v(a,"incorrect signature for the given public key")}function tt(e,t){var r=[];p(t),e=f(r,e,"seed");var a,n=0|kt._crypto_sign_seedbytes();e.length!==n&&g(r,"invalid seed length"),a=y(e),r.push(a);var _=new i(0|kt._crypto_sign_publickeybytes()),s=_.address;r.push(s);var c=new i(0|kt._crypto_sign_secretkeybytes()),o=c.address;if(r.push(o),0==(0|kt._crypto_sign_seed_keypair(s,o,a))){var u={publicKey:h(_,t),privateKey:h(c,t),keyType:"ed25519"};return d(r),u}v(r,"invalid usage")}function rt(e,t,r){var a=[];p(r),b(a,e,"state_address");var n=y(t=f(a,t,"message_chunk")),_=t.length;a.push(n),0!=(0|kt._crypto_sign_update(e,n,_))&&v(a,"invalid usage"),d(a)}function at(e,t,r){var a=[];e=f(a,e,"signature");var n,_=0|kt._crypto_sign_bytes();e.length!==_&&g(a,"invalid signature length"),n=y(e),a.push(n);var s=y(t=f(a,t,"message")),c=t.length;a.push(s),r=f(a,r,"publicKey");var h,o=0|kt._crypto_sign_publickeybytes();r.length!==o&&g(a,"invalid publicKey length"),h=y(r),a.push(h);var p=0==(0|kt._crypto_sign_verify_detached(n,s,c,0,h));return d(a),p}function nt(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"input_message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_stream_chacha20_ietf_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=y(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_stream_chacha20_ietf_keybytes();r.length!==l&&g(n,"invalid key length"),u=y(r),n.push(u);var b=new i(0|s),m=b.address;if(n.push(m),0===kt._crypto_stream_chacha20_ietf_xor(m,_,s,0,c,u)){var k=h(b,a);return d(n),k}v(n,"invalid usage")}function _t(e,t,r,a,n){var _=[];p(n);var s=y(e=f(_,e,"input_message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_stream_chacha20_ietf_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=y(t),_.push(o),b(_,r,"nonce_increment"),("number"!=typeof r||(0|r)!==r||r<0)&&g(_,"nonce_increment must be an unsigned integer"),a=f(_,a,"key");var l,m=0|kt._crypto_stream_chacha20_ietf_keybytes();a.length!==m&&g(_,"invalid key length"),l=y(a),_.push(l);var k=new i(0|c),x=k.address;if(_.push(x),0===kt._crypto_stream_chacha20_ietf_xor_ic(x,s,c,0,o,r,0,l)){var E=h(k,n);return d(_),E}v(_,"invalid usage")}function st(e){var t=[];p(e);var r=new i(0|kt._crypto_stream_chacha20_keybytes()),a=r.address;t.push(a),kt._crypto_stream_chacha20_keygen(a);var n=h(r,e);return d(t),n}function ct(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"input_message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_stream_chacha20_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=y(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_stream_chacha20_keybytes();r.length!==l&&g(n,"invalid key length"),u=y(r),n.push(u);var b=new i(0|s),m=b.address;if(n.push(m),0===kt._crypto_stream_chacha20_xor(m,_,s,0,c,u)){var k=h(b,a);return d(n),k}v(n,"invalid usage")}function ht(e,t,r,a,n){var _=[];p(n);var s=y(e=f(_,e,"input_message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_stream_chacha20_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=y(t),_.push(o),b(_,r,"nonce_increment"),("number"!=typeof r||(0|r)!==r||r<0)&&g(_,"nonce_increment must be an unsigned integer"),a=f(_,a,"key");var l,m=0|kt._crypto_stream_chacha20_keybytes();a.length!==m&&g(_,"invalid key length"),l=y(a),_.push(l);var k=new i(0|c),x=k.address;if(_.push(x),0===kt._crypto_stream_chacha20_xor_ic(x,s,c,0,o,r,0,l)){var E=h(k,n);return d(_),E}v(_,"invalid usage")}function ot(e){var t=[];p(e);var r=new i(0|kt._crypto_stream_keybytes()),a=r.address;t.push(a),kt._crypto_stream_keygen(a);var n=h(r,e);return d(t),n}function pt(e){var t=[];p(e);var r=new i(0|kt._crypto_stream_xchacha20_keybytes()),a=r.address;t.push(a),kt._crypto_stream_xchacha20_keygen(a);var n=h(r,e);return d(t),n}function it(e,t,r,a){var n=[];p(a);var _=y(e=f(n,e,"input_message")),s=e.length;n.push(_),t=f(n,t,"nonce");var c,o=0|kt._crypto_stream_xchacha20_noncebytes();t.length!==o&&g(n,"invalid nonce length"),c=y(t),n.push(c),r=f(n,r,"key");var u,l=0|kt._crypto_stream_xchacha20_keybytes();r.length!==l&&g(n,"invalid key length"),u=y(r),n.push(u);var b=new i(0|s),m=b.address;if(n.push(m),0===kt._crypto_stream_xchacha20_xor(m,_,s,0,c,u)){var k=h(b,a);return d(n),k}v(n,"invalid usage")}function yt(e,t,r,a,n){var _=[];p(n);var s=y(e=f(_,e,"input_message")),c=e.length;_.push(s),t=f(_,t,"nonce");var o,u=0|kt._crypto_stream_xchacha20_noncebytes();t.length!==u&&g(_,"invalid nonce length"),o=y(t),_.push(o),b(_,r,"nonce_increment"),("number"!=typeof r||(0|r)!==r||r<0)&&g(_,"nonce_increment must be an unsigned integer"),a=f(_,a,"key");var l,m=0|kt._crypto_stream_xchacha20_keybytes();a.length!==m&&g(_,"invalid key length"),l=y(a),_.push(l);var k=new i(0|c),x=k.address;if(_.push(x),0===kt._crypto_stream_xchacha20_xor_ic(x,s,c,0,o,r,0,l)){var E=h(k,n);return d(_),E}v(_,"invalid usage")}function ut(e,t){var r=[];p(t),b(r,e,"length"),("number"!=typeof e||(0|e)!==e||e<0)&&g(r,"length must be an unsigned integer");var a=new i(0|e),n=a.address;r.push(n),kt._randombytes_buf(n,e);var _=h(a,t);return d(r),_}function lt(e,t,r){var a=[];p(r),b(a,e,"length"),("number"!=typeof e||(0|e)!==e||e<0)&&g(a,"length must be an unsigned integer"),t=f(a,t,"seed");var n,_=0|kt._randombytes_seedbytes();t.length!==_&&g(a,"invalid seed length"),n=y(t),a.push(n);var s=new i(0|e),c=s.address;a.push(c),kt._randombytes_buf_deterministic(c,e,0,t);var o=h(s,r);return d(a),o}function dt(e){p(e),kt._randombytes_close()}function vt(e){p(e);var t=kt._randombytes_random()>>>0;return d([]),t}function gt(e,t){var r=[];p(t);for(var a=kt._malloc(24),n=0;n<6;n++)kt.setValue(a+4*n,kt.Runtime.addFunction(e[["implementation_name","random","stir","uniform","buf","close"][n]]),"i32");0!=(0|kt._randombytes_set_implementation(a))&&v(r,"unsupported implementation"),d(r)}function bt(e){p(e),kt._randombytes_stir()}function ft(e,t){var r=[];p(t),b(r,e,"upper_bound"),("number"!=typeof e||(0|e)!==e||e<0)&&g(r,"upper_bound must be an unsigned integer");var a=kt._randombytes_uniform(e)>>>0;return d(r),a}function mt(){var e=kt._sodium_version_string(),t=kt.Pointer_stringify(e);return d([]),t}var kt,xt="uint8array",Et=t.ready.then(function(){if(0!==(kt=t)._sodium_init())throw new Error("libsodium was not correctly initialized.");for(var r=["crypto_aead_chacha20poly1305_decrypt","crypto_aead_chacha20poly1305_decrypt_detached","crypto_aead_chacha20poly1305_encrypt","crypto_aead_chacha20poly1305_encrypt_detached","crypto_aead_chacha20poly1305_ietf_decrypt","crypto_aead_chacha20poly1305_ietf_decrypt_detached","crypto_aead_chacha20poly1305_ietf_encrypt","crypto_aead_chacha20poly1305_ietf_encrypt_detached","crypto_aead_chacha20poly1305_ietf_keygen","crypto_aead_chacha20poly1305_keygen","crypto_aead_xchacha20poly1305_ietf_decrypt","crypto_aead_xchacha20poly1305_ietf_decrypt_detached","crypto_aead_xchacha20poly1305_ietf_encrypt","crypto_aead_xchacha20poly1305_ietf_encrypt_detached","crypto_aead_xchacha20poly1305_ietf_keygen","crypto_auth","crypto_auth_hmacsha256","crypto_auth_hmacsha256_keygen","crypto_auth_hmacsha256_verify","crypto_auth_hmacsha512","crypto_auth_hmacsha512_keygen","crypto_auth_hmacsha512_verify","crypto_auth_keygen","crypto_auth_verify","crypto_box_beforenm","crypto_box_detached","crypto_box_easy","crypto_box_easy_afternm","crypto_box_keypair","crypto_box_open_detached","crypto_box_open_easy","crypto_box_open_easy_afternm","crypto_box_seal","crypto_box_seal_open","crypto_box_seed_keypair","crypto_generichash","crypto_generichash_final","crypto_generichash_init","crypto_generichash_keygen","crypto_generichash_update","crypto_hash","crypto_hash_sha256","crypto_hash_sha512","crypto_kdf_derive_from_key","crypto_kdf_keygen","crypto_kx_client_session_keys","crypto_kx_keypair","crypto_kx_seed_keypair","crypto_kx_server_session_keys","crypto_onetimeauth","crypto_onetimeauth_final","crypto_onetimeauth_init","crypto_onetimeauth_keygen","crypto_onetimeauth_update","crypto_onetimeauth_verify","crypto_pwhash","crypto_pwhash_scryptsalsa208sha256","crypto_pwhash_scryptsalsa208sha256_ll","crypto_pwhash_scryptsalsa208sha256_str","crypto_pwhash_scryptsalsa208sha256_str_verify","crypto_pwhash_str","crypto_pwhash_str_verify","crypto_scalarmult","crypto_scalarmult_base","crypto_secretbox_detached","crypto_secretbox_easy","crypto_secretbox_keygen","crypto_secretbox_open_detached","crypto_secretbox_open_easy","crypto_secretstream_xchacha20poly1305_init_pull","crypto_secretstream_xchacha20poly1305_init_push","crypto_secretstream_xchacha20poly1305_keygen","crypto_secretstream_xchacha20poly1305_pull","crypto_secretstream_xchacha20poly1305_push","crypto_secretstream_xchacha20poly1305_rekey","crypto_shorthash","crypto_shorthash_keygen","crypto_shorthash_siphashx24","crypto_sign","crypto_sign_detached","crypto_sign_ed25519_pk_to_curve25519","crypto_sign_ed25519_sk_to_curve25519","crypto_sign_ed25519_sk_to_pk","crypto_sign_ed25519_sk_to_seed","crypto_sign_final_create","crypto_sign_final_verify","crypto_sign_init","crypto_sign_keypair","crypto_sign_open","crypto_sign_seed_keypair","crypto_sign_update","crypto_sign_verify_detached","crypto_stream_chacha20_ietf_xor","crypto_stream_chacha20_ietf_xor_ic","crypto_stream_chacha20_keygen","crypto_stream_chacha20_xor","crypto_stream_chacha20_xor_ic","crypto_stream_keygen","crypto_stream_xchacha20_keygen","crypto_stream_xchacha20_xor","crypto_stream_xchacha20_xor_ic","randombytes_buf","randombytes_buf_deterministic","randombytes_close","randombytes_random","randombytes_set_implementation","randombytes_stir","randombytes_uniform","sodium_version_string"],a=[m,k,x,E,w,S,T,Y,A,K,B,I,M,L,N,U,O,R,P,C,G,D,X,V,F,H,j,z,W,J,q,Q,Z,$,ee,te,re,ae,ne,_e,se,ce,he,oe,pe,ie,ye,ue,le,de,ve,ge,be,fe,me,ke,xe,Ee,we,Se,Te,Ye,Ae,Ke,Be,Ie,Me,Le,Ne,Ue,Oe,Re,Pe,Ce,Ge,De,Xe,Ve,Fe,He,je,ze,We,Je,qe,Qe,Ze,$e,et,tt,rt,at,nt,_t,st,ct,ht,ot,pt,it,yt,ut,lt,dt,vt,gt,bt,ft,mt],n=0;n<a.length;n++)"function"==typeof kt["_"+r[n]]&&(e[r[n]]=a[n]);for(var _=["SODIUM_LIBRARY_VERSION_MAJOR","SODIUM_LIBRARY_VERSION_MINOR","crypto_aead_chacha20poly1305_ABYTES","crypto_aead_chacha20poly1305_KEYBYTES","crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX","crypto_aead_chacha20poly1305_NPUBBYTES","crypto_aead_chacha20poly1305_NSECBYTES","crypto_aead_chacha20poly1305_ietf_ABYTES","crypto_aead_chacha20poly1305_ietf_KEYBYTES","crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX","crypto_aead_chacha20poly1305_ietf_NPUBBYTES","crypto_aead_chacha20poly1305_ietf_NSECBYTES","crypto_aead_xchacha20poly1305_ietf_ABYTES","crypto_aead_xchacha20poly1305_ietf_KEYBYTES","crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX","crypto_aead_xchacha20poly1305_ietf_NPUBBYTES","crypto_aead_xchacha20poly1305_ietf_NSECBYTES","crypto_auth_BYTES","crypto_auth_KEYBYTES","crypto_auth_hmacsha256_BYTES","crypto_auth_hmacsha256_KEYBYTES","crypto_auth_hmacsha512_BYTES","crypto_auth_hmacsha512_KEYBYTES","crypto_box_BEFORENMBYTES","crypto_box_MACBYTES","crypto_box_MESSAGEBYTES_MAX","crypto_box_NONCEBYTES","crypto_box_PUBLICKEYBYTES","crypto_box_SEALBYTES","crypto_box_SECRETKEYBYTES","crypto_box_SEEDBYTES","crypto_core_hchacha20_CONSTBYTES","crypto_core_hchacha20_INPUTBYTES","crypto_core_hchacha20_KEYBYTES","crypto_core_hchacha20_OUTPUTBYTES","crypto_generichash_BYTES","crypto_generichash_BYTES_MAX","crypto_generichash_BYTES_MIN","crypto_generichash_KEYBYTES","crypto_generichash_KEYBYTES_MAX","crypto_generichash_KEYBYTES_MIN","crypto_hash_BYTES","crypto_hash_sha256_BYTES","crypto_hash_sha512_BYTES","crypto_kdf_BYTES_MAX","crypto_kdf_BYTES_MIN","crypto_kdf_CONTEXTBYTES","crypto_kdf_KEYBYTES","crypto_kx_PUBLICKEYBYTES","crypto_kx_SECRETKEYBYTES","crypto_kx_SEEDBYTES","crypto_kx_SESSIONKEYBYTES","crypto_onetimeauth_BYTES","crypto_onetimeauth_KEYBYTES","crypto_pwhash_ALG_ARGON2I13","crypto_pwhash_ALG_ARGON2ID13","crypto_pwhash_ALG_DEFAULT","crypto_pwhash_BYTES_MAX","crypto_pwhash_BYTES_MIN","crypto_pwhash_MEMLIMIT_INTERACTIVE","crypto_pwhash_MEMLIMIT_MAX","crypto_pwhash_MEMLIMIT_MIN","crypto_pwhash_MEMLIMIT_MODERATE","crypto_pwhash_MEMLIMIT_SENSITIVE","crypto_pwhash_OPSLIMIT_INTERACTIVE","crypto_pwhash_OPSLIMIT_MAX","crypto_pwhash_OPSLIMIT_MIN","crypto_pwhash_OPSLIMIT_MODERATE","crypto_pwhash_OPSLIMIT_SENSITIVE","crypto_pwhash_PASSWD_MAX","crypto_pwhash_PASSWD_MIN","crypto_pwhash_SALTBYTES","crypto_pwhash_STRBYTES","crypto_pwhash_STR_VERIFY","crypto_pwhash_scryptsalsa208sha256_BYTES_MAX","crypto_pwhash_scryptsalsa208sha256_BYTES_MIN","crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE","crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX","crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN","crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE","crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE","crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX","crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN","crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE","crypto_pwhash_scryptsalsa208sha256_SALTBYTES","crypto_pwhash_scryptsalsa208sha256_STRBYTES","crypto_pwhash_scryptsalsa208sha256_STR_VERIFY","crypto_scalarmult_BYTES","crypto_scalarmult_SCALARBYTES","crypto_secretbox_KEYBYTES","crypto_secretbox_MACBYTES","crypto_secretbox_MESSAGEBYTES_MAX","crypto_secretbox_NONCEBYTES","crypto_secretstream_xchacha20poly1305_ABYTES","crypto_secretstream_xchacha20poly1305_HEADERBYTES","crypto_secretstream_xchacha20poly1305_KEYBYTES","crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX","crypto_secretstream_xchacha20poly1305_MESSAGESBYTES_MAX","crypto_secretstream_xchacha20poly1305_NPUBBYTES","crypto_secretstream_xchacha20poly1305_TAG_FINAL","crypto_secretstream_xchacha20poly1305_TAG_MESSAGE","crypto_secretstream_xchacha20poly1305_TAG_PUSH","crypto_secretstream_xchacha20poly1305_TAG_REKEY","crypto_shorthash_BYTES","crypto_shorthash_KEYBYTES","crypto_shorthash_siphashx24_BYTES","crypto_shorthash_siphashx24_KEYBYTES","crypto_sign_BYTES","crypto_sign_MESSAGEBYTES_MAX","crypto_sign_PUBLICKEYBYTES","crypto_sign_SECRETKEYBYTES","crypto_sign_SEEDBYTES","crypto_stream_KEYBYTES","crypto_stream_MESSAGEBYTES_MAX","crypto_stream_NONCEBYTES","crypto_stream_chacha20_KEYBYTES","crypto_stream_chacha20_NONCEBYTES","crypto_stream_chacha20_ietf_KEYBYTES","crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX","crypto_stream_chacha20_ietf_NONCEBYTES","crypto_stream_xchacha20_KEYBYTES","crypto_stream_xchacha20_MESSAGEBYTES_MAX","crypto_stream_xchacha20_NONCEBYTES","randombytes_SEEDBYTES"],n=0;n<_.length;n++)"function"==typeof(c=kt["_"+_[n].toLowerCase()])&&(e[_[n]]=c());for(var s=["SODIUM_VERSION_STRING","crypto_pwhash_STRPREFIX","crypto_pwhash_scryptsalsa208sha256_STRPREFIX"],n=0;n<s.length;n++){var c=kt["_"+s[n].toLowerCase()];"function"==typeof c&&(e[s[n]]=kt.Pointer_stringify(c()))}}),wt={ORIGINAL:1,ORIGINAL_NO_PADDING:3,URLSAFE:5,URLSAFE_NO_PADDING:7};return i.prototype.to_Uint8Array=function(){var e=new Uint8Array(this.length);return e.set(kt.HEAPU8.subarray(this.address,this.address+this.length)),e},e.add=function(e,t){if(!(e instanceof Uint8Array&&t instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can added");var r=e.length,a=0,n=0;if(t.length!=e.length)throw new TypeError("Arguments must have the same length");for(n=0;n<r;n++)a>>=8,a+=e[n]+t[r],e[n]=255&a},e.base64_variants=wt,e.compare=function(e,t){if(!(e instanceof Uint8Array&&t instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be compared");if(e.length!==t.length)throw new TypeError("Only instances of identical length can be compared");for(var r=0,a=1,n=e.length;n-- >0;)r|=t[n]-e[n]>>8&a,a&=(t[n]^e[n])-1>>8;return r+r+a-1},e.from_base64=function(e,t){t=_(t);var r,a=[],n=new i(3*(e=f(a,e,"input")).length/4),s=y(e),c=u(4),h=u(4);return a.push(s),a.push(n.address),a.push(n.result_bin_len_p),a.push(n.b64_end_p),0!==kt._sodium_base642bin(n.address,n.length,s,e.length,0,c,h,t)&&v(a,"invalid input"),kt.getValue(h,"i32")-s!==e.length&&v(a,"incomplete input"),n.length=kt.getValue(c,"i32"),r=n.to_Uint8Array(),d(a),r},e.from_hex=function(e){var t,r=[],a=new i((e=f(r,e,"input")).length/2),n=y(e),_=u(4);return r.push(n),r.push(a.address),r.push(a.hex_end_p),0!==kt._sodium_hex2bin(a.address,a.length,n,e.length,0,0,_)&&v(r,"invalid input"),kt.getValue(_,"i32")-n!==e.length&&v(r,"incomplete input"),t=a.to_Uint8Array(),d(r),t},e.from_string=r,e.increment=function(e){if(!(e instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be incremented");for(var t=256,r=0,a=e.length;r<a;r++)t>>=8,t+=e[r],e[r]=255&t},e.is_zero=function(e){if(!(e instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be checked");for(var t=0,r=0,a=e.length;r<a;r++)t|=e[r];return 0===t},e.libsodium=t,e.memcmp=function(e,t){if(!(e instanceof Uint8Array&&t instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be compared");if(e.length!==t.length)throw new TypeError("Only instances of identical length can be compared");for(var r=0,a=0,n=e.length;a<n;a++)r|=e[a]^t[a];return 0===r},e.memzero=function(e){if(!(e instanceof Uint8Array))throw new TypeError("Only Uint8Array instances can be wiped");for(var t=0,r=e.length;t<r;t++)e[t]=0},e.output_formats=c,e.pad=function(e,t){if(!(e instanceof Uint8Array))throw new TypeError("buffer must be a Uint8Array");if((t|=0)<=0)throw new Error("block size must be > 0");var r,a=[],n=u(4),_=1,s=0,c=0|e.length,h=new i(c+t);a.push(n),a.push(h.address);for(var o=h.address,p=h.address+c+t;o<p;o++)kt.HEAPU8[o]=e[s],s+=_=1&~((65535&((c-=_)>>>48|c>>>32|c>>>16|c))-1>>16);return 0!==kt._sodium_pad(n,h.address,e.length,t,h.length)&&v(a,"internal error"),h.length=kt.getValue(n,"i32"),r=h.to_Uint8Array(),d(a),r},e.unpad=function(e,t){if(!(e instanceof Uint8Array))throw new TypeError("buffer must be a Uint8Array");if((t|=0)<=0)throw new Error("block size must be > 0");var r=[],a=y(e),n=u(4);return r.push(a),r.push(n),0!==kt._sodium_unpad(n,a,e.length,t)&&v(r,"unsupported/invalid padding"),e=new Uint8Array(e),e=e.subarray(0,kt.getValue(n,"i32")),d(r),e},e.ready=Et,e.symbols=function(){return Object.keys(e).sort()},e.to_base64=s,e.to_hex=n,e.to_string=a,e}var r="object"==typeof e.sodium&&"function"==typeof e.sodium.onload?e.sodium.onload:null;"function"==typeof define&&define.amd?define(["exports","libsodium"],t):"object"==typeof exports&&"string"!=typeof exports.nodeName?t(exports,require("libsodium")):e.sodium=t(e.commonJsStrict={},e.libsodium),r&&e.sodium.ready.then(function(){r(e.sodium)})}(this); |
{ | ||
"name": "libsodium-wrappers", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"description": | ||
@@ -13,3 +13,3 @@ "The Sodium cryptographic library compiled to pure JavaScript (wrappers)", | ||
"dependencies": { | ||
"libsodium": "0.7.2" | ||
"libsodium": "0.7.3" | ||
}, | ||
@@ -16,0 +16,0 @@ "keywords": [ |
@@ -98,8 +98,5 @@ # libsodium.js | ||
A `sodium` object should be defined in the global namespace, with the | ||
following properties: | ||
following property: | ||
- `onload`: the function to call after the wrapper is initialized. | ||
- `totalMemory` (optional): the maximum amount of memory that sodium can use. | ||
The default value should be fine for most applications, unless you | ||
need to use password hashing functions with a large amount of memory. | ||
@@ -120,23 +117,2 @@ Example: | ||
## List of wrapped APIs: | ||
* [`crypto_aead`](https://download.libsodium.org/doc/secret-key_cryptography/aead.html) | ||
* [`crypto_auth`](https://download.libsodium.org/doc/secret-key_cryptography/secret-key_authentication.html) | ||
* [`crypto_box`](https://doc.libsodium.org/public-key_cryptography/authenticated_encryption.html) | ||
* [`crypto_box_seal`](https://download.libsodium.org/libsodium/content/public-key_cryptography/sealed_boxes.html) | ||
* [`crypto_generichash`](https://download.libsodium.org/libsodium/content/hashing/generic_hashing.html) | ||
* [`crypto_hash`](https://download.libsodium.org/libsodium/content/advanced/sha-2_hash_function.html) | ||
* [`crypto_kdf`](https://download.libsodium.org/doc/key_derivation/) | ||
* [`crypto_kx`](https://download.libsodium.org/doc/key_exchange/) | ||
* [`crypto_onetimeauth`](https://download.libsodium.org/doc/advanced/poly1305.html) | ||
* [`crypto_pwhash`](https://download.libsodium.org/libsodium/content/password_hashing/) | ||
* [`crypto_scalarmult`](https://download.libsodium.org/libsodium/content/advanced/scalar_multiplication.html) | ||
* [`crypto_secretbox`](https://download.libsodium.org/libsodium/content/secret-key_cryptography/authenticated_encryption.html) | ||
* [`crypto_secretstream`](https://download.libsodium.org/doc/secret-key_cryptography/secretstream.html) | ||
* [`crypto_shorthash`](https://download.libsodium.org/libsodium/content/hashing/short-input_hashing.html) | ||
* [`crypto_sign`](https://download.libsodium.org/libsodium/content/public-key_cryptography/public-key_signatures.html) | ||
* [`crypto_stream`](https://download.libsodium.org/doc/advanced/stream_ciphers.html) | ||
* [Ed25519->Curve25519 conversion](https://download.libsodium.org/libsodium/content/advanced/ed25519-curve25519.html) | ||
* [`randombytes`](https://download.libsodium.org/libsodium/content/generating_random_data/) | ||
## Additional helpers | ||
@@ -170,2 +146,3 @@ | ||
Example: | ||
```javascript | ||
@@ -180,36 +157,19 @@ var key = sodium.randombytes_buf(sodium.crypto_shorthash_KEYBYTES), | ||
However, an extra parameter can be given to all wrapped functions, in | ||
order to specify what format the output should be in. Valid options | ||
are `uint8array' (default), 'text', 'base64' and 'hex'. | ||
Example (shorthash): | ||
```javascript | ||
var key = sodium.randombytes_buf(sodium.crypto_shorthash_KEYBYTES), | ||
hash_hex = sodium.crypto_shorthash('test', key, 'hex'); | ||
``` | ||
Example (secretbox): | ||
```javascript | ||
// Load your secret key from a safe place and reuse it across multiple | ||
// secretbox calls. (Obviously don't use this example key for anything | ||
// real.) | ||
// | ||
var secret = Buffer.from('724b092810ec86d7e35c9d067702b31ef90bc43a7b598626749914d6a3e033ed', 'hex'); | ||
let key = sodium.from_hex('724b092810ec86d7e35c9d067702b31ef90bc43a7b598626749914d6a3e033ed'); | ||
// Given a message as a string, return a Buffer containing the | ||
// nonce (in the first 24 bytes) and the encrypted content. | ||
var encrypt = function(message) { | ||
// You must use a different nonce for each message you encrypt. | ||
var nonce = Buffer.from(sodium.randombytes_buf(sodium.crypto_box_NONCEBYTES)); | ||
var buf = Buffer.from(message); | ||
return Buffer.concat([nonce, Buffer.from(sodium.crypto_secretbox_easy(buf, nonce, secret))]); | ||
}, | ||
function encrypt_and_prepend_nonce(message) { | ||
let nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES); | ||
return nonce.concat(sodium.crypto_secretbox_easy(message, nonce, key)); | ||
} | ||
// Decrypt takes a Buffer and returns the decrypted message as plain text. | ||
var decrypt = function(encryptedBuffer) { | ||
var nonce = encryptedBuffer.slice(0, sodium.crypto_box_NONCEBYTES); | ||
var encryptedMessage = encryptedBuffer.slice(sodium.crypto_box_NONCEBYTES); | ||
return sodium.crypto_secretbox_open_easy(encryptedMessage, nonce, secret, 'text'); | ||
function decrypt_after_extracting_nonce(nonce_and_ciphertext) { | ||
if (nonce_and_ciphertext.length < sodium.crypto_secretbox_NONCEBYTES + sodium.crypto_secretbox_MACBYTES) { | ||
throw "Short message"; | ||
} | ||
let nonce = nonce_and_ciphertext.slice(0, sodium.crypto_secretbox_NONCEBYTES), | ||
ciphertext = nonce_and_ciphertext.slice(sodium.crypto_secretbox_NONCEBYTES); | ||
return sodium.crypto_secretbox_open_easy(ciphertext, nonce, key); | ||
} | ||
@@ -216,0 +176,0 @@ ``` |
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
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
224
68716
227
1
+ Addedlibsodium@0.7.3(transitive)
- Removedlibsodium@0.7.2(transitive)
Updatedlibsodium@0.7.3