@subsocial/utils
Version:
JavaScript utils for Subsocial blockchain.
26 lines (25 loc) • 900 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.naclBoxPairFromSecret = void 0;
const tweetnacl_1 = __importDefault(require("tweetnacl"));
/**
* @name naclBoxPairFromSecret
* @summary Creates a new public/secret box keypair from a secret.
* @description
* Returns a object containing a box `publicKey` & `secretKey` generated from the supplied secret.
* @example
* <BR>
*
* ```javascript
* import { naclBoxPairFromSecret } from '@subsocial/utils';
*
* naclBoxPairFromSecret(...); // => { secretKey: [...], publicKey: [...] }
* ```
*/
function naclBoxPairFromSecret(secret) {
return tweetnacl_1.default.box.keyPair.fromSecretKey(secret.slice(0, 32));
}
exports.naclBoxPairFromSecret = naclBoxPairFromSecret;