nx_attest.nx
buildroot/runtime/nx_attest.nx
about
nx_attest.nx -- append-only Merkle log for cryptographic attestation
of every state-changing operation.
Per docs/SECURITY_POSTURE.md principle P11: every privileged
operation (commit, signing, key gen, deploy, capability grant,
rate-limit lockout) gets logged with a chained SHA-256 hash that
external witnesses can verify and that prevents tampering with
the historical record.
Append-only Merkle structure:
record_n = sha256(prev_hash || record_n_data)
prev_hash for record_0 is a published genesis hash
Anyone holding a later record_k can verify all earlier records
by walking back to genesis. Tampering with any historical
record breaks the chain at that point and every subsequent
hash; instantly detectable.
Use:
log = nx_attest_log_new(genesis_hash)
nx_attest_record(log, op_type, op_data, op_data_len)
nx_attest_verify(log, expected_head_hash) -> 1 / 0
The genesis hash is committed to git + signed by the K-of-N
authority keys. Forking history from genesis is detectable by
any verifier with a different genesis (i.e. external witness).
Pairs with: sha256.nx (chain hash), nx_rate_limit.nx (logs failures),
nx_caps.nx (logs capability grants/revokes), nx_pqc.nx (signs the
log head with PQ-safe keys).
dependencies 2 imports · 0 importers
imports: syscalls.nxsha256.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 62 | struct NxAttestLog |
consts
| 41 | const NX_MAGIC_1000000: i64 = 1000000 |
| 42 | const NX_MAGIC_65536: i64 = 65536 |
| 46 | const NX_ATT_OP_KEY_GEN: i64 = 1 |
| 47 | const NX_ATT_OP_SIGN: i64 = 2 |
| 48 | const NX_ATT_OP_VERIFY_PASS: i64 = 3 |
| 49 | const NX_ATT_OP_VERIFY_FAIL: i64 = 4 |
| 50 | const NX_ATT_OP_CAP_GRANT: i64 = 5 |
| 51 | const NX_ATT_OP_CAP_REVOKE: i64 = 6 |
| 52 | const NX_ATT_OP_DEPLOY: i64 = 7 |
| 53 | const NX_ATT_OP_RATE_LOCKOUT: i64 = 8 |
| 54 | const NX_ATT_OP_RATE_UNLOCK: i64 = 9 |
| 55 | const NX_ATT_OP_BOOTSTRAP: i64 = 10 |
| 56 | const NX_ATT_OP_KEY_ROTATE: i64 = 11 |
| 57 | const NX_ATT_OP_VALIDATOR_FAIL: i64 = 12 |
| 58 | const NX_ATT_OP_BUILD: i64 = 13 |
| 70 | const NX_ATT_LOG_BYTES: i64 = 40 |
| 72 | const NX_ATT_HASH_BYTES: i64 = 32 |
| 81 | const NX_ATT_REC_HEADER: i64 = 20 |
functions
| 84 | func nx_attest_log_new(genesis_hash: *u8, cap: i64) -> *NxAttestLog called by 1: main |
| 101 | func nx_attest_now_ms() -> i64 called by 1: nx_attest_record |
| 109 | func nx_attest_w_u32(dst: *u8, off: i64, v: i64) -> i64 called by 1: nx_attest_record |
| 118 | func nx_attest_w_u64(dst: *u8, off: i64, v: i64) -> i64 called by 1: nx_attest_record |
| 137 | func nx_attest_record(l: *NxAttestLog, op_type: i64, |
| 195 | func nx_attest_verify(l: *NxAttestLog, expected_head_hash: *u8) -> i64 called by 1: main |
| 205 | func nx_attest_get_head(l: *NxAttestLog, out: *u8) -> i64 called by 1: main |
| 216 | func main() -> i64 |