code wiki / (root) / nx_asset_provenance.nx

nx_asset_provenance.nx

buildroot/runtime/nx_asset_provenance.nx

10560 B203 linesdepth 9pulls 15 transitivereach 15 importersview sourcekind librarytopic asset
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_canon_cid.nx nx_uxf_decode.nx nx_ed25519_signature.nx nx_asset_provenance.nx nx_asset_exceed_gate.nx nx_asset_provenance_gate.nx nx_asset_signals.nx nx_asset_signals_gate.nx nx_ingest_foundation.nx

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

134const PROV_MAGIC0: i64 = 78 // 'N'
135const PROV_MAGIC1: i64 = 88 // 'X'
136const PROV_MAGIC2: i64 = 80 // 'P'
137const PROV_MAGIC3: i64 = 67 // 'C'
138const PROV_MAGIC4: i64 = 49 // '1'
139const PROV_HDR: i64 = 9 // magic(5) + u32be assertion_len(4)
140const PROV_SIG: i64 = 64 // ed25519 signature

functions

47func ap_len(s: *u8) -> i64
53func ap_streq(a: *u8, b: *u8) -> i64
called by 2: prov_verifyprov_get
64func ap_present(v: *u8) -> i64
72func ap_addf(keys: *i64, vals: *i64, kv: *i64, key: *u8, val: *u8) -> i64
called by 1: prov_make calls 1: ap_present
82func ap_w32(p: *u8, off: i64, v: i64) -> i64
called by 1: prov_sign
89func ap_r32(p: *u8, off: i64) -> i64
called by 1: prov_verify
101func prov_class_human() -> *u8 { return "human\x00" as *u8 }
called by 2: mainmain
102func prov_class_machine() -> *u8 { return "machine\x00" as *u8 }
103func prov_class_downloaded() -> *u8 { return "downloaded\x00" as *u8 }
111func prov_make(record_cid: *u8, class: *u8, agent: *u8, tool: *u8, model: *u8,
142func prov_sign(assertion: *u8, n: i64, privkey: *u8, out_cred: *u8) -> i64
164func prov_verify(cred: *u8, clen: i64, trusted_pubkey: *u8, expect_record_cid: *u8) -> i64
196func prov_get(keys: *i64, vals: *i64, nf: i64, key: *u8) -> *u8
called by 2: prov_verifymain calls 1: ap_streq