NostrElixir.Mnemonic (nostr_elixir v0.1.0)
View SourceBIP-39 Mnemonic utilities for Nostr (NIP-06 compatible).
This module provides functions to generate, validate, and use BIP-39 mnemonics. It is the recommended entry point for mnemonic-related operations in Elixir.
Examples
iex> mnemonic = NostrElixir.Mnemonic.generate(12)
%NostrElixir.Mnemonic{phrase: phrase} = mnemonic
String.split(phrase) |> length() == 12
iex> NostrElixir.Mnemonic.valid?(mnemonic)
true
iex> NostrElixir.Mnemonic.valid?(NostrElixir.Mnemonic.from_phrase("not a real mnemonic"))
false
iex> NostrElixir.Mnemonic.to_seed(mnemonic)
<<_::512>>
iex> NostrElixir.Mnemonic.to_seed(mnemonic, "passphrase") |> byte_size()
64
Summary
Functions
Create a mnemonic struct from a phrase string.
Generate a new mnemonic with the given word count (12, 15, 18, 21, or 24).
Convert a mnemonic to a binary seed. Optionally takes a passphrase.
Check if a mnemonic is valid.
Types
@type t() :: %NostrElixir.Mnemonic{phrase: String.t()}
Functions
Create a mnemonic struct from a phrase string.
Generate a new mnemonic with the given word count (12, 15, 18, 21, or 24).
Convert a mnemonic to a binary seed. Optionally takes a passphrase.
Check if a mnemonic is valid.