The Lisk elements passphrase package provides tools for generating and validating mnemonic passphrases.


How to perform the installation:

$ npm install @liskhq/lisk-passphrase@3.0.1


How to perform an upgrade:

npm update @liskhq/lisk-passphrase


This exposes the bip39 NPM package for easily generating and managing BIP39 compliant mnemonic passphrases. Please refer to their documentation for full usage details.


import * as passphrase from '@liskhq/lisk-passphrase';

const { Mnemonic } = passphrase;

const passphrase = Mnemonic.generateMnemonic(); // 'drastic spot aerobic web wave tourist library first scout fatal inherit arrange'
const japanesePassphrase = Mnemonic.generateMnemonic(null, null, Mnemonic.wordlists.japanese); // 'こやく そうだん ねだん せめる たらす むげん へんたい さめる おんだん こうてい ていこく におい'
Mnemonic.validateMnemonic(japanesePassphrase, Mnemonic.wordlists.japanese); // true

Additional validation methods

In addition to the validation provided by the BIP39 library, a helper function is provided in order to help understand which errors may have occurred with an invalid passphrase.


This returns an array of validation errors to help with usability.


getPassphraseValidationErrors(passphrase, [wordlist], expectedWords)


passphrase: This is the candidate’s passphrase to validate.

wordlist: The wordlist for the passphrase, (default is English). Word lists are provided by the BIP39 library described above.

expectedWords: The number of words of the passphrase. The default value is 12 in the case where it is undefined.

Return value

array: An array of errors containing details about why a passphrase is invalid. The array is empty if the passphrase is valid.


import * as passphrase from '@liskhq/lisk-passphrase';

const errors = passphrase.validation.getPassphraseValidationErrors('this passphrase is not    valid', Mnemonic.wordlist.english, 24);
/* [
        code: 'INVALID_AMOUNT_OF_WORDS',
        message: 'Passphrase contains 5 words instead of expected 24. Please check the passphrase.',
        expected: 24,
        actual: 5,
        code: 'INVALID_MNEMONIC',
        message: 'Passphrase is not a valid mnemonic passphrase. Please check the passphrase.',
        expected: true,
        actual: false,
        actual: 7,
        expected: 23,
        location: [],
            'Passphrase contains 7 whitespaces instead of expected 23. Please check the passphrase.',
] */