diff --git a/nostr_core/utils.c b/nostr_core/utils.c index 46b80ef2..ed0228ac 100644 --- a/nostr_core/utils.c +++ b/nostr_core/utils.c @@ -1331,6 +1331,11 @@ static int find_word_index(const char* word) { return -1; } +const char * const *nostr_bip39_get_wordlist(int *count) { + if (count) *count = 2048; + return BIP39_WORDLIST; +} + int nostr_bip39_mnemonic_from_bytes(const unsigned char* entropy, size_t entropy_len, char* mnemonic) { if (!entropy || !mnemonic || entropy_len < 16 || entropy_len > 32) return -1; diff --git a/nostr_core/utils.h b/nostr_core/utils.h index a1b927b8..aa0aed2f 100644 --- a/nostr_core/utils.h +++ b/nostr_core/utils.h @@ -24,6 +24,11 @@ void nostr_bytes_to_hex(const unsigned char *bytes, size_t len, char *hex); // Convert hexadecimal string to bytes int nostr_hex_to_bytes(const char *hex, unsigned char *bytes, size_t len); +// Get the BIP-39 English wordlist (2048 words). Returns a pointer to a +// static array; count is set to 2048 if non-NULL. The pointer is valid +// for the lifetime of the process. +const char * const *nostr_bip39_get_wordlist(int *count); + // Base64 encoding function size_t base64_encode(const unsigned char *data, size_t len, char *output, size_t output_size);