Skip to content

Mnemonic code for generating deterministic keys, BIP39 in Crystal lang

License

Notifications You must be signed in to change notification settings

Hamdy/mnemonic.cr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mnemonic.cr

Reference implementation of BIP-0039: Mnemonic code for generating deterministic keys built python-mnemonic as a reference

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      mnemonic:
        github: crystaluniverse/mnemonic.cr
  2. Run shards install

Usage

require "mnemonic"

en = Mnemonic::Mnemonic.new
# only get seed
seed = en.to_entropy "finger feel food anchor morning benefit stable gesture kiwi tortoise amount glide deputy cake party few canyon title effort gentle route tape gallery over"

# get Signing key from pass phrase directly 
sk = en.get_signing_key "finger feel food anchor morning benefit stable gesture kiwi tortoise amount glide deputy cake party few canyon title effort gentle route tape gallery over"

# An example on using signing key to sign a message
id = 40
created = Time.utc.to_unix
expires = created + 1000
headers = %((created): #{created}\n)
headers += %((expires): #{expires}\n)
headers += %((key-id): #{id})

signature = Base64.strict_encode(String.new sk.sign_detached(headers))

About

Mnemonic code for generating deterministic keys, BIP39 in Crystal lang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published