Skip to content

Commit 233e9b4

Browse files
committed
more colors available for printable bip39 calculator and wordlist
1 parent 6823be3 commit 233e9b4

File tree

3 files changed

+92
-66
lines changed

3 files changed

+92
-66
lines changed

pub/functora-hakyll/blog/2025-09-18-bitcoin-seed-security.markdown

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ Because of how important your Bitcoin seed is, we cannot afford to take any risk
2020

2121
### Generator tools
2222

23-
1. A good non-digital source of randomness. A coin is acceptable, but casino-grade dice are better. You need a die with an even number of sides.
24-
2. A printed BIP39 dice [calculator](/bip39/calculator.html).
25-
3. A printed BIP39 indexed [wordlist](/bip39/wordlist.html). Do not trust me. Verify the [script](https://github.com/functora/functora.github.io/blob/master/nix/bip39-wordlist.nix) and generate your own wordlist. If your printer is missing ink in certain colors, you can choose or generate a word list that only uses the colors available:
23+
1. A good non-digital source of randomness. A coin is acceptable, but casino-grade dice are better. You need dice with an even number of sides.
24+
2. A printed BIP39 dice [calculator](/bip39/calculator.html). If your printer is missing ink in certain colors, you can use the other available colors instead:
25+
- [red](/bip39/calculator-red.html)
26+
- [green](/bip39/calculator-green.html)
27+
- [blue](/bip39/calculator-blue.html)
28+
- [cyan](/bip39/calculator-cyan.html)
29+
- [magenta](/bip39/calculator-magenta.html)
30+
3. A printed BIP39 indexed [wordlist](/bip39/wordlist.html). Do not trust me. Verify the [script](https://github.com/functora/functora.github.io/blob/master/nix/bip39-wordlist.nix) and generate your own wordlist. Wordlists in other colors are also available:
2631
- [red](/bip39/wordlist-red.html)
2732
- [green](/bip39/wordlist-green.html)
2833
- [blue](/bip39/wordlist-blue.html)
@@ -49,7 +54,7 @@ The BIP39 wordlist contains 2048 words. To randomly select one of them, you need
4954

5055
Example:
5156

52-
1. Rolling the standard six-sided die:
57+
1. Rolling the standard six-sided dice:
5358
- Rolls: 3, 2, 1, 4, 4, 2, 5, 4, 5, 6, 1.
5459
- Parity: odd, even, odd, even, even, even, odd, even, odd, even, odd.
5560
- Bits: 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1.

pub/functora-hakyll/site.hs

Lines changed: 79 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{-# LANGUAGE OverloadedStrings #-}
22

3-
import Control.Monad (replicateM)
3+
import Control.Monad (forM_, replicateM)
44
import Data.Maybe (fromMaybe)
55
import Data.Monoid
6+
import Data.String (fromString)
67
import Hakyll
78
import Main.Utf8 (withUtf8)
89
import System.FilePath
@@ -75,63 +76,73 @@ main = withUtf8 . hakyllWith cfg $ do
7576
match "bip39/*" $ do
7677
route idRoute
7778
compile copyFileCompiler
78-
create ["bip39/calculator.html"] $ do
79-
let defCtx = mkStyleCtx Formal
80-
route idRoute
81-
compile $ do
82-
let idxs items label =
83-
listField
84-
label
85-
( field "idx" (pure . itemBody)
86-
<> defCtx
87-
)
88-
( do
89-
xs <- mapM (makeItem . ("\8470" <>) . show) items
90-
x <- makeItem mempty
91-
pure $ x : xs
92-
)
93-
let rows top label =
94-
listField
95-
label
96-
( listFieldWith
97-
"cols"
98-
(field "col" (pure . itemBody))
99-
( \item -> do
100-
let (idx, raw) = itemBody item
101-
h <-
102-
makeItem . (\x -> "<b>" <> x <> "</b>") $
103-
if idx <= 11
104-
then "bit " <> show idx
105-
else raw
106-
xs <-
107-
replicateM 11 . makeItem $
108-
if idx <= 11
109-
then raw
110-
else mempty
111-
t <-
112-
makeItem $
113-
if (top || idx < 4) && idx <= 11
114-
then raw
115-
else mempty
116-
pure $ [h] <> xs <> [t]
117-
)
118-
)
119-
( mapM makeItem
120-
. zip [1 ..]
121-
. (<> ["sum=", "sum+1=", "word="])
122-
$ fmap (show . (2 ^)) [0 .. 10]
123-
)
124-
let ctx =
125-
idxs [1 .. 12] "idxs-top"
126-
<> idxs [13 .. 24] "idxs-bottom"
127-
<> rows True "rows-top"
128-
<> rows False "rows-bottom"
129-
<> constField "title" "BIP39 Dice Calculator"
130-
<> defCtx
131-
makeItem ""
132-
>>= loadAndApplyTemplate "templates/bip39-dice-calculator.html" ctx
133-
>>= loadAndApplyTemplate "templates/default.html" ctx
134-
>>= relativizeUrls
79+
forM_ colors $ \mcolor -> do
80+
let color = fromMaybe "black" mcolor
81+
let name =
82+
"bip39/calculator"
83+
<> maybe mempty ("-" <>) mcolor
84+
<> ".html"
85+
create [fromString name] $ do
86+
let defCtx =
87+
mkStyleCtx Formal
88+
<> constField "table-color" color
89+
route idRoute
90+
compile $ do
91+
let idxs items label =
92+
listField
93+
label
94+
( field "idx" (pure . itemBody)
95+
<> defCtx
96+
)
97+
( do
98+
xs <- mapM (makeItem . ("\8470" <>) . show) items
99+
x <- makeItem mempty
100+
pure $ x : xs
101+
)
102+
let rows top label =
103+
listField
104+
label
105+
( listFieldWith
106+
"cols"
107+
( field "col" (pure . itemBody)
108+
<> defCtx
109+
)
110+
( \item -> do
111+
let (idx, raw) = itemBody item
112+
h <-
113+
makeItem . (\x -> "<b>" <> x <> "</b>") $
114+
if idx <= 11
115+
then "bit " <> show idx
116+
else raw
117+
xs <-
118+
replicateM 11 . makeItem $
119+
if idx <= 11
120+
then raw
121+
else mempty
122+
t <-
123+
makeItem $
124+
if (top || idx < 4) && idx <= 11
125+
then raw
126+
else mempty
127+
pure $ [h] <> xs <> [t]
128+
)
129+
)
130+
( mapM makeItem
131+
. zip [1 ..]
132+
. (<> ["sum=", "sum+1=", "word="])
133+
$ fmap (show . (2 ^)) [0 .. 10]
134+
)
135+
let ctx =
136+
idxs [1 .. 12] "idxs-top"
137+
<> idxs [13 .. 24] "idxs-bottom"
138+
<> rows True "rows-top"
139+
<> rows False "rows-bottom"
140+
<> constField "title" "BIP39 Dice Calculator"
141+
<> defCtx
142+
makeItem ""
143+
>>= loadAndApplyTemplate "templates/bip39-dice-calculator.html" ctx
144+
>>= loadAndApplyTemplate "templates/default.html" ctx
145+
>>= relativizeUrls
135146
match "templates/*" $ compile templateBodyCompiler
136147
match "license.markdown" $ compile pandocCompiler
137148
match "index/*.markdown" $ compile pandocCompiler
@@ -207,3 +218,13 @@ mkStyleCtx style =
207218
constField "formal" "true"
208219
<> constField "color" "white"
209220
<> defaultContext
221+
222+
colors :: [Maybe String]
223+
colors =
224+
[ Nothing,
225+
Just "red",
226+
Just "green",
227+
Just "blue",
228+
Just "cyan",
229+
Just "magenta"
230+
]

pub/functora-hakyll/templates/bip39-dice-calculator.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
<thead>
33
<tr>
44
$for(idxs-top)$
5-
<th style="padding-right: 0.6em">$idx$</th>
5+
<th style="padding-right: 0.6em; color: $table-color$">$idx$</th>
66
$endfor$
77
</tr>
88
</thead>
99
<tbody>
1010
$for(rows-top)$
1111
<tr>
1212
$for(cols)$
13-
<td style="padding-right: 0.6em">$col$</td>
13+
<td style="padding-right: 0.6em; color: $table-color$">$col$</td>
1414
$endfor$
1515
</tr>
1616
$endfor$
1717
</tbody>
1818
<thead>
1919
<tr>
2020
$for(idxs-bottom)$
21-
<th style="padding-right: 0.6em">$idx$</th>
21+
<th style="padding-right: 0.6em; color: $table-color$">$idx$</th>
2222
$endfor$
2323
</tr>
2424
</thead>
2525
<tbody>
2626
$for(rows-bottom)$
2727
<tr>
2828
$for(cols)$
29-
<td style="padding-right: 0.6em">$col$</td>
29+
<td style="padding-right: 0.6em; color: $table-color$">$col$</td>
3030
$endfor$
3131
</tr>
3232
$endfor$

0 commit comments

Comments
 (0)