DevelopersBuild and test

Reproduce a release

Rebuild a published Liana release from source and check that you get the same bytes.

A good signature on the hash list proves who published a release file, not that the public source produced it. Rebuild the release on your own machine and compare the hashes. A match ties the file to the public source, so you no longer trust the release machine or the people who ran it. The Reproducible builds page explains what each check proves.

Every command below checks Liana 16.0, the current release. An earlier release may need different commands.

You will need

  • A Linux machine: An x86_64 Linux computer or virtual machine. The release script builds every platform on one such machine.
  • Git and GnuPG: With Edouard Paris's key imported into GnuPG, as in Verify your download.
  • 7-Zip: The 7z command, to open the macOS disk image.
  • A working folder: Run the first command in an empty folder. The commands then create liana/ for the source and published/ for the release files.

Two release files cannot be reproduced

liana-16.0-macos.dmg and liana-16.0.exe carry code signatures that only their signers can produce. The Reproducible builds page says who signs them. Rebuild and compare liana-16.0-macos-noncodesigned.dmg and liana-16.0-noncodesigned.exe instead.

Get the signed source and hash list

Check out the release tag

git clone https://github.com/wizardsardine/liana.git
cd liana
git checkout v16.0
git verify-tag v16.0
End of the expected output
gpg: Good signature from "Edouard Paris (reine des reines) <m@edouard.paris>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 5B63 F3B9 7699 C7EE F3B0  40B1 9B7F 629A 53E7 7B83
     Subkey fingerprint: 4730 DDCC 64DF AEC1 6CEF  EB5B E65F 7A08 9C20 DC8F

Do not build a tag that lacks Good signature and this primary key fingerprint. Ignore the WARNING lines. Verify your download explains why.

Download and verify the hash list

From the working folder:

mkdir published
cd published
curl -LO https://github.com/wizardsardine/liana/releases/download/v16.0/liana-16.0-shasums.txt
curl -LO https://github.com/wizardsardine/liana/releases/download/v16.0/liana-16.0-shasums.txt.asc
gpg --verify liana-16.0-shasums.txt.asc liana-16.0-shasums.txt

GnuPG must print the same Good signature and primary key fingerprint as for the tag. Every comparison below trusts this list.

Rebuild the Linux binaries with Guix

The Guix build makes the x86_64 Linux binaries only. The macOS and Windows files come from the Nix builds below.

Install Guix

On a distribution that runs systemd, the installer needs the newgidmap command. On Debian or Ubuntu, install the uidmap package first. Then run the installer as root, as the Guix manual instructs. Open a root shell:

sudo -i

In the root shell it opens, run:

cd /tmp
wget https://guix.gnu.org/guix-install.sh
chmod +x guix-install.sh
./guix-install.sh
exit

The installer asks whether Guix may download pre-built packages, called substitutes, from its build farms. Accept: this page trusts the farms for the compilers. To build the compilers yourself, refuse and follow Bootstrap a release.

Check that this command prints a version:

guix --version

Then update Guix and restart its daemon. The daemon that the installer sets up predates the fix of flaws that a substitute server can exploit. On a distribution that runs systemd:

sudo --login guix pull
sudo systemctl restart guix-daemon.service

Need more detail on installing Guix?

Bitcoin Core's Guix installation guide goes into more detail. Almost all of it applies to Liana.

Install Rust

The build script vendors the Rust dependencies with your own cargo, before the offline container starts.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Restart your shell so that cargo is on your PATH.

Run the Guix build

From liana/:

BUILD_ROOT=$PWD/../guix-build ./contrib/reproducible/guix/guix-build.sh

The script uses all your cores unless you set JOBS. BUILD_ROOT holds the vendored dependencies, the build cache and the binaries, in $BUILD_ROOT/out. Without it, the script uses a new temporary folder. When it finishes, it prints Build successful. Output available at and the output folder.

Compare with the published archive

From published/:

curl -LO https://github.com/wizardsardine/liana/releases/download/v16.0/liana-16.0-x86_64-linux-gnu.tar.gz
sha256sum --check --ignore-missing liana-16.0-shasums.txt
tar -xzf liana-16.0-x86_64-linux-gnu.tar.gz
sha256sum liana-16.0-x86_64-linux-gnu/{lianad,liana-cli,liana-gui} \
  ../guix-build/out/x86_64-unknown-linux-gnu/release/{lianad,liana-cli,liana-gui}

The check prints liana-16.0-x86_64-linux-gnu.tar.gz: OK. The last command prints six lines. Each hash must appear twice: once for the published binary, once for yours.

Set up Nix for macOS and Windows

The repository's Nix flake cross-compiles both platforms on your Linux machine.

Install Nix

The Nix download page recommends the multi-user installation on Linux with systemd and SELinux disabled:

curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install | sh -s -- --daemon

Turn on flakes

If flakes are not on in your Nix, add this line:

~/.config/nix/nix.conf
experimental-features = nix-command flakes

Rebuild the macOS binaries

Download Xcode 12.2

The build needs Apple's macOS SDK from Xcode_12.2.xip. Nobody may redistribute that archive, so you download it from Apple. Sign in with an Apple ID, which is free, and find it on Apple's downloads page. Apple's site needs cookies. Once you are signed in, the direct link also starts the download.

Save it in the working folder, then check it:

sha256sum Xcode_12.2.xip
Expected output
28d352f8c14a43d9b8a082ac6338dc173cb153f964c6e8fb6ba389e5be528bd0  Xcode_12.2.xip

Add the SDK to the Nix store

From the working folder:

nix run github:edouardparis/unxip#unxip -- Xcode_12.2.xip Xcode_12.2
cd Xcode_12.2
nix-store --add-fixed --recursive sha256 Xcode.app

This can take a long time.

Build the application binary

From liana/:

nix build .#liana.universal2-apple-darwin

Nix writes result/universal2-apple-darwin/liana-gui, which joins the Apple silicon and Intel builds of liana-gui.

Compare with the published application

The release script copies that file into Liana.app as Contents/MacOS/Liana, inside the .dmg disk image. Compare that binary, not the image. 7-Zip extracts it in two steps: the image first, then the Liana 16.0 volume inside it. Do not mount or run anything from the image. From published/:

curl -LO https://github.com/wizardsardine/liana/releases/download/v16.0/liana-16.0-macos-noncodesigned.dmg
sha256sum --check --ignore-missing liana-16.0-shasums.txt
7z e -odmg liana-16.0-macos-noncodesigned.dmg 3.hfs
7z e -odmg dmg/3.hfs "Liana 16.0/Liana.app/Contents/MacOS/Liana"
sha256sum dmg/Liana ../liana/result/universal2-apple-darwin/liana-gui

The check prints liana-16.0-macos-noncodesigned.dmg: OK. The last two hashes must be identical. 7-Zip may print a Headers Error warning for the image. Ignore it, because the hash comparison is the check.

Checking the signed application on a Mac?

To check the code signature of the signed application on a Mac, run this command:

codesign --verify --verbose /Applications/Liana.app

To check the command-line archives too, build .#liana.aarch64-apple-darwin or .#liana.x86_64-apple-darwin. Compare the three binaries in result/<target>/ with those in liana-16.0-<target>.tar.gz, as on Linux.

Rebuild the Windows binary

Build liana-gui for Windows

From liana/:

nix build .#liana.x86_64-pc-windows-gnu

Nix writes result/x86_64-pc-windows-gnu/liana-gui.exe.

Compare with the signed hash

The release script publishes this file unchanged as liana-16.0-noncodesigned.exe. From liana/:

grep noncodesigned.exe ../published/liana-16.0-shasums.txt
sha256sum result/x86_64-pc-windows-gnu/liana-gui.exe

Both lines must show the same hash. Here <hash> stands for the 64 characters of that hash:

Expected output
<hash>  liana-16.0-noncodesigned.exe
<hash>  result/x86_64-pc-windows-gnu/liana-gui.exe

Investigate a hash that differs

A mismatch does not prove tampering. Check these first, then build again:

  • Source: The first command prints v16.0 and the second shows no change:

    git describe --tags
    git status
  • Machine: You built on x86_64 Linux.

  • File: You compared a noncodesigned file, not liana-16.0-macos.dmg or liana-16.0.exe.

The hashes still differ?

Do not install that release from the published files. Report the mismatch as Report a vulnerability describes.

Next steps

The Reproducible builds page explains what a match proves. Bootstrap a release also builds the compilers that Guix and Nix can build from a seed.