code wiki / hub / nx_bip39.nx

nx_bip39.nx

buildroot/runtime/hub/nx_bip39.nx

9299 B257 linesdepth 6pulls 9 transitivereach 86 importersview sourcekind librarytopic bip39
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_csprng.nx sha256.nx nx_bip39_wordlist.nx nx_bip39.nx nx_bip39_kat.nx nx_modern_auth_flow.nx nx_social_auth_recover.nx

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

24const NX_B39_OK: i64 = 0
25const NX_B39_BAD_INPUT: i64 = 1480
26const NX_B39_BUF_OVERFLOW: i64 = 1481
27const NX_B39_UNKNOWN_WORD: i64 = 1482
28const NX_B39_BAD_CHECKSUM: i64 = 1483
29const NX_B39_BAD_WORD_COUNT: i64 = 1484
31const NX_B39_MAX_ENT_BYTES: i64 = 32 // 256-bit entropy = 24 words
32const NX_B39_MIN_ENT_BYTES: i64 = 16 // 128-bit entropy = 12 words
33const NX_B39_MAX_WORDS: i64 = 24
34const NX_B39_MAX_MNEMONIC_LEN: i64 = 256 // 24 * (8+1) worst case + slack

functions

39func nx_b39_word_at(idx: i64, out: *u8, out_cap: i64) -> i64
called by 1: nx_bip39_encode calls 1: _b39_chunk
69func nx_b39_word_index(word: *u8, word_n: i64) -> i64
called by 1: nx_bip39_decode calls 1: _b39_chunk
109func _b39_bit_at(entropy: *u8, cs_byte: i64, ent_bytes: i64, bit: i64) -> i64
called by 1: nx_bip39_encode
122func nx_bip39_encode(
165func nx_bip39_generate_24(
180func nx_bip39_decode(