This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Review, and followup on ledger integration #176
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
95ce661
Ledger integration into KMS
f38e570
Run 'cargo fmt'
75bdb0b
Exclude ledger from test harness
9caeec2
Remove incorrect comment
7f0e046
Update to latest dependencies
99b5b27
Refactoring and adjusting to new ledger-tm library
jleni f6a9c8f
Merge pull request #1 from ZondaX/zondax/ledger-tm
47289c0
Upgrading creates + fmt fixes
jleni ff43eb5
Merge pull request #2 from ZondaX/ledger_integration
jleni 76e054c
Disabling ledgertm tests until a ledgermock is available
jleni 90e37d5
Merge pull request #4 from ZondaX/ledger_integration
jleni 562109d
Add better logging to sign requests
1305ef9
make sure only one config entry for ledgertm exists and add a comment
liamsi 0de0aa3
Revert "Add better logging to sign requests"
liamsi 88c2ba9
remove boilerplate / unused code
liamsi 2dd4809
remove boilerplate / unused code
liamsi bdaa630
add TODO about key_id in ledgertm signer
liamsi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ tmkms.toml | |
|
||
# Ignore VIM swap files | ||
*.swp | ||
|
||
\.idea/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
//! Configuration for Ledger Tendermint signer | ||
|
||
/// Ledger Tendermint signer configuration | ||
#[derive(Clone, Deserialize, Debug)] | ||
pub struct LedgerTendermintConfig {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Ledger Tendermint signer | ||
|
||
use signatory::PublicKeyed; | ||
use signatory_ledger_tm::{self, Ed25519LedgerTmAppSigner}; | ||
|
||
use crate::{ | ||
config::provider::ledgertm::LedgerTendermintConfig, | ||
error::{KmsError, KmsErrorKind::*}, | ||
keyring::{ed25519::Signer, KeyRing}, | ||
}; | ||
|
||
pub const LEDGER_TM_PROVIDER_LABEL: &str = "ledgertm"; | ||
pub const LEDGER_TM_ID: &str = "ledgertm"; | ||
|
||
/// Create Ledger Tendermint signer object from the given configuration | ||
pub fn init( | ||
keyring: &mut KeyRing, | ||
ledgertm_configs: &[LedgerTendermintConfig], | ||
) -> Result<(), KmsError> { | ||
if ledgertm_configs.is_empty() { | ||
return Ok(()); | ||
} | ||
|
||
if ledgertm_configs.len() != 1 { | ||
fail!( | ||
ConfigError, | ||
"expected one [providers.ledgertm] in config, found: {}", | ||
ledgertm_configs.len() | ||
); | ||
} | ||
let provider = Box::new(Ed25519LedgerTmAppSigner::connect()?); | ||
let pk = provider.public_key()?; | ||
// TODO: key_id shouldn't be a constant here (see LEDGER_TM_ID): | ||
let signer = Signer::new(LEDGER_TM_PROVIDER_LABEL, LEDGER_TM_ID.to_string(), provider); | ||
keyring.add(pk, signer)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@jleni Will there be an equivalent to a key_id we can put into the config? e.g. for yubihsm we can have sth like
keys = [{ id = "gaia-9000", key = 1 }]
. I guess this makes sense here, too?I'll add a TODO here and merge 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.
The validator app needs to rely on Ledger's crypto API for Ed25519 so in practice there is a Bip32 derivation path. At the moment, this is not exposed in the API but it would be actually possible to have different keys to allow for something like that. Actually, it could be even possible to have both secp256k1 and ed25519 in the same device.
Should we open an issue for this new feature?
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.
Yes, please that would be awesome! Thanks :)
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.
Created issues for this:
#177
cosmos/ledger-cosmos#108