# Reproducible Builds
> Technical details and current coverage of reproducible builds for Gem Wallet Android and iOS releases.

Reproducible builds provide a verifiable link between published source code and a release binary. Our current reproducible-build coverage applies to the Android F-Droid release. We intend to expand this coverage to additional Android and iOS distribution channels.

## Android

### F-Droid

Gem Wallet uses the independent [F-Droid build infrastructure](https://f-droid.org/docs/Reproducible_Builds/) to rebuild the F-Droid APK and verify it before publication.

#### Verification model

Gem Wallet publishes a signed F-Droid APK for each release. Separately, the F-Droid build servers execute the public build recipe from a clean environment:

1. The [F-Droid metadata](https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/com.gemwallet.android.yml?ref_type=heads) selects an exact Git commit and Android NDK version.
2. F-Droid checks out that commit from the public [Gem Wallet repository](https://github.com/gemwalletcom/wallet).
3. The public [reproducible build scripts](https://github.com/gemwalletcom/wallet/tree/main/android/reproducible) install the pinned native toolchain and run `:app:assembleFdroidRelease`.
4. The build produces an unsigned APK. F-Droid downloads the corresponding developer-signed APK and confirms that it is signed by the certificate fingerprint declared in `AllowedAPKSigningKeys`.
5. F-Droid copies the APK signature to the rebuilt artifact and verifies it. Android APK Signature Scheme v2/v3 signatures cover the complete APK outside the signing block, so successful verification requires the rebuilt APK payload to match the Gem Wallet release byte-for-byte.
6. F-Droid publishes the developer-signed APK only when verification succeeds. A release that does not reproduce is not published.

#### Deterministic build controls

Gem Wallet includes Rust native libraries, which makes the output sensitive to compiler, linker, NDK, host-platform, and optimizer differences. The F-Droid build controls these inputs by:

- pinning the Rust toolchain and `cargo-ndk` versions in `android/reproducible/versions.sh`;
- installing `cargo-ndk` with `--locked`, while application Rust dependencies are resolved by the committed `Cargo.lock`;
- pinning the exact Android NDK revision in both the Android project and the F-Droid metadata;
- building on a Linux `x86_64` host with explicit NDK linker and archiver paths;
- restricting native APK targets to `armeabi-v7a` and `arm64-v8a`, independently of the `x86_64` build host;
- using the dedicated `fdroid` product channel, without Google push and review modules;
- disabling R8 optimization with `-dontoptimize` to prevent non-deterministic DEX output and mapping identifiers;
- running Gradle without the daemon or configuration cache and clearing transformation caches before the release build.

The exact source commit, build commands, output path, NDK revision, upstream APK URL, and allowed signing certificate are public in the [F-Droid metadata](https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/com.gemwallet.android.yml?ref_type=heads). The scripts that configure Rust, Cargo, the NDK toolchain, and Gradle are maintained with the application source under [`android/reproducible`](https://github.com/gemwalletcom/wallet/tree/main/android/reproducible).

#### Security properties and limitations

A successful F-Droid verification demonstrates that the signed APK published by Gem Wallet can be reproduced from the declared source commit and build recipe. The rebuild is performed outside Gem Wallet infrastructure, reducing reliance on our release pipeline as a single point of trust.

Reproducibility does not prove that the source code is vulnerability-free, that every dependency is trustworthy, or that the selected compiler toolchain is free from compromise. Those risks require source review, dependency controls, and toolchain security in addition to reproducible builds.

Build status and verified releases are available on the [Gem Wallet F-Droid page](https://f-droid.org/en/packages/com.gemwallet.android).

### Universal APK and Google Play

The Gem Wallet universal APK and Google Play release are not currently covered by the F-Droid verification described above. Reproducible-build support for these Android distribution channels is planned for future work.

## iOS

The App Store release is not currently reproducible. Reproducible-build support for iOS and independent verification of the App Store binary are planned for future work.
