#bip-39 #mnemonic #bitcoin #crypto #binary-encoding #binary-representation

no-std bip39-dict

BIP39 dictionaries with apis to convert between words and binary representation

4 releases

0.1.3 Oct 5, 2023
0.1.2 Oct 3, 2023
0.1.1 Apr 1, 2022
0.1.0 Mar 24, 2022

#14 in #bip-39

Download history 35/week @ 2024-06-17 49/week @ 2024-06-24 63/week @ 2024-07-01 111/week @ 2024-07-08 26/week @ 2024-07-15 32/week @ 2024-07-22 222/week @ 2024-07-29 294/week @ 2024-08-05 320/week @ 2024-08-12 288/week @ 2024-08-19 204/week @ 2024-08-26 73/week @ 2024-09-02 156/week @ 2024-09-09 177/week @ 2024-09-16 120/week @ 2024-09-23 243/week @ 2024-09-30

711 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

300KB
12K SLoC

BIP39 Dictionary

BIP39 dictionary encoding/decoding

BIP39 dictionaries gives a set of 2048 order specific words for multiple languages.

Every words represent a 11 bits index, which combined together represent a binary encoding by adding some checksum bits (which serve as padding), this allow to encode any arbitary data stream.

This crate can be used to produced standard BIP39 data, but also give the ability to relax the standard with more capabilities.

The maximum length allowed for the checksum is 32 bytes (256 bits), and the checksum used is currently always SHA2-256. At later point this could be made customizable as well.

The following relation need to hold for having a valid decoding/encoding:

length_bytes(data) * 8 + checksum = number_of(words) * 11

The standard BIP39 encoding use the following value:

Words In Bits Full Bytes Checksum Bits
12 132 16 (128) 4
15 165 20 (160) 5
18 198 24 (192) 6
21 231 28 (224) 7
24 264 32 (256) 8

But by relaxing this BIP39 standard, we can make the checksum variable and all combinaison of words valid:

Words In Bits Full Bytes Remaining Bits Standard
1 11 1 (8) 3 no
2 22 2 (16) 6 no
3 33 4 (32) 1 no
4 44 5 (40) 4 no
5 55 6 (48) 7 no
6 66 8 (64) 2 no
7 77 9 (72) 5 no
8 88 11 (88) 0 no
9 99 12 (96) 3 yes
10 110 13 (104) 6 no
11 121 15 (120) 1 no
12 132 16 (128) 4 yes
... ... ... ... no
... ... ... ... no
15 165 20 (160) 5 yes
... ... ... ... no
... ... ... ... no
18 198 24 (192) 6 yes
... ... ... ... no
... ... ... ... no
21 231 28 (224) 7 yes
... ... ... ... no
... ... ... ... no
24 264 32 (256) 8 yes
24 264 33 (264) 0 no
... ... ... ... no
... ... ... ... no
27 297 37 (296) 1 no

Thanks

This crate has been heavily inspired by the BIP39 implementation at rust-cardano bip39 and dictionary data and test vectors have been lifted from this source.

Dependencies

~755KB
~15K SLoC