-
Notifications
You must be signed in to change notification settings - Fork 226
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
Add support for secp256k1 consensus keys #1358
Add support for secp256k1 consensus keys #1358
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1358 +/- ##
=======================================
+ Coverage 59.8% 60.4% +0.5%
=======================================
Files 274 275 +1
Lines 27254 27062 -192
=======================================
+ Hits 16314 16361 +47
+ Misses 10940 10701 -239
... and 6 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Thanks!
#[cfg(feature = "secp256k1")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "secp256k1")))] | ||
#[serde( | ||
rename = "tendermint/PrivKeySecp256k1", | ||
serialize_with = "serialize_secp256k1_privkey", | ||
deserialize_with = "deserialize_secp256k1_privkey" | ||
)] | ||
Secp256k1(Secp256k1), |
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.
Feature-guarded enum variants bring fragility. I'd rather make the whole thing non-optional, secp256k1
support does not add much in terms of dependencies. But the enum is #[non_exhaustive]
so maybe it's OK for now.
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.
since the secp256k1
is marked almost everywhere as feature I fell with the same approach. But I agree that conditional enums are not as great. Though rust is pretty good with handling conditional compilation via features.
Therefore I hold no strong opinion here
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 problem with conditional enum variants is that they make match expressions fail to compile dependent on features. #[non_exhaustive]
does a lot to make it less fragile, as you can't have a match that would be exhaustive without certain features and then fail to compile if the features are enabled. But anyone wanting to match on the conditionally-enabled variant would have to enable the corresponding feature. This, perhaps, is no worse than other conditionally defined APIs, so I'm willing to let it go.
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.
FYI, I believe the original motivation for feature-gating was at the time libsecp256k1 was being used and it didn’t work with WASM.
We’ve since moved to the pure Rust k256
crate so that isn’t an issue.
I think it would probably make more sense to feature gate all the cryptographic functionality under a single feature rather than just secp256k1, that way people who just want e.g. tendermint-rpc for an API client aren’t pulling in a bunch of crypto deps they aren’t using.
Closes: #1364
This adds the support for parsing secp256k1 consensus key from
priv_validator_key.json
.A while ago I've merged support for secp256k1 consensus key type to
tmkms
mainly for band protocol network. It came out that the functionality to import the private key from tendermint format to tmkms doesn't work due to lack of support intendermint-rs
..changelog/