Chapter 10: Mnemonically Generated Secrets

Forging Keys

Mi'kail Eli'yah
11 min readAug 12, 2023

The principle of MGS (Mnemonically Generated Secrets) is merely in the way you select your mnemonic materials and how they are used to generate keys. You can read from a source of words and select them into a mnemonic word list.

import hashlib
import binascii
import requests

url = "https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.txt"

nums = {}
wordlist = []

response = requests.get(url)
if response.status_code == 200:
content = response.text
words = content.strip().split("\n")
for i, word in enumerate(words):
nums[word] = i
wordlist.append(word)
else:
print("Failed to fetch the content from the URL.")

# words = [w.lower() for w in sys.argv[1:] if w in nums]
# print(len(words), 'valid words:', ' '.join(words))

It need not be specifically from any standards of BIP-xx, where xx := 39, 32, 44, 49, 85, etc. There is no end to the fashion. The next code snippet is an example of mnemonic word list selection. It does not need to be following:

from hashlib import sha256
import secrets

#depending on the number of words, we take the value for ENT, and CS.

word_number=24
size_ENT_bits = 256
size_CS=int(size_ENT_bits/32)

print(f"size_CS = {size_CS}")

#with open("bip39-wordlist.txt", "r") as wordlist_file:
# words =…

--

--

Mi'kail Eli'yah
Mi'kail Eli'yah

No responses yet