Mnemonic

public struct Mnemonic : Equatable, Codable

A list of words which can generate a private key.

  • Helper enum used to choose the number of words for a mnemonic

    See more

    Declaration

    Swift

    public enum NumberOfWords : Int
  • The list of words as a single sentence.

    Declaration

    Swift

    public var phrase: String
  • The list of words.

    Declaration

    Swift

    public var words: [String] { get }
  • Declaration

    Swift

    public init(seedPhrase phrase: String?) throws
  • Declaration

    Swift

    public init(strength: Int = .strongest, in vocabulary: WordList = .english) throws
  • Declaration

    Swift

    public init(numberOfWords: NumberOfWords, in vocabulary: WordList = .english) throws
  • Create a mnemonic from a pre-computed entropy, with phrase_ pulled from the vocabulary list.

    Declaration

    Swift

    public init<Entropy>(entropy: Entropy, in vocabulary: WordList = .english) throws where Entropy : EntropyGenerator
  • Create the mnemonic’s private key (seed).

    Warning

    Calling this function can take some time. Avoid calling this function from the main thread, when possible.

    BIP39:

    https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#from-mnemonic-to-seed

    Declaration

    Swift

    public func seed(passphrase: String = "") throws -> Data

    Return Value

    A result with the seed’s bytes, or an Error.

  • Scrub the phrase from memory by replacing with 0’s

    Declaration

    Swift

    public mutating func scrub()
  • Derive the checksum portion of an array of bits

    Declaration

    Swift

    public static func deriveChecksumBits(_ bytes: [UInt8]) -> String
  • Verify the chechsum of the supplied words to esnure its a valid phrase

    Declaration

    Swift

    public static func isValidChecksum(phrase: [String], wordlist: WordList = WordList.english) -> Bool
  • Check a mnemonic is of the correct length, and is made up of valid BIP39 words

    Declaration

    Swift

    public func isValid(in vocabulary: WordList = .english) -> Bool