The Mnemonic class provides functionality related to mnemonic phrases, including encoding to bytes, generating, validating, and deriving keys from mnemonic words based on the BIP39 standard. It implements the VeChainDataModel interface.

VeChainDataModel

Implements

Constructors

Accessors

  • get bi(): bigint
  • Throws an exception because the mnemonic cannot be represented as a big integer.

    Returns bigint

    The BigInt representation of the mnemonic.

    The mnemonic cannot be represented as a bigint. VeChainDataModel#bi

    The conversion to BigInt is not supported for a mnemonic.

  • get bytes(): Uint8Array<ArrayBufferLike>
  • Generates a mnemonic as encoded bytes.

    Returns Uint8Array<ArrayBufferLike>

    The bytes representation of the words with spaces.

  • get n(): number
  • Throws an exception because the mnemonic cannot be represented as a number.

    Returns number

    The number representation of the mnemonic.

    The mnemonic cannot be represented as a number. VeChainDataModel#n

    The conversion to number is not supported for a mnemonic.

Methods

  • Check if the given mnemonic words are valid.

    Parameters

    • words: string | string[]

      The mnemonic words to check.

    Returns boolean

    true if the words are valid, false otherwise.

    Security auditable method, depends on

  • Generates a BIP39 Mnemonic Words phrase using the specified wordlist size and random generator.

    Parameters

    Returns string[]

    The generated mnemonic.

    If the number of words is not valid.

    Security auditable method, depends on

    • entropyToMnemonic;
    • generateMnemonic;
    • randomGenerator - Must provide a cryptographic secure source of entropy else any secure audit certification related with this software is invalid.
  • Derives a private key for the given mnemonic words and derivation path.

    Parameters

    • words: string[]

      An array of mnemonic words used to generate the private key.

    • Optionalpath: string = ...

      The BIP32 derivation path to derive the private key.

    Returns Uint8Array<ArrayBufferLike>

    The derived private key as a Uint8Array.

    If the provided derivation path is invalid.

    Security auditable method, depends on HDKey.