-
Notifications
You must be signed in to change notification settings - Fork 16
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 an intermediate tuto for baking using a Ledger device #506
Open
spalmer25
wants to merge
4
commits into
trilitech:main
Choose a base branch
from
spalmer25:palmer@functori@tuto-running-baker-with-ledger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0a30ea4
Add an intermediate tuto for baking using a Ledger device
spalmer25 dd121a9
fixup! Add an intermediate tuto for baking using a Ledger device
spalmer25 cfd18d4
fixup! add record to install the baking app
spalmer25 6d92a85
fixup! some wording
spalmer25 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
title: Bake using a Ledger device | ||
authors: Sébastien Palmer | ||
last_update: | ||
date: 10 January 2025 | ||
--- | ||
|
||
## What is a Ledger device? | ||
|
||
A Ledger device is a physical wallet provided by [Ledger](https://www.ledger.com). Its main purpose is to store the holder's private keys without ever disclosing them. | ||
|
||
Applications can be installed on your Ledger device so that you can take advantage of the many features of the blockchain without any entity having direct access to your private key. | ||
|
||
## Why using a Ledger device to bake? | ||
|
||
Baker involves, in particular, providing constant access to the baker's private key so that the baking daemon can sign consensus operations and blocks. | ||
If a malicious entity manages to get access to this private key, it will also gain access to the baker's funds. | ||
Keeping your private key on a Ledger device and only interacting with an application dedicated to baking would prevent any direct access to your private key. | ||
|
||
|
||
In this tutorial, we'll look at: | ||
- how to install the Tezos baking application on your Ledger device | ||
- how to configure your Ledger device so that the [Ledger baking application of Tezos](https://github.com/trilitech/ledger-app-tezos-baking) works properly | ||
- how to use an external signer (`octez-signer`) while running your baker for enhanced protection | ||
|
||
## Prerequisites | ||
|
||
- You need Ledger device. | ||
- Baker program needs to run constantly, so you need a computer / cloud vm which can run without interruptions. |
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,35 @@ | ||
--- | ||
title: "Install the Ledger baking application of Tezos" | ||
authors: Sébastien Palmer | ||
last_update: | ||
date: 10 January 2025 | ||
--- | ||
|
||
[`Tezos Baking`](https://github.com/trilitech/ledger-app-tezos-baking) is the application developed to bake on Tezos using your Ledger device. | ||
It allows you to sign block and consensus operations while keeping your private keys secure in the Ledger hardware. Some of its additional features are: | ||
1. HWM tracking to avoid double baking | ||
2. Restricted signing permission, i.e. it only allows signing baking related operations. You can not approve signing of funds transfer using baking app on Ledger. | ||
|
||
## Download `Ledger Live` | ||
|
||
To download the Tezos baking application, you first need to download `Ledger Live`. | ||
[`Ledger Live`](https://www.ledger.com/ledger-live) is the application provided by Ledger to allow you to download the various applications compatible with your Ledger device. | ||
|
||
## Download `Tezos Baking` | ||
|
||
Once you have downloaded `Ledger Live`, launch it. | ||
|
||
The Tezos baking application is only available when developer mode is activated. To activate it, go to settings and, in the `Experimental features` tab, activate `Developer mode`. With developer mode enabled, the Tezos baking application is now accessible. | ||
|
||
Click on `My Ledger`. If you have not already done so, connect your Ledger device to the USB port and authorize the secure connection to `Ledger Live` on your Ledger device. | ||
|
||
Search for the `Tezos Baking` application and click on `Install`. | ||
|
||
![Install the Ledger `Tezos Baking` application from `Ledger Live`](/img/tutorials/bake-with-ledger/install-ledger-tezos-baking-app.gif) | ||
|
||
## Download `Tezos Wallet (XTZ)` | ||
|
||
To be able to sign operation needed to setup your baker, you will also need the `Tezos Wallet (XTZ)` application. | ||
[`Tezos Wallet (XTZ)`](https://github.com/trilitech/ledger-app-tezos-wallet) is the application developed to sign Tezos operations using your Ledger device. | ||
|
||
Find and install the `Tezos Wallet (XTZ)` application. |
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,104 @@ | ||
--- | ||
title: "Running a baker signing using a Ledger baking key" | ||
authors: Sébastien Palmer | ||
last_update: | ||
date: 10 January 2025 | ||
--- | ||
|
||
Now that the Ledger baking key is set up, you can follow the steps of [Run a Tezos node in 5 step](/tutorials/join-dal-baker). However, some steps will differ. | ||
|
||
## Set up a baker account | ||
|
||
Complete the [Step 1: Run an Octez node](/tutorials/join-dal-baker/run-node) of the tutorial, and make following changes in [Step 2: Set up a baker account](/tutorials/join-dal-baker/prepare-account). | ||
For this step, you already have a baker! No need to regenerate it, just import it: | ||
|
||
```bash | ||
octez-client import secret key my_baker remote:tz... | ||
``` | ||
|
||
> Replace the `tz...` with the public key hash of your Ledger baking key. | ||
|
||
To be able to sign the operations you find in **Step 2**, you need to use the `Tezos Wallet (XTZ)` application. | ||
Quit the `Tezos Baking` application and open the `Tezos Wallet (XTZ)` application. | ||
|
||
## Before running the Octez baking daemon | ||
|
||
Complete [Step 3: Run an Octez DAL node](/tutorials/join-dal-baker/run-dal-node). For the [Step 4: Run an Octez baking daemon](/tutorials/join-dal-baker/run-baker), make following changes to setup `octez-signer` and `Tezos Baking` application. | ||
|
||
### Setup the Ledger high watermark (HWM) | ||
|
||
For security reason, always reset HWM to highest block value before starting to bake. The highest block can be obtained from [Tzkt](https://www.tzkt.io/blocks?expand=1) | ||
|
||
Go back to the `Tezos Baking` application and run: | ||
|
||
```bash | ||
octez-signer set ledger high watermark for my_ledger_key to <LEVEL> | ||
``` | ||
|
||
On your Ledger device, you should see a screen sequence similar to: | ||
![Ledger Setup Review](/img/tutorials/bake-with-ledger/set-hwm-review.png) | ||
<!-- https://lucid.app/lucidchart/26df7357-40e6-4c1b-8ffe-0e4b8eebf707/edit?beaconFlowId=D98D3B908C0603CC&invitationId=inv_08b134b7-3e40-4429-af31-101e36489cc3&page=0_0# --> | ||
|
||
Output: | ||
|
||
```console | ||
ledger://masculine-pig-stupendous-dugong/secp256k1/0h/0h has now high water mark: 42 (round: 0) | ||
``` | ||
|
||
:::note | ||
|
||
Alternatively, the HWM can be set up from the setup command: | ||
|
||
```bash | ||
octez-signer setup ledger to bake for my_ledger_key --main-hwm <LEVEL> | ||
``` | ||
|
||
::: | ||
|
||
### Setup additionnal checks for `octez-signer` | ||
|
||
`octez-signer` also has the ability to enable various checks. Stop the previously launched `octez-signer` TCP socket and restart it with the following command: | ||
|
||
```bash | ||
octez-signer launch socket signer -M 0x11,0x12,0x13 -W -a localhost | ||
``` | ||
|
||
> The `-M 0x11,0x12,0x13` option is used to only request consensus operations and blocks to be signed. | ||
|
||
> The `-W` tag is used to activate the HWM check. | ||
|
||
:::note Warning | ||
|
||
The `-W` tag is required if you have chosen to disable the `High Watermark` option in the `Tezos Baking` application. | ||
|
||
::: | ||
|
||
## Security verifications | ||
|
||
Everything is ready, you can now finish the tutorial [Run a Tezos node in 5 step](/tutorials/join-dal-baker), the baking daemon will send the data to be signed to `octez-signer` which will send it to your Ledger device which will sign them. | ||
|
||
Once the baking daemon has started, you can check on your Ledger device that the HWM is evolving in accordance with the blocks signed by your Ledger baking key. | ||
|
||
The `octez-signer` also stores the HWM for the blocks it has signed. You can find them in a file named `Net..._highwatermarks` in the `.tezos-client` folder. | ||
|
||
> `Net...` being the chain-id of the chain in which you bake. | ||
|
||
Open the file and check that the HWMs evolve in accordance with the blocks signed by your Ledger baking key: | ||
|
||
```bash | ||
cat .tezos-client/NetXnHfVqm9iesp_highwatermarks | ||
``` | ||
|
||
```json | ||
{ "blocks": | ||
[ { "delegate": "tz...", | ||
"highwatermark": { "round": 0, "level": 107095 } } ], | ||
"preattestations": | ||
[ { "delegate": "tz...", | ||
"highwatermark": { "round": 0, "level": 107096 } } ], | ||
"attestations": | ||
[ { "delegate": "tz...", | ||
"highwatermark": { "round": 0, "level": 107096 } } ] } | ||
``` | ||
|
||
|
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,105 @@ | ||
--- | ||
title: "Setup your Ledger baking key with `octez-signer`" | ||
authors: Sébastien Palmer | ||
last_update: | ||
date: 10 January 2025 | ||
--- | ||
|
||
It’s recommended to use a separate machine to run the remote signer. For simplicity, in this tutorial, we assume a setup where the Ledger device is connected to the same machine running the baker binary. On the same machine, the following commands can be used to set up the baking key with `octez-signer`. | ||
|
||
## Import a key from your Ledger device to the `octez-signer` context | ||
|
||
Let's start by importing a key from your Ledger device for `octez-signer`. | ||
Connect your Ledger device with a USB cable and open the `Tezos Baking` application. | ||
To see the available keys, run: | ||
|
||
```bash | ||
octez-signer list connected ledgers | ||
``` | ||
|
||
Output: | ||
|
||
```console | ||
## Ledger `masculine-pig-stupendous-dugong` | ||
Found a Tezos Baking 2.4.7 (git-description: "v2.4.7-70-g3195b4d2") | ||
application running on Ledger Nano S Plus at [1-1.4.6:1.0]. | ||
|
||
To use keys at BIP32 path m/44'/1729'/0'/0' (default Tezos key path), use one | ||
of: | ||
octez-client import secret key ledger_username "ledger://masculine-pig-stupendous-dugong/ed25519/0h/0h" | ||
octez-client import secret key ledger_username "ledger://masculine-pig-stupendous-dugong/secp256k1/0h/0h" | ||
octez-client import secret key ledger_username "ledger://masculine-pig-stupendous-dugong/P-256/0h/0h" | ||
octez-client import secret key ledger_username "ledger://masculine-pig-stupendous-dugong/bip25519/0h/0h" | ||
``` | ||
|
||
Key's URIs are of the form `ledger://<animals>/<curve>[/<path>]` where: | ||
- `<animals>` is the identifier of the ledger. | ||
- `<curve>` is the signing curve | ||
- `<path>` is a BIP32 path anchored at m/44h/1729h. The ledger does not yet support non-hardened paths, so each node of the path must be hardened. | ||
|
||
:::note Signing curve | ||
|
||
The `secp256k1` and `P-256` signature schemes (resp. `tz2` and `tz3`) have the best signature performance with the `Tezos Baking` application. | ||
|
||
::: | ||
|
||
Choose one of the URIs shown, modifying the BIP32 path as you like, then import it using `octez-signer`: | ||
|
||
```bash | ||
octez-signer import secret key my_ledger_key "ledger://masculine-pig-stupendous-dugong/secp256k1/0h/0h" | ||
``` | ||
|
||
On your Ledger device, you should see a screen sequence similar to: | ||
![Ledger Key Review](/img/tutorials/bake-with-ledger/pkh-review.png) | ||
<!-- https://lucid.app/lucidchart/26df7357-40e6-4c1b-8ffe-0e4b8eebf707/edit?beaconFlowId=D98D3B908C0603CC&invitationId=inv_08b134b7-3e40-4429-af31-101e36489cc3&page=0_0# --> | ||
|
||
Output: | ||
|
||
```console | ||
Please validate (and write down) the public key hash displayed on the Ledger, | ||
it should be equal | ||
to `tz...`: | ||
Tezos address added: tz... | ||
``` | ||
|
||
## Authorise the baking key in the `Tezos Baking` application | ||
|
||
For your security, the `Tezos Baking` application only allows one key to be used for signing. So you need to specify which key you want to bake with: | ||
|
||
```bash | ||
octez-signer setup ledger to bake for my_ledger_key | ||
``` | ||
|
||
On your Ledger device, you should see a screen sequence similar to: | ||
![Ledger Setup Review](/img/tutorials/bake-with-ledger/setup-review.png) | ||
<!-- https://lucid.app/lucidchart/26df7357-40e6-4c1b-8ffe-0e4b8eebf707/edit?beaconFlowId=D98D3B908C0603CC&invitationId=inv_08b134b7-3e40-4429-af31-101e36489cc3&page=0_0# --> | ||
|
||
Output: | ||
|
||
```console | ||
Setting up the ledger: | ||
* Main chain ID: 'Unspecified' -> NetXdQprcVkpaWU | ||
* Main chain High Watermark: 0 (round: 0) -> 0 (round: 0) | ||
* Test chain High Watermark: 0 (round: 0) -> 0 (round: 0) | ||
Authorized baking for address: tz... | ||
Corresponding full public key: ..pk... | ||
``` | ||
|
||
## Link `octez-signer` to `octez-client` | ||
|
||
Now that your baking key on `octez-signer` is linked to your Ledger device, `octez-signer` will be in charge of signing using your Ledger device. Let's launch `octez-signer`: | ||
|
||
```bash | ||
octez-signer launch socket signer -a localhost | ||
``` | ||
|
||
> The default port is `7732` | ||
|
||
To be able to sign from `octez-client` and from the baker binaries, you have to link your remote signer for `octez-client`. | ||
In a new terminal, run: | ||
|
||
```bash | ||
octez-client -R 'tcp://localhost:7732' config update | ||
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. Does this end here? Need to complete the command and some text below 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. The command is complete. |
||
``` | ||
|
||
This way, the key stored in the context of your `octez-signer` will be accessible by remote from the `octez-client` context. |
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,40 @@ | ||
--- | ||
title: "Setup your ledger" | ||
authors: Sébastien Palmer | ||
last_update: | ||
date: 10 January 2025 | ||
--- | ||
|
||
## Disable PIN lock | ||
|
||
The Tezos baking application allows you to bake securely without interruption. However, you will need to disable auto PIN lock feature in the Ledger to avoid getting locked out of the Ledger. Otherwise the Ledger device will lock itself and baking app will not work. | ||
|
||
:::note Warning | ||
|
||
Disabling the automatic lock on your Ledger device poses a risk that if any other app except baking-app is left open on your device, someone could get access to your funds by using that Ledger if left unattended. | ||
The Tezos baking application is extremely secure and it only allows you to sign baking-related transactions and requires a PIN code to exit the application. However, remember to **reactivate the automatic lock on your Ledger device if you stop using the Tezos baking application on this device**. | ||
|
||
::: | ||
|
||
Go to the settings of your Ledger device and search for the automatic PIN lock option, then deactivate it. | ||
- For Nanos, Nanos+ and Nanox devices, go to `Settings` then `Security` and finally `PIN lock`. | ||
- For Stax and Flex devices, go to `Settings` then `Lock screen` and then `Auto-lock`. | ||
|
||
## Screen saver | ||
|
||
In order to preserve the performance and integrity of your Ledger device, it is **strongly recommended** to activate the screen saver of your Ledger device. Go to the settings of your Ledger device and look for the screen saver option, then activate it for a value that suits you. | ||
- For Nanos, Nanos+ and Nanox devices, go to `Settings` then `Security` and finally `Screen saver`. | ||
- For Stax and Flex devices, there is no screen saver as of writing this article (Jan 25). | ||
|
||
## HWM option | ||
|
||
:::note Warning | ||
|
||
HWM (High Watermark) protection exists in the Ledger `Tezos Baking` application to avoid double-baking, double-attesting or double-preattesting at the level. The HWM is stored in NVRAM (Non-volatile Random Access Memory), after every signature, by the `Tezos Baking` application (that is on each pre-attestation, attestation, but also while signing blocks). | ||
|
||
The NVRAM on Ledger has limited read/write lifetime, thus frequent updates of NVRAM leads to NVRAM burn. To resolve this, an **optional** setting called HWM (ENABLE/DISABLE) is added to the Ledger `Tezos Baking` application (since v 2.4.7). When disabled, it allows storing HWM on RAM instead of NVRAM during the signature of operations. This increases the speed/performance of the Ledger `Tezos Baking` application and extends the lifetime of Ledger devices. The last HWM value on the Ledger’s RAM is written to NVRAM at the time of exiting the Ledger `Tezos Baking` application for persistent storage. | ||
In case of an abrupt interruption of the Ledger `Tezos Baking` application, e.g. caused by an abrupt power off of the Ledger device, the current HWM value may not be updated to the device’s NVRAM. Thus, it’s important to reset the value of the HWM on the Ledger device to the highest HWM value signed by the baker, before resuming baking. (See [Setup the Ledger high watermark (HWM)](/tutorials/bake-with-ledger/run-baker#setup-the-ledger-high-watermark-hwm) to setup the HWM) | ||
|
||
::: | ||
|
||
For additional protection from double-baking, we will demonstrate use of external signer (`octez-signer`), which keeps track of HWM and prevents double baking. Its recommended to use this external signer, when you disable the HWM feature on your Ledger device. |
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
Binary file added
BIN
+411 KB
static/img/tutorials/bake-with-ledger/install-ledger-tezos-baking-app.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
a series of screenshots might help here. Not sure.
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.
I've added the screen flows.
The original document can be found here :
https://lucid.app/lucidchart/26df7357-40e6-4c1b-8ffe-0e4b8eebf707/edit?beaconFlowId=D98D3B908C0603CC&invitationId=inv_08b134b7-3e40-4429-af31-101e36489cc3&page=0_0#
Do you have access to it?
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