Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

feat: convert signing to k256 #72

Merged
merged 7 commits into from
Oct 1, 2020
Merged

feat: convert signing to k256 #72

merged 7 commits into from
Oct 1, 2020

Conversation

gakonst
Copy link
Owner

@gakonst gakonst commented Sep 25, 2020

Supersedes #67 by @roynalnaruto (rebased / cherry picked on master due to lots of changes since the original PR)

@gakonst gakonst mentioned this pull request Sep 25, 2020
2 tasks
@shamatar
Copy link
Contributor

@gakonst Georgios, you should be able to fix the PR and use it now

@gakonst
Copy link
Owner Author

gakonst commented Sep 27, 2020

Signature verification works now with the new method added here RustCrypto/elliptic-curves#205. We're only missing a method to also sign a prehashed message now, to replace the SigningKey.sign call, and then we should be good

@gakonst gakonst mentioned this pull request Sep 30, 2020
Comment on lines +1 to +2
//! This is a helper module used to pass the pre-hashed message for signing to the
//! `sign_digest` methods of K256.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a bit more straightforward to use RecoverableSignPrimitive:: try_sign_recoverable_prehashed (which is impl'd on k256::Scalar) for this:

https://docs.rs/ecdsa/0.8.3/ecdsa/hazmat/trait.RecoverableSignPrimitive.html

The API to compute an ephemeral scalar with RFC6979 is public:

https://docs.rs/ecdsa/0.8.3/ecdsa/rfc6979/fn.generate_k.html

You can convert the raw message digest to a scalar using Scalar::from_bytes_reduced

@gakonst
Copy link
Owner Author

gakonst commented Oct 1, 2020

@tarcieri wasn't sure how to do it exactly, ended up going with @shamatar's solution which does the job! Thank you @shamatar @roynalnaruto @tarcieri for your help, this was great (and @tuxxy for the original k256 impl).

@gakonst gakonst merged commit c654975 into master Oct 1, 2020
@gakonst gakonst deleted the feat/k256 branch October 1, 2020 08:02
meetmangukiya pushed a commit to meetmangukiya/ethers-rs that referenced this pull request Mar 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants