-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use signing/recovery from fuel_crypto in fuels_signers #165
Conversation
Since there's still |
Whoops, pressed too early. Will add this impl soon :) |
77ef9c9
to
d9fb22f
Compare
Rebased on |
Weird that GH wants to merge/rebase this with |
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.
Remove lockfile and update from master
using the button if needed
@adlerjohn Removed and |
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.
Some remarks about the unsafe
, and also I'm not sure about the error handling but this might come from a misunderstanding on my end :) Otherwise looks good!
fuels-signers/src/lib.rs
Outdated
@@ -48,26 +46,26 @@ mod tests { | |||
let mut secret_seed = [0u8; 32]; | |||
rng.fill_bytes(&mut secret_seed); | |||
|
|||
let secret = | |||
SecretKey::from_slice(&secret_seed).expect("Failed to generate random secret!"); | |||
let secret = unsafe { SecretKey::from_bytes_unchecked(secret_seed) }; |
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.
This should be both commented to explain why we are doing an unsafe
block, and IMO we should figure out the proper way to make it non-unsafe. We can't really compromise memory safety (even in this trivial case) for something like signing.
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.
The proper way would be via TryFrom.
However, from the lines above, looks like you are creating a new random key. Hence, in this case, the proper way would be to call Secret::random
fuels-signers/src/util.rs
Outdated
@@ -37,14 +36,10 @@ pub mod test_helpers { | |||
|
|||
let secret_seed = rng.gen::<[u8; 32]>(); | |||
|
|||
let secret = | |||
SecretKey::from_slice(&secret_seed).expect("Failed to generate random secret!"); | |||
let secret = unsafe { SecretKey::from_bytes_unchecked(secret_seed) }; |
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.
Same remark as before
fuels-signers/src/wallet.rs
Outdated
@@ -32,8 +29,7 @@ use thiserror::Error; | |||
/// let mut secret_seed = [0u8; 32]; | |||
/// rng.fill_bytes(&mut secret_seed); | |||
/// | |||
/// let secret = | |||
/// SecretKey::from_slice(&secret_seed).expect("Failed to generate random secret!"); | |||
/// let secret = unsafe { SecretKey::from_bytes_unchecked(secret_seed) }; |
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.
see above
Merge commit, so that reviewers know what's changed. On the topic of the lockfile, you need to remove because it's not supposed to be there: #179 Updating from |
e2dbb35
to
bd63da9
Compare
Remove secp256k1 dep from fuels-signers Remove secp256k1 dep from fuels-signers
Remove unneeded Result
c546124
to
ebd17bd
Compare
Needs UTXO validation in |
@Br1ght0ne Please take a look at the changes I introduced at a5026c6. Here's a quick explanation:
Before, this is what you were doing: let id = tx.id();
let sig = Signature::sign(&self.private_key, &Message::new(&id)); Effectively hashing the transaction bytes twice. This caused the recovered public key to be wrong because the |
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.
All my questions have been nicely addressed afai can see! lgtm!
Close #65.
Things left:
impl FromStr for fuel_crypto::Signature
Signature::from_str