Skip to content

Commit

Permalink
optimizing mnemonic_to_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
tadeubas committed Aug 12, 2024
1 parent cbb69fd commit ef58d03
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/krux/bip39.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ def mnemonic_to_bytes(
raise ValueError("Invalid recovery phrase")

Check warning on line 14 in src/krux/bip39.py

View check run for this annotation

Codecov / codecov/patch

src/krux/bip39.py#L14

Added line #L14 was not covered by tests

accumulator = 0
for word in words:
try:
if wordlist is WORDLIST:
try:
if wordlist is WORDLIST:
for word in words:
accumulator = (accumulator << 11) + WORDINDEX[word]

Check warning on line 20 in src/krux/bip39.py

View check run for this annotation

Codecov / codecov/patch

src/krux/bip39.py#L19-L20

Added lines #L19 - L20 were not covered by tests
else:
else:
for word in words:
accumulator = (accumulator << 11) + wordlist.index(word)
except Exception:
raise ValueError("Word '%s' is not in the dictionary" % word)
except Exception:
raise ValueError("Word '%s' is not in the dictionary" % word)

Check warning on line 25 in src/krux/bip39.py

View check run for this annotation

Codecov / codecov/patch

src/krux/bip39.py#L24-L25

Added lines #L24 - L25 were not covered by tests

entropy_length_bits = len(words) * 11 // 33 * 32
checksum_length_bits = len(words) * 11 // 33
Expand Down

0 comments on commit ef58d03

Please sign in to comment.