Extends archy-fips-core with the two companion-release features' crypto (#128, #139), same JNI-over-JSON contract as the mesh surface: backup.rs — the ADR-005 encrypted-backup envelope, byte-compatible with the node's backup code (Argon2id default params + ChaCha20-Poly1305, blob = base64(salt||nonce||ct)); decrypt ignores extra envelope fields so node backups read here too. Round-trip, tamper, wrong-passphrase and cross-shape tests included. nostr.rs — the phone-side remote-signer crypto: nsec/npub bech32 keys, BIP340 schnorr event signing (NIP-01 id serialization), NIP-44 v2 payloads (HKDF-SHA256 + ChaCha20 + HMAC-SHA256, both padding prefixes), NIP-04 fallback, nostrconnect:// parsing with repeated relay params. Verified against the official NIP-44 vectors (conversation keys, message keys, padded lengths, byte-exact encrypt vectors), the BIP-340 reference sign vectors, and round-trip/tamper/failure tests. secp256k1 0.29 note: Keypair::public_key() is the 33-byte compressed key — x-only pubkeys must go through .x_only_public_key().0 (one real bug the vectors caught). JNI glue adds com.archipelago.app.NativeCore: backupEncrypt/Decrypt, nostrGenerateSecret/SecretFromAny/ParseConnectUri/SignEvent and the NIP-44/NIP-04 cipher pairs. Android arm64 build verified via cargo-ndk (7.2 MB .so, +0.4 MB for both modules). Host: cargo test 23/23, clippy clean.
78 lines
3.5 KiB
TOML
78 lines
3.5 KiB
TOML
# Embedded FIPS mesh node for the Archipelago companion app.
|
|
#
|
|
# Built for Android via cargo-ndk (see Android/app/build.gradle.kts, task
|
|
# buildRustArm64) into app/src/main/jniLibs/arm64-v8a/libarchy_fips_core.so.
|
|
# Also builds on the host so `cargo test` covers the non-JNI logic.
|
|
#
|
|
# `fips` is pinned to the fips-native fork rev that this integration was
|
|
# developed against — the fork carries Android support upstream lacks
|
|
# (Tun::from_fd for a VpnService-owned fd, cfg(target_os = "android") paths).
|
|
# Override with a local checkout when hacking on fips itself:
|
|
# CARGO_NET_OFFLINE=false cargo ndk ... --config 'patch."https://github.com/9qeklajc/fips-native".fips.path="/path/to/fips-native/fips"'
|
|
[package]
|
|
name = "archy-fips-core"
|
|
version = "0.1.0"
|
|
edition = "2021"
|
|
license = "MIT"
|
|
publish = false
|
|
|
|
[lib]
|
|
name = "archy_fips_core"
|
|
# rlib for host tests; cdylib for the Android shared library.
|
|
crate-type = ["lib", "cdylib"]
|
|
|
|
[dependencies]
|
|
# default-features drops the ratatui TUI; tun-support enables Node::start_with_tun_fd.
|
|
# Zazawowow/fips-native `fast-join-pinned` = upstream pinned rev 46494a74 +
|
|
# discovery re-fire on topology change (fresh 5G join: first route no longer
|
|
# waits out doomed pre-join lookups). Upstream 9qeklajc denies pushes.
|
|
fips = { git = "https://github.com/Zazawowow/fips-native", rev = "07d21d4482be56b14295d2525e41f8386d1bfe6f", default-features = false, features = ["tun-support"] }
|
|
anyhow = "1.0"
|
|
serde_json = "1.0"
|
|
hex = "0.4"
|
|
# OS CSPRNG for identity generation (crypto rule: no thread-local RNG for keys).
|
|
getrandom = "0.2"
|
|
tokio = { version = "1", features = ["rt-multi-thread", "sync", "time", "macros"] }
|
|
tracing = "0.1"
|
|
# fcntl: force the VpnService TUN fd into blocking mode (see mesh::start).
|
|
libc = "0.2"
|
|
|
|
# ── Companion backup (#128) ───────────────────────────────────────────────
|
|
# ADR-005 envelope: the SAME crates and blob layout as the node's backup code
|
|
# (core/archipelago/src/backup/identity.rs) — Argon2id KDF + ChaCha20-Poly1305
|
|
# AEAD — applied to the companion's own JSON payload. Do not diverge from
|
|
# those parameters: a companion backup and a node backup must decrypt with
|
|
# the same code path on either side.
|
|
argon2 = "0.5"
|
|
chacha20poly1305 = "0.10"
|
|
base64 = "0.22"
|
|
|
|
# ── NIP-46 remote signer (#139) ───────────────────────────────────────────
|
|
# BIP340 schnorr signing + secp256k1 ECDH (NIP-44/NIP-04 conversation keys).
|
|
# Audited libsecp256k1 via cc; cargo-ndk provides the NDK clang on Android.
|
|
secp256k1 = "0.29"
|
|
# NIP-44 v2: HKDF-SHA256 (conversation/message keys) + HMAC-SHA256 (MAC).
|
|
sha2 = "0.10"
|
|
hmac = "0.12"
|
|
hkdf = "0.12"
|
|
# NIP-44 v2 stream cipher (raw ChaCha20, RFC 8439 — NOT the AEAD).
|
|
chacha20 = "0.9"
|
|
# NIP-04 fallback (deprecated in the spec but still sent by real clients):
|
|
# AES-256-CBC, key = raw ECDH x-coordinate.
|
|
aes = "0.8"
|
|
cbc = { version = "0.1", features = ["alloc"] }
|
|
# npub/nsec (bech32, BIP173 variant — NOT Bech32m).
|
|
bech32 = "0.11"
|
|
# nostrconnect:// URI parsing (repeated relay params + percent-decoding).
|
|
url = "2.5"
|
|
|
|
# The JNI surface only exists on Android; host builds skip it and drive the
|
|
# mesh module directly (tests).
|
|
[target.'cfg(target_os = "android")'.dependencies]
|
|
jni = "0.21"
|
|
# Bridge `tracing` (ours + fips) to logcat: `adb logcat -s archy-fips`.
|
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
|
paranoid-android = "0.2"
|
|
|
|
[workspace]
|