UNPKG

@signumjs/crypto

Version:

Cryptographic functions for building Signum Network apps.

38 lines 1.36 kB
"use strict"; /** * Original work Copyright (c) 2024 Signum Network */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Strength = void 0; exports.generateMnemonic = generateMnemonic; const en_1 = require("./dictionaries/en"); const random_1 = require("./random"); /** * The Strength of the generated mnemonic * Ranging from 128 bit (12 Words) to 256 bit (24 Words) * * @see {@link generateMnemonic} * * @category signing */ var Strength; (function (Strength) { Strength[Strength["Bits_128"] = 12] = "Bits_128"; Strength[Strength["Bits_160"] = 15] = "Bits_160"; Strength[Strength["Bits_192"] = 18] = "Bits_192"; Strength[Strength["Bits_224"] = 21] = "Bits_224"; Strength[Strength["Bits_256"] = 24] = "Bits_256"; })(Strength || (exports.Strength = Strength = {})); /** * Generates a passphrase aka mnemonic aka recovery phrase based on given dictionary, and strength * @category signing */ function generateMnemonic(args = { strength: Strength.Bits_192, dictionary: en_1.words }) { const { strength = Strength.Bits_192, dictionary = en_1.words } = args; if (dictionary.length < 1024) { throw new Error('Dictionary too weak'); } const randomWords = (0, random_1.getRandomWords)(strength.valueOf(), dictionary); return randomWords.join(' '); } //# sourceMappingURL=mnemonic.js.map