Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle non-prime order curves more gracefully #344

Merged
merged 4 commits into from
Aug 21, 2024
Merged

Conversation

tomato42
Copy link
Member

@tomato42 tomato42 commented Aug 6, 2024

when the order of the curve is not a prime, then point doubling can return INFINITY, this will cause some negative values not to be reduced modulo curve p; fix this

fixes #343

@tomato42 tomato42 added the bug unintended behaviour in ecdsa code label Aug 6, 2024
@tomato42 tomato42 self-assigned this Aug 6, 2024
@tomato42 tomato42 force-pushed the non-prime-order-curve branch 3 times, most recently from bb3c719 to 0f2e764 Compare August 8, 2024 22:18
@tomato42 tomato42 force-pushed the non-prime-order-curve branch 2 times, most recently from 30067c2 to bed582b Compare August 16, 2024 01:14
tomato42 and others added 3 commits August 17, 2024 00:27
when the order of the curve is not a prime, then point doubling
can return INFINITY, this will cause some negative values not
to be reduced modulo curve p; fix this
enc = b'\x06' + enc[1:]

with self.assertRaises(MalformedPointError):
b = VerifyingKey.from_string(enc, valid_encodings=("hybrid",))

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable b is not used.
Copy link

@ZoltanFridrich ZoltanFridrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't spotted any mistake. Looks OK to me.

@tomato42 tomato42 merged commit 4096fa0 into master Aug 21, 2024
68 checks passed
@tomato42 tomato42 deleted the non-prime-order-curve branch August 21, 2024 13:52
@tomato42 tomato42 added this to the v0.20.0 milestone Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unintended behaviour in ecdsa code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 Bugs on general ECC calculation
2 participants