code wiki / (root) / nx_mathcore.nx

nx_mathcore.nx

buildroot/runtime/nx_mathcore.nx

4125 B107 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_mathcore.nx -- emit an EXACT multi-precision product so an OUTSIDE arithmetic can adjudicate it. The gate beside this organ (nx_mathcore_gate) proves our exact arithmetic by algebraic identity, which is OUR instrument judging OUR artifact. That is one method class. The second class needs a witness we did not write and cannot influence, which is why this organ exists: it prints a real product of real operands in a form any arbitrary-precision arithmetic on earth can check, so a third party can CONFIRM it -- and, handed a perturbed digit, must REFUSE it. A witness that cannot disagree proves nothing. nx_mathcore mul <decimal_a> <decimal_b> -> MATHCORE-MUL a=<dec> b=<dec> product=<32 hex digits, big-endian, 128 bits> Operands are parsed as unsigned decimal into two 32-bit limbs each; the product is four limbs, serialised big-endian by the same bi_to_bytes_be the crypto lane uses. No floats anywhere, by construction. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_bigint_lib.nx nx_itoa_lib.nx nx_mathcore.nx

imports: nx_bigint_lib.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

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

main mc_puts mc_slen mc_streq mc_atou mc_put64 bi_zero bi_zero ↻ bi_mul bi_zero ↻ bi_to_bytes_be mc_hexdigit

structs

none

consts

18const MC_SLOTS: i64 = 8
19const MC_SLOT_BYTES: i64 = 64
20const MC_PROD_BYTES: i64 = 16 // 4 limbs x 32 bits = 128 bits
21const MC_FULL_LIMB: i64 = 0xFFFFFFFF
22const MC_N2: i64 = 2
23const MC_N4: i64 = 4
24const MC_ASCII_0: i64 = 48
25const MC_ASCII_9: i64 = 57
26const MC_ASCII_a: i64 = 97
27const MC_HEX_A_OFF: i64 = 10
28const MC_USAGE: i64 = 2

functions

30func mc_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: mc_puts
31func mc_puts(s: *u8) -> i64 { sys_write(1, s, mc_slen(s)); return 0 }
called by 1: main calls 1: mc_slen
32func mc_streq(a: *u8, b: *u8) -> i64
called by 1: main
39func mc_atou(s: *u8) -> i64
called by 1: main
52func mc_put64(x: *i64, v: i64) -> i64
called by 1: main calls 1: bi_zero
58func mc_hexdigit(v: i64) -> i64
called by 1: main
63func main(argc: i64, argv: *i64) -> i64