Skip to content

Commit

Permalink
refactor: move wordlist to separate package
Browse files Browse the repository at this point in the history
  • Loading branch information
kklash committed Jan 28, 2023
1 parent 7e9ed5c commit 5ab625c
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 842 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Mnemonikey is primarily concerned with defining two high-level procedures:

| Dependency | Usage |
|------------|-------|
|[wordlist-4096](https://github.com/kklash/wordlist-4096)|An English word list for mnemonic encoding. Encodes the backup payload into a form that is easy to write down on paper, or remember mnemonically. Each word is one of 4096 potential words, thus encodes 12 bits of information.|
|[`wordlist4096`](https://github.com/kklash/wordlist4096)|An English word list for mnemonic encoding. Encodes the backup payload into a form that is easy to write down on paper, or remember mnemonically. Each word is one of 4096 potential words, thus encodes 12 bits of information.|
|[HMAC-based Key Derivation Function (HKDF)](https://www.rfc-editor.org/rfc/rfc5869)|Stretches the root key into suitable PGP private keys. |
|[ED25519 (EdDSA)](https://ed25519.cr.yp.to/)|Algorithm used for the certification master key, and for the authentication and signing subkeys. Used to create signatures to bind the PGP key set together.|
|[Curve25519 (ECDH)](https://en.wikipedia.org/wiki/Curve25519)|Generates the encryption subkey.|
Expand Down
4 changes: 2 additions & 2 deletions cmd/mnemonikey/recover.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/kklash/mnemonikey"
"github.com/kklash/mnemonikey/mnemonic"
"github.com/kklash/wordlist4096"
)

const maxSubkeyIndex uint = 0xFFFF
Expand Down Expand Up @@ -180,7 +180,7 @@ func readWordFile(fpath string) ([]string, error) {
words := make([]string, 0, mnemonikey.MnemonicSize)
for scanner.Scan() {
word := strings.ToLower(scanner.Text())
if _, ok := mnemonic.WordMap[word]; !ok {
if _, ok := wordlist4096.WordMap[word]; !ok {
return nil, fmt.Errorf("found word in %s not present in wordlist", fpath)
}
words = append(words, word)
Expand Down
6 changes: 3 additions & 3 deletions cmd/mnemonikey/word_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"golang.org/x/term"

"github.com/kklash/mnemonikey"
"github.com/kklash/mnemonikey/mnemonic"
"github.com/kklash/wordlist4096"
)

const (
Expand Down Expand Up @@ -94,7 +94,7 @@ func userInputMnemonic(wordCount uint) ([]string, error) {
}

// See if the user's input might be a valid word in the wordlist.
searchResult := mnemonic.Search(wordInput)
searchResult := wordlist4096.Search(wordInput)

// Autocomplete without submitting
if charBuf[0] == '\t' && len(searchResult.Suffixes) > 0 {
Expand Down Expand Up @@ -179,7 +179,7 @@ func userInputMnemonicSimple(wordCount uint) ([]string, error) {
wordInput := strings.ToLower(strings.TrimSpace(scanner.Text()))

// See if the user's input might be a valid word in the wordlist.
searchResult := mnemonic.Search(wordInput)
searchResult := wordlist4096.Search(wordInput)

if searchResult.ExactMatch {
// We have a match! Remove any error message if needed
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ module github.com/kklash/mnemonikey

go 1.19

require golang.org/x/crypto v0.4.0
require (
github.com/kklash/wordlist4096 v0.0.0-20230128234442-e74f115f6d92
golang.org/x/crypto v0.4.0
)

require golang.org/x/sys v0.3.0 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/kklash/wordlist4096 v0.0.0-20230128234442-e74f115f6d92 h1:slB3aXYu4WRJPCkBES+oE22LxXdJqufifwIDeBEoAeg=
github.com/kklash/wordlist4096 v0.0.0-20230128234442-e74f115f6d92/go.mod h1:HHJbj9GOEhOBCMSBTwJO0NaOzl4dgu3uuavrgtzrH+Q=
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
Expand Down
46 changes: 0 additions & 46 deletions mnemonic/decode.go

This file was deleted.

44 changes: 0 additions & 44 deletions mnemonic/encode.go

This file was deleted.

87 changes: 0 additions & 87 deletions mnemonic/search.go

This file was deleted.

118 changes: 0 additions & 118 deletions mnemonic/search_test.go

This file was deleted.

Loading

0 comments on commit 5ab625c

Please sign in to comment.