loftafi/bip39
BIP39 Seed Phrase generator zig package
This is a zig implementation of BIP39. It was created for educational purposes. Do not use for anything important or of value. Use at your own risk.
Below is example code that demonstrates how to create and read seed phrases.
// Generate a 12 word seed phrase
const secret_entropy = try generateEntropy(.length_12);
const seed_phrase = try entropyToSeedPhrase(i.entropy, allocator),
defer allocator.free(seed_phrase);
// Read the secret entropy from the seed phrase
var buffer = [_]u8{0} ** 32;
const extract_entropy = try seedPhraseToEntropy(seed_phrase, &buffer);
// Confirm the initial secret entropy matches what was
// read from the seed phrase.
try testing.expectEqualSlices(u8, secret_entropy, extract_entropy);
// Convert a seed phrase into a seed that can be used for
// generating a public/private key.
const optional_passphrase = "";
const seed = try createSeed(seed_phrase, optional_passphrase, allocator);
defer allocator.free(seed);
This code is released under the MIT license. License must be included in any distribution or adaptation of this source. Use at your own risk. No warrantee is given or implied.