diff --git a/README.md b/README.md index 49cacce..4b5ba4b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,33 @@ # bip39checksum-go -A simple go program to find the last BIP39 mnemonic word + +A simple program written in Go to find the last BIP39 mnemonic word (checksum). + +This program test all possible words and print them. + + +Inspired by: [GitHub - massmux/bip39checksum: BIP39 checksum word finder](https://github.com/massmux/bip39checksum) + +## Dependencies + +`go get github.com/tyler-smith/go-bip39` + + + +## How to run + +### Run the program yourself + +`go run bip39checksum.go` + +### Use the compiled binary (Linux) + +1. `chmod +x bip39checksum.go` + +2. ./bip39checksum + + + +## Disclamer + +This program is provided "as is", I am not responsible for any loss of funds caused by the use of this program. +It is strongly recommended to use it on an offline computer. diff --git a/bip39checksum.go b/bip39checksum.go new file mode 100644 index 0000000..2e3a02a --- /dev/null +++ b/bip39checksum.go @@ -0,0 +1,50 @@ +package main + +import ( + "bufio" + "fmt" + "github.com/tyler-smith/go-bip39" + "os" +) + +// 23 words for testing +// loud omit domain valve topic engine velvet chat foil few wrap unable practice snap gift version brass board broom loud amateur cabin toss + +func main() { + reader := bufio.NewReader(os.Stdin) + + fmt.Print("Please insert your mnemonic phrase: ") + input, _ := reader.ReadString('\n') + words := brute(input) + n := len(words) + + if n > 0 { + fmt.Println("\nPossible last words for this mnemonic: ") + PrintWords(words) + } else { + fmt.Println("Mnemonic invalid") + } + +} + +func brute(mnemonic string) []string { + english := bip39.GetWordList() + var valid_words []string + + for _, word := range english { + current := mnemonic + " " + word + valid := bip39.IsMnemonicValid(current) + + if valid { + valid_words = append(valid_words, word) + } + } + return valid_words +} + +func PrintWords(arr []string) { + for _, w := range arr { + fmt.Printf("- %s\n", w) + } + +}