code wiki / (root) / base58.nx

base58.nx

buildroot/runtime/base58.nx

6174 B182 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

base58.nx -- Bitcoin / IPFS base58 encoder + decoder. Alphabet (omits 0/O/l/I to avoid visual confusion): 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz Used by: Bitcoin addresses, IPFS CID v0, Stellar account IDs, Monero addresses. Less efficient than base64 (log(58)/log(256) ≈ 0.73 bytes of data per char vs base64's 0.75) but preserves 1:1 byte-to-copy safety when pasted into phishing-resistant UI contexts. Leading zero bytes in input map to leading '1' chars in output. This preserves information for binary protocols where leading zeros are significant (Bitcoin addresses have a version prefix byte that's often 0x00). Invariants: B58_1 Alphabet is Bitcoin/IPFS canonical; no URL-safe variant (unlike base64). B58_2 Round-trip exact: decode(encode(x)) == x. B58_3 Decoder rejects non-alphabet chars with negative err.

dependencies 1 imports · 0 importers

syscalls.nx base58.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main base58_encode base58_encode_after_zeros

structs

none

consts

25const B58_ERR_BAD_CHAR: i64 = -1
26const B58_ERR_OVERFLOW: i64 = -2

functions

29func b58_enc_char(v: i64) -> i64 {
45func b58_dec_val(c: i64) -> i64 {
called by 1: base58_decode
56func base58_encode_after_zeros(in_bytes: *u8, n: i64, zeros: i64, out: *u8) -> i64;
called by 1: base58_encode
61func base58_encode(in_bytes: *u8, n: i64, out: *u8) -> i64 {
called by 1: main calls 1: base58_encode_after_zeros
77func base58_encode_after_zeros(in_bytes: *u8, n: i64, zeros: i64, out: *u8) -> i64 {
calls 1: b58_enc_char
125func base58_decode(in_chars: *u8, n: i64, out: *u8) -> i64 {
calls 1: b58_dec_val
174func main() -> i64 {
calls 1: base58_encode