#seed #word #phrase #random-seed #entropy #key-pair #checksum

seed15

general library for working with 15 word seed phrases

5 releases

0.1.5 Feb 10, 2023
0.1.3 Jan 23, 2023
0.1.2 Jan 23, 2023
0.1.1 Nov 30, 2022
0.1.0 Nov 28, 2022

#1410 in Algorithms


Used in centichain_keypair

MIT license

19KB
286 lines

seed15

seed15 is a standard for converting user secrets into seed phrases. The seed15 library includes helper functions for generating new seeds (which contain 16 bytes of entropy) and converting between seeds and seed phrases.

The seed15 seed phrase uses a 1024 word english dictionary, meaning each word contains 10 bits of entropy. 13 words total are needed to get the 128 bits that map to a 16 byte seed. The final two bits of the 13th word are explicitly set to zero, a valid seed may only use a specific 256 words of the dictionary for the 13th word.

The final two words are used for a checksum. The checksum is computed by taking the sha256 of the seed and then using the first 20 bits of the result. 20 bits of entropy means that an incorrectly transcribed seed has a one in a million chance of having a correct checksum. Using a 20 bit checksum also means that with high probability the correct seed can be found by brute force without any false positives as long as only one or two words is incorrect.

use seed15::random_seed;
use seed15::phrase::{seed_to_seed_phrase, seed_phrase_to_seed};
use seed15::keypair::keypair_from_seed;

// Create a seed, convert it to a human-readable phrase, then convert the phrase back to a
// seed.
let new_seed = random_seed();
let phrase = seed_to_seed_phrase(new_seed);
let seed = seed_phrase_to_seed(&phrase).unwrap();

// Use the seed to create an ed25519 keypair.
let keypair = keypair_from_seed(seed);

A full specification of the seed protocol can be found here: https://blog.sia.tech/a-technical-breakdown-of-mysky-seeds-ba9964505978

Dependencies

~4.5MB
~84K SLoC