test: hinted P-384 adversarial soundness tests (supersedes #31)#33
Merged
Merged
Conversation
leopoldjoy
reviewed
Jun 17, 2026
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>
3eaf1b6 to
b9b3372
Compare
leopoldjoy
approved these changes
Jun 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #31, rebased onto current
mainand scoped down to tests only.Since #31 was opened, its other contents landed or moved elsewhere:
pcrs/cabundle) plus its docs are handled in feat: forward-compatible attestation parsing (skip unknown keys, indefinite-length CBOR) #32. test+docs: hinted P-384 review tests and forward-compat documentation #31's L1/L2 skipped specs, README bullet, design-doc section, and_parseAttestationNatSpec are therefore dropped here to avoid duplicating/contradicting feat: forward-compatible attestation parsing (skip unknown keys, indefinite-length CBOR) #32.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 smallU384TestWrapper):test_UnreducedInverseHintIsSound— a non-canonical inverse hint (inv + p) passes the on-chainb·inv ≡ 1 (mod p)check and yields the identical reduced result, so it can't change the accept decision.test_ModulusConfusionHintReverts— a hint valid modnis rejected where modpis 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 theverifiedParentfirst-writer-wins liveness edge (needs a same-key-renewed AWS CA fixture to realise).Testing
forge test— 108 passed, 1 skipped, 0 failed.forge fmt --check src test— clean.No
srclogic changes; tests only.🤖 Generated with Claude Code