“Don’t trust. Verify.”![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FX5RewuH.jpg&t=665&c=eY1HqB6fXEU7ZA)
The best way to prove you didn`t has a backdoor of your product is to make it Open Source. It doesn`t means that will be 100% safe but means we can work with the whole geek community to avoid any attack.
Open Source means any users can compile the firmware by themselves. Therefore, BitHD hardware wallet team prepared this tutorial to guide you to verify the consistency of the codes between the firmware on GitHuband the actual firmware on the BitHD hardware wallet product being sold on Amazon and eBay.
Before We Start:This tutorial is based on mac system operation, windows system users can download linux system to complete the operation process.
During the compilation process, please do not close the terminal program.
Open TerminalYou can find Terminal by search ‘Terminal’ in the Launchpad.
2. Install the compilation environment2.1 Install Docker
https://docs.docker.com/install/ ![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FXRlU0SH.png&t=665&c=POz-f0rYGkbKXw)
2.2 Input the following command in the terminal and hit ‘enter’ to install homebrew
ruby -e “$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FA6hTimf.png&t=665&c=eBUMgFBL5I3Irw)
2.3 Paste the following command in the terminal to install python3 and pipenv through homebrew
brew install python3 pipenv
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2Fd3sRsYh.png&t=665&c=l8Ps49b057qNFQ)
Get BITHD firmware open source code
Create a new folder on the desktop and name it “BITHD”
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FFoh1eOQ.png&t=665&c=tP4rrvC8UOwu_A)
2. Open terminal and input the following command to enter the folder directory
cd ./Desktop/BITHD/
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FEen1liF.png&t=665&c=HFeoItQ1-bgKfw)
3. Continue to input the following command in the terminal to get the open source code on GitHub
git clone
https://github.com/bithd/bithd-mcu.git![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2Fdh8DEFO.png&t=665&c=hRo3MdWHcIhJxw)
4. After successful acquisition, a BITHD-mcu folder will be generated in the BITHD file
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FYL9hnJG.png&t=665&c=UG6A9cmHCISokw)
This folder is the open source BITHD firmware code on GitHub, and subsequent compilation operations will be performed in this file directory.
CompilationThis step requires high computer performance, and some steps will take a long time. Please do not close the terminal before the terminal completes the operation, and wait patiently for the terminal to finish compiling.
Input the following command in the terminal to enter the firmware code root directory
cd bithd-mcu
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2F42GfDTa.png&t=665&c=v9NfCioF3khY-A)
2. Input the following command in the terminal to compile the corresponding version firmware.
export TAG=v2.7.4; ./build-firmware.sh $TAG
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FMVelnNj.png&t=665&c=52KxKUDa6BDYLw)
After the compilation is completed, the compiled firmware file will be generated in the BITHD / BITHD-mcu / build folder. At this time, the compilation steps for the GitHub open source code have been completed.
Sign the compiled firmware
Input the following command to install designated python environment.
pipenv — python 3 install
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FPpblKFS.png&t=665&c=ROKjAHxZVdqlbQ)
2. Input the following command to generate a bin file to sign
pipenv run ./script/prepare_firmware.py -f ./build/bithd-$TAG-unsigned.bin
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FMjqMJLP.png&t=665&c=cy2t5DMvt3XLgw)
A file named bithd-v2.7.4-prepared.bin will be created in the folder BITHD/BITHD-mcu/build.
3. Input the following command at the terminal. Sign this file with the signing file provided by BITHD official.
The signing file is saved in the folder BITHD/BITHD-mcu/signatures
export TAG=v2.7.4
pipenv run ./script/build_signed_firmware.py -f ./build/bithd-$TAG-prepared.bin -s . signatures/$TAG.csv
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2Fzk1Ylsi.png&t=665&c=89N52DsY6P47Bg)
After signing, a new file bithd-v2.7.4-signed will be generated in BITHD/BITHD-mcu/build. This file is the firmware we compiled and signed with the GitHub source coded and official signing file.
So far, we have completed all the steps of getting code from GitHub, compiling and signing. Then, we will verify the firmware.
Firmware VerificationConnect BITHD, choose to export the firmware in Bitpie APP. Tip: this exporting is only about firmware information and has nothing to do with your assets.
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2Ff83GFK8.jpg&t=665&c=kt6G0r3pc1Ggiw)
2. Through comparison, verify the consistency between the firmware in your hardware and the GitHub open-source firmware.
Input the following command in the terminal, and the comparison result will be shown as export
TAG=v2.7.4diff <(xxd build/bithd-$TAG-prepared.bin) <(xxd build/bithd-$TAG-firmware.bin)
Tip: please move the exported firmware file into folder BITHD/BITHD-mcu/build and edit the file name as same as the name in the command. E.g. the exported file name is bithd-wallet-firmware, we need to rename it as bithd-v2.7.4-firmware and put it into folder “build”. Otherwise the command would report an error.
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FAQGugkt.png&t=665&c=kEoeNV8LOoH2Aw)
By comparing the compiled firmware and the exported firmware, we can find the only difference is the first 256 signing information is different. Apart from that, all the remaining codes are all idential. That’s proved the two firmwares are totally the same.
3. Through Hash computing, verify the consistency between the firmware in hardware and the open-source firmware codes on GitHub.
3.1 Input the following command to compute the hash value of the exported firmware file.
shasum -a 256 ./build/bithd-$TAG-firmware.bin
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2F8ItkU6i.png&t=665&c=ifDtMkzXtp6TMg)
3.2 Compare the hash value with the firmware codes on GitHub.
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FrpK7wqO.png&t=665&c=TXQ84vyeJmqBbQ)
GitHud Address:
https://github.com/bithd/bithd-mcu/releasesWe can find the two hash values are identical. That demonstrates that the two firmware are exactly the same.
Find us on:
👉Twitter 👉 Telegram 👉Facebook 👉 Telegram HK 👉 News