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
Ledger integration into KMS #172
Merged
liamsi
merged 12 commits into
tendermint:master
from
cryptiumlabs:adrian/ledger_integration
Feb 20, 2019
Merged
Changes from all commits
Commits
Show all changes
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use abscissa::Callable; | ||
|
||
/// The `ledgertm detect` subcommand | ||
#[derive(Debug, Default, Options)] | ||
pub struct DetectCommand { | ||
/// Print debugging information | ||
#[options(short = "v", long = "verbose")] | ||
pub verbose: bool, | ||
} | ||
|
||
impl Callable for DetectCommand { | ||
/// Detect all Ledger devices running the Tendermint app | ||
fn call(&self) { | ||
println!("This feature will be soon available"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why include the detect command if it does not do anything yet? |
||
} | ||
} |
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,17 @@ | ||
use abscissa::{Callable, Command}; | ||
|
||
use super::LedgertmCommand; | ||
|
||
/// The `ledgertm help` subcommand | ||
#[derive(Debug, Default, Options)] | ||
pub struct HelpCommand { | ||
#[options(free)] | ||
pub args: Vec<String>, | ||
} | ||
|
||
impl Callable for HelpCommand { | ||
/// Print help for the `ledgertm` subcommand | ||
fn call(&self) { | ||
LedgertmCommand::print_usage(self.args.as_slice()); | ||
} | ||
} |
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,32 @@ | ||
//! The KMS `ledgertm` subcommand | ||
|
||
use abscissa::Callable; | ||
|
||
mod detect; | ||
mod help; | ||
|
||
pub use self::{detect::DetectCommand, help::HelpCommand}; | ||
|
||
/// The `ledgertm` subcommand | ||
#[derive(Debug, Options)] | ||
pub enum LedgertmCommand { | ||
#[options(help = "detect connected Ledger devices running the Tendermint app")] | ||
Detect(DetectCommand), | ||
|
||
#[options(help = "show help for the 'ledgertm' subcommand")] | ||
Help(HelpCommand), | ||
} | ||
|
||
impl_command!(LedgertmCommand); | ||
|
||
impl Callable for LedgertmCommand { | ||
/// Call the given command chosen via the CLI | ||
fn call(&self) { | ||
match self { | ||
LedgertmCommand::Detect(detect) => detect.call(), | ||
LedgertmCommand::Help(help) => help.call(), | ||
} | ||
} | ||
} | ||
|
||
impl LedgertmCommand {} |
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,22 @@ | ||
//! Ledger Tendermint signer | ||
|
||
use signatory::PublicKeyed; | ||
use signatory_ledger_tm::{self, Ed25519LedgerTmAppSigner}; | ||
|
||
use crate::{ | ||
config::provider::ledgertm::LedgerTendermintConfig, | ||
error::KmsError, | ||
keyring::{ed25519::Signer, KeyRing}, | ||
}; | ||
|
||
pub const LEDGER_TM_PROVIDER_LABEL: &str = "ledgertm"; | ||
pub const LEDGER_TM_ID: &str = "ledgertm"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the ID come from the config? An ID that is always the same (and the same as the constant |
||
|
||
/// Create Ledger Tendermint signer object from the given configuration | ||
pub fn init(keyring: &mut KeyRing, _config: &[LedgerTendermintConfig]) -> Result<(), KmsError> { | ||
let provider = Box::new(Ed25519LedgerTmAppSigner::connect()?); | ||
let pk = provider.public_key()?; | ||
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
Oops, something went wrong.
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.
Why is this change necessary?
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 test harness does not work with the Ledger since I haven't implemented a ledger-mock.