Skip to content

test(mmr): run the CLL -02 known-answer vectors; name the revision in the docs (#178) - #179

Open
drk-ram wants to merge 1 commit into
agentrust-io:mainfrom
drk-ram:feat/cll-02-mmr-vectors-178
Open

drk-ram wants to merge 1 commit into
agentrust-io:mainfrom
drk-ram:feat/cll-02-mmr-vectors-178

Conversation

@drk-ram

@drk-ram drk-ram commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What and why

Closes #178 (steps 1 and 2; the optional COSE emitter in step 3 is not part of this PR).

docs/mmr-checkpoint.md said the registry conforms to draft-mih-scitt-checkpointed-local-log without naming a revision, and nothing in CI checked the MMR layer against anyone else's answers.

Docs. The status line now names draft-mih-scitt-checkpointed-local-log-02 and the MMR profile it builds on (draft-bryce-cose-receipts-mmr-profile-03, now draft-ietf-scitt-receipts-mmr-profile). A new "Conformance to CLL -02" section says what is claimed: the MMR construction conforms; the checkpoint stays the registry's JSON form, signed over a JSON digest, and is not -02's COSE wire form. It adds the field mapping table and lists where trace_verify differs from -02.

Tests. tests/test_mmr_kat39.py now also runs the -02 vectors against trace_verify. The vectors are pinned byte-exact in tests/fixtures/cll-02/ (upstream commit 43300c3, SHA256SUMS checked by a test, .gitattributes keeps the line endings):

  • Log: nodes, and all 22 prefixes (0 to 21 entries, log_size 0 to 39): node count, peak hashes, concatenated commitment, commitment_sha256.
  • Chain: cp1 to cp4 are mapped into the registry's JSON checkpoint, re-signed with the vectors' fixture key, and run through verify_checkpoint_link and verify_checkpoint_chain. The consistency proofs trace_verify generates for 4 to 11 and 11 to 39 equal the vectors' proofs.
  • Negatives: every fail-* vector that has a counterpart in the JSON form, plus sub-per-checkpoint-is-first-seen.

Registry impact

  • This PR does not modify any existing line under registry/

Checks

  • pytest passes
  • Registry and producer files still validate (tools/validate_registry.py, tools/validate_producers.py)
  • If the anchor format or verification semantics changed, docs/anchor-format.md is updated in the same PR, and existing inclusion proofs still verify. Neither changed: no verifier code is touched.
  • Commits are signed off (DCO)

Notes for reviewers

What the negatives show. Ten fail-* vectors are refused by verify_checkpoint_chain with a named reason: a wrong or incomplete log_size, a missing, tampered, mis-sized, mis-ordered or short proof, a commitment that does not extend the previous one, a skipped registration, and a no-growth checkpoint with a changed commitment. sub-per-checkpoint-is-first-seen is refused too, as a log_id mismatch. The other four fail-* vectors do not become refusals, and the tests say so instead of hiding it:

  • fail-leaf-count-mismatch: the registry checkpoint has no leaf_count, so the vector cannot reach its verifier. The test holds it to _mmr.leaf_count(log_size), which the honest vectors satisfy and this one does not.
  • fail-proof-on-first: trace_verify does not refuse it. The registry's proof is outside the signed body and a first checkpoint's proof is never read. -02 requires refusal. I pinned today's behaviour and listed it in the docs rather than change a published verifier in this PR. If you want it refused, it is a short check in verify_checkpoint_chain, and the pinned test flips.
  • fail-commitment-cbor-array and fail-proof-legacy-map break -02 wire encodings. The registry's JSON proof is the size_a/size_b/old_peaks/witness/new_peaks shape that fail-proof-legacy-map describes, so neither has a counterpart. A test fails if a refresh adds a vector id the tests do not account for.

No-growth checkpoints. cp3 repeats cp2's size. _mmr.verify_consistency accepts the unchanged case and rejects the changed one, but verify_checkpoint_link requires mmr_size to strictly increase, so any chain containing cp3 is refused. The registry adds a leaf per checkpoint and never emits one, so this is a difference from -02, not a bug. The tests check both layers, that cp1, cp2, cp4 verify as a chain, and that the full four fail at exactly one link.

Mapping. root is the right-to-left bag of the vectors' peaks, folded independently in a test rather than through root_from_peaks. new_peaks is the peaks the consistency-paths reach followed by the right-peaks, which equals the commitment's peaks for the honest proofs. The negatives use the same mapping, so a truncated right-peaks list shortens new_peaks.

Mutation check. I mutated _mmr.py and _checkpoint.py one change at a time in a scratch copy: interior hash position, leaf prefix, peak bagging order, the old-peak path comparison, proof size check, strict growth, prev_size continuity, log_id, and the missing-proof check. Each is killed by these tests. The new_peaks count check and the root_b check each survive when removed alone, because either one refuses a truncated right-peaks list. Removing both is killed.

Validation, Python 3.11.9, Windows:

  • python -m unittest tests.test_mmr_kat39: 25 tests OK. python -m pytest tests/test_mmr_kat39.py -q: 25 passed, 54 subtests passed.
  • Coverage of the test module (coverage run --branch): 306 statements and 76 branches, one miss, the pre-existing unittest.main() guard. Everything added is covered.
  • ruff check .: all checks passed.
  • python tools/validate_registry.py and python tools/validate_producers.py: valid.
  • git diff origin/main...HEAD --check: clean.
  • python -m unittest discover -s tests (the CI command, with src on PYTHONPATH because trace_verify is not pip-installed here): 462 tests, 1 failure. test_release_safeguards.py::TestInstalledArtifactChecks::test_actual_chain_controls asserts a /-terminated path suffix and fails on Windows. Without PYTHONPATH, four more installed-package tests fail with No module named trace_verify. All five fail the same way on origin/main and none touches this change.

When the CLL maintainers ship a new revision, refresh tests/fixtures/cll-02/ and the revision named in docs/mmr-checkpoint.md together. A test fails if the docs stop naming the fixture's draft revisions.

… the docs (agentrust-io#178)

docs/mmr-checkpoint.md said the registry conforms to
draft-mih-scitt-checkpointed-local-log without a revision. It now names -02
and the SCITT MMR profile it builds on, says the checkpoint is the
registry's JSON form rather than -02's COSE form, and gives the field
mapping and the places trace_verify differs from -02.

tests/test_mmr_kat39.py runs the -02 vectors against trace_verify:

- the 21-entry log at every prefix: node count, peaks, concatenated
  commitment and its SHA-256
- the four-checkpoint chain mapped to the JSON shape, through
  verify_checkpoint_link and verify_checkpoint_chain, with the proofs
  trace_verify generates compared to the vectors'
- the negative cases: eleven are refused by the chain verifier; the
  leaf_count case is checked as MMR arithmetic because the registry
  checkpoint has no leaf_count; a proof on a first checkpoint and a
  no-growth checkpoint are pinned as differences from -02

The vectors are pinned byte-exact under tests/fixtures/cll-02/ with the
upstream commit, and .gitattributes keeps their line endings. No verifier
behaviour changes.

Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
@drk-ram
drk-ram force-pushed the feat/cll-02-mmr-vectors-178 branch from 6ce7dc3 to dafdb80 Compare November 25, 2026 16:40

@rajnisht7 rajnisht7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs look mostly good, but the new “Where trace_verify differs from -02” section is incomplete.

  • Key rotation: CLL-02 §2 lets you rotate by appending an entry signed by the old key that names the new one. We reject any key_id change in verify_checkpoint_link because the JSON format has no rotation statement. This should be listed as a difference.
  • Log identity: CLL-02 uses the CWT pair (iss, sub). We only map sub -> log_id and have no iss. Worth saying explicitly that this is a partial mapping.
  • Cadence: CLL-02 §4.4 requires a declared cadence once you start publishing. We don’t carry it. The mapping table should note that we’re claiming MMR construction compatibility, not full checkpoint-discipline conformance.
  • sub-per-checkpoint-is-first-seen: Upstream marks this expected_result: "first-seen", not FAIL. The test treats it as a refused negative. The verifier correctly rejects an identity change mid-chain, but the characterisation should be “identity-switch / continuity case”, not “upstream negative that fails”.
  • new_peaks: The mapping table says the full peak list is in consistency_proof.new_peaks. That’s only true for checkpoints that actually have a proof (first checkpoint and no-growth ones don’t).

The first-checkpoint proof acceptance and no-growth behaviour are already correctly documented and pinned, no change needed there. Tests and MMR construction coverage look good.

Would be good to add the missing differences to the conformance section (and a small note on the sub- vector) so readers don’t treat this as full CLL-02 checkpoint conformance.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLL checkpoints: name the draft revision and run the -02 MMR vectors in CI

2 participants