Skip to content

Commit fb2d902

Browse files
gamarin2jackzampolin
authored andcommitted
Merge PR #3649: improve ledger docs
1 parent d66db6a commit fb2d902

File tree

2 files changed

+71
-20
lines changed

2 files changed

+71
-20
lines changed

docs/gaia/delegator-guide-cli.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ Then, to create an account, use the following command:
178178
gaiacli keys add <yourAccountName> --ledger
179179
```
180180

181+
::: warning
182+
**This command will only work while the Ledger is plugged in and unlocked**
183+
:::
184+
181185
- `<yourKeyName>` is the name of the account. It is a reference to the account number used to derive the key pair from the mnemonic. You will use this name to identify your account when you want to send a transaction.
182186
- You can add the optional `--account` flag to specify the path (`0`, `1`, `2`, ...) you want to use to generate your account. By default, account `0` is generated.
183187

@@ -380,8 +384,8 @@ gaiacli tx distr withdraw-all-rewards --from <delegatorKeyName> --gas auto --gas
380384
gaiacli tx staking unbond <validatorAddress> <amountToUnbond> --from <delegatorKeyName> --gas auto --gas-prices <gasPrice>
381385
```
382386
383-
::: tip
384-
If you use a connected Ledger, you will be asked to confirm the transaction on the device before it is signed and broadcast to the network
387+
::: warning
388+
**If you use a connected Ledger, you will be asked to confirm the transaction on the device before it is signed and broadcast to the network. Note that the command will only work while the Ledger is plugged in and unlocked.**
385389
:::
386390
387391
To confirm that your transaction went through, you can use the following queries:

docs/gaia/ledger.md

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,76 @@
11
# Ledger Nano Support
22

3-
### Ledger Support for account keys
3+
## A note on HD wallet
44

5-
`gaiacli` now supports derivation of account keys from a Ledger seed. To use this functionality you will need the following:
5+
HD Wallets, originally specified in Bitcoin's [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki), are a special kind of wallet that let users derive any number of accounts from a single seed. To understand what that means, let us first define some terminology:
66

7-
- A running `gaiad` instance connected to the network you wish to use.
8-
- A `gaiacli` instance configured to connect to your chosen `gaiad` instance.
9-
- A LedgerNano with the `ledger-cosmos` app installed
10-
* Install the Cosmos app onto your Ledger by following the instructions in the [`ledger-cosmos`](https://github.com/cosmos/ledger-cosmos/blob/master/docs/BUILD.md) repository.
11-
* A production-ready version of this app will soon be included in the [Ledger Apps Store](https://www.ledgerwallet.com/apps)
7+
- **Wallet**: Set of accounts obtained from a given seed.
8+
- **Account**: A pair of public key/private key.
9+
- **Private Key**: A private key is a secret piece of information used to sign messages. In the blockchain context, a private key identifies the owner of an account. The private key of a user should never be revealed to others.
10+
- **Public Key**: A public key is a piece of information obtained by applying a one-way mathematical function on a private key. From it, an address can be derived. A private key cannot be found from a public key.
11+
- **Address**: An address is a public string with a human-readable prefix that identifies an account. It is obtained by applying mathematical transformations to a public key.
12+
- **Digital Signature**: A digital signature is a piece of cryptographic information that proves the owner of a given private key approved of a given message without revealing the private key.
13+
- **Seed**: Same as Mnemonic.
14+
- **Mnemonic**: A mnemonic is a sequence of words that is used as seed to derive private keys. The mnemonic is at the core of each wallet. NEVER LOSE YOUR MNEMONIC. WRITE IT DOWN ON A PIECE OF PAPER AND STORE IT SOMEWHERE SAFE. IF YOU LOSE IT, THERE IS NO WAY TO RETRIEVE IT. IF SOMEONE GAINS ACCESS TO IT, THEY GAIN ACCESS TO ALL THE ASSOCIATED ACCOUNTS.
1215

13-
> **NOTE:** Cosmos keys are derived acording to the [BIP 44 Hierarchical Deterministic wallet spec](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki). For more information on Cosmos derivation paths [see the hd package](https://github.com/cosmos/cosmos-sdk/blob/develop/crypto/keys/hd/hdpath.go#L30).
16+
At the core of a HD wallet, there is a seed. From this seed, users can deterministically generate accounts. To generate an account from a seed, one-way mathematical transformations are applied. To decide which account to generate, the user specifies a `path`, generally an `integer` (`0`, `1`, `2`, ...).
1417

15-
Once you have the Cosmos app installed on your Ledger, and the Ledger is accessible from the machine you are using `gaiacli` from you can create a new account key using the Ledger:
18+
By specifying `path` to be `0` for example, the Wallet will generate `Private Key 0` from the seed. Then, `Public Key 0` can be generated from `Private Key 0`. Finally, `Address 0` can be generated from `Public Key 0`. All these steps are one way only, meaning the `Public Key` cannot be found from the `Address`, the `Private Key` cannot be found from the `Public Key`, ...
1619

17-
```bash
18-
$ gaiacli keys add { .Key.Name } --ledger
19-
NAME: TYPE: ADDRESS: PUBKEY:
20-
{ .Key.Name } ledger cosmos1aw64xxr80lwqqdk8u2xhlrkxqaxamkr3e2g943 cosmospub1addwnpepqvhs678gh9aqrjc2tg2vezw86csnvgzqq530ujkunt5tkuc7lhjkz5mj629
2120
```
21+
Account 0 Account 1 Account 2
2222
23-
This key will only be accessible while the Ledger is plugged in and unlocked. To send some coins with this key, run the following:
24-
25-
```bash
26-
$ gaiacli tx send { .Destination.AccAddr } 10stake --from { .Key.Name } --chain-id=gaia-7000
23+
+------------------+ +------------------+ +------------------+
24+
| | | | | |
25+
| Address 0 | | Address 1 | | Address 2 |
26+
| ^ | | ^ | | ^ |
27+
| | | | | | | | |
28+
| | | | | | | | |
29+
| | | | | | | | |
30+
| + | | + | | + |
31+
| Public key 0 | | Public key 1 | | Public key 2 |
32+
| ^ | | ^ | | ^ |
33+
| | | | | | | | |
34+
| | | | | | | | |
35+
| | | | | | | | |
36+
| + | | + | | + |
37+
| Private key 0 | | Private key 1 | | Private key 2 |
38+
| ^ | | ^ | | ^ |
39+
+------------------+ +------------------+ +------------------+
40+
| | |
41+
| | |
42+
| | |
43+
+--------------------------------------------------------------------+
44+
|
45+
|
46+
+---------+---------+
47+
| |
48+
| Mnemonic (Seed) |
49+
| |
50+
+-------------------+
2751
```
2852

29-
You will be asked to review and confirm the transaction on the Ledger. Once you do this you should see the result in the console! Now you can use your Ledger to manage your Atoms and Stake!
53+
The process of derivating accounts from the seed is deterministic. This means that given the same path, the derived private key will always be the same.
54+
55+
The funds stored in an account are controlled by the private key. This private key is generated using a one-way function from the mnemonic. If you lose the private key, you can retrieve it using the mnemonic. However, if you lose the mnemonic, you will lose access to all the derived private keys. Likewise, if someone gains access to your mnemonic, they gain access to all the associated accounts.
56+
57+
## Ledger Support for account keys
58+
59+
At the core of a Ledger device, there is a mnemonic that is used to generate private keys. When you initialize you Ledger, a mnemonic is generated.
60+
61+
::: danger
62+
**Do not lose or share your 12 words with anyone. To prevent theft or loss of funds, it is best to ensure that you keep multiple copies of your mnemonic, and store it in a safe, secure place and that only you know how to access. If someone is able to gain access to your mnemonic, they will be able to gain access to your private keys and control the accounts associated with them.**
63+
:::
64+
65+
This mnemonic is compatible with Cosmos accounts. The tool used to generate addresses and transactions on the Cosmos Hub network is called `gaiacli`, which supports derivation of account keys from a Ledger seed. Note that the Ledger device acts as an enclave of the seed and private keys, and the process of signing transaction takes place within it. No private information ever leaves the Ledger device.
66+
67+
To use `gaiacli` with a Ledger device you will need the following:
68+
69+
- [A Ledger Nano with the `COSMOS` app installed and an account](./delegator-guide-cli.md#using-a-ledger-device)
70+
- [A running `gaiad` instance connected to the network you wish to use.](./delegator-guide-cli.md#accessing-the-cosmos-hub-network)
71+
- [A `gaiacli` instance configured to connect to your chosen `gaiad` instance.](./delegator-guide-cli.md#setting-up-gaiacli)
72+
73+
Now, you are all set to start [sending transactions on the network](./delegator-guide-cli.md#sending-transactions).
74+
75+
76+

0 commit comments

Comments
 (0)