Rovereto, Tuesday 17 November 2026 · Year XIII, n. 321 itende
Bitcoin Valley
ContentsClose

Dispatches from the valley where you pay in bitcoin.

Learn · Guide · Lesson 6

A key from dice

You trust a paper wallet as much as you trust whoever made it. If you make it yourself, the trust stays at home. Here is how, with dice in place of the computer's randomness.

The program is paperwallet-tools, by Marco Amadori. It is free software, licensed under the GNU GPL version 3 or later, and this guide follows version 0.1.1. It runs from the command line, it is tested on Debian, and it does two things:

  • paperwallet.py creates a bc1q… address with its private key, and prints them on a card the size of a credit card. On the outside is the address, for receiving and checking the balance. On the inside, folded and covered by a pattern that hides it against the light, is the key that spends.
  • paperseed.py creates the recovery words, 12 or 24, and prints them on a larger card.

Both write a PDF to print double-sided and a .md file with the same data.

Why dice

Without dice the key comes from 32 random bytes of /dev/random, and that is the recommended choice. Dice are for those who would rather not trust the computer for randomness: you bring the randomness yourself, one roll at a time. The key is the SHA-256 of what you type.

You need a lot of it. For a 256-bit key:

What you roll Each roll Rolls for 256 bits
16-sided die, from 0 to F one hexadecimal digit, 4 bits 64
6-sided die about 2.6 bits 100
Coin, 1 for heads and 0 for tails 1 bit 256

A 16-sided die carries the digits 0 to 9 and the letters A to F: each roll is one hexadecimal digit. They are rare, and the Valley shop used to sell them. With a 6-sided die you write the numbers as they come up, from 1 to 6. Spaces and line breaks do not count, and neither does upper or lower case.

Your rolls64 with the 16-sided die, 100 with the 6-sided one
SHA-256
→
The private keyinside the folded paper: whoever has it can spend
↓ from the key, the address ↓
The address bc1q…outside the paper: for receiving and checking the balance
You bring the randomness, the key is born from the rolls and the address from the key. On the outside you can read only what can be shown.

Three rules:

  1. Every digit comes from a real roll. Do not write them by feel and do not correct them: people are no good at being random.
  2. No made-up sentences. A sentence or a password thought up by a person is a brain wallet: sooner or later someone guesses it and empties the wallet.
  3. The rolls are worth as much as the key. The same rolls always give the same key. If you note them on a sheet of paper, that sheet must be destroyed.

The program estimates how much randomness there is in what you type. If it is below 256 bits it warns you before asking for more, and you can stop with Ctrl-C. The estimate is optimistic: it flags the cases that are surely too weak, but it does not vouch for the others. More rolls do no harm.

The computer and the printer

  • A machine disconnected from the network. Better still a live system such as Tails, with the files in memory (tmpfs) and the machine switched off at the end.
  • A USB printer with no memory. A network printer, or one with internal memory, can keep a copy of what it prints.
  • Never photograph the open card, the rolls or the screen.

The program does its part too: at startup it blocks Python's sockets, so neither it nor its libraries can open connections. That protects against an accidental connection, but it does not replace unplugging.

Installing

You install first, on a machine you will then disconnect, or on the live system. You need Python 3 and five libraries. On Debian:

sudo apt install libsecp256k1-6 python3-mnemonic python3-pycryptodome python3-reportlab python3-qrcode fonts-open-sans

On Debian 13 trixie the library is called libsecp256k1-2: use that instead of libsecp256k1-6. You can also install with pip, in a virtual environment, or build the Debian package: the instructions are in the project's README.

Download the code from the project page, then disconnect the network. The programs are run from the project folder, as ./paperwallet.py and ./paperseed.py. If a library is missing they stop and tell you which one.

The paper wallet, step by step

1. A test print

First you try with a throwaway wallet, on signet, a test network whose coins are worth nothing: every panel says so diagonally.

./paperwallet.py --network signet -o prova

Print prova.pdf on A4, at 100% scale (not “fit to page”), double-sided, flipping on the long edge. Hold the sheet against the light: the marks in the middle of the margins must line up. Then delete the test files.

2. The wallet, with your rolls

./paperwallet.py --entropy-prompt -o wallet

The program asks for the rolls and does not show them as you type. Out come wallet.pdf and wallet.md. Only public data appears on the screen, such as the address: never the key.

You can also read the rolls from a file, with --entropy-file dadi.txt: that file is a secret just like the key, and it should be kept in memory and deleted. There is also --entropy-string, but the text would end up in the shell history.

If you want the key protected by a password, add --bip38: the password is asked for twice and never shown. With the two copies printed by default, one is in clear and one is encrypted.

3. Print, cut, fold

Each sheet carries two strips: by default two copies of the same wallet, to keep in different places. Cut along the marks and fold following the steps printed on the back: key side up, then lines 1, 2 and 3 in order. The address and the cover stay on the outside, the key on the inside, under at least two layers of paper on each side.

Close the open edge with sticky tape over the two SEAL bands, and sign across the tape: if someone opens the card, it shows.

4. Checking the address

Before sending money to it, import the key from the .md file into an offline wallet and check that it gives the printed address. Electrum starts like this:

electrum --offline

Then you create a new wallet with “Import Bitcoin addresses or private keys” and paste the text of the key's QR, the one that starts with p2wpkh:.

5. Delete, and switch off

Delete wallet.pdf and wallet.md, or put them in an encrypted archive. Then switch off the machine.

Recovery words from dice

The same goes for the recovery words:

./paperseed.py --entropy-prompt -o parole

Out come 24 words, or 12 with --words 12, on one card per A4 sheet that measures 148 × 60 mm when folded. Inside are the numbered words and a SeedQR, which SeedSigner, Blockstream Jade and BlueWallet read, among others, plus a second QR with the words in clear for the wallets that do not read SeedQR, such as Electrum. On the outside is the account's extended public key, the xpub: it is enough for a watch-only wallet to follow the balance, and it cannot spend.

With --passphrase you add a passphrase: asked for twice, never printed. The card only says that one is needed.

Test print, cutting, folding and sealing are the same. Then, as with the words in metal in lesson 6, before you trust it, try restoring the wallet from the card, with a few satoshis. At the end delete parole.pdf and parole.md, or encrypt them.

For whoever receives the card

A paper wallet makes a fine gift. The instructions for whoever receives it are printed inside; in short:

  1. Check the balance with the address alone, in a watch-only wallet. How to do it privately is in lesson 3. For a quick look there is ericonto: you scan the address and see the balance.
  2. When you want to spend, sweep it: open the card and, from a device you trust, move the whole balance into a wallet of your own. In Electrum it is Wallet › Private keys › Sweep, and you scan the key's QR. In Sparrow it is Tools › Sweep Private Key: choose Native SegWit and enter the key without p2wpkh:.
  3. All at once. After the sweep the key is not used again, and no more money is received on it.
  4. Destroy every copy of the card.

For checking the address and for the sweep we gladly recommend two free, non-custodial programs: Electrum and Sparrow.

What the program does, and what is left to you

The program:

  • blocks Python's sockets at startup;
  • uses no temporary files, and writes the PDF and the .md only once, readable only by you;
  • checks its own work before writing: from the key to the address, from the words to the seed;
  • shows only public data on the screen.

What the program cannot control is left to you: the system's print queue, which writes to disk, network printers or printers with memory, swap. And the computer's memory: Python does not guarantee to wipe secrets from it. That is why the ideal is still an offline live system, a USB printer with no memory and the machine switched off at the end.

Back to lesson 6: keeping it, and leaving it All the lessons