forked from whs/tweetnacl-sealed-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sealedbox.node.js
1 lines (1 loc) · 2 KB
/
sealedbox.node.js
1
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(global,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t){e.exports=require("tweetnacl")},function(e,t){e.exports=require("blakejs/blake2b")},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r);const u=o.a.box.publicKeyLength+o.a.box.overheadLength;var a=n(1),i=n.n(a);function l(e,t){var n=i.a.blake2bInit(o.a.box.nonceLength,null);return i.a.blake2bUpdate(n,e),i.a.blake2bUpdate(n,t),i.a.blake2bFinal(n)}function f(e,t){var n=new Uint8Array(u+e.length),r=o.a.box.keyPair();n.set(r.publicKey);var a=l(r.publicKey,t),i=o.a.box(e,a,t,r.secretKey);return n.set(i,r.publicKey.length),function(e){for(var t=0;t<e.length;t++)e[t]=0}(r.secretKey),n}function c(e,t,n){var r=e.subarray(0,o.a.box.publicKeyLength),u=l(r,t),a=e.subarray(o.a.box.publicKeyLength);return o.a.box.open(a,u,r,n)}n.d(t,"overheadLength",function(){return u}),n.d(t,"seal",function(){return f}),n.d(t,"open",function(){return c});t.default={seal:f,open:c}}])});