nx_bip39.nx
buildroot/runtime/hub/nx_bip39.nx
about
nx_bip39.nx -- V-MODAUTH-3: BIP39 mnemonic encode/decode (the recovery-phrase rung).
BIP39: entropy (ENT bits, 128..256, multiple of 32) + checksum (first ENT/32 bits
of SHA-256(entropy)) -> (ENT+CS)/11 words from the 2048-word English list.
24 words = 256-bit entropy = what nx_modern_auth_register issues as the
forgot-passphrase credential (the mnemonic entropy keys a SECOND OPAQUE record,
so recovery stores nothing offline-crackable either -- exceeds the charter's
recovery_hash sketch).
Decode validates the checksum: a mistyped word fails loudly (1-in-2^CS miss rate
per BIP39 design; 256 for 24 words).
COMPOSES: nx_bip39_wordlist (generated from canonical bitcoin/bips english.txt,
sha256-verified at staging), sha256, nx_csprng
COMPOSED BY: hub/nx_modern_auth_flow (register issues, recover redeems)
SPEC: BIP-0039 (bitcoin/bips); gate vectors = trezor/python-mnemonic vectors.json
license_tier: ORIGINAL
dependencies 4 imports · 3 importers
imports: nx_syscalls.nxnx_csprng.nxsha256.nxnx_bip39_wordlist.nx
imported by: nx_bip39_kat.nxnx_modern_auth_flow.nxnx_social_auth_recover.nx
structs
| none |
consts
| 24 | const NX_B39_OK: i64 = 0 |
| 25 | const NX_B39_BAD_INPUT: i64 = 1480 |
| 26 | const NX_B39_BUF_OVERFLOW: i64 = 1481 |
| 27 | const NX_B39_UNKNOWN_WORD: i64 = 1482 |
| 28 | const NX_B39_BAD_CHECKSUM: i64 = 1483 |
| 29 | const NX_B39_BAD_WORD_COUNT: i64 = 1484 |
| 31 | const NX_B39_MAX_ENT_BYTES: i64 = 32 // 256-bit entropy = 24 words |
| 32 | const NX_B39_MIN_ENT_BYTES: i64 = 16 // 128-bit entropy = 12 words |
| 33 | const NX_B39_MAX_WORDS: i64 = 24 |
| 34 | const NX_B39_MAX_MNEMONIC_LEN: i64 = 256 // 24 * (8+1) worst case + slack |
functions
| 39 | func nx_b39_word_at(idx: i64, out: *u8, out_cap: i64) -> i64 |
| 69 | func nx_b39_word_index(word: *u8, word_n: i64) -> i64 |
| 109 | func _b39_bit_at(entropy: *u8, cs_byte: i64, ent_bytes: i64, bit: i64) -> i64 called by 1: nx_bip39_encode |
| 122 | func nx_bip39_encode( |
| 165 | func nx_bip39_generate_24( |
| 180 | func nx_bip39_decode( |