replaced words generation mechanism: now it works

This commit is contained in:
tcsenpai 2024-07-24 00:14:04 +02:00
parent 44fa2c7c59
commit 6528dbf419
2 changed files with 2 additions and 25 deletions

View File

@ -1,22 +0,0 @@
import binascii
# Can generate a mnemonic seed from data of 16, 20, 24, 28 or 32 bytes
def gen_from_data(data):
# Checking if the data length is correct
if len(data) not in [16, 20, 24, 28, 32]:
raise ValueError(
"Data length should be one of the following: [16, 20, 24, 28, 32], but it is not (%d).” % len(data)"
)
# Converting the data to binary
bindata = bin(int(binascii.hexlify(data), 16))[2:].zfill(8 * len(data))
# Opening wordlist
with open("data/wordlist.txt", "r") as f:
wordlist = [w.strip() for w in f.readlines()]
# Generating a seed from the binary data
seed = []
for i in range((len(bindata)//11)+1):
index = int(bindata[11*i:11*(i+1)],2)
seed.append(wordlist[index])
return seed

View File

@ -2,8 +2,8 @@
from fido2.hid import CtapHidDevice
from fido2.client import Fido2Client, UserInteraction
from getpass import getpass
import libs.word_gen as word_gen
import libs.cred_manager as cred_manager
import libs.mem_gen as mem_gen
import hashlib
import sys
import os
@ -92,8 +92,7 @@ if __name__ == "__main__":
secret = result.extension_results["hmacGetSecret"]["output1"]
print("[OK] Authenticated and secret retrieved")
mnemonic_words = word_gen.gen_from_data(secret)
mnemonic_string = " ".join(mnemonic_words)
mnemonic_string = mem_gen.gen_mnemonic(secret)
print("\nALERT: This is your mnemonic seed. Keep it in a safe place. You will need it to recover your wallet.")
print("If you lose it, you will lose access to your wallet. There is no way to recover it later.")
print("Anyone with access to your mnemonic seed can recover your wallet. Keep it in a secure location.")