tyler-smith / go-bip39

The BIP39 library for Go.
MIT License
549 stars 196 forks source link

IsMnemonicValid does not validate checksum #32

Closed husio closed 5 years ago

husio commented 5 years ago

IsMnemonicValid returns true for invalid mnemonic sequences that do not pass the checsum test. Take any valid mnemonic and change one of the words. IsMnemonicValid must return false for that input.

go-bip39 $ go test .
--- FAIL: TestIsMnemonicValid (0.00s)
    bip39_test.go:450: Expected false, got true
FAIL
FAIL    _/home/piotr/go-bip39   0.232s

go-bip39 $ git diff
diff --git a/bip39_test.go b/bip39_test.go
index 230c831..63d19e0 100644
--- a/bip39_test.go
+++ b/bip39_test.go
@@ -408,6 +408,7 @@ func testVectors() []vector {

 func badMnemonicSentences() []vector {
        return []vector{
+               {mnemonic: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon letter"},
                {mnemonic: "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon"},
                {mnemonic: "legal winner thank year wave sausage worth useful legal winner thank yellow yellow"},
                {mnemonic: "letter advice cage absurd amount doctor acoustic avoid letter advice caged above"},
tyler-smith commented 5 years ago

Thank you for the report. Fixed in PR #33.