bip39
Version, currently 0.1.12 versions
- 0.1.1latestAug 3, 2022
- 0.1.0not indexedJan 5, 2023
github.com/q9f/bip39.cr
A native library implementing BIP-0039 mnemonics for the Crystal programming language.
17 stars
0 dependents
License: APLv2
Installation
# Add this to your shard.yml
dependencies:
bip39:
github: q9f/bip39.cr
version: ~> 0.1.1Then run:
shards installshard.yml
- Crystal
1.5.0- License
- APLv2
- Author
- Afr Schoe <crystal@q9f.cc>
Dependencies
This version declares no dependencies.
README
# bip39.cr
[](https://github.com/q9f/bip39.cr/actions)
[](https://codecov.io/gh/q9f/bip39.cr)
[](https://q9f.github.io/bip39.cr/)
[](https://github.com/q9f/bip39.cr/releases/latest)
[](https://github.com/q9f/bip39.cr/search?l=crystal)
[](LICENSE)
a native library implementing `bip-0039` mnemonics purely for the crystal language.
> _this bip (0039) describes the implementation of a mnemonic code or mnemonic sentence -- a group of easy to remember words -- for the generation of deterministic wallets._
>
> _it consists of two parts: generating the mnemonic and converting it into a binary seed. this seed can be later used to generate deterministic wallets using bip-0032 or similar methods._
ref: [bitcoin/bips/bip-0039](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki)
# installation
add the `bip39` library to your `shard.yml`
```yaml
dependencies:
bip39:
github: q9f/bip39.cr
version: "~> 0.1"
```
# usage
```crystal
# import bip39
require "bip39"
```
you can generate and recover mnemonics fully adhering to the [bip-0039 specification](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki).
```crystal
m0 = Bip0039::Mnemonic.new
# => <Bip0039::Mnemonic:0x7f51769bcd20 @ent=128, @seed=183297182565288719506055787609377395053>
m0.to_words
# => ["measure", "come", "cube", "ostrich", "wide", "inspire", "hello", "essay", "ready", "cute", "reform", "sustain"]
m0.to_hex
# => "89e5c0d5ce7faaea9ab269b2c6d6d16d"
```
the default entropy is of 128 bits. this shard can generate seeds of of 128/160/192/224/256-bit entropy. just initialize mnemonics with the bit-size, e.g., `Bip0039::Mnemonic.new 256`.
it's easily possible to recover bip-0039 mnemonics from a phrase or a seed by simply passing it to the constructor.
```crystal
m1 = Bip0039::Mnemonic.new ["measure", "come", "cube", "ostrich", "wide", "inspire", "hello", "essay", "ready", "cute", "reform", "sustain"]
# => <Bip0039::Mnemonic:0x7f37ca6e4c80 @ent=128, @seed=183297182565288719506055787609377395053>
m1.to_hex
# => "89e5c0d5ce7faaea9ab269b2c6d6d16d"
m2 = Bip0039::Mnemonic.new "89e5c0d5ce7faaea9ab269b2c6d6d16d"
# => <Bip0039::Mnemonic:0x7f37ca6e4be0 @ent=128, @seed=183297182565288719506055787609377395053>
m2.to_words
# => ["measure", "come", "cube", "ostrich", "wide", "inspire", "hello", "essay", "ready", "cute", "reform", "sustain"]
```
# documentation
the full library documentation can be found here: [q9f.github.io/bip39.cr](https://q9f.github.io/bip39.cr/)
generate a local copy with:
```
crystal docs
```
# testing
the library is entirely specified through tests in `./spec`; run:
```bash
crystal spec --verbose
```
# contribute
create a pull request, and make sure tests and linter passes.
license: apache license v2.0
contributors: [**@q9f**](https://github.com/q9f/)
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.1- Tagged
- Aug 3, 2022
- Commit
d8e8ce6bf375- Crystal
1.5.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/q9f/bip39.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 13, 2026
- Synced
- Aug 13, 2026
- Versions
- 2