Conversation
|
@claude analyze |
|
test review complete Generated by Claude Code |
|
Starting spec review now. I'll analyze the spec for completeness and ambiguity, and post my findings shortly. Generated by Claude Code |
|
Spec Analysis: ECDSA Inputs Sanitation
Status: Questions remain — 3 ambiguities to resolve before implementation. The prior Questions: 1. [Constraints]
<Secp256k1Fq as ECField>::from_u64_arr_unchecked(&malicious_limbs)The spec must address this escape hatch. Options:
Which approach does this spec intend? This is the primary blocker for achieving Invariant 7. 2. [Constraints]
Making it Similarly, How should the implementer handle these cross-crate internal uses? Options:
3. [Success Criteria] Defense-in-depth vs. redundant validation — what's the intended layering?
The spec proposes both restrictions simultaneously (internal validation + constructor restriction), which is good defense-in-depth. But the spec should clarify the intended layering:
This matters because if the trait issue (Question 1) proves too invasive to fix, the implementer needs to know whether internal validation alone is an acceptable fallback. Minor notes (non-blocking):
Generated by Claude Code |
|
Implementation plan for: ECDSA Inputs Sanitation Changes:
Note on Order: Visibility changes first → validation logic → tests → QA → spec update Generated by Claude Code |
|
Implementation complete for: ECDSA Inputs Sanitation Changes made:
Evaluation results:
Tests: All 28 tests passing (12 secp256k1 + 16 P-256) Note: Generated by Claude Code |
Move input validation into ecdsa_verify() for both secp256k1 and P-256, and restrict _unchecked constructors to pub(crate). Addresses the security footgun documented in PR #1391.
…-256 Move input validation into ecdsa_verify() itself so callers no longer need to ensure correctness of inputs. Both secp256k1 and P-256 now check: - Scalar field range (z, r, s must be < n) - Base field range (q.x, q.y must be < p) - On-curve (y² = x³ + ax + b) - Not-infinity and r,s non-zero (already existed) Restrict from_u64_arr_unchecked() to pub(crate) on Secp256k1Fq, Secp256k1Fr, and P256Field so external callers cannot bypass validation. Add negative tests for each rejection case in both crates. Update spec status to implemented. Closes #1391 https://claude.ai/code/session_01LrsxHRLvWQUDE5WFBHvDNV
f9f5c94 to
93b50c6
Compare
Summary
ecdsa_verify()for both secp256k1 and P-256_uncheckedconstructors topub(crate)visibilityecdsa_verifyfunctions forsecp256k1andP256#1391Test plan
@claude analyzeon the PR for second-opinion analysis