|
| 1 | +## Using Mintlayer with Trezor |
| 2 | + |
| 3 | +In order to use a Trezor device with Mintlayer, you'll have to: |
| 4 | +- Flash the device with custom firmware provided by Mintlayer. |
| 5 | +- Use one of the Mintlayer Core wallets - node-gui or wallet-cli. I.e. Trezor Suite won't be able to see your ML coins. Also, at this moment Mojito wallet doesn't support Trezor either, though there are plans to add the support in the future. |
| 6 | + |
| 7 | +Note: Core wallets still require you to create a wallet file on your computer. In this case though only public keys will be kept in the wallet file (unless you explicitly add a standalone private key to it). Also note that you have to create a separate wallet file for each device/passphrase combination. |
| 8 | + |
| 9 | +### Caveats |
| 10 | + |
| 11 | +From the Trezor perspective, there are two types of firmware: a) the official one, signed by Trezor and perfectly safe to use; b) custom-built one, potentially unsafe to use. |
| 12 | + |
| 13 | +Since Mintlayer is not officially supported by Trezor, the firmware we provide falls into the latter category. This has certain implications: |
| 14 | +- When installing the firmware, the device will show the warning "UNSAFE, DO NOT USE!". |
| 15 | +- When installing custom firmware over the official one, **the device will be wiped clean**. Make sure you have a backup of your seed phrase. |
| 16 | +- When installing custom firmware over different custom firmware, the device will **not** be wiped clean. This makes it succeptible to the so-called "evil maid attack", |
| 17 | +where the attacker has physical access to your device. It goes like this: |
| 18 | + * The "maid" temporarily steals your device and installs on it firmware that she has built herself; it looks identical to the previously installed firmware, but also logs the PIN and the passphrase entered by the user. Then she puts the device back. |
| 19 | + * You use the device. |
| 20 | + * She steals the device again and can now extract the logged PIN and passphrase. Moreover, knowing the PIN and being able to flash arbitrary firmware, she can now extract the seed phrase as well. So now she can either steal your coins right away or |
| 21 | + simply put the device back and wait until you accumulate more of them. |
| 22 | + |
| 23 | + So: |
| 24 | + * keep your device in a safe place; |
| 25 | + * preferably, use a dedicated device with a dedicated seed phrase and PIN specifically for Mintlayer; |
| 26 | +- In order to install custom firmware on a Trezor Safe family device (e.g. Safe 3 or Safe 5), you have to [unlock the bootloader first](https://trezor.io/learn/security-privacy/how-trezor-keeps-you-safe/unlocking-the-bootloader-on-trezor-safe-devices); |
| 27 | +this is an irreversible operation after which the device authenticity check will no longer work. This means that every time you use Trezor Suite, you will be presented with a warning "Your device may have been compromised" (unless you disable |
| 28 | +the authenticity check in the Trezor Suite's device settings). |
| 29 | + |
| 30 | +### Building and flashing the firmware |
| 31 | + |
| 32 | +#### A note about versioning |
| 33 | + |
| 34 | +Firmware built from the Mintlayer fork has two version numbers: |
| 35 | +- A version number assigned by Trezor; this is the original release that we've based our release upon |
| 36 | + and this is what is shown to you on the device screen when you flash the firmware. |
| 37 | +- An additional version number assigned by us, to which we refer as "Mintlayer firmware version". |
| 38 | + It is obtainable via `trezorctl mintlayer get-firmware-info` and it's what |
| 39 | + our wallets display in their UI. |
| 40 | + |
| 41 | +The table of correspondence between the two versions can be found in the [firmware repository](https://github.com/mintlayer/mintlayer-trezor-firmware/blob/mintlayer-master/README.md). |
| 42 | + |
| 43 | +The Mintlayer firmware version determines the compatibility between the firmware and the Core wallets: |
| 44 | + |
| 45 | +| Mintlayer Core version | Required Mintlayer firmware version | |
| 46 | +| --- | --- | |
| 47 | +| 1.1.0 | 1.x.x | |
| 48 | + |
| 49 | +Note: if you've built Core wallets directly from `master` instead of using a specific release, |
| 50 | +you'll probably won't be able to use a specific release for the firmware either. |
| 51 | +Instead, you'll have to build it from `mintlayer-master`. |
| 52 | + |
| 53 | +#### How to build |
| 54 | + |
| 55 | +##### Get the source code |
| 56 | + |
| 57 | +Clone the repository and `cd` into it: |
| 58 | +```sh |
| 59 | +git clone --recurse-submodules https://github.com/mintlayer/mintlayer-trezor-firmware |
| 60 | +cd mintlayer-trezor-firmware |
| 61 | +``` |
| 62 | + |
| 63 | +Then checkout the required revision: |
| 64 | +- If you want the latest version that is in development, checkout the `mintlayer-master` branch: |
| 65 | + ```sh |
| 66 | + git checkout --recurse-submodules mintlayer-master |
| 67 | + ``` |
| 68 | +- If you want a particular release, checkout the tag corresponding to that release. The list of tags |
| 69 | + can be found [here](https://github.com/mintlayer/mintlayer-trezor-firmware/tags). |
| 70 | + Assuming that you've chosen `mintlayer-v1.0.0`, run: |
| 71 | + ```sh |
| 72 | + git checkout --recurse-submodules mintlayer-v1.0.0 |
| 73 | + ``` |
| 74 | + |
| 75 | +##### Install `Nix` |
| 76 | + |
| 77 | +On a Debian-based system you can do this via `sudo apt install nix-bin`. |
| 78 | + |
| 79 | +Check that `Nix` works by running `nix-shell -p hello --run hello` |
| 80 | + |
| 81 | +If you're getting the error `getting status of /nix/var/nix/daemon-socket/socket: Permission denied` |
| 82 | +on your Linux machine, you may need to add the current user to the `nix-users` group: |
| 83 | +```sh |
| 84 | +sudo usermod -aG nix-users your_username |
| 85 | +``` |
| 86 | +You'll also need to re-login after that. |
| 87 | + |
| 88 | +If you're getting the error `file 'nixpkgs' was not found in the Nix search path`, add |
| 89 | +the `nixpkgs` channel by running: |
| 90 | +```sh |
| 91 | +nix-channel --add https://nixos.org/channels/nixos-25.05 nixpkgs |
| 92 | +nix-channel --update |
| 93 | +``` |
| 94 | + |
| 95 | +Run `nix-shell -p hello --run hello` again. If everything is ok, it should print `Hello, world!`. |
| 96 | + |
| 97 | +##### Install required Python dependencies via `Poetry` |
| 98 | + |
| 99 | +```sh |
| 100 | +nix-shell --run "poetry install" |
| 101 | +``` |
| 102 | + |
| 103 | +##### Build the firmware |
| 104 | + |
| 105 | +Run: |
| 106 | + |
| 107 | +```sh |
| 108 | +TREZOR_MODEL=T3T1 nix-shell --run "poetry run make -C core vendor build_firmware" |
| 109 | +``` |
| 110 | + |
| 111 | +The value of the `TREZOR_MODEL` env variable determines the target device which the firmware will be built for. |
| 112 | +The possible values are: |
| 113 | +| TREZOR_MODEL value | Device model | |
| 114 | +| --- | --- | |
| 115 | +| T2T1 | Model T | |
| 116 | +| T2B1 | Safe 3 revision A | |
| 117 | +| T3B1 | Safe 3 revision B | |
| 118 | +| T3T1 | Safe 5 | |
| 119 | + |
| 120 | +Note: |
| 121 | +- Trezor Safe 3 revision A and B look identical. To determine the revision of your particular device, |
| 122 | + first connect the device (which means, both connect it physically and enter the PIN) and then run: |
| 123 | + ```sh |
| 124 | + nix-shell --run "poetry run trezorctl get-features" |
| 125 | + ``` |
| 126 | + Look for the `internal_model` value in the output. |
| 127 | +- Trezor Model One is not supported. |
| 128 | + |
| 129 | +##### Flash the firmware |
| 130 | + |
| 131 | +First you need to put your device into bootloader mode. To do so |
| 132 | +- On Safe 3, hold the left button when connecting the USB cable. |
| 133 | +- On Model T and Safe 5, swipe across the screen when connecting the USB cable. |
| 134 | + |
| 135 | +After that the device will present you with an option to install firmware, select that option. |
| 136 | + |
| 137 | +Now you can flash the firmware by running: |
| 138 | +```sh |
| 139 | +nix-shell --run "poetry run make -C core upload" |
| 140 | +``` |
| 141 | + |
| 142 | +Note: instead of executing `nix-shell --run "poetry run the_command"` every time, you can enter |
| 143 | +the nix-shell by running `nix-shell` |
| 144 | +and then inside the nix-shell enter poetry shell by running `poetry shell`. |
| 145 | +After this, you can run the commands directly, e.g. `trezorctl get-features`. |
0 commit comments