code wiki / (root) / _ed25519_ct_gate.nx

_ed25519_ct_gate.nx

buildroot/runtime/_ed25519_ct_gate.nx

3881 B80 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic ed25519
docsdependenciesstructsconstsfunctions

about

_ed25519_ct_gate.nx -- constant-time gate for SEC-CT-002 (ed25519-scalarmul-constant-time). The FIXED ge_scalar_mul has NO secret-bit branch: each of the 256 bit-iterations runs ge_p3_add UNCONDITIONALLY and masked-selects with ge_p3_cmov. So the number of point additions executed is a CONSTANT 256, independent of the scalar's Hamming weight -- whereas the prior `if bit==1 {ge_p3_add}` ran the add popcount(scalar) times (the variable-time / SPA leak). This gate models BOTH control-flow structures over the EXACT MSB-first 32-byte bit walk ge_scalar_mul uses, on scalars of very different Hamming weight, and asserts: NEW add-count is CONSTANT (256, scalar-independent); OLD add-count VARIES (the NEG control -- proves the gate distinguishes constant-time from variable-time, and that the leak it removes was real). FUNCTIONAL correctness + byte-identity are proven separately and unfakeably by nx_ed25519_signature_test (RFC8032 vectors) + nx_ed25519_scalar_test. Sovereign native: exit 0 = GREEN.

dependencies 1 imports · 0 importers

nx_syscalls.nx _ed25519_ct_gate.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap fill32 ct_addcount_new ct_addcount_old gw sys_write sys_openat_append sys_close

structs

none

consts

14const ECG_LOG: *u8 = "knowledge/status/speed_gate.log"

functions

16func gw(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
called by 1: main calls 1: sys_write
20func ct_addcount_new(scalar_32: *u8) -> i64
called by 1: main
36func ct_addcount_old(scalar_32: *u8) -> i64
called by 1: main
52func fill32(s: *u8, val: i64) -> i64 { var i: i64 = 0; while i < 32 { s[i] = val as u8; i = i + 1 } return 0 }
called by 1: main
54func main() -> i64