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 moreDeclaration
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 thevocabulary
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
-
Check a mnemonic contains valid words and a valid length (all other checks are ignored)
Declaration
Swift
public func isValidWords(in vocabulary: WordList = .english) -> Bool
-
Check a mnemonic is of the correct length, is made up of valid BIP39 words, and the checksum matches
Declaration
Swift
public func isValid(in vocabulary: WordList = .english) -> Bool
-
Modifed from: https://github.com/pengpengliu/BIP39/blob/master/Sources/BIP39/Mnemonic.swift Convert the current Mnemonic back into entropy
-
Take a
PrivateKey
from a TorusWallet and generate a custom “shifted checksum” mnemonic, so that we can recover wallets that previously had no seed wordsDeclaration
Swift
public static func shiftedMnemonic(fromSpskPrivateKey pk: PrivateKey) -> Mnemonic?
-
Convert a shifted Mnemoinc back to normal
Declaration
Swift
public static func shiftedMnemonicToMnemonic(mnemonic: Mnemonic) -> Mnemonic?
-
Check if a supplied Spsk string is valid
Declaration
Swift
public static func validSpsk(_ sk: String) -> Bool