Skip to content
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 ed25519-consensus instead of ed25519-dalek #1046

Closed

Conversation

hdevalence
Copy link
Collaborator

Closes #355 (see that issue for more context; ed25519-consensus is a fork of
ed25519-zebra that's Zcash-independent).

This change ensures that tendermint-rs has the same signature verification as
tendermint, which uses the validation criteria provided by the Go
ed25519consensus library.

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • [ ] Added entry in .changelog/ I did not do this, because I'm not sure what release to target.

Closes informalsystems#355 (see that issue for more context; `ed25519-consensus` is a fork of
`ed25519-zebra` that's Zcash-independent).

This change ensures that `tendermint-rs` has the same signature verification as
`tendermint`, which uses the validation criteria provided by the Go
`ed25519consensus` library.
@codecov-commenter
Copy link

codecov-commenter commented Dec 8, 2021

Codecov Report

Merging #1046 (71bef2d) into master (f739e86) will decrease coverage by 0.0%.
The diff coverage is 69.1%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1046     +/-   ##
========================================
- Coverage    62.4%   62.4%   -0.1%     
========================================
  Files         236     236             
  Lines       21321   21322      +1     
========================================
- Hits        13325   13317      -8     
- Misses       7996    8005      +9     
Impacted Files Coverage Δ
p2p/src/error.rs 0.0% <ø> (ø)
p2p/src/secret_connection/amino_types.rs 0.0% <0.0%> (ø)
pbt-gen/src/time.rs 94.9% <ø> (ø)
proto/src/serializers/timestamp.rs 98.0% <ø> (ø)
tendermint/src/error.rs 0.0% <0.0%> (ø)
tendermint/src/time.rs 98.5% <ø> (ø)
tendermint/src/private_key.rs 56.8% <47.0%> (-2.1%) ⬇️
p2p/src/secret_connection/protocol.rs 59.8% <60.0%> (ø)
tendermint/src/public_key.rs 74.9% <66.6%> (+0.4%) ⬆️
p2p/src/secret_connection.rs 86.3% <78.5%> (-0.2%) ⬇️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f739e86...71bef2d. Read the comment docs.

tendermint/src/public_key.rs Outdated Show resolved Hide resolved
tendermint/src/public_key.rs Outdated Show resolved Hide resolved
Comment on lines 37 to 38
Signature
[ DisplayOnly<SignatureError> ]
| _ | { "signature error" },
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it not be worthwhile to bubble up the original error here? Unfortunately it seems like the ed25519_consensus::Error type doesn't implement std::fmt::Display unless you turn on the std feature.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The motivation for removing the original error was that the code this is replacing used an opaque error type, so there's no additional information conveyed by the original error, and was easier to just remove it rather than patch the ed25519_consensus::Error type to have an extra Display impl. But I could add that Display impl in another release.

@@ -184,8 +183,8 @@ impl Version {
#[cfg(not(feature = "amino"))]
fn encode_auth_signature_amino(
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this method's even necessary. Why would one want to convert a compile-time error to a runtime error like this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure, I tried to leave the rest of the code untouched as a drop-in change.

Comment on lines 210 to +211
Signature
[ DisplayOnly<signature::Error> ]
|_| { format_args!("signature error") },
|_| { "signature error" },
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to my other comment: should we not find a way here to bubble up the original error?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@thanethomson
Copy link
Contributor

I did not do this, because I'm not sure what release to target.

I'd say target master (i.e. v0.24.0 of tendermint-rs). If you'd like this to appear in the v0.23.x series then you'd need to submit a separate PR targeting the v0.23.x branch, or make a note of it in #1033 and I'll handle it in the next couple of days.

The changelog entry should probably be listed as a breaking change, right?

Co-authored-by: Thane Thomson <[email protected]>
Comment on lines +111 to +113
Ed25519::try_from(bytes)
.map(PublicKey::Ed25519)
.ok()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Ed25519::try_from(bytes)
.map(PublicKey::Ed25519)
.ok()
Ed25519::try_from(bytes).map(PublicKey::Ed25519).ok()

cargo fmt complaint

@@ -3,7 +3,7 @@ use std::io::Write as _;
use std::net::{TcpListener, TcpStream};
use std::thread;

use ed25519_dalek::{self as ed25519};
use ed25519_consensus;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
use ed25519_consensus;

clippy lint

@thanethomson
Copy link
Contributor

Just a changelog entry please and these (hopefully) last few lints, then we can merge.

@thanethomson
Copy link
Contributor

Updated and superseded by #1067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider ed25519-zebra crate?
3 participants