Skip to content

Conversation

@tcharding
Copy link
Member

BIP39 says

The allowed size of ENT is 128-256 bits.

Once we add the checksum this is 132-264 bits. This is divided by 11 to
get the word count. From the BIP

CS = ENT / 32
MS = (ENT + CS) / 11

|  ENT  | CS | ENT+CS |  MS  |
+-------+----+--------+------+
|  128  |  4 |   132  |  12  |
|  160  |  5 |   165  |  15  |
|  192  |  6 |   198  |  18  |
|  224  |  7 |   231  |  21  |
|  256  |  8 |   264  |  24  |

Currently we are limiting word count to be a multiple of 6, I do not
know why this is being done but from reading the BIP it seems that 15 is
a valid word count value.

Allow word count of 15 by checking the word count modulo 3 instead of
modulo 6.

Fixes: #15

@tcharding tcharding force-pushed the word-counts branch 2 times, most recently from 46bf358 to 151816a Compare November 9, 2021 22:15
BIP39 says

> The allowed size of ENT is 128-256 bits.

Once we add the checksum this is 132-264 bits. This is divided by 11 to
get the word count. From the BIP141
```
CS = ENT / 32
MS = (ENT + CS) / 11

|  ENT  | CS | ENT+CS |  MS  |
+-------+----+--------+------+
|  128  |  4 |   132  |  12  |
|  160  |  5 |   165  |  15  |
|  192  |  6 |   198  |  18  |
|  224  |  7 |   231  |  21  |
|  256  |  8 |   264  |  24  |
```

Currently we are limiting word count to be a multiple of 6, I do not
know why this is being done but from reading the BIP it seems that 15 is
a valid word count value.

Allow word count of 15 by checking the word count modulo 3 instead of
modulo 6. Since this check appears twice in the code, add a helper
function to reduce code duplication.

Fixes: rust-bitcoin#15
We just enabled word counts of 15, add a unit test that verifies all the
valid word count values.
@stevenroose
Copy link
Collaborator

tACK af958a2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

passphrases with 15 words should be possible

2 participants