northroot-proof-engine 0.3.2

Core proof computation and validation library for PoSH (Proof of Shape) and PoX (Proof of Execution)
Documentation
Proof-of-Execution (PoX) — v0.2 Mini Spec

Purpose (What + When; bound to How): Prove a specific run occurred on specific bytes at specific times, linked to PoSH method shape.

Out of scope: pricing, invoices, semantic quality (handled by Po$ and PoΣ).

1) Objects

1.1 Trace (run context)

{
  "schema_version": "trace.v2",
  "trace_id": "tr_01H...",
  "method_ref": {
    "method_id": "com.acme/normalize-ledger",
    "version": "1.0.0",
    "method_shape_root": "sha256:...",
    "image_digest": "sha256:oci-image-...",
    "method_fingerprint": "git:deadbeef"
  },
  "data_shape_hash": "sha256:dsAAA...",
  "policy_id": "pol:standard-v1",
  "identity_route": "did:key:zTenant",
  "content_route": "s3://tenant/proj-42",
  "execution_route": { "provider":"aws","account":"123...","region":"us-east-1","runtime_digest":"sha256:..." } // optional
}

1.2 Span Commitment (atomic unit; hashed)

{
  "schema_version": "proof.v2",
  "trace_id": "tr_01H...",
  "span_id": "sp-0001",
  "method_ref": { "...": "..." },
  "data_shape_hash": "sha256:dsAAA...",
  "span_shape_hash": "sha256:ss-READCSV@1...",
  "inputs":  [ { "name":"csv",   "content_hash":"sha256:i1...", "uri":"s3://.../in.csv?sig=..." } ],
  "outputs": [ { "name":"frame", "content_hash":"sha256:o1..." } ],
  "start_time": "2025-11-06T12:00:00.000Z",
  "end_time":   "2025-11-06T12:00:00.042Z",
  "status": "OK",
  "meta": { "lamport":17, "parents":["sp-0000"] } // optional causality hints
}

	•	Hash: span_commitment_hash = sha256(JCS(span_commitment))

Signature Envelope (transport):

{ "commitment": { ... }, "signature": { "alg":"ed25519","kid":"did:key:zExec","sig":"..." } }

1.3 Trace Roots (computed at end)

{
  "trace_id": "tr_01H...",
  "roots": {
    "span_commitments": ["sha256:...","sha256:..."],
    "trace_set_root": "sha256:...",           // H(sorted(C_span_i,"|"))
    "identity_root": "sha256:...",            // H({trace_id, identity_route, sorted(C_span_i)})
    "trace_seq_root": "sha256:..."            // optional (order claim)
  },
  "method_shape_root": "sha256:...",          // carried from PoSH
  "tier01_status": "pass",
  "server_sig": { "alg":"ed25519","kid":"did:key:zNorthroot","sig":"..." }
}

2) Canonicalization & Hashing
	•	Canonicalization: JCS or sorted-key JSON; normalize timestamps to RFC3339 UTC ms.
	•	Hashed object: the Span Commitment only.
	•	Trace roots:
	•	trace_set_root = sha256(join_sorted(C_span_i,"|"))
	•	identity_root = sha256(JCS({trace_id, identity_route, sorted(C_span_i)}))
	•	trace_seq_root = sha256(join_in_order(C_span_i,"|")) (optional)

3) API (PoX)
	•	POST /trace/begin → { trace_id }
requires: method_ref, data_shape_hash, policy_id, identity_route, content_route (and optional execution_route)
	•	POST /proofs (batch SignedSpan) — idempotent on (trace_id, span_id)
	•	POST /trace/{trace_id}/end → { TraceRoots, server_sig }
	•	GET /traces/{trace_id} → trace + roots (optionally ?expand=spans)

4) Verification (inline)
	•	Tier-0: schema, timestamp normalization, hash formats.
	•	Tier-1: ed25519 signature (executor), method_ref pins match PoSH manifest, policy constraints met.
	•	Tier-2 (async/sampled): replays/checkers (belongs to PoΣ, triggered separately).

5) Validation Rules
	•	data_shape_hash required at trace level.
	•	Every span must include span_shape_hash, input/output content_hash(es).
	•	Spans from the same (trace_id, span_id) are idempotent (first-write wins).
	•	end_time >= start_time; monotonic lamport if provided.
	•	method_shape_root from trace must match registered manifest.

6) Acceptance (PoX)
	•	Re-running the same method pins over identical input bytes → identical span commitments and roots.
	•	Changing any input chunk changes only the affected span commitments and the resulting roots.
	•	Removing Po$ or PoΣ receipts does not change PoX hashes.
	•	Identity binding: changing identity_route alters identity_root (not trace_set_root).

⸻

Notes on Optional Layers (context, not part of these hashes)
	•	Po$ Spend: separate SpendReceipt referencing {trace_id, span_ids?} for tokens/vCPU/GB/prices; used in reconciliation.
	•	PoΣ Semantics: separate CheckerReceipt referencing {trace_id, span_ids?}, pass/fail + metrics; used for SLAs/quality.
	•	Identity proofs (PoI): executor signatures already present; long-lived CA/role chains can be added as a linked IdentityReceipt.
	•	Environment/TEE (PoE): add EnvAttestationReceipt if policy requires attested runtime/region.

⸻

Test Vector Hints (both specs)
	•	Produce golden cases:
	1.	Same shapes, different param values → same span_shape_hash.
	2.	Same run twice → identical PoX span commitments & roots.
	3.	One input row changed → only affected spans/roots change.
	4.	Identity change → identity_root changes, trace_set_root stable.
	5.	Sorting/canonicalization fuzz → identical hashes across platforms.

⸻