-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
precompiles: Implement secp256k1 ECDSA recovery using EVMMAX #688
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #688 +/- ##
==========================================
+ Coverage 97.60% 97.73% +0.13%
==========================================
Files 95 98 +3
Lines 8645 9235 +590
==========================================
+ Hits 8438 9026 +588
- Misses 207 209 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
|
return z; | ||
} | ||
|
||
uint256 scalar_inv(const ModArith<uint256>& m, const uint256& x) noexcept |
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.
Can we add a comment (or extend the one below) to include a reference to the expmod.tmpl
file?
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.
Yes. The commit messages have all the information how to generate this code, but I will add this information here too.
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.
Added detailed instruction how this was generated.
364da97
to
b7764a4
Compare
TEST(evmmax, secp256k1_calculate_u1) | ||
{ | ||
// u1 = -zr^(-1) | ||
const auto z = 0x31d6fb860f6d12cee6e5b640646089bd5883d586e43de3dedc75695c11ac2da9_u256; |
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.
would it be possible to document the source of the hardcoded values throughout this file?
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.
I think we just dumped these intermediate value from some other implementation or used PyEC to compute this example. At this point we may just remove these tests.
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.
ok, will remove the intermediate result tests, but we still could document the values from the add
and mul
tests (which are more like end-result tests). If you don't have it handy, I can try to recreate, unless you think this is overdoing.
fe62d43
to
9c39559
Compare
Add new library `evmone_precompiles` with the intention to contain EVMMAX-based implementations of Ethereum precompiles.
0eef2f0
to
aeb740b
Compare
Add generic procedures for point arithmetic on Elliptic Curves. Co-authored-by: rodiazet <rodiazet@ethereum.org> Co-authored-by: pdobacz <5735525+pdobacz@users.noreply.github.com>
Generated by addchain (https://github.com/mmcloughlin/addchain). addchain search 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2d > secp256k1_field_inv.acc addchain gen -tmpl expmod.tmpl secp256k1_field_inv.acc > secp256k1_field_inv.cpp
Main part generated by addchain (https://github.com/mmcloughlin/addchain). addchain search 0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c > secp256k1_sqrt.acc addchain gen -tmpl expmod.tmpl secp256k1_sqrt.acc > secp256k1_sqrt.cpp
Generated by addchain (https://github.com/mmcloughlin/addchain). addchain search 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413f > secp256k1_scalar_inv.acc addchain gen -tmpl expmod.tmpl secp256k1_scalar_inv.acc > secp256k1_scalar_inv.cpp Co-authored-by: pdobacz <5735525+pdobacz@users.noreply.github.com>
Calculate y coordinate of a secp256k1 point having x coordinate and y parity. Co-authored-by: Paweł Bylica <pawel@ethereum.org>
Add implementation of procedure that converts EC Point (uncompressed public key) to Ethereum address by Keccak hash. Co-authored-by: Paweł Bylica <pawel@ethereum.org>
Implement Elliptic Curve Digital Signature Algorithm (ECDSA) Public Key Recovery algorithm for secp256k1 curve using EVMMAX primitives. This can be used to provide ecrecovery EVM precompile but also to verify signatures in Ethereum transactions. This work has been done at ETHPrague Hackathon https://devfolio.co/projects/evmmax-ecrecovery-bd49 Co-authored-by: Alex Beregszaszi <alex@rtfs.hu> Co-authored-by: Andrei Maiboroda <andrei@ethereum.org> Co-authored-by: rodiazet <rodiazet@ethereum.org> Co-authored-by: Hugo De La Cruz <jhugodc@gmail.com> Co-authored-by: pdobacz <5735525+pdobacz@users.noreply.github.com>
aeb740b
to
3903936
Compare
Use EVMMAX-based secp256k1 ecrecovery implementation for the precompile. Co-authored-by: Paweł Bylica <pawel@ethereum.org>
3903936
to
7f0d0e0
Compare
Implement Elliptic Curve Digital Signature Algorithm (ECDSA)
Public Key Recovery algorithm for secp256k1 curve
using EVMMAX primitives.
This can be used to provide ecrecovery EVM precompile
but also to verify signatures in Ethereum transactions.
This work has been done at ETHPrague Hackathon
https://devfolio.co/projects/evmmax-ecrecovery-bd49