keepkey / keepkey-firmware

KeepKey Device Firmware
GNU Lesser General Public License v3.0
152 stars 102 forks source link

v7.8.0 is not reproducible #342

Open mohammadrafigh opened 1 year ago

mohammadrafigh commented 1 year ago

I followed the build process but received 2 different hashes from the binary in repo and what I built:

github: b0fc047c7789bee9fba72e5720fb5c8129c9a32f94f7fe9dca4f4675c8d3ddc2 built binary: aa5d303ae15d2b5dd3ace06ad4d8665c644efbfba1946c25aa5e25d6d17ed917

to see the differences, I transformed binaries to hex formatted files:

$ xxd bin/firmware.keepkey.bin > built-bin.hex
$ xxd firmware.keepkey.bin > github-bin.hex

then got a diff excluding signature part:

18563,18566c18563,18566
< 00048820: 3a00 556e 6b6e 6f77 6e00 3036 3834 3465  :.Unknown.06844e
< 00048830: 6239 3761 3765 3563 3430 6366 6161 3835  b97a7e5c40cfaa85
< 00048840: 3232 3935 3437 6163 3534 6235 3734 6536  229547ac54b574e6
< 00048850: 3339 004e 6f74 2069 6e20 626f 6f74 6c6f  39.Not in bootlo
---
> 00048820: 3a00 556e 6b6e 6f77 6e00 3737 3933 6539  :.Unknown.7793e9
> 00048830: 3236 3938 3863 3063 3364 6164 3664 3062  26988c0c3dad6d0b
> 00048840: 3762 6639 3937 3235 3734 6139 3232 3864  7bf9972574a9228d
> 00048850: 6131 004e 6f74 2069 6e20 626f 6f74 6c6f  a1.Not in bootlo
Giszmo commented 1 year ago

For more context, our full review can be found here.

We tested 7.8.0 with hash 31c1cdd945a7331e01b3cced866cb28add5b49eef87c2bbc08370e5aa7daf9bf

Our test script:

#!/bin/bash

### provide this script with the version without "v" and the published buildHash

version=$1
buildHash=$2

cd /tmp
git clone https://github.com/keepkey/keepkey-firmware
cd keepkey-firmware
git checkout v${version}
git submodule update --init --recursive
# rm deps/python-keepkey/keepkeylib/eth/ethereum-lists/src/tokens/eth/0x45804880de22913dafe09f4980848ece6ecbaf78.json
./scripts/build/docker/device/release.sh
wget https://github.com/keepkey/keepkey-firmware/releases/download/v${version}/firmware.keepkey.bin
sha256sum firmware.keepkey.bin
tail -c +257 firmware.keepkey.bin | sha256sum
tail -c +257 ./bin/firmware.keepkey.bin | sha256sum