Hardware wallet are one of the most secure way to handle your cryptocurrency like bitcoin.
The trezor is a hardware bitcoin and other cryptocurrency wallet made by satoshilabs used to secure online transactions. The security reside in the fact that the private key used to sign a transaction never leave the device.
The hardware wallet device connect via USB to a host computer. Any transaction that would imply sending money to someone must be signed to be considered valid by the cryptocurrency network, like the bitcoin network. To perform that, the transaction is sent to the hardware wallet device via USB. The user can confirm its authenticity on the device display and press a button on the device to sign it with the internal private key. The hardware wallet device will send back the signed transaction to the computer to be broadcasted to the internet. In this process, the private key is never accessed by the computer.
On the other hand, the raspberry pi zero is a low cost and small but powerful computer. You can buy one for about 5$. It is used on numerous projects by ton of developers and hobbyists around the world.
In this web page I will show you how to create your own hardware bitcoin wallet based on the original trezor source code and run on it on a raspberry pi zero. This is a fun, low cost, D.I.Y. project for any cryptocurrency enthusiasm!
News:refer to update procedure below before reflashing the SD card
- Updated 3 January 2019: pitrezor-184.108.40.206.zip
- Based on trezor firmware 1.7.3
- Moved pitrezor specific code to separate folder in trezor fw fork
- Updated November 20th 2018: pitrezor-220.127.116.11.zip
- Based on trezor firmware 1.7.1
- Now support WebUSB. I updated the usb driver. That mean no more bridge to install if (still beta) wallet is used and the latest version of chrome.
- Updated September 6th 2018: pitrezor-18.104.22.168.zip
- Based on trezor firmware 1.6.3
- Updated July 9th 2018 : pitrezor-22.214.171.124.zip
- Based on trezor firmware 1.6.2
- Use libSDL2 instead of plain old SDL. That mean it used default hdmi resolution and the 3D engine to scale the output. Code is also more in sync with the original.
- Updated May 3rd 2018:
- Based on trezor firmware 1.6.1
- Added support of SPI OLED (I2C OLED were already supported)
- Added option to flip screen vertically
- Added option to customize GPIO pins used by buttons
- Support the Adafruit OLED bonnet
- Renamed TREZOR_SDL_SCALE to TREZOR_OLED_SCALE setting in pitrezor.config file to respect new firmware.
- Low cost parts
- Easy to build
- Use the original trezor code. Only a thin layer is used to adapt the code to the pi zero Linux platform.
- All code modifications are open source, like the original trezor code.
- 100% Compatible with trezor web wallet to perform transactions.
- Use the hardware random number generator of the raspberry pi for more security.
- Can be very secure if you use a pass phrase (see security section below)
- Support small OLED display and/or display via HDMI output.
- Adafruit OLED bonnet is also supported
- Adjustable display scale factor on HDMI output
- Fast boot (around 5 seconds)
- No trezor shield required
- Software is free but donations are accepted!
HDMI Display:The basic version only needs to connect two push buttons to the pi zero to act as the 2 input buttons of the device. The pi zero as an HDMI connector that is used for output in this configuration. This is a simple solution to start with.
Only two buttons required!
(Picture courtesy of Damian Bevan)
It is also possible to use the Adafruit bonnet (see https://www.adafruit.com/product/3531). In that case you just have to install the pins on the pi zero and connect the bonnet!
Quick start guide:
List of required components:
|Required components for the PiTrezor|
- A raspberry pi zero. You don't need the pi zero W, it cost probably a little bit more than the regular pi zero, but it will work anyway. The difference is that pi zero W has wifi and bluetooth but this project don't use it. The network drivers are not loaded by the platform so the W can be considered as secure.
- An SD card. The image to write on the SD card is very small (around 50 Megs) so virtually any decent SD card should work. Make sure you have one that is compatible with the pi.
- A good micro-usb to usb cable.
- A mini HDMI male to HDMI female adapter to verify the output via the HDMI output. You need HDMI cable and a TV or monitor too!
- Two push buttons (normally open contact, SPST)
- Some wires to solder the buttons to the pi zero
- Optionally, an I2C or SPI OLED display. Supported OLED are based on the SH1106 controller or Adafruit controller.
- Optionally, a box or enclosure for a more professional look.
Of course, If you are using the Adafruit bonnet, you don't need separate push buttons or OLED. Refer to Adafruit documentation about how to connect the bonnet to the pi zero.
- If you don't have the software called "etcher" already installed in your computer, download it here : https://etcher.io/ . This software is used to write the program image to the SD card.
- Download the latest pitrezor SD card image by clicking here and select "save" to save the zip file
- Start etcher and follow the instructions. You will need to connect the SD card to your computer to flash the pitrezor image file.
- After the card is flashed, put it in the SD card slot in the pi zero.
- Connect the HDMI output to a monitor or tv using the cable and adapter.
- Connect the USB cable in the USB port near the center of the pi zero, not the one near the corner. Refer to next picture.
- Connect the other end of the USB cable to your computer or a USB power supply. You should see the pi zero boot sequence in the monitor and after 4-5 seconds the trezor logo should appear. Good! That confirms that your pi zero and SD card are working correctly.
- At this point you cannot do much, so disconnect the USB cable, HDMI adapter and cable and remove SD card.
- If you are using the Adafruit bonnet, it is time to connect it and go straight to the "Configuration" section below. Otherwise, continue reading
- Solder the 2 buttons to the pi zero as showed in the following diagram. The left button (called "no") is connected to the pins 30 and 32 (in yellow in the next picture). The right button (called "yes") is connected to the pins 34 and 36 (in red in the picture). This is the default setup but can be tweaked from configuration file.
connecting the button
- Put back the SD card in the pi zero and reconnect the HDMI and USB cable back to your computer.
- It should boot again, otherwise that means something went bad during the soldering of the buttons :(
- Open a browser on your computer and navigate to https://wallet.trezor.io
- You will be requested to install the trezor bridge if you never did it before. Select your operating system to download the correct bridge software and perform installation. If you plan to use the trezor beta wallet, the bridge installation is optional but you must a recent version of chrome.
- If you installed the bridge, close and reopen your browser and go back to https://wallet.trezor.io
- If you don't plan to use the bridge on Linux, don't forget to set the permission accordingly. Refer to setting up chrome on linux.
- If the bridge is already installed, you should see a message that invites you to connect your trezor. Connect the USB cable of your pi zero.
- The browser application should detect the device and invite you to perform the trezor setup.
- During the setup you will need the buttons to, at least, go from one seed word to another.
- If all is working correctly you can disconnect everything to solder the OLED display. The I2C OLED display need 4 wires to solder and the SPI OLED uses 7 wires. Refer to the next picture to determine how to solder the OLED depending on interface.:
- Connect the SD card back to your computer and refer to the configuration section below to correctly configure your OLED model and orientation. Their is only 2 possibles orientations so you can try both and see which one is better for you.
- Reconnect everything and retry your device. Now you should see the output on the HDMI connector if connected and also on the OLED at the same time.
- If that work, put everything in a box!
- Enjoy! And please don't forget to send a donation to continue the support this project update (see below). Any amount is welcome.
You can download the latest pitrezor SD card image by clicking here .
ConfigurationIf you connect the SD card in your computer you should see a file named "pitrezor.config" in the first partition (boot partition). You can open this file with your favorite text editor. You will be able to change the configuration variables which are:
- TREZOR_OLED_SCALE : This control the scale factor of the display to apply when using the HDMI output. A scale factor of 1 means the default size of 128x64 pixel. A scale factor of 2 will stretch the image to 256x128 and so on.
- TREZOR_OLED_TYPE: Specify the type of OLED connected to the pi zero. The file enumerate the different value and their meaning. Select the one that match your OLED display.
- TREZOR_OLED_FLIP: Set to 0 or 1 to control the image vertically (normal or inverted) This is useful depending how you assemble the OLED in n enclosure.
- TREZOR_GPIO_YES and TREZOR_GPIO_NO : Specify the GPIO number to use for the yes/no button. If you soldered the buttons like mentionned in the tutorial, you can keep the default values.
For the Adafruit bonnet, you must change the values to these (courtesy of Damian Bevan):
Is this secure ?The main difference of this device versus the real trezor device is that the pi zero stores everything on the SD card. The equivalent of the flash memory for the trezor is stored in a file on the first partition. That means that anybody that has your SD card can access your seed words and private key.
However, the wallet supports the usage of a passphrase. The passphrase is a kind of an extra seed word that is not stored on SD card. By using a passphrase, you would prevent a thief that could have your SD card to empty your wallet.
Thus, the recommendation is to always use a passphrase!
Updating from previous pitrezor imageIf you are updating your pitrezor to the latest image you will need your seed words with you:
- Flash the SD card with the latest image.
- Disconnect and reconnect the SD card in your computer
- Redo the modification you did previously in the pitrezor.config file.
- Remove the SD card of your computer and install it in the pi zero.
- Boot your pitrezor as usual.
- When you will go to the wallet web site, your pitrezor will be detected as a new device. Select the recover option. You will have to enter all the words of your seed word list.
- Don't forget to enable the pass phrase option after if you were using one before. You should!
The modification to trezor original code are available in this repo: https://github.com/heneault/trezor-mcu
The platform code is based on yocto to which I added my own layer and some build scripts. The repo is there: https://github.com/heneault/yocto-pitrezor
Comments are welcome in the comment section below. You can also reach me at email@example.com
|Scan to send bitcoin donation!|
Donation !A lot of work and effort has been put in this project and still needed to keep it up to date. If you like it, please consider giving a donation. Any amount is welcome!
Copyright and Legal WarningThere are inherent dangers in the use of any software available for download on the Internet, and I caution you to make sure that you completely understand the potential risks before downloading any of the software.
The Software and SD card image available on this website are provided "as is" without warranty of any kind, either express or implied. Use at your own risk.
The use of the software and SD card image downloaded on this site is done at your own discretion and risk and with agreement that you will be solely responsible for any damage to your computer system or loss of data that results from such activities. You are solely responsible for adequate protection and backup of the data and equipment used in connection with any of the software, and I will not be liable for any damages that you may suffer in connection with using, modifying or distributing any of this software. No advice or information, whether oral or written, obtained by you from me or from this website shall create any warranty for the software.
I make no warranty that:
- the software will meet your requirements
- the software will be uninterrupted, timely, secure or error-free
- the results that may be obtained from the use of the software will be effective, accurate or reliable
- the quality of the software will meet your expectations
- any errors in the software obtained from me will be corrected.
- could include technical or other mistakes, inaccuracies or typographical errors. I may make changes to the software or documentation made available on its web site at any time without prior-notice.
- may be out of date, and I make no commitment to update such materials.
In no event shall I be liable to you or any third parties for any special, punitive, incidental, indirect or consequential damages of any kind, or any damages whatsoever, including, without limitation, those resulting from loss of use, data or profits, and on any theory of liability, arising out of or in connection with the use of this software.
© Yannick Heneault, 2018. Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to Yannick Heneault with appropriate and specific direction to the original content.
The name and logo trezor are the properties of satoshilabs
The name and logo raspberry pi and raspberry pi zero are properties of the raspberry pi foundation