-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [ecdsa] pull message hashing out of `impl` procs Done so that future public key recovery can simply call `verifyImpl` to verify public key is found (signImpl changed to match). * [ecdsa] implement public key recovery * [tests] add test case to recover public key from sig&msgHash * [ecdsa] allow customizing the hash function to be used ECDSA over secp256k1 commonly uses both SHA256 (e.g. Bitcoin) and Keccak256 (e.g. Ethereum). Other combinations may also exist. We default to SHA256 for the time being. * [ecdsa] add `recoverPubkey` which directly takes a hash digest as scalar ECRecover provides the message hash and not the message. We need an API to pass that directly to the internal ECDSA procedure. We export the impl `vartime` routine for that purpose. We could alternatively also import that file using `{.all.}`. * [precompiles] add ECRecover Ethereum precompile We extend the CttEVMStatus enum by two further elements. One for an invalid signature in ECRecover and another for an invalid `v` value. * [tests] add test case for ECRecover * Update constantine/signatures/ecdsa.nim Co-authored-by: Mamy Ratsimbazafy <[email protected]> * Update constantine/signatures/ecdsa.nim Co-authored-by: Mamy Ratsimbazafy <[email protected]> * Update constantine/signatures/ecdsa.nim Co-authored-by: Mamy Ratsimbazafy <[email protected]> * [precompiles] remove invalid V enum field, invalid -> malformed sig * [ecdsa] rename ECDSA over secp256k1 file to eth specific * [ecdsa] remove hash from Eth ECDSA file, specific to Eth now * [tests] update the OpenSSL wrapper signing function to use Keccak256 * [ecdsa] name `recoverPubkey` -> `recoverPubkeyFromDigest` for variant Given that we generate a C API from the code, we need to differentiate the function names for the types. The default takes a message and this variant takes a digest (as used in Ethereum's precompile for ECRecover). * take out ECDSA test requiring OpenSSL v3.3 or higher --------- Co-authored-by: Mamy Ratsimbazafy <[email protected]>
- Loading branch information
Showing
8 changed files
with
280 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.