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

Commit

Permalink
Replace "mnemonic" with "bip-utils"
Browse files Browse the repository at this point in the history
  • Loading branch information
jibeee committed Mar 23, 2022
1 parent bea5c21 commit 6b8b5b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
11 changes: 4 additions & 7 deletions recoverMasterSeed.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from functools import reduce
from itertools import count

from bip_utils import Bip32Secp256k1
from mnemonic.mnemonic import Mnemonic

from bip_utils import Bip39MnemonicValidator, Bip32Secp256k1, Bip39SeedGenerator

VAULT_BIP32_PATH = "m/5655636'/4932953'"

Expand All @@ -14,21 +12,20 @@ def xor(*argv):

def ask_seeds() -> list[bytes]:
components = []
m = Mnemonic("english")

print(
"Input each Shared Owner recovery mnemonic (24 words) when requested. End with an empty line."
)
for i in count():
while True:
words = input(f"Shared Owner {i + 1} recovery mnemonic: ")
if len(words) == 0 or m.check(words):
if len(words) == 0 or Bip39MnemonicValidator().IsValid(words):
break
print("Invalid 24 words")
if len(words) == 0:
break

bip32_key = Bip32Secp256k1.FromSeedAndPath(m.to_seed(words), VAULT_BIP32_PATH)
seed = Bip39SeedGenerator(words).Generate()
bip32_key = Bip32Secp256k1.FromSeedAndPath(seed, VAULT_BIP32_PATH)
private_key = bip32_key.PrivateKey().Raw().ToBytes()
chain_code = bip32_key.ChainCode().ToBytes()
components.append(private_key + chain_code)
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
bip-utils==2.3.0
mnemonic==0.20

0 comments on commit 6b8b5b4

Please sign in to comment.