|
libwebsockets
Lightweight C library for HTML5 websockets
|
Functions | |
| LWS_VISIBLE LWS_EXTERN int | lws_mnemonic_generate (struct lws_context *ctx, const uint8_t *entropy, char *dest, size_t dest_len) |
| LWS_VISIBLE LWS_EXTERN int | lws_mnemonic_to_entropy (struct lws_context *ctx, const char *src, uint8_t *dest) |
Lws provides an API to convert 128-bit entropy (e.g. AES-128 keys) to and from a 12-word English mnemonic phrase following the BIP-39 standard.
This is useful for providing a human-readable/writable backup of a key.
| LWS_VISIBLE LWS_EXTERN int lws_mnemonic_generate | ( | struct lws_context * | ctx, |
| const uint8_t * | entropy, | ||
| char * | dest, | ||
| size_t | dest_len ) |
#include <include/libwebsockets/lws-mnemonic.h>
lws_mnemonic_generate() - Generate a mnemonic phrase from entropy
| ctx | lws_context (used for random if needed, or SHA256) |
| entropy | 16 bytes of entropy (e.g. an AES-128 key) |
| dest | buffer to receive the NUL-terminated mnemonic string |
| dest_len | size of the dest buffer (should be at least 128 bytes) |
Converts 128 bits of entropy into a 12-word mnemonic phrase. Returns 0 on success, or non-zero on error.
References LWS_EXTERN, and LWS_VISIBLE.
| LWS_VISIBLE LWS_EXTERN int lws_mnemonic_to_entropy | ( | struct lws_context * | ctx, |
| const char * | src, | ||
| uint8_t * | dest ) |
#include <include/libwebsockets/lws-mnemonic.h>
lws_mnemonic_to_entropy() - Recover entropy from a mnemonic phrase
| ctx | lws_context (used for SHA256) |
| src | the mnemonic phrase (12 words separated by single spaces) |
| dest | 16-byte buffer to receive the recovered entropy |
Converts a 12-word mnemonic phrase back into 128 bits of entropy. Validates the BIP-39 checksum. Returns 0 on success, or non-zero if the phrase is invalid or checksum fails.