code wiki / _hdl_build / nx_pow_challenge.nx

nx_pow_challenge.nx

buildroot/runtime/_hdl_build/nx_pow_challenge.nx

2864 B73 linesdepth 5pulls 5 transitivereach 1 importersview sourcekind librarytopic pow
docsdependenciesstructsconstsfunctions

about

nx_pow_challenge.nx -- proof-of-work client puzzle for the access wall's L7 DDoS shedding (hashcash; Cloudflare "under attack"). Under high load/anomaly the server issues a fresh CHALLENGE + a difficulty D; the client must find a SOLUTION such that sha256(challenge || solution) has >= D leading zero bits. The server VERIFIES in O(1) (one sha256) but the client pays O(2^D) expected work -- the asymmetry that makes a flood expensive for the attacker and a one-time cost for a legit client. Reuses the KAT-verified nx_sha256 (no rolled crypto). license_tier: ORIGINAL

dependencies 2 imports · 1 importers

nx_sha256.nx nx_syscalls.nx nx_pow_challenge.nx nx_pow_challenge_gate.nx

imports: nx_sha256.nxnx_syscalls.nx

imported by: nx_pow_challenge_gate.nx

structs

none

consts

none

functions

11func pow_lzb(h: *u8) -> i64
called by 2: pow_verifymain
38func pow_u2s(v: i64, out: *u8) -> i64
called by 1: pow_solve calls 1: sys_mmap
50func pow_verify(challenge: *u8, clen: i64, solution: *u8, slen: i64, difficulty: i64) -> i64
65func pow_solve(challenge: *u8, clen: i64, difficulty: i64, sol_out: *u8, max_tries: i64) -> i64
called by 1: main calls 2: pow_u2spow_verify