Skip to content

test: hinted P-384 adversarial soundness tests (supersedes #31)#33

Merged
leopoldjoy merged 1 commit into
base:mainfrom
leanthebean:hinted-p384-review-tests
Jun 17, 2026
Merged

test: hinted P-384 adversarial soundness tests (supersedes #31)#33
leopoldjoy merged 1 commit into
base:mainfrom
leanthebean:hinted-p384-review-tests

Conversation

@leanthebean

@leanthebean leanthebean commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Supersedes #31, rebased onto current main and scoped down to tests only.

Since #31 was opened, its other contents landed or moved elsewhere:

What remains is the genuinely additive part of the security review: adversarial soundness tests for the hinted P-384 change.

Tests added

test/hinted/HintedNitroAttestation.t.sol (via a small U384TestWrapper):

  • test_UnreducedInverseHintIsSound — a non-canonical inverse hint (inv + p) passes the on-chain b·inv ≡ 1 (mod p) check and yields the identical reduced result, so it can't change the accept decision.
  • test_ModulusConfusionHintReverts — a hint valid mod n is rejected where mod p is expected.
  • test_CorruptedSignatureNeverAccepts — no attacker hint stream (empty / garbage / original-valid / padded) makes a corrupted signature verify.
  • test_MalleableTwinSignatureAccepted(r, n-s) also verifies (intentional, CURVE_LOW_S_MAX = n-1) and decodes to the identical attestation, so signature bytes must not be used as a uniqueness key.
  • test_AttestationReplayHasNoOnChainProtection — the same (tbs, sig) verifies repeatedly; freshness/replay is the integrator's responsibility.

test/CertManager.t.sol:

  • test_CacheGriefingSameKeyCaRenewalBricksCachedLeaf — skipped spec documenting the verifiedParent first-writer-wins liveness edge (needs a same-key-renewed AWS CA fixture to realise).

Testing

  • forge test108 passed, 1 skipped, 0 failed.
  • forge fmt --check src test — clean.

No src logic changes; tests only.

🤖 Generated with Claude Code

Comment thread test/hinted/HintedNitroAttestation.t.sol
Focused tests from the security review of the hinted P-384 change (tests only).
Revocation landed in base#29 and the forward-compatibility implementation + docs in
base#32, so this carries only the adversarial soundness tests that part of the review
surfaced.

test/hinted/HintedNitroAttestation.t.sol (via a small U384TestWrapper):
- test_UnreducedInverseHintIsSound — a non-canonical inverse hint (inv + p)
  passes the on-chain b*inv == 1 check and yields the identical reduced result,
  so it cannot change the accept decision.
- test_ModulusConfusionHintReverts — a hint valid mod n is rejected where mod p
  is expected.
- test_CorruptedSignatureNeverAccepts — no hint stream makes a corrupted signature
  verify: non-self-consistent hints (empty/garbage/original/padded) revert at the
  inverse-hint gate, and self-consistent hints collected for the corrupted sig pass
  the gate but fail the final ECDSA curve check (returns false).
- test_MalleableTwinSignatureAccepted — (r, n-s) also verifies (intentional,
  CURVE_LOW_S_MAX = n-1) and decodes to the identical attestation.
- test_AttestationReplayHasNoOnChainProtection — the same (tbs, sig) verifies
  repeatedly; freshness/replay is the integrator's responsibility.

test/CertManager.t.sol:
- test_CacheGriefingSameKeyCaRenewalBricksCachedLeaf — skipped spec documenting
  the verifiedParent first-writer-wins liveness edge.

Adds P384HintCollector.collectVerifyHintsAllowInvalid so a self-consistent hint
stream can be collected for a signature that fails the final check.

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@leanthebean leanthebean force-pushed the hinted-p384-review-tests branch from 3eaf1b6 to b9b3372 Compare June 17, 2026 15:59
@leopoldjoy leopoldjoy merged commit 331bb42 into base:main Jun 17, 2026
3 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.

2 participants