UNPKG

tweetnacl-ts

Version:

Port of TweetNaCl cryptographic library to TypeScript (and ES6)

30 lines 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function checkLengths(k, n) { if (k.length != 32 /* Key */) throw new Error('bad key size'); if (n.length != 24 /* Nonce */) throw new Error('bad nonce size'); } exports.checkLengths = checkLengths; function checkBoxLengths(pk, sk) { if (pk.length != 32 /* PublicKey */) throw new Error('bad public key size'); if (sk.length != 32 /* SecretKey */) throw new Error('bad secret key size'); } exports.checkBoxLengths = checkBoxLengths; function checkArrayTypes() { var arrays = []; for (var _i = 0; _i < arguments.length; _i++) { arrays[_i] = arguments[_i]; } for (var _a = 0, arrays_1 = arrays; _a < arrays_1.length; _a++) { var array = arrays_1[_a]; if (!(array instanceof Uint8Array)) { throw new TypeError('unexpected type, use ByteArray'); } } } exports.checkArrayTypes = checkArrayTypes; //# sourceMappingURL=check.js.map