-
Notifications
You must be signed in to change notification settings - Fork 23
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
Accept elementary types for Q #48
Accept elementary types for Q #48
Conversation
Hi Mikhail ! Thanks a lot for submitting this PR. However modifying the API breaks the CI. In order for it to be accepted, it would require to update FCL_ecdsa_utils.t.sol and FCL_ecdsa.t.sol accordingly. |
Hey, I will tackle this today. That's strange because I haven't touched the files, and the tests passed locally. One question - do you think it makes sense to add tests for the new functions we're proposing? We suspect they might be also slightly more gas-efficient. |
Yeah, weird cause it is overloading. By the way as overloading, it might suffice to just make a separate call in the existing test (just by adding two uint256 and use the existing callcata as input). |
For the gas cost i'm on a 140K gas version, still experimental, should push it in the next weeks. |
parameters (since it is common for those to either be read from storage or immutables). An overload is provided to maintain backwards compatibility. Co-authored-by: Nicholas Rodrigues Lordello <[email protected]> Co-authored-by: Mikhail Mikheev <mikhail@safe@global>
1b450b9
to
5d3c3f7
Compare
@rdubois-crypto the formatting is now fixed. Regarding the failed tests, it seems that
I'm unsure if this is something I need to fix or better be fixed in a separate PR. |
The private key in the failed tests matches the one here: kmackay/micro-ecc#141 Also, quoting one of the comments:
|
Wow, thanks, as wycheproof is used in the invariant test, problems must be circomvented. It should be investigated if the problem comes also on the verification part, or only signature, added to be able to make fuzzing (it compute the signature part, which of course is not meant to be onchain). Signing requires many more functions, cause we abuse the x only double multiplication (we choose v=0) and perform point decompression. |
addressOfLibrary = address(new FCL_ecdsa_wrapper{salt: 0}()); | ||
} | ||
} | ||
|
||
contract Script_Deploy_FCL_all is BaseScript { | ||
function run() external broadcast returns (address addressOfLibrary) { | ||
// deploy the library contract and return the address | ||
addressOfLibrary = address(new FCL_all_wrapper{salt:0}()); | ||
addressOfLibrary = address(new FCL_all_wrapper{salt: 0}()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for the record, those changes were required to pass the formatting verification on the CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't seem that the private key operation is at stake, i just added a test vector for multiplication on the edge case here:
#49
Running 1 test for test/FCL_ecmulmul_edge.t.sol:edgemultTest
[PASS] test_edgeMul() (gas: 189600)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 2.90ms
Trace must be further analyzed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So @nlordell and me debugged this and here are our findings. We compared all the outputs to the @noble/curves library. The inputs we used:
the real hero behind that is @nlordell, he will jump into the discussion and provide more thoughts |
Also, if you use a smaller K value, the verification passes. |
I don't think there is anything inherently wrong with verifying signatures with Take this with a grain of salt, as it is just an intuition and not really confirmed. |
Very specifically, this appears to be returning an incorrect value:
Compared to manually computing:
|
Ok, now this edge case captures it Expected X results is 93995665850302450053183256960521438033484268364047930968443817833761593125805 |
I posted an additional (and arguably smaller) test case that also shows the issue in the aforementioned PR. |
Currently, the public key is accepted as a fixed-size array in the webauthn/ecdsa functions. This is a concern for #9
When using EIP-1271, you can slice all the variables and pass them as call data, except for the public key (Q), which most likely exists as a state variable of some form in the signer contract.
A very naive POC implementation would look like:
(will be open sourced if this PR gets accepted)
Exisiting workarounds include creating a wrapper library with an external function which is inefficient.
This PR adds new functions in a backwards-compatible manner that accept Q as two elementary uint256 variables.
The original idea comes from @nlordell, many thanks to him :)