Verify signature with compressed public key#5542
Conversation
…s parts of the signature
Codecov Report
@@ Coverage Diff @@
## master #5542 +/- ##
==========================================
+ Coverage 61.9% 61.95% +0.04%
==========================================
Files 344 344
Lines 28757 28776 +19
Branches 3267 3269 +2
==========================================
+ Hits 17802 17827 +25
+ Misses 9784 9781 -3
+ Partials 1171 1168 -3 |
| bool verify(Public const& _k, Signature const& _s, h256 const& _hash); | ||
|
|
||
| // Verify signature with compressed public key | ||
| bool verify(PublicCompressed const& _key, h512 const& _signature, h256 const& _hash); |
There was a problem hiding this comment.
Should we name the args similar to the other verify function i.e. _k/_s?
|
|
||
| BOOST_AUTO_TEST_CASE(verifyWithPublicCompressed) | ||
| { | ||
| PublicCompressed pub{ |
There was a problem hiding this comment.
Presumably you encrypted the hash into the hex value you're using as the signature value outside of the test case...can we include the encryption as part of the test?
There was a problem hiding this comment.
It's what signAndVerify test does
|
|
||
| BOOST_AUTO_TEST_CASE(signAndVerify) | ||
| { | ||
| KeyPair kp = KeyPair::create(); |
| BOOST_AUTO_TEST_CASE(signAndVerify) | ||
| { | ||
| KeyPair kp = KeyPair::create(); | ||
| auto msg = h256::random(); |
There was a problem hiding this comment.
(Nit) Can msg and sig be const?
| auto msg = h256::random(); | ||
| auto sig = sign(kp.secret(), msg); | ||
|
|
||
| auto pubCompressed = toPublicCompressed(kp.secret()); |
There was a problem hiding this comment.
(Nit) can pubCompressed be const?
halfalicious
left a comment
There was a problem hiding this comment.
Take my approval with a grain of salt since I'm not very familiar with encryption 😄 Nothing jumped out at me as obviously wrong though
We'll need to verify ENR signature having only compressed public key (33 bytes) and
[r, s]part of the signature (64 bytes)For reference go-ethereum code doing the same: https://github.com/ethereum/go-ethereum/blob/c4109d790ffd26d67feb7745d4af8a8bc5090bd9/crypto/secp256k1/ext.h#L46-L63