Securely generate 24-word Mnemonic using Dice

Securely generate 24-word Mnemonic using Dice

>**Disclaimer:** This is for education purposes only. This is quite advanced for the average user. If you are to going to protect funds with a mnemonic generated using this method, use only a verified copy of tails and do all processes in a completely secure offline environment.

Let me begin by saying there is nothing to suggest that the RNG used in popular software/hardware wallets is flawed. The generation process uses TRNG’s certified from 3rd parties which should satisfy the large majority of users. However, if you are the type that trusts no one and you want to verify your BIP39 Mnemonic is truly random or you just want to find out how it works, then you must generate it yourself.

The process itself is straightforward, The BIP39 dictionary contains 2048 words, each of these words represents 11 binary bits (0 or 1). A 24-word Mnemonic consists of 23 Words and a Checksum word. To create our own mnemonic we start by generating 256 bits of random binary then calculating the rest of the checksum. There is many ways to randomly generate the binary, but specifically for this tutorial we use six-sided dice. (If you have another means of generating the 256-bits, such as coin flips, then jump straight to step 10)

The entire process will be done only using tools built-in to tails. All base converisons will be done in the linux terminal using the [‘bc’](https://www.gnu.org/software/bc/manual/html_mono/bc.html) or Basic Calculator command. Calculating the checksum will use python standard library.

**Tools needed:**

– Set of Casino Grade Six-Sided Dice
– BIP39 Wordlist (**MUST BE NUMBERED 0-2047**)
– USB stick w/[Tails](https://zdnet4.cbsistatic.com/hub/i/r/2020/04/08/4c0c2d36-1443-4d7f-a341-61cf63ed6ef8/resize/1200×900/749fc4d5610595d5143320e3203f658c/tails.png) Linux Distro

————————————————–

#Create BIP39 Mnemonic with Dice#

– **Step 1** – Download Tails onto a USB stick. Follow instructions on the tails website. You can validate tails using the extension or manually. Boot from the live USB, be sure to turn network connection to “offline” before starting tails. (click the + sign and it is one of the few options) [**IMAGE**](https://i.imgur.com/4mVdeHS.jpg)

– **Step 2** – Open the built-in text editor: [**IMAGE**](https://i.imgur.com/9W3ZQID.jpg)

– **Step 3** – Roll your 99 dice rolls recording each roll in the text editor with no spaces between the numbers.[**IMAGE**](https://i.imgur.com/b8XCbow.png)

– **Step 4** – You can check the number of rolls input by going to document statistics. Click the 3 bars to the right of the “Save” button. It will be under “Tools”. Make sure there is no additional spaces. [**IMAGE**](https://i.imgur.com/e1S0Rfl.png)

– **Step 5** – Convert the dicerolls into base6. To do this simply turn all the 6’s into 0’s. You can use “Find and Replace” function of the text editor to achieve this. [**IMAGE**](https://i.imgur.com/Z8DJKTE.png) [IMAGE](https://i.imgur.com/xt7oPLx.png)

– **Step 6** – Open the terminal [**IMAGE**](https://i.imgur.com/0JHNWLB.jpg)

– **Step 7** – Convert the base6 string into binary. We use “bc” or basic calculator which is a built-in command line function. We are converting into base2 from base6. (replace [diceRolls] with your 99-digit base6 string) [**IMAGE**](https://i.imgur.com/sLN6eSM.png)

echo “obase=2;ibase=6;[diceRolls]” | bc

– **Step 8** – Paste the binary output into a new tab in the text editor. (to copy/paste in the terminal you need to hold ctrl+shift c to copy or ctrl+shift v to paste) [**IMAGE**](https://i.imgur.com/mYTcVYn.png)

– **Step 9** – Remove the backslashes and extra spaces from the binary string. It should be a solid string of 0’s and 1’s with no extra spaces at the end. [**IMAGE**](https://i.imgur.com/k8e3yiR.png)

– **Step 10:** – Check the length of the binary string using document statistics. In order to calculate a checksum the binary string must be exactly 256 characters. If the resulting binary is less then 256 characters, then add zeroes to the start of the string until it is 256 characters. This is called padding. [**IMAGE**](https://i.imgur.com/zemkcuA.png) [**IMAGE**](https://i.imgur.com/X3x0UQt.png)

– **Step 11:** – Convert the 256-bit binary into a hex value using the terminal. (replace [binary] with your 256-bit binary) [**IMAGE**](https://i.imgur.com/X0Z1Blg.png)

echo “obase=16;ibase=2;[binary]” | bc

– **Step 12:** – To generate the checksum we need to write a small python program using the python standard library. Open a new tab in the text editor and save it as “checksum.py” in the Documents folder. Once it is saved copy the below text to the file or copy it directly from the screenshot. Replace the Pink “hex_val” with your own hex value and save the file. [**IMAGE**](https://i.imgur.com/0tOGOFw.png)

import hashlib
import binascii

hex_val = “” # <– Enter your hex value here
bin_data = binascii.a2b_hex(hex_val)
sha256hash = hashlib.sha256(bin_data).hexdigest()

print(sha256hash)

– **Step 13:** -Change directory to Documents using the command “`cd Documents“` then run checksum.py by using the command “`python3 checksum.py“`. The output will be a long hex value. The first 2 characters will be the checksum. [**IMAGE**](https://i.imgur.com/spqX0SD.png)

– **Step 14:** – Convert the 2 hex characters into binary using the terminal. The hex input for bc MUST BE capitalized or the result will be 0. In the above example the first 2 characters from checksum.py are 9c. So we use 9C as the input for base conversion. “`echo “obase=2;ibase=16;[hex]” | bc“` (replace [hex] with the first 2 characters given back from checksum.py. Make sure to capitalize any letters). If the result is less then 8 bits, add zeroes to the start. Example: 2C would equal “101100” in binary which is only 6-bits. In this case add 2 zeroes to the start to make “00101100”, [**IMAGE**](https://i.imgur.com/qfKgCbB.png)

– **Step 15:** – Add the 8-bits of binary from the previous step to the existing binary string from step 10. Check to make sure the resulting binary is exactly 264 characters using document statistics. [**IMAGE**](https://i.imgur.com/SOJA4XG.png)

– **Step 16** – Split the 264-bit binary into equal 11-bit chunks. There should be exactly 24 groups of 11 bits. [**IMAGE**](https://i.imgur.com/igDJ2rc.png)

– **Step 17** – Convert each group of binary into a decimal number using the terminal. Record each number next to the corresponding binary. Do this for all 24 binary strings. (press the up arrow to access previous commands) [**IMAGE**](https://i.imgur.com/vXagdz1.png)

– **Step 18** – Look up the numbers in the BIP39 wordlist. Make sure the wordlist in zero-indexed meaning it begins with 0 and ends with 2047. This is your 24-word seed which can be used with any BIP39 compatible wallet.
Take care to properly wipe the USB device after use. [**IMAGE**](https://i.imgur.com/nKIQV4U.png)

Picture Album – https://imgur.com/a/sXTHr6c



View Reddit by McgillbyView Source

Leave a Comment

Your email address will not be published. Required fields are marked *