From 6528dbf419e36ed71a4c393e95280ea7c866fdfb Mon Sep 17 00:00:00 2001 From: tcsenpai Date: Wed, 24 Jul 2024 00:14:04 +0200 Subject: [PATCH] replaced words generation mechanism: now it works --- libs/word_gen.py | 22 ---------------------- main.py | 5 ++--- 2 files changed, 2 insertions(+), 25 deletions(-) delete mode 100644 libs/word_gen.py diff --git a/libs/word_gen.py b/libs/word_gen.py deleted file mode 100644 index 5e1436f..0000000 --- a/libs/word_gen.py +++ /dev/null @@ -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 diff --git a/main.py b/main.py index 309c642..0ab3345 100644 --- a/main.py +++ b/main.py @@ -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.")