# Does BIP39 mnemonic construction avoid repeating words?

Will all 24 words of a seed-phrase be unique by specification? Or is it possible for a word to occupy two positions (ie the word "tool" is #8 AND #20 in a valid, securely generated seed)

There is nothing stopping a word to be repeated more than once. In a 24 word mnemonic, with 2048 possible words in the dictionary (BIP 39), there is a probability of at least one duplicate around 12.7% of the time (variation of the birthday paradox).

• Preventing duplicate words will in fact restrict the entropy of the seed phrase.
– pim
Oct 23 '17 at 14:34

I went to https://iancoleman.github.io/bip39/ and after generating a dozen or so mnemonics I got

audit again guess butter minute predict grid image fresh kit west will before noodle supply magic bread protect mimic butter credit tragic recipe clarify

So this confirms the other answers: assuming this is a correct implementation, repeats are allowed.

No, the BIP39 construction does not avoid repeating words.

It is possible for a word to show up multiple times, but since there are 2048 words it is fairly unlikely for repeats to show up in randomly generated keys.

In fact,

A mnemonic derived of Raw binary @256 bits using all 1's would be as follows.

zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo vote

1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

A 24 word BIP39 mnemonic phrase, with 256 bits of entropy and an 8 bit checksum, is encoded as 256 + 8 = 264 = 24 x 11 bits, with each 11 bits corresponding to a word out of the 2048 (= 211) available, so there's nothing to stop the same word occuring more than once.

We can write the probability of that as :-

Pr(a repeated word) = Pr(a repeated word in first 23 words) + Pr(no repeated word in first 23 words, but one of them equals the 24th word)

= Pr(A) + Pr(B), say, with Pr(B) >= 0 (A, B mutually exclusive).

Pr(A) is easy to calculate and is similar to the "birthday problem" :-

Pr(not A) = no of 'success' outcomes / total no of outcomes

= 2048P23 / 204823

because every 'successful' outcome is a sequence of DISTINCT choices from the 2048 words. (This would actually be the birthday problem for 23 people in a room if we lived in a world with 2048 days in the year).

These are quite big numbers but can be computed on a standard Casio calculator - comes out at approx 0.883, so Pr(A) = 0.117.

Thus the chances of a repeated word is >= approx 11.7%.

If you generate random 24 word mnemonic phrases from https://iancoleman.io/bip39/ and put one phrase on each line of a text file `phrase.txt` then you can pick out the repeated words by running :-

``````perl wsl.pl phrase.txt | perl dwc.pl
``````

where wsl.pl and dwc.pl are as below.

``````#wsl.pl
\$, = "\n";
while (<>) {
print (sort(split), "==================================\n");
}

#dwc.pl
\$last = "";
while (<STDIN>) {
print if \$_ eq \$last;
\$last = \$_;
}
``````

I tried out 21 phrases and 2 of them had repeats, roughly the expected number.