Skip to content

security(pqc): standards-alignment metadata registry + conformance/NatSpec wording fixes - #135

Merged
sirmrdrgod merged 2 commits into
mainfrom
security/pqc-standards-alignment-hardening
Jul 17, 2026
Merged

security(pqc): standards-alignment metadata registry + conformance/NatSpec wording fixes#135
sirmrdrgod merged 2 commits into
mainfrom
security/pqc-standards-alignment-hardening

Conversation

@sirmrdrgod

Copy link
Copy Markdown
Contributor

Summary

Implements findings H1, H2, M2, L6, L7 from docs/security/pqc-standards-alignment-audit.md (private-repo audit, not yet merged upstream). Does not implement M3/PR-G (the off-chain crypto-agility redesign) — explicitly out of scope for this change.

  • New: src/standards/pq-algorithm-registry.ts — canonical, purely descriptive PQ algorithm registry. Models ML-DSA-65 as implemented / not-validated / prototype with its real implementation package+version (@noble/post-quantum@0.6.1), and ML-KEM (FIPS 203) / SLH-DSA (FIPS 205) as explicitly not-implemented — no cryptographic code added for either. Also exposes a derived standards-alignment status helper (no percentage/score, by design).
  • Evidence schema extension (M2, L7): src/verifier/evidence.ts + docs/schemas/pq-verifier-evidence.v1.schema.json gain an optional standards snapshot (certificationStatus, structured implementation, conformanceStatus, productionStatus). buildEvidence() auto-populates it from the registry; validateEvidence() rejects malformed values but treats absence as valid (backward-compatible with pre-existing evidence). The same block is added to evidence/ml-dsa/manifest.json + its schema, required there since the manifest is a single generated file, not a widely-forked artifact type.
  • L6: the fips const's schema description now explicitly states it's an algorithm identifier, not a validation flag — standards.certificationStatus is the authoritative validation-status field.
  • H1: ZKMLDSAVerifier.sol NatSpec softened from present-tense "Trustless verification... Replaces the trusted-attestation model" to intent language, plus an explicit PROTOTYPE — not deployed, unaudited disclaimer noting the unproven SP1-vkey↔ML-DSA binding.
  • H2: the "15/15 ACVP test cases" overclaim in README.md and the NIST CAVP fixture README corrected to the actual committed/exercised surface (6 of 15 group-3 vectors); MLDSAConformance.test.ts's describe() renamed from "full ACVP test group 3" to "committed group-3 subset".

None of this touches the verifier's algorithm-selection/dispatch logic (PQ_VERIFIER_ALGORITHM/PQ_VERIFIER_FIPS string-literal typing, isValidReason), scoring, Dune, provider-spend, or verifier governance/timelocks.

Test plan

  • npm run compile — 18 Solidity files compile clean
  • npm run typecheck (tsc --noEmit) — clean
  • npm test (hardhat/mocha) — 834 passing, 11 pending (gated SP1/RUN_SP1_E2E, pre-existing), 0 failing
  • npm run format:check (prettier) — clean
  • npm run lint (solhint) — 0 errors (79 pre-existing warnings in files this PR doesn't touch)
  • npm run security:audit (npm audit --omit=dev) — 0 vulnerabilities
  • git diff --check — clean
  • Regenerated docs/schemas/examples/*.json and evidence/ml-dsa/manifest.json via their existing generator scripts (npm run evidence:fixtures, npm run evidence:manifest) — no drift between generator and committed artifacts
  • Grepped the diff for NIST certified|FIPS certified|FIPS compliant|FIPS validated|CMVP validated — no matches
  • New tests: test/PQAlgorithmRegistry.test.ts (registry invariants, ML-KEM/SLH-DSA non-implementation) + extensions to PQEvidence.test.ts/MLDSAEvidenceManifest.test.ts (standards field accept/reject/backward-compat/malformed-rejection, schema-sync checks)

Draft — not to be merged without review.

🤖 Generated with Claude Code

…tSpec wording fixes

Implements findings H1, H2, M2, L6, L7 from docs/security/pqc-standards-alignment-audit.md.

- Add a canonical PQ algorithm registry (src/standards/pq-algorithm-registry.ts)
  modeling ML-DSA-65 as implemented/not-validated/prototype, and ML-KEM/SLH-DSA
  as explicitly not-implemented, plus a derived standards-alignment status
  helper. Purely descriptive metadata; does not touch verifier selection or
  dispatch (src/verifier/schema.ts, evidence.ts's algorithm/fips typing and
  isValidReason remain untouched — out of scope per M3/PR-G).
- Extend the evidence envelope (src/verifier/evidence.ts) and its JSON Schema
  with an optional `standards` snapshot (fipsValidated-equivalent
  certificationStatus, structured implementation{provider,package,version},
  conformanceStatus, productionStatus). buildEvidence() auto-populates it;
  validateEvidence() rejects malformed values while treating absence as
  backward-compatible legacy evidence, never a positive claim (M2, L7).
- Same `standards` block added to the ML-DSA evidence manifest
  (evidence/ml-dsa/manifest.json + its schema + scripts/lib/ml-dsa-evidence-manifest.ts),
  required there since the manifest is a single generated file.
- Clarify the `fips` const field's JSON Schema description as an algorithm
  identifier, not a validation flag (L6).
- Soften ZKMLDSAVerifier.sol's NatSpec from present-tense "Trustless
  verification... Replaces the trusted-attestation model" to intent language
  plus an explicit PROTOTYPE/not-deployed/unaudited/unproven-vkey-binding
  disclaimer (H1).
- Correct the "15/15 ACVP test cases" overclaim in README.md and the NIST
  CAVP fixture README to the actual committed/exercised surface (6 of 15
  group-3 vectors); rename the conformance test's describe() block from
  "full ACVP test group 3" to "committed group-3 subset" (H2).
- Add PQAlgorithmRegistry.test.ts and extend PQEvidence/MLDSAEvidenceManifest
  tests: registry invariants (nothing validated today, ML-KEM/SLH-DSA carry
  no implementation details), standards field accept/reject/backward-compat,
  malformed-metadata rejection, schema-sync checks.

Regenerated docs/schemas/examples/*.json and evidence/ml-dsa/manifest.json via
their existing generator scripts (npm run evidence:fixtures / evidence:manifest)
so committed artifacts match the code with no drift.

Does not implement M3/PR-G (off-chain crypto-agility redesign) or M1 (embedded
research copy reconciliation, private-repo side) — out of scope for this PR.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sirmrdrgod
sirmrdrgod marked this pull request as ready for review July 17, 2026 00:27
@sirmrdrgod
sirmrdrgod marked this pull request as draft July 17, 2026 00:28
@sirmrdrgod
sirmrdrgod marked this pull request as ready for review July 17, 2026 00:29
…idateStandardsMetadata

Addresses SonarCloud findings on the twin implementation in the private app
(src/lib/pqVerifierEvidence.js): the enum-membership checks in
validateStandardsMetadata are now data-driven via STANDARDS_ENUM_CHECKS
instead of six sequential if-statements, and the implementation-shape check
is extracted into validateStandardsImplementation(). Object.keys(...).sort()
now takes an explicit localeCompare comparator.

Pure refactor — same error messages, same validation behavior. 834 vault
tests passing, tsc --noEmit clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sirmrdrgod
sirmrdrgod marked this pull request as draft July 17, 2026 00:42
@sirmrdrgod
sirmrdrgod marked this pull request as ready for review July 17, 2026 00:42
@sirmrdrgod
sirmrdrgod merged commit 6fcb0f4 into main Jul 17, 2026
5 checks passed
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.

1 participant