nx_asset_provenance.nx
buildroot/runtime/nx_asset_provenance.nx
about
nx_asset_provenance.nx -- UNIVERSAL ORGANIZATION TOOLING arc, R2.
CRYPTOGRAPHICALLY SIGNED, TAMPER-EVIDENT PROVENANCE for asset records, so we can TRULY KNOW
whether an artifact is a generated image, a downloaded video, or human-authored -- not by a
trusting a mutable metadata field, but by a signature only the platform/author key could make.
THE MODEL (cited to knowledge/registry/org_research.tsv CONFIRMED claims):
* c2pa-content-credentials: a provenance CREDENTIAL is a C2PA-style SIGNED, tamper-evident
assertion that travels with the asset -- who/what made it (incl. generative-AI).
* prov-model: the assertion is shaped as the W3C PROV graph ENTITY <- ACTIVITY <- AGENT.
The ENTITY is the asset's RECORD CID -- this BINDS the credential to that exact content
(change one byte of the asset/record -> its CID changes -> the credential no longer matches).
* provenance-class-three: the assertion states the class human|machine|downloaded, the agent,
and (machine) tool+model / (downloaded) source URL+fetch date.
THE BACKBONE NEEDS ZERO NEW CRYPTO -- this organ is pure COMPOSITION (Rule 15, DRY):
* canonical assertion bytes -> nx_canon_cid (canon_encode: key-sorted, byte-deterministic,
so the SAME assertion is the SAME bytes everywhere -> the
signer and verifier agree on exactly what was signed)
* ed25519 sign / verify -> nx_ed25519_signature (ed25519_sign_full / ed25519_verify_full /
ed25519_pub_from_priv) -- the SAME RFC-8032, KAT-verified
ed25519 that nx_device_cert and nx_fw_capsule use. NO rolled
crypto: forgery (wrong-key signing) is what plain hashing
CANNOT catch, and what ed25519 verification DOES catch.
CREDENTIAL FORMAT (C2PA "claim || signature", self-framed so verify recovers the exact signed
bytes -- the same shape as nx_fw_capsule's payload||sig, here magic + len + assertion + sig):
magic "NXPC1" (5) | u32be assertion_len | assertion bytes (canon_encode'd) | ed25519 sig (64)
The signature covers magic || len || assertion (everything before the sig), so flipping ANY byte
of the framing or the assertion breaks verification.
VERIFY is DENY-BY-DEFAULT (Rule 12, fail-closed): a credential ALLOWs (returns 1) ONLY IF
(1) the framing is intact (magic + length within bounds), AND
(2) the ed25519 signature verifies against the TRUSTED public key over the exact assertion, AND
(3) the assertion's `entity` field == the expect_record_cid the caller demands (binding holds).
Any failure -> 0 (REJECT). Tampering the asset (different CID), tampering the assertion (sig
fails), forging the signature (wrong key fails), or re-binding a credential to a different
record (entity mismatch) are each detected.
No hardware/persistent-firmware writes (Rule 26). license_tier: ORIGINAL
dependencies 4 imports · 5 importers
imports: nx_syscalls.nxnx_canon_cid.nxnx_uxf_decode.nxnx_ed25519_signature.nx
imported by: nx_asset_exceed_gate.nxnx_asset_provenance_gate.nxnx_asset_signals.nxnx_asset_signals_gate.nxnx_ingest_foundation.nx
structs
| none |
consts
| 134 | const PROV_MAGIC0: i64 = 78 // 'N' |
| 135 | const PROV_MAGIC1: i64 = 88 // 'X' |
| 136 | const PROV_MAGIC2: i64 = 80 // 'P' |
| 137 | const PROV_MAGIC3: i64 = 67 // 'C' |
| 138 | const PROV_MAGIC4: i64 = 49 // '1' |
| 139 | const PROV_HDR: i64 = 9 // magic(5) + u32be assertion_len(4) |
| 140 | const PROV_SIG: i64 = 64 // ed25519 signature |
functions
| 47 | func ap_len(s: *u8) -> i64 |
| 53 | func ap_streq(a: *u8, b: *u8) -> i64 |
| 64 | func ap_present(v: *u8) -> i64 |
| 72 | func ap_addf(keys: *i64, vals: *i64, kv: *i64, key: *u8, val: *u8) -> i64 |
| 82 | func ap_w32(p: *u8, off: i64, v: i64) -> i64 called by 1: prov_sign |
| 89 | func ap_r32(p: *u8, off: i64) -> i64 called by 1: prov_verify |
| 101 | func prov_class_human() -> *u8 { return "human\x00" as *u8 } |
| 102 | func prov_class_machine() -> *u8 { return "machine\x00" as *u8 } |
| 103 | func prov_class_downloaded() -> *u8 { return "downloaded\x00" as *u8 } |
| 111 | func prov_make(record_cid: *u8, class: *u8, agent: *u8, tool: *u8, model: *u8, called by 6: px_provnc_forgenc_tampercredmainmainingest_foundation calls 3: sys_mmapap_addfcanon_encode |
| 142 | func prov_sign(assertion: *u8, n: i64, privkey: *u8, out_cred: *u8) -> i64 called by 6: px_provnc_forgenc_tampercredmainmainingest_foundation calls 3: ap_w32sys_mmaped25519_sign_full |
| 164 | func prov_verify(cred: *u8, clen: i64, trusted_pubkey: *u8, expect_record_cid: *u8) -> i64 |
| 196 | func prov_get(keys: *i64, vals: *i64, nf: i64, key: *u8) -> *u8 |