Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Mnenonic Words.count check #308

Open
v-sharaev opened this issue Oct 25, 2019 · 0 comments
Open

Mnenonic Words.count check #308

v-sharaev opened this issue Oct 25, 2019 · 0 comments

Comments

@v-sharaev
Copy link

Hello

In BIP39.swift class Mnemonic has public init(_ string: String, language: BIP39Language = .english) throws

There have checking code:

// checking entropy
let wordList = string.components(separatedBy: " ")
guard wordList.count >= 12 else { throw EntropyError.notEnoughtWords }
guard wordList.count % 4 == 0 else { throw EntropyError.invalidNumberOfWords }

But it's not valid, because method
public init(entropySize: EntropySize = .b256, language: BIP39Language = .English)
generate 12, 15, 18, 21, 24 word. By BIP39 spec

If you write test:

do {
    let mnemonic = Mnemonics(entropySize: .b192, language: .english)
    let mnemonic2 = try Mnemonics(mnemonic.string, language: .english)
} catch let error {
    print(error) // web3swift.Mnemonics.EntropyError.invalidNumberOfWords
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant