Skip to content

loftafi/bip39

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BIP39 implementation for zig

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.

Example usage

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);

License

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.

About

BIP39 Seed Phrase generator zig package

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages