Function generateBip39MnemonicNonStandard

  • Generate a new, cryptographically secure, BIP39 mnemonic phrase using a localized or custom word list.

    See generateBip39Mnemonic to generate a standard, 12-word English mnemonic phrase.

    See encodeBip39Mnemonic to encode existing entropy as a BIP39 mnemonic phrase.

    Usage

    import {
    assertSuccess,
    bip39WordListSpanish,
    generateBip39Mnemonic
    } from '@bitauth/libauth';

    const { phrase } = assertSuccess(generateBip39Mnemonic(bip39WordListSpanish, 32));

    Parameters

    • wordList: string[]

      a 2048-word array to use as the BIP39 word list

    • entropyLength: Bip39ValidEntropyLength = Bip39.minEntropyBytes

      the entropy length to generate – 16, 20, 24, 28, or 32 bytes (defaults to 16).

    • __namedParameters: {
          generateRandomBytes?: ((length, generate?) => Uint8Array);
      } = {}
      • Optional generateRandomBytes?: ((length, generate?) => Uint8Array)
          • (length, generate?): Uint8Array
          • Generate a Uint8Array of the specified length containing a cryptographically-random series of bytes.

            For safety, this function first verifies that the provided generate function produces unique results across two evaluations; by default, this verifies that the crypto.getRandomValues function provided by the JavaScript environment appears to be producing random values.

            While this validation can't prevent a compromised environment from producing attacker-known entropy, it may help to prevent software defects in unusual environments (e.g. React Native) from impacting end-user security.

            An Error is thrown if this validation fails, otherwise, the Uint8Array produced by the first evaluation is returned.

            Parameters

            • length: number

              the length of the Uint8Array to generate

            • generate: ((length, cryptoInstance?) => Uint8Array) = generateRandomBytesUnchecked

              a function used to generate the random bytes, defaults to generateRandomBytesUnchecked.

                • (length, cryptoInstance?): Uint8Array
                • Generate a Uint8Array of the specified length containing a cryptographically-random series of bytes. See generateRandomBytes for a safer alternative.

                  Parameters

                  • length: number

                    the length of the Uint8Array to generate

                  • cryptoInstance: {
                        getRandomValues: (<T>(array) => T);
                    } = crypto

                    an instance of the Crypto object with the getRandomValues function (defaults to the crypto global property).

                    • getRandomValues: (<T>(array) => T)
                        • <T>(array): T
                        • Type Parameters

                          • T extends null | ArrayBufferView

                          Parameters

                          • array: T

                          Returns T

                  Returns Uint8Array

            Returns Uint8Array

    Returns string | Bip39MnemonicResult

Generated using TypeDoc