This article was translated from Japanese with AI. Read the original (日本語) · Report a translation issue

Bitcoiners are particular about everything, right down to how they generate their seed phrase. That isn't anyone's official slogan, but it's true that the hardcore crowd has long paid close attention to how their wallet seeds are generated. The reason is simple: if you generate a seed with too little randomness, your funds could be stolen.

In fact, we recently covered the Milk Sad vulnerability, and incidents in which seeds generated by software wallets from pseudorandom numbers turned out to be vulnerable keep happening. It's a serious risk, and by the time you find out, it may already be too late, so you want reliable randomness that doesn't depend on electronic devices or software.

Libbitcoin Explorer (bx)に深刻な脆弱性。Milk Sad脆弱性とは
今週、ビットコイン関連の技術者にとって衝撃的なニュースが発表されました。Libbitcoin Explorer (bx)というツールにシード生成の脆弱性があり、このツールを利用して生成されたウォレットから資金が盗難されているというのです。 Trust Walletなども最近シードの生成に関する脆弱性で大きな流出を起こしている中、ノンカストディアルウォレットで同じような問題が相次いでいることになります。せめてもの救いは人気のウォレットであるTrust Walletと比較してLibbitcoinは老舗ながら近年ほとんど使われていないことでしょう。 Milk Sad脆弱性について解説していきます。 ・Libbitcoinはビットコイン関連のウォレットやアプリケーションの作成に使える老舗C++ライブラリ ・エントロピー不足とMilk Sad…で始まるシードフレーズ ・意図的に仕込まれていた?という疑惑について milksad.info

So today we'll look at generating random numbers with ordinary dice. Most recently, the Hanseikai Expo held at Tokyo Bitcoin Base included a workshop on generating seed phrases with dice, and one comment we heard a lot was, "I'm not confident this actually produces secure random numbers." Today we'll answer that question and also consider whether you really should bother using dice to generate randomness.

• What is the "entropy" behind a seed phrase?

• Generating a seed with dice is quite simple

• How biased do dice have to be before the seed becomes vulnerable?

• Is it worth actively choosing over generating the seed on a hardware wallet?

💡
If any of the calculations in this article are wrong, please let me know. To give you the conclusion up front: if you're worried, generating a 24-word seed phrase will basically keep you safe.

What is the "entropy" behind a seed phrase?

Anyone who has used a Bitcoin wallet has run into the unavoidable "seed phrase" at some point. A seed phrase usually consists of 12 or 24 words, each chosen at random from a list of 2,048, and each word corresponds to a unique 11 bits of information.

Each word corresponds to an 11-digit binary number, like this

Putting these words together lets you restore the random number at the root of the wallet, called the "seed." In other words, a 12-word seed phrase represents a 128-bit seed, and a 24-word phrase represents a 256-bit seed.

💡
The math doesn't line up exactly (12×11 = 132 > 128 and 24×11 = 264 > 256) because the last word contains a string of bits used for error detection (a checksum). If you mistype one of the earlier words, there's a high probability that an error will be detected once you've entered the full seed phrase.

If a seed leaks or can be guessed, someone else can use that wallet, so you need a source with enough randomness when generating it. This randomness, and especially in key generation the information obtained from it (a random string of bits), is called entropy.

For example, an ideal coin lands on either heads or tails with equal probability each time it's tossed, so we say a coin toss has 1 bit of entropy. If you toss it repeatedly, as long as each toss is independent (they don't affect each other), 10 tosses give you 10 bits of entropy.

For that to hold, though, the conditions of each toss have to be random. If the position of your hand and the coin, the force, the temperature and so on are exactly the same every time, the tosses lose their independence. It's easy to see if you picture tossing the coin in a way that aims to land heads.

The pseudorandom number generators in PCs and smartphones tend to produce biased entropy because of the physical constraints that come with their small size and the fact that they run on electricity, so various techniques are needed to boost their randomness. Humans, on the other hand, have easy access to good-quality entropy through coin tosses and dice, so why not use it? That's the reason for using dice to generate Bitcoin seeds.

Generating a seed with dice is quite simple

There are several procedures for generating a seed with dice, but here's a simple one.

Get five dice and one coin, and roll the dice in a thoroughly random way. (Shake them in your hands for varying lengths of time, or use a cup and shake them well inside it. Basically, it's fine as long as you don't find yourself rolling them the same way every time or always starting from the same faces.)

There are several tables that convert dice rolls into seed phrase words, so read the results left to right and top to bottom according to the dice positions, and look them up. With five dice you also need one coin toss at the end, so toss the coin. Again, try to make this as random as possible. (Don't adjust things, such as always starting with heads up, and don't use the same force or height for every toss.)

Roll your own Bitcoin seed
Learn how to create your own random Bitcoin hardware wallet seed with these easy step-by-step instructions.

An example of the procedure presented by hardware wallet maker BitBox

Repeating this gives you 11 or 23 words. The final word also serves as the checksum, which makes it hard to work out by hand, so you'll restore the seed phrase on a hardware wallet or similar device. (There are several valid options for the last word, so choose it randomly using whatever method you like. What matters is that you pick it at random, not because you like a particular word.)

That's all there is to the simple method. It doesn't take much time, and many people find it easier than they expected, which is exactly why I understand if it leaves you feeling uneasy.

How biased do dice have to be before the seed becomes vulnerable?

The biggest worry is probably whether there's enough randomness. So let's consider: if you happened to use biased dice to generate a seed, at what point would it start to meaningfully hurt your security?

As an extreme example, imagine dice that only ever land on 1, 2, 5 or 6.

With the algorithm described above, only four die values (1–4) come into play, so with five dice each word is chosen from a pool of just 2048/32 = 64 words. In other words, each word should carry 11 bits of entropy (1/2048), but in reality you're getting only 6 bits of entropy (1/64).

Number of words Intended entropy Entropy in this case
12 128 73
24 256 141

For a 12-word seed phrase, even if the last word is chosen at random (7 bits), you end up with only 66+7 = 73 bits of entropy. Strictly speaking it isn't the same thing, but that level of randomness is comparable to having 5 or more of the 12 words exposed, which is clearly not good.

With a 24-word seed phrase, though, you'd still have 138+3 = 141 bits of entropy even in this case. That's more than a completely random 12-word seed phrase. And in reality, you're never going to use dice this biased. So if you're worried, the right first step is to generate a 24-word seed. In any case, as long as you use ordinary dice, minor manufacturing imperfections basically won't result in a vulnerable seed.

Buying better dice isn't great value for money

You can also buy dice with almost no bias. Called casino dice, they're transparent so you can check for air bubbles or hidden weights inside, they're nearly perfect cubes, and the pips are neither indented nor raised; they're made from plastic of the same density as the body, just in a different color. Of course, they aren't perfect down to the atomic level, but many Bitcoiners buy them to generate their seeds.

That said, if you're generating a 256-bit seed, I don't think you need to go that far.

Proper casino dice cost around 5,000 yen

There are also algorithms that correct for biased dice

There are also algorithms that correct for the effects of biased dice or coins. One was invented by the mathematician John von Neumann, and we've covered it in a previous article, so check that out if you're interested.

紙とペンでシャミアの秘密分散法を使いシードフレーズを分割する:Codex32
コアなビットコイナーは秘密鍵の管理にうるさかったり、一家言ある人が多いというイメージはありませんか?少なくとも自分の印象ではWeb3系の人たちよりよほど秘密鍵の生成や管理に関心がある気がします。 ビットコイナーの一部の間ではマルチシグによって自身のコールドストレージのセキュリティを強化する人も見られるようになりました。しかし通常のシードフレーズとは異なり、複数のシードフレーズとスクリプト文のデータなどを用意し別々の場所で安全に保管するのが煩雑なのも間違いありません。 他にはシャミアの秘密分散法という知名度の高い手法を使って1つのシードフレーズを複数の「シェア」に分割し、それらのシェアを使ってn-of-mのマルチシグを擬似的に再現することも考えられます。実際には1つのシードフレーズを復元するので狭義のマルチシグトランザクションにはなりませんが、比較的シンプルな手法で(ビットコイン以外のブロックチェーン系のウォレットで)人気があります。 例えば友人や親戚にシェアを1つ預けてソーシャルリカバリーできるようなウォレットの多くはこのスキームになっています。数人に結託して裏切られないように注

Combining different entropy sources is another option

As I mentioned briefly earlier, the pseudorandom number generators in electronic devices strengthen their randomness by combining multiple sources of randomness that are as uncorrelated as possible. Humans can take the same approach. For example, toss a coin alongside the procedure above: if it lands heads, leave the bits as they are; if tails, flip every bit (0→1, 1→0). That simply doubles the entropy.

Hardware wallets such as Coldcard that support generating seeds from dice rolls or coin tosses also sometimes have a setting that combines the dice with other entropy sources rather than relying on the dice alone.

COLDCARD - The Most Trusted and Secure Signing Device (a.k.a. Hardware Wallet)
COLDCARD Is The Most Trusted and Secure Bitcoin Signing Device (aka. Bitcoin Hardware Wallet)

Is it worth actively choosing over generating the seed on a hardware wallet?

As far as I know, there has never been a case of a hardware wallet's seed generation being vulnerable, and unless the manufacturer is malicious, I think it's very unlikely to happen when generating 24 words. So I can understand trusting the seed your hardware wallet generates.

However, if it turned out that a vulnerability had been deliberately planted, it might already be too late by the time it was discovered. A vulnerable seed stays vulnerable forever. As a countermeasure, I think generating your own seed is very much worth considering.

💡
Either way, once you're storing large amounts, I think it's also important to verify that the wallet derived from your seed really is the same on hardware wallets from different manufacturers (which also tells you whether the hardware wallets themselves can be trusted).

Summary

• When generating a seed with dice, following a procedure that produces a 24-word seed phrase is basically safe even without perfect dice or a perfect rolling technique (though aiming for as much randomness as possible is of course still important)

• Some hardware wallets can add their own entropy on top of your dice rolls

• It takes a little more effort than relying on a hardware wallet alone, but it's more secure, so I strongly recommend generating your own seed, especially when large amounts are involved