1# `btcd`'s Reproducible Build System 2 3This package contains the build script that the `btcd` project uses in order to 4build binaries for each new release. As of `go1.13`, with some new build flags, 5binaries are now reproducible, allowing developers to build the binary on 6distinct machines, and end up with a byte-for-byte identical binary. However, 7this wasn't _fully_ solved in `go1.13`, as the build system still includes the 8directory the binary is built into the binary itself. As a result, our scripts 9utilize a work around needed until `go1.13.2`. 10 11## Building a New Release 12 13### macOS/Linux/Windows (WSL) 14 15No prior set up is needed on Linux or macOS is required in order to build the 16release binaries. However, on Windows, the only way to build the release 17binaries at the moment is by using the Windows Subsystem Linux. One can build 18the release binaries following these steps: 19 201. `git clone https://github.com/btcsuite/btcd.git` 212. `cd btcd` 223. `./build/release/release.sh <TAG> # <TAG> is the name of the next 23 release/tag` 24 25This will then create a directory of the form `btcd-<TAG>` containing archives 26of the release binaries for each supported operating system and architecture, 27and a manifest file containing the hash of each archive. 28 29## Verifying a Release 30 31With `go1.13`, it's now possible for third parties to verify release binaries. 32Before this version of `go`, one had to trust the release manager(s) to build the 33proper binary. With this new system, third parties can now _independently_ run 34the release process, and verify that all the hashes of the release binaries 35match exactly that of the release binaries produced by said third parties. 36 37To verify a release, one must obtain the following tools (many of these come 38installed by default in most Unix systems): `gpg`/`gpg2`, `shashum`, and 39`tar`/`unzip`. 40 41Once done, verifiers can proceed with the following steps: 42 431. Acquire the archive containing the release binaries for one's specific 44 operating system and architecture, and the manifest file along with its 45 signature. 462. Verify the signature of the manifest file with `gpg --verify 47 manifest-<TAG>.txt.sig`. This will require obtaining the PGP keys which 48 signed the manifest file, which are included in the release notes. 493. Recompute the `SHA256` hash of the archive with `shasum -a 256 <filename>`, 50 locate the corresponding one in the manifest file, and ensure they match 51 __exactly__. 52 53At this point, verifiers can use the release binaries acquired if they trust 54the integrity of the release manager(s). Otherwise, one can proceed with the 55guide to verify the release binaries were built properly by obtaining `shasum` 56and `go` (matching the same version used in the release): 57 584. Extract the release binaries contained within the archive, compute their 59 hashes as done above, and note them down. 605. Ensure `go` is installed, matching the same version as noted in the release 61 notes. 626. Obtain a copy of `btcd`'s source code with `git clone 63 https://github.com/btcsuite/btcd` and checkout the source code of the 64 release with `git checkout <TAG>`. 657. Proceed to verify the tag with `git verify-tag <TAG>` and compile the 66 binaries from source for the intended operating system and architecture with 67 `BTCDBUILDSYS=OS-ARCH ./build/release/release.sh <TAG>`. 688. Extract the archive found in the `btcd-<TAG>` directory created by the 69 release script and recompute the `SHA256` hash of the release binaries (btcd 70 and btcctl) with `shasum -a 256 <filename>`. These should match __exactly__ 71 as the ones noted above. 72