Skip to content

ecdsa: remove unnecessary check in FromStr impl#1255

Merged
tarcieri merged 1 commit intomasterfrom
ecdsa/hex_check
Mar 20, 2026
Merged

ecdsa: remove unnecessary check in FromStr impl#1255
tarcieri merged 1 commit intomasterfrom
ecdsa/hex_check

Conversation

@newpavlov
Copy link
Member

We already check that hex.len() == C::FieldBytesSize::USIZE * 4, so split_at should not panic and any invalid strings should be properly handled by parses.

@newpavlov newpavlov requested a review from tarcieri March 16, 2026 16:08
@newpavlov
Copy link
Member Author

newpavlov commented Mar 16, 2026

We could harden the hex.len() check to account for potential overflow by using hex.len() % 4 != 0 || hex.len() / 4 != C::FieldBytesSize::USIZE, but I am not sure it's worth the trouble since it only matters for impractical values of C bigger than usize::MAX / 4.

@tarcieri tarcieri merged commit b033cce into master Mar 20, 2026
9 checks passed
@tarcieri tarcieri deleted the ecdsa/hex_check branch March 20, 2026 16:39
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