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

ext/gmp: add test for uses of gmp_pow with number sizes commonly used in cryptography #16896

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brainpower
Copy link

In #16870 I suggested testing common operations performed by crypto implementations,
since those are one of the primary use cases of "big numbers", thus probably GMP.

During my troubleshooting the issue I found that when doing Elyptic Curve calculations,
it seems squaring and cubing Keys or Points on the Curve is a common operation.
So test squaring and cubing numbers which are of typical ECC key sizes.

I'm no crypto expert, so I don't really know much which other common crypto operations could be added,
but this should be a start.

This test succeeds on versions without the new checks introduced with #16384 ,
but currently fails on master.
It succeeds when applying the proposed fix in #16884.

@cmb69
Copy link
Member

cmb69 commented Nov 22, 2024

Thank you for the PR!

Regarding the test name: it's okay as is, but might also be called gmp_pow_crypto.phpt or so.

@brainpower
Copy link
Author

I don't care about the name, so if you really like the descriptive one, I'll simply rename it.
But if I do, the description inside the test should probably be generalized too?

@cmb69
Copy link
Member

cmb69 commented Nov 25, 2024

@brainpower, I think we need to fix the actual issue first (very important wrt gmp_pow()); then we can figure out what to do with the test.

@famoser
Copy link
Contributor

famoser commented Nov 25, 2024

Hi, thanks you two for tackling this! I can help here add some unit cases of "real" crypto if this is still useful after the newest patch (and its tests) landed.

Common operations would include additions and multiplications on the curves. Using a more applied perspective, one could add examples of signatures, committments and zero-knowledge proofs.

@cmb69
Copy link
Member

cmb69 commented Nov 26, 2024

@famoser, more test cases (especially if they are about real world usage) are certainly welcome! Not only to serve as regression tests, but also to explain/show-case some of the algorithms typically used for cryptographic purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants