Uh oh!
There was an error while loading. Please reload this page.
ext/gmp: add test for uses of gmp_pow with number sizes commonly used in cryptography - #16896
ext/gmp: add test for uses of gmp_pow with number sizes commonly used in cryptography#16896brainpower wants to merge 2 commits into
Conversation
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
commented
Nov 22, 2024
I don't care about the name, so if you really like the descriptive one, I'll simply rename it. |
cmb69
commented
Nov 25, 2024
@brainpower, I think we need to fix the actual issue first (very important wrt |
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
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. |
famoser
commented
Nov 27, 2024
A proposal for a test, which I would place in Can be tested by executing |
I've updated the PR to include the posted test, with the small change of splitting the long description into a And decided to keep my test, too, since it had still failed on the master I had before rebasing (c84b7ed), |
Thank you for the cleanup with the
Yes you are right, I do not actually use It would therefore make sense to also either add elliptic curve operations, or try to test the different type of executed operations in such code (... which are not already tested in my testcase). For example, another function I never use is Another thing we might tackle is testing the overload operators: While |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
famoser
commented
Nov 30, 2024
To make some progress here, I propose:
Then, I see two future PRs:
Reasoning:
|
brainpower
commented
Dec 2, 2024
Makes sense. |
famoser
commented
Dec 2, 2024
LGTM. So I guess you may now remove the draft status of the PR, so that @Girgias can take a look? |
Uh oh!
There was an error while loading. Please reload this page.
Girgias
left a comment
There was a problem hiding this comment.
I think it would be good to add a similar test for the overloaded operators.
famoser
commented
Dec 2, 2024
Would you do this now, and if so, for what operators? Or what do you think about the proposed approach here: #16896 (comment) |
Girgias
commented
Dec 2, 2024
That approach makes sense, adding more tests that cover most operators is best. |
So you would be OK with doing this in a future PR (by the reasoning of #16896 (comment)), and merge this PR in the state as it is now? |
Girgias
commented
Dec 2, 2024
Sure, does not need to all be in the same one. |
famoser
commented
Dec 2, 2024
@brainpower if you also agree, could you please unset the draft / WIP state of the PR? |
Girgias
left a comment
There was a problem hiding this comment.
One question, but otherwise LGTM
There was a problem hiding this comment.
Normal that the 3rd call in each block is commented out?
There was a problem hiding this comment.
That was some experiment by me, that was not meant to be committed. Thought I had that stashed, but seems like I hadn't.
I've removed them.
with common number sizes used there
Girgias
commented
Dec 4, 2024
So GitHub is just being crap today, it somehow merged it as 47942be but does not close the PR.... |
… in cryptography (php#16896) With common number sizes used there --------- Co-authored-by: Florian Moser <git@famoser.ch>
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.