diff --git a/.forgejo/workflows/android-release.yml b/.forgejo/workflows/android-release.yml index 1e34c17..4894a8e 100644 --- a/.forgejo/workflows/android-release.yml +++ b/.forgejo/workflows/android-release.yml @@ -398,14 +398,7 @@ jobs: needs: android # Pi runner, not docker-amd64: POST /releases from amd64 dind returns 422 # with an empty body (core run 116). This job only curls the Forgejo API. - # `always()` is load-bearing on this runner, not decoration. Without it the - # job-level `needs.android.result` gate is evaluated as unset, the job is - # dropped before it is ever created (it does not appear in - # /actions/runs//jobs at all, so it reads as a silent skip), and the APK - # and AAR never reach the release. Run 770 did exactly that: `android` - # green, no `publish` job, eleven assets and no APK. release.yml's publish - # job carries the same prefix for the same reason (run 135). - if: always() && needs.android.result == 'success' && needs.android.outputs.dry_run != 'true' + if: needs.android.result == 'success' && needs.android.outputs.dry_run != 'true' runs-on: docker timeout-minutes: 20 steps: diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index fe6fe69..1052092 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -57,7 +57,7 @@ env: # feature 'vec_deque_pop_if'`, after the job has already built the rest of # the graph. 1.98 is the release this graph is built with on the dev machine # and in the Android workflows. `--no-default-features` still builds on 1.91 - # (Arti 0.49's floor); the default build does not, so the image follows the + # (Arti 0.46's floor); the default build does not, so the image follows the # default build. RUST_IMAGE: rust:1.98-bookworm CARGO_REGISTRY_VOLUME: onionwire-cargo-registry diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index d625d19..df510e8 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -416,11 +416,7 @@ jobs: # Pi runner, not docker-amd64: the amd64 dind runner is capacity=1 and # android-release sat in front of run 116's publish for ~1h; the Pi # already created the tag over the public API (version job), so publish - # uses that same path. This job needs the docker CLI for one thing only — - # running scripts/sign-release.sh in the pinned builder image — and it uses - # a named volume + docker cp, never a bind mount of $GITHUB_WORKSPACE - # (that path exists only inside this container; docker resolves a -v source - # on the host and hands the container an empty /work — run 768). + # uses that same path. This job only curls the Forgejo API — no docker CLI. # Fail-closed tag delete lives as a step here: a sibling cleanup job ran # after a successful publish (act treats needs.publish.result as unset, so # != success) and Early-terminated on run 135. Do not restore that job. @@ -450,35 +446,11 @@ jobs: with: path: artifacts - - name: Stage both arch artifacts into dist - if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success' - run: | - set -euo pipefail - # Everything the signer signs must already be in dist/ when the sign - # step runs. This loop used to live inside the publish step, i.e. - # AFTER the signature step, so signing ran against an empty dist/. - mkdir -p dist - find artifacts -type f -print - for target in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do - for name in "onionwire-$target" "onionwire-$target.sha256" "build-info-$target.txt"; do - src=$(find artifacts -type f -name "$name" -print -quit) - if [ -z "$src" ]; then - echo "missing artifact: $name" >&2 - find artifacts -type f >&2 || true - exit 1 - fi - cp "$src" "dist/$name" - done - done - ls -l dist - - name: Sign the release assets (minisign, fail closed) if: needs.version.outputs.dry_run != 'true' && needs.aarch64.result == 'success' && needs.x86_64.result == 'success' env: MINISIGN_SECRET_KEY: ${{ secrets.MINISIGN_SECRET_KEY }} RELEASE_TAG: ${{ needs.version.outputs.tag }} - SIGN_VOLUME: onionwire-sign-${{ github.run_id }} - SIGN_CONTAINER: onionwire-sign-${{ github.run_id }} run: | set -euo pipefail # Signing runs BEFORE publish on purpose. A run without the key stops @@ -490,46 +462,20 @@ jobs: echo "See docs/VERIFY.md, \"Maintainer: the signing key\"." >&2 exit 1 fi - # NO `-v "${GITHUB_WORKSPACE}:/work"`: GITHUB_WORKSPACE is a path - # INSIDE this job container, but docker resolves a bind mount's source - # on the HOST, where it does not exist. Docker then creates an empty - # /work and the sign script is simply absent (run 768: "bash: - # .ci-tools/scripts/sign-release.sh: No such file or directory"). - # Same pattern as the build jobs: named volume + docker cp in/out. - # minisign still comes from the same pinned image the builds used, so - # our signature and the verifier's check are the same implementation. - cleanup() { - docker rm -f "$SIGN_CONTAINER" >/dev/null 2>&1 || true - docker volume rm "$SIGN_VOLUME" >/dev/null 2>&1 || true - } - trap cleanup EXIT - docker volume create "$SIGN_VOLUME" >/dev/null - docker rm -f "$SIGN_CONTAINER" >/dev/null 2>&1 || true - docker create --name "$SIGN_CONTAINER" \ + # minisign comes from the same pinned image the builds used, so our + # signature and the verifier's check are the same implementation. + docker run --rm \ + -v "${GITHUB_WORKSPACE}:/work" \ -e MINISIGN_SECRET_KEY \ -e RELEASE_TAG \ - -v "$SIGN_VOLUME:/work" \ -w /work \ "$RUST_IMAGE" \ bash -c 'apt-get update -qq && apt-get install -y -qq --no-install-recommends minisign >/dev/null \ - && bash /work/scripts/sign-release.sh \ - /work/dist/onionwire-aarch64-unknown-linux-gnu \ - /work/dist/onionwire-aarch64-unknown-linux-gnu.sha256 \ - /work/dist/onionwire-x86_64-unknown-linux-gnu \ - /work/dist/onionwire-x86_64-unknown-linux-gnu.sha256' - docker cp .ci-tools/scripts "$SIGN_CONTAINER:/work/scripts" - docker cp dist/. "$SIGN_CONTAINER:/work/dist/" - docker start -a "$SIGN_CONTAINER" - docker cp "$SIGN_CONTAINER:/work/dist/." dist/ - # Verify the signatures came back out before anything is published. - for f in \ - dist/onionwire-aarch64-unknown-linux-gnu.minisig \ - dist/onionwire-aarch64-unknown-linux-gnu.sha256.minisig \ - dist/onionwire-x86_64-unknown-linux-gnu.minisig \ - dist/onionwire-x86_64-unknown-linux-gnu.sha256.minisig - do - [ -s "$f" ] || { echo "signing produced no $f" >&2; exit 1; } - done + && bash .ci-tools/scripts/sign-release.sh \ + dist/onionwire-aarch64-unknown-linux-gnu \ + dist/onionwire-aarch64-unknown-linux-gnu.sha256 \ + dist/onionwire-x86_64-unknown-linux-gnu \ + dist/onionwire-x86_64-unknown-linux-gnu.sha256' # The public key ships as an asset too, so a verifier can get it from # the release; getting it from the repo instead is stronger, and # docs/VERIFY.md says so. @@ -543,9 +489,19 @@ jobs: TAG: ${{ needs.version.outputs.tag }} run: | set -euo pipefail - # dist/ is staged and signed by the two steps above; this step only - # refuses to upload a hole in it. - find dist -type f -print + mkdir -p dist + find artifacts -type f -print + for target in aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu; do + for name in "onionwire-$target" "onionwire-$target.sha256" "build-info-$target.txt"; do + src=$(find artifacts -type f -name "$name" -print -quit) + if [ -z "$src" ]; then + echo "missing artifact: $name" >&2 + find artifacts -type f >&2 || true + exit 1 + fi + cp "$src" "dist/$name" + done + done missing=0 for f in \ dist/onionwire-aarch64-unknown-linux-gnu \ diff --git a/Cargo.lock b/Cargo.lock index 443af58..52967c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,9 +175,9 @@ checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" [[package]] name = "arti-client" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b3624d7bee91f821b04fe5412f561671e5500677781d3f070a2fa101a128b0" +checksum = "aafcbc506657d886b27ef2d8e06a99edd9014b28130c798a3013935b46983097" dependencies = [ "async-trait", "cfg-if", @@ -193,9 +193,10 @@ dependencies = [ "libc", "once_cell", "postage", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", + "tempfile", "thiserror 2.0.20", "time", "tor-async-utils", @@ -256,7 +257,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.119", - "synstructure 0.13.2", + "synstructure", ] [[package]] @@ -271,10 +272,16 @@ dependencies = [ ] [[package]] -name = "async-compression" -version = "0.4.54" +name = "assert_matches" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c31224bd2c09447484a1143f2fc1d871eb405789859c8e5470a3e7f95f40a18" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "async-compression" +version = "0.4.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f10dafd0c8d2e51ae9a748805777613ed0bbe17bf586b76c8311f45c020a32f" dependencies = [ "compression-codecs", "compression-core", @@ -636,9 +643,9 @@ checksum = "0d74937895e761d5984206f82ca8ff7725d0fd8021921011921894b41ab1b9f7" [[package]] name = "caret" -version = "0.11.2" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3f1a1c7fa296eb2367469e6226783ed07cb778d75d13f7b6ee3f1de593ba7f4" +checksum = "23a6f83e57018d15e7615a6f8e5e2c6b6b0226e24a1c562cd705f855a2bc751a" [[package]] name = "castaway" @@ -663,9 +670,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" @@ -800,9 +807,9 @@ checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" [[package]] name = "coarsetime" -version = "0.1.38" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae63702c5627c75addbfb1ea9d1b3842205a6ffd43e4cce884a2a9eb1828fd7" +checksum = "e58eb270476aa4fc7843849f8a35063e8743b4dbcdf6dd0f8ea0886980c204c2" dependencies = [ "libc", "wasix", @@ -831,9 +838,9 @@ checksum = "ea0095f6103c2a8b44acd6fd15960c801dafebf02e21940360833e0673f48ba7" [[package]] name = "compression-codecs" -version = "0.4.49" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f938fc0d88fbe2c8d6f0e1ba96ba1165d89ff698e98468cd019d92cff2ecd367" +checksum = "58a6d0db8759036a783bc7c3f7a07f8cef3bf9470eb1db3bc86e8bcd1c5d0fe8" dependencies = [ "compression-core", "flate2", @@ -844,9 +851,9 @@ dependencies = [ [[package]] name = "compression-core" -version = "0.4.34" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ebdda89edc534bf8d5dd2857562633b6495557e5846552ade994b99ed13c36a" +checksum = "6e8ccc4ea9f6acc32d102c0f6d471d11d913ad15f20c04de743374861fa1d414" [[package]] name = "const-oid" @@ -1088,9 +1095,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" dependencies = [ - "getrandom 0.4.3", "hybrid-array", - "rand_core 0.10.1", ] [[package]] @@ -1229,7 +1234,7 @@ dependencies = [ "cuprate-cryptonight", "cuprate-helper", "cuprate-types", - "curve25519-dalek 4.1.3", + "curve25519-dalek", "hex", "hex-literal 1.1.0", "indexmap 2.14.2", @@ -1331,8 +1336,8 @@ source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d5 dependencies = [ "chrono", "cuprate-constants", - "curve25519-dalek 4.1.3", - "dirs 6.0.0", + "curve25519-dalek", + "dirs", "futures", "libc", "monero-oxide", @@ -1596,7 +1601,7 @@ dependencies = [ "thiserror 2.0.20", "tokio", "tokio-util", - "toml 1.2.3+spec-1.1.0", + "toml 1.1.5+spec-1.1.0", "toml_edit 0.25.13+spec-1.1.0", "tower", "tower-http", @@ -1615,24 +1620,7 @@ dependencies = [ "cpufeatures 0.2.17", "curve25519-dalek-derive", "digest 0.10.7", - "fiat-crypto 0.2.9", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c1aa5a9b7626ed65ac0cf5ea9d4f1547af89017fbac20bd4de40022fff516f" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "curve25519-dalek-derive", - "digest 0.11.3", - "fiat-crypto 0.3.0", - "rand_core 0.10.1", + "fiat-crypto", "rustc_version", "subtle", "zeroize", @@ -1814,16 +1802,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "der" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a" -dependencies = [ - "const-oid 0.10.2", - "zeroize", -] - [[package]] name = "der-parser" version = "10.0.0" @@ -1849,9 +1827,9 @@ dependencies = [ [[package]] name = "derive-deftly" -version = "1.14.0" +version = "1.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "724949bdda5310709ca2f97bf69c2b01e3362f44fef1fb47913445db4c1debb5" +checksum = "98e02cd118058400797c74550dca132b57cf2e6af0e9ea0672a83eb186fd655e" dependencies = [ "derive-deftly-macros", "heck", @@ -1859,9 +1837,9 @@ dependencies = [ [[package]] name = "derive-deftly-macros" -version = "1.14.0" +version = "1.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17933e749f2502cfcd1c27519292fbbea22e8fc64ce680e863f855e8cd8cce23" +checksum = "ba91f619216e76a5eb2515783f7ec2e271938b51aadac592f4930517f4626863" dependencies = [ "heck", "indexmap 2.14.2", @@ -1948,10 +1926,8 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.12.1", "const-oid 0.10.2", "crypto-common 0.2.2", - "ctutils", ] [[package]] @@ -1972,15 +1948,6 @@ dependencies = [ "dirs-sys", ] -[[package]] -name = "dirs" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs-sys" version = "0.5.0" @@ -2031,12 +1998,12 @@ version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ - "der 0.7.10", + "der", "digest 0.10.7", "elliptic-curve", "rfc6979", - "signature 2.2.0", - "spki 0.7.3", + "signature", + "spki", ] [[package]] @@ -2045,18 +2012,8 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8 0.10.2", - "signature 2.2.0", -] - -[[package]] -name = "ed25519" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a" -dependencies = [ - "pkcs8 0.11.0", - "signature 3.0.0", + "pkcs8", + "signature", ] [[package]] @@ -2065,29 +2022,12 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" dependencies = [ - "curve25519-dalek 4.1.3", - "ed25519 2.2.3", + "curve25519-dalek", + "ed25519", + "merlin", "rand_core 0.6.4", "serde", - "sha2 0.10.9", - "subtle", - "zeroize", -] - -[[package]] -name = "ed25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de" -dependencies = [ - "curve25519-dalek 5.1.0", - "ed25519 3.0.0", - "keccak 0.2.2", - "rand_core 0.10.1", - "serde", - "sha2 0.11.3", - "signature 3.0.0", - "strobe-rs", + "sha2", "subtle", "zeroize", ] @@ -2122,7 +2062,7 @@ dependencies = [ "ff", "generic-array", "group", - "pkcs8 0.10.2", + "pkcs8", "rand_core 0.6.4", "sec1", "subtle", @@ -2246,12 +2186,6 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" -[[package]] -name = "fiat-crypto" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" - [[package]] name = "figment" version = "0.10.19" @@ -2368,12 +2302,12 @@ dependencies = [ [[package]] name = "fs-mistrust" -version = "0.16.2" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628799db8c034e020e48ee393c271f423aa749fde1c3195bd3bbc8bb5cfcbe8" +checksum = "9b2c81a5a0e7d67644309a15694eb7f414a4d6556c64c1ece1e5969aa609c8a9" dependencies = [ "derive_builder_fork_arti", - "dirs 7.0.0", + "dirs", "extend", "libc", "pwd-grp", @@ -2385,9 +2319,9 @@ dependencies = [ [[package]] name = "fslock-guard" -version = "0.9.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba455a614874a0b1814cf3e30f8a6d4c8858e2bc38569bd293e3ff8cbad49032" +checksum = "d10ce5036d49f8add4a11d08bc1b1afb0e3cefdd88778ab87fb4202d47b765e1" dependencies = [ "libc", "thiserror 2.0.20", @@ -2695,16 +2629,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ - "hmac 0.12.1", -] - -[[package]] -name = "hkdf" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" -dependencies = [ - "hmac 0.13.0", + "hmac", ] [[package]] @@ -2716,15 +2641,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "hmac" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" -dependencies = [ - "digest 0.11.3", -] - [[package]] name = "hostname-validator" version = "1.1.1" @@ -2798,7 +2714,6 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" dependencies = [ - "ctutils", "typenum", "zeroize", ] @@ -3077,9 +2992,9 @@ dependencies = [ [[package]] name = "inventory" -version = "0.3.25" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +checksum = "a4f0c30c76f2f4ccee3fe55a2435f691ca00c0e4bd87abe4f4a851b1d4dac39b" dependencies = [ "rustversion", ] @@ -3141,25 +3056,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc" dependencies = [ "defmt", - "jiff-core 0.1.0", - "jiff-static 0.2.35", - "jiff-tzdb-platform 0.1.3", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", - "windows-link", -] - -[[package]] -name = "jiff" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379ed44bd4e16d3926160e2b3a78b79ca0952ef5c037f124f554842ba272ef92" -dependencies = [ - "jiff-core 1.1.0", - "jiff-static 1.1.0", - "jiff-tzdb-platform 1.0.0", + "jiff-core", + "jiff-static", + "jiff-tzdb-platform", "log", "portable-atomic", "portable-atomic-util", @@ -3176,67 +3075,31 @@ dependencies = [ "defmt", ] -[[package]] -name = "jiff-core" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df46fc314b4f458aee614afcd8676ed6cb3637413aa359d47d2646cbc038b79" -dependencies = [ - "log", -] - [[package]] name = "jiff-static" version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204" dependencies = [ - "jiff-core 0.1.0", + "jiff-core", "proc-macro2", "quote", "syn 2.0.119", ] -[[package]] -name = "jiff-static" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b729c549d3efb5855b3c80b0ee8ee1850d56330a127382fe2760965741c1f3" -dependencies = [ - "jiff-core 1.1.0", - "proc-macro2", - "quote", - "syn 3.0.5", -] - [[package]] name = "jiff-tzdb" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e" -[[package]] -name = "jiff-tzdb" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc" - [[package]] name = "jiff-tzdb-platform" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" dependencies = [ - "jiff-tzdb 0.1.8", -] - -[[package]] -name = "jiff-tzdb-platform" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e" -dependencies = [ - "jiff-tzdb 1.0.0", + "jiff-tzdb", ] [[package]] @@ -3262,13 +3125,12 @@ dependencies = [ [[package]] name = "k12" -version = "0.5.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a8cc72399dffa4a445bc5f5a84d4af4d441c76604231bc52e9c529c1d47693" +checksum = "f4dc5fdb62af2f520116927304f15d25b3c2667b4817b90efdc045194c912c54" dependencies = [ - "digest 0.11.3", - "keccak 0.2.2", - "sponge-cursor", + "digest 0.10.7", + "sha3 0.10.9", ] [[package]] @@ -3299,17 +3161,6 @@ checksum = "d8f198d1db720e4940b5a493201d199d9f24f568f8f746bd13706243a2f71598" dependencies = [ "cfg-if", "cpufeatures 0.3.1", - "hybrid-array", -] - -[[package]] -name = "kem" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01737161ba802849cfd486b5bd209d38ba4943494c249a8126005170c7621edd" -dependencies = [ - "crypto-common 0.2.2", - "rand_core 0.10.1", ] [[package]] @@ -3524,21 +3375,23 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "memmap2" -version = "0.9.12" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" dependencies = [ "libc", ] [[package]] -name = "metrics" -version = "0.24.6" +name = "merlin" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89550ee9f79e88fef3119de263694973a8adb26c21d75322164fb8c493039fe2" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" dependencies = [ - "portable-atomic", - "rapidhash", + "byteorder", + "keccak 0.1.6", + "rand_core 0.6.4", + "zeroize", ] [[package]] @@ -3575,34 +3428,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "ml-kem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ba01ebcf90f6aff8e9b9f55bb69b19e6250e4ade5787d0040eaa27dd226238" -dependencies = [ - "hybrid-array", - "kem", - "module-lattice", - "pkcs8 0.11.0", - "rand_core 0.10.1", - "sha3 0.12.0", - "shake", - "zeroize", -] - -[[package]] -name = "module-lattice" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c61b87c9683ab7cb1c6871d261ad5479b6b10ceb52c4352aaca3b5d35a8febe" -dependencies = [ - "ctutils", - "hybrid-array", - "num-traits", - "zeroize", -] - [[package]] name = "monero-address" version = "0.1.0" @@ -3630,7 +3455,7 @@ name = "monero-borromean" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-ed25519", "monero-io", "std-shims", @@ -3642,7 +3467,7 @@ name = "monero-bulletproofs" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-bulletproofs-generators", "monero-ed25519", "monero-io", @@ -3658,7 +3483,7 @@ name = "monero-bulletproofs-generators" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-ed25519", "monero-io", "monero-primitives", @@ -3670,7 +3495,7 @@ name = "monero-clsag" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "group", "monero-ed25519", "monero-io", @@ -3688,7 +3513,7 @@ version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ "crypto-bigint 0.5.5", - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-io", "rand_core 0.6.4", "sha3 0.10.9", @@ -3710,7 +3535,7 @@ name = "monero-mlsag" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-ed25519", "monero-io", "std-shims", @@ -3723,7 +3548,7 @@ name = "monero-oxide" version = "0.1.4-alpha" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "hex-literal 1.1.0", "monero-borromean", "monero-bulletproofs", @@ -3940,9 +3765,9 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "oneshot-fused-workaround" -version = "0.8.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f851210432a7498257e0f1675c25b95131308f157b87821b70df756b01aa1dbc" +checksum = "56892f7dcba21c5eb4181b8de221620855805891ee55ef960aad7cac3b5d88b2" dependencies = [ "futures", ] @@ -3955,12 +3780,11 @@ dependencies = [ "arti-client", "chacha20poly1305", "cuprated", - "ed25519-dalek 2.2.0", + "ed25519-dalek", "futures", - "hkdf 0.12.4", - "hmac 0.12.1", + "hkdf", + "hmac", "md-5", - "ml-kem", "qrcode", "rand 0.8.8", "ratatui", @@ -3969,7 +3793,7 @@ dependencies = [ "rustls", "safelog", "serde_json", - "sha2 0.10.9", + "sha2", "sha3 0.10.9", "snow", "tempfile", @@ -3979,7 +3803,7 @@ dependencies = [ "tor-hsservice", "tor-rtcompat", "tracing-subscriber", - "x25519-dalek 2.0.1", + "x25519-dalek", "zeroize", ] @@ -4075,7 +3899,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -4087,7 +3911,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -4101,7 +3925,7 @@ dependencies = [ "elliptic-curve", "primeorder", "rand_core 0.6.4", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -4273,9 +4097,9 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" dependencies = [ - "der 0.7.10", - "pkcs8 0.10.2", - "spki 0.7.3", + "der", + "pkcs8", + "spki", ] [[package]] @@ -4284,18 +4108,8 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.10", - "spki 0.7.3", -] - -[[package]] -name = "pkcs8" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7" -dependencies = [ - "der 0.8.2", - "spki 0.8.1", + "der", + "spki", ] [[package]] @@ -4401,6 +4215,17 @@ dependencies = [ "elliptic-curve", ] +[[package]] +name = "priority-queue" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93980406f12d9f8140ed5abe7155acb10bb1e69ea55c88960b9c2f117445ef96" +dependencies = [ + "equivalent", + "indexmap 2.14.2", + "serde", +] + [[package]] name = "proc-macro-crate" version = "3.5.0" @@ -4533,9 +4358,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.10.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" dependencies = [ "chacha20 0.10.2", "getrandom 0.4.3", @@ -4644,15 +4469,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d" -[[package]] -name = "rapidhash" -version = "4.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da7e78a036ce858e8d55b7e7dc8ba3a88b78350fd2155d3591bbd966b58589e" -dependencies = [ - "rustversion", -] - [[package]] name = "ratatui" version = "0.30.2" @@ -4829,9 +4645,9 @@ dependencies = [ [[package]] name = "retry-error" -version = "0.14.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67f26b5caa81adf9b23ab230ce975acbf46aec461bc357f9fb51cfd4f2bfaebf" +checksum = "d350ad359aca3414f7261cdcc763e37ccc9fa56fe40ca30a9758c28a295bcad0" dependencies = [ "humantime", "web-time", @@ -4843,7 +4659,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "hmac 0.12.1", + "hmac", "subtle", ] @@ -4884,11 +4700,11 @@ dependencies = [ "num-integer", "num-traits", "pkcs1", - "pkcs8 0.10.2", + "pkcs8", "rand_core 0.6.4", - "sha2 0.10.9", - "signature 2.2.0", - "spki 0.7.3", + "sha2", + "signature", + "spki", "subtle", "zeroize", ] @@ -4957,9 +4773,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.46" +version = "0.23.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba" dependencies = [ "log", "once_cell", @@ -4981,9 +4797,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.17" +version = "0.103.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" dependencies = [ "ring", "rustls-pki-types", @@ -5016,9 +4832,9 @@ checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "safelog" -version = "0.10.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c090399e87e5eaec9515d6b859fdb7ec417c269c2e7564c169a8963df75a2ce" +checksum = "73ef1d6e273fc8ce5cc1376cf498c06d23b786e80e4a7679a643bb0a838b0029" dependencies = [ "derive_more", "educe", @@ -5047,12 +4863,9 @@ dependencies = [ [[package]] name = "saturating-time" -version = "0.6.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950f7f265dc6fc082387eccf710b1adbf22d75f17c4ee0db4648c9b6959b50d" -dependencies = [ - "web-time-compat", -] +checksum = "802bdbfcca9a239cb46eeaaedea507e37bb13ba1a673762d2e2ef7a9dac63144" [[package]] name = "schannel" @@ -5100,9 +4913,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", - "der 0.7.10", + "der", "generic-array", - "pkcs8 0.10.2", + "pkcs8", "subtle", "zeroize", ] @@ -5210,9 +5023,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.154" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "itoa", "memchr", @@ -5243,18 +5056,18 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.1.3" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" dependencies = [ "serde_core", ] [[package]] name = "serde_with" -version = "3.25.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56cb1ca7c93ae63d6439b5250f6b6b040f7e121f32e5dd2f5d523dd4149b3204" +checksum = "935177bb8c0cd8ca1a4e6d1a2ac8988bea69cab4f9d3a31311e012ad27868ea4" dependencies = [ "base64", "bs58", @@ -5262,8 +5075,7 @@ dependencies = [ "hex", "indexmap 1.9.3", "indexmap 2.14.2", - "jiff 0.2.35", - "jiff 1.1.0", + "jiff", "schemars 0.9.0", "schemars 1.2.2", "serde_core", @@ -5274,9 +5086,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.25.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff15a7c864bbec77d9586ca6822bc7c369bdf19e9243134a62b0b51ce26b31f" +checksum = "1d607aa01a3cb0ad757d6fd216136910db3c97b102fe686585689615a02dbcdc" dependencies = [ "darling 0.24.1", "proc-macro2", @@ -5297,13 +5109,13 @@ dependencies = [ [[package]] name = "sha1" -version = "0.11.0" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" dependencies = [ "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", + "cpufeatures 0.2.17", + "digest 0.10.7", ] [[package]] @@ -5317,17 +5129,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha2" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "820083d430c52864bf834423fc988cbcf61685d6f9d22a765a64e3f6cfe3521c" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", -] - [[package]] name = "sha3" version = "0.10.9" @@ -5349,17 +5150,6 @@ dependencies = [ "sponge-cursor", ] -[[package]] -name = "shake" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09057cb2149ad4cbd2da1e26b351f9a4c354219421229c69c3063e6f61947c4a" -dependencies = [ - "digest 0.11.3", - "keccak 0.2.2", - "sponge-cursor", -] - [[package]] name = "sharded-slab" version = "0.1.7" @@ -5376,7 +5166,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32824fab5e16e6c4d86dc1ba84489390419a39f97699852b66480bb87d297ed8" dependencies = [ "bstr", - "dirs 6.0.0", + "dirs", "os_str_bytes", ] @@ -5427,15 +5217,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "signature" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" -dependencies = [ - "rand_core 0.10.1", -] - [[package]] name = "simd-adler32" version = "0.3.10" @@ -5476,14 +5257,15 @@ dependencies = [ [[package]] name = "slotmap-careful" -version = "0.9.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e13aa7333b92ad3a6d3136abaa7fb5d8c19cc121441fcb435f6947d6ef2f8f7" +checksum = "ba7bcbd01d9b495f4509e74f660ebaf3315219b2f8a81753667ee7d6d8a199ac" dependencies = [ "paste", "serde", "slotmap", "thiserror 2.0.20", + "void", ] [[package]] @@ -5501,11 +5283,11 @@ dependencies = [ "aes-gcm", "blake2", "chacha20poly1305", - "curve25519-dalek 4.1.3", + "curve25519-dalek", "getrandom 0.3.4", "ring", "rustc_version", - "sha2 0.10.9", + "sha2", "subtle", ] @@ -5541,17 +5323,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der 0.7.10", -] - -[[package]] -name = "spki" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef958a98b9d5da290cfc78946e9f3e61e1e62a18db0d92cac0b83cc161491a9" -dependencies = [ - "base64ct", - "der 0.8.2", + "der", ] [[package]] @@ -5578,7 +5350,7 @@ checksum = "e0cf03c3a7ea88451ff83a129a79451fd9891d44fc76c25e916a11848b81814c" dependencies = [ "base64ct", "pem-rfc7468", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -5594,8 +5366,8 @@ dependencies = [ "rand_core 0.6.4", "rsa", "sec1", - "sha2 0.10.9", - "signature 2.2.0", + "sha2", + "signature", "ssh-cipher-fork-arti", "ssh-encoding-fork-arti", "subtle", @@ -5625,19 +5397,6 @@ dependencies = [ "spin 0.10.1", ] -[[package]] -name = "strobe-rs" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83561175f0a962dea437885589480d216d8741debf853e0d36edd526344fd273" -dependencies = [ - "bitflags 2.13.2", - "byteorder", - "keccak 0.2.2", - "subtle", - "zeroize", -] - [[package]] name = "strsim" version = "0.10.0" @@ -5733,17 +5492,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "synstructure" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - [[package]] name = "sysinfo" version = "0.38.4" @@ -5796,7 +5544,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" dependencies = [ "rustix", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -5888,9 +5636,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" dependencies = [ "displaydoc", "serde_core", @@ -5914,9 +5662,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.54.1" +version = "1.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" dependencies = [ "bytes", "libc", @@ -5965,9 +5713,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.20" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" dependencies = [ "bytes", "futures-core", @@ -5995,14 +5743,14 @@ dependencies = [ [[package]] name = "toml" -version = "1.2.3+spec-1.1.0" +version = "1.1.5+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b1f26e9485c1fa43ee89fe76e9f3fb9e2e52bb227f8594b4d687496b83d073" +checksum = "12c0ba9680044b4ce98d391a62094047eada0d64860b80166c39f4a6b5640785" dependencies = [ "indexmap 2.14.2", "serde_core", - "serde_spanned 1.1.3", - "toml_datetime 1.1.3+spec-1.1.0", + "serde_spanned 1.1.1", + "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", "toml_writer", "winnow 1.0.4", @@ -6019,9 +5767,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "1.1.3+spec-1.1.0" +version = "1.1.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" dependencies = [ "serde_core", ] @@ -6047,7 +5795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b" dependencies = [ "indexmap 2.14.2", - "toml_datetime 1.1.3+spec-1.1.0", + "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", "toml_writer", "winnow 1.0.4", @@ -6055,9 +5803,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.1.7+spec-1.1.0" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb28d6e049a9766c3bd91a8326e6179f5b132dec87906bb97018ef7a2f3431a" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" dependencies = [ "winnow 1.0.4", ] @@ -6070,15 +5818,15 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "toml_writer" -version = "1.2.0+spec-1.1.0" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" [[package]] name = "tor-async-utils" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea51881be51a4dff308071d7cf6489445fd658e821a8bf35c47a4830effd1ab" +checksum = "31d9f28de36ed7646f0f03835ce2e306e2c5df8a1784a2cac27bd549cdc07599" dependencies = [ "cfg-if", "derive-deftly", @@ -6102,9 +5850,9 @@ dependencies = [ [[package]] name = "tor-basic-utils" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235993fcf72e09e597e6b609d52b4cfc2f28bfa8ca827ed304127889639d5776" +checksum = "1a2bd42110ae0faea1d446b35899aa5c3591cd31a94b593aa9264f00baba41da" dependencies = [ "derive-deftly", "derive_more", @@ -6115,7 +5863,7 @@ dependencies = [ "itertools 0.15.0", "libc", "paste", - "rand 0.10.4", + "rand 0.10.2", "rand_chacha 0.10.0", "serde", "slab", @@ -6128,13 +5876,13 @@ dependencies = [ [[package]] name = "tor-bytes" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb3c0504ae2bca19b92e55c869fe58f68688505737ce2ddae85b60b9806ed4c" +checksum = "73de2ba54a125c27a440616f2d806a171bcb4e30013de166c7dc0a79bde44ab4" dependencies = [ "bytes", "derive-deftly", - "digest 0.11.3", + "digest 0.10.7", "educe", "getrandom 0.4.3", "safelog", @@ -6146,9 +5894,9 @@ dependencies = [ [[package]] name = "tor-cell" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6a814400b9bd2a8d07ee89057db816eed53b2b2719066f77630698f0bd2cb0" +checksum = "118f2b6a56605bedd077003ee5678fda215965d550dd0aef21ce8e10dd082750" dependencies = [ "amplify", "bitflags 2.13.2", @@ -6159,7 +5907,7 @@ dependencies = [ "educe", "itertools 0.15.0", "paste", - "rand 0.10.4", + "rand 0.10.2", "smallvec", "thiserror 2.0.20", "tor-basic-utils", @@ -6177,14 +5925,15 @@ dependencies = [ [[package]] name = "tor-cert" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68df0747b5d218cfb2c481b2a267bbdbf89dda2849911630e966eed3dc630f7b" +checksum = "b2cec6ae3abafc382e126a26e74f000bffbbf2c9b1a8c9ec26bb84463f0120b4" dependencies = [ "caret", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", + "saturating-time", "thiserror 2.0.20", "tor-bytes", "tor-checkable", @@ -6195,9 +5944,9 @@ dependencies = [ [[package]] name = "tor-chanmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b5dec2bf27e75dd65bfe9289f24eee230c49ac4a65f85f0ead3b3b3c19f51d" +checksum = "6cef673b170f10790ff81d2f190e0a8150e5c9683c2c8f4c09652a6954c0e5ab" dependencies = [ "async-trait", "base64ct", @@ -6211,7 +5960,7 @@ dependencies = [ "oneshot-fused-workaround", "percent-encoding", "postage", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", "serde_with", @@ -6238,13 +5987,13 @@ dependencies = [ [[package]] name = "tor-checkable" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee5237cfbec5e4e7860b6579932072e2dd3dfa91a950a3d2c4c8c253f405c4a" +checksum = "d3872a5bda49647ad4c4a822c58774995ad3acd02327f1cabe6cfc019d714535" dependencies = [ "humantime", "itertools 0.15.0", - "signature 3.0.0", + "signature", "thiserror 2.0.20", "tor-llcrypto", "web-time-compat", @@ -6252,9 +6001,9 @@ dependencies = [ [[package]] name = "tor-circmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bead875b0e3876110dbfa584ea65af47ed44ebc7ffebb32c460723837aa4843" +checksum = "2cf1eb6c2e3184c9e51c746df81f1a890ba7b663ac418debe2dac3756d840c8a" dependencies = [ "amplify", "async-trait", @@ -6271,7 +6020,7 @@ dependencies = [ "once_cell", "oneshot-fused-workaround", "pin-project", - "rand 0.10.4", + "rand 0.10.2", "retry-error", "safelog", "serde", @@ -6302,9 +6051,9 @@ dependencies = [ [[package]] name = "tor-config" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9788a9af2a0303e4c05a9bdbf08efbba485c4e92978f140713bc5e201f14580" +checksum = "dd8ca5684100c9223590c11685f3f39c4e4c0037c65daddc26927b3ae4cc893d" dependencies = [ "amplify", "cfg-if", @@ -6327,7 +6076,7 @@ dependencies = [ "serde_ignored", "strum", "thiserror 2.0.20", - "toml 1.2.3+spec-1.1.0", + "toml 1.1.5+spec-1.1.0", "tor-basic-utils", "tor-error", "tor-rtcompat", @@ -6337,9 +6086,9 @@ dependencies = [ [[package]] name = "tor-config-path" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d165d5b36b7518e8cf0a51a9ed831019cf9d02afd88b408f2ca8d922710565" +checksum = "cbed06099bacbdbb1d91cfff1032863896d6097c33eece067ab20756e4a6fa2b" dependencies = [ "directories", "serde", @@ -6351,12 +6100,12 @@ dependencies = [ [[package]] name = "tor-consdiff" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "543cd2e0796c7959fe89a2c264ea09ebbb0d1bb70ce4870a2b394ee8d099bbea" +checksum = "9760d0051159a257b1d0065615ad6bc023da4e178d41ff5640222a29852de848" dependencies = [ "derive_more", - "digest 0.11.3", + "digest 0.10.7", "hex", "imara-diff", "static_assertions", @@ -6368,9 +6117,9 @@ dependencies = [ [[package]] name = "tor-dirclient" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d683861c37ff8c0c522c5cdfed94a8f43d8c07fc9ae6ce3622ca29ec1b76db2" +checksum = "403a79a0d00de6c78f15773a284e790459cff6983449e8578490e6b5dfb2afcd" dependencies = [ "async-compression", "base64ct", @@ -6381,6 +6130,7 @@ dependencies = [ "httparse", "httpdate", "itertools 0.15.0", + "memchr", "thiserror 2.0.20", "tor-circmgr", "tor-error", @@ -6396,9 +6146,9 @@ dependencies = [ [[package]] name = "tor-dircommon" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9d4239fe25e4797edc7cf7b6efb4935bcec4552d7fe1ed1b61a30b165736b6" +checksum = "dd5cd2a4f641ecb007cc50914bb1b46128de0975aba08baa56497c8e03c71c71" dependencies = [ "base64ct", "derive-deftly", @@ -6417,15 +6167,15 @@ dependencies = [ [[package]] name = "tor-dirmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed9e6665621160a7065f3bb56f7bbc77b85aff362f0950415dd882e8c22af9" +checksum = "805da4e947311285ce0782ab129df318701c2c08046c316086cb6bb3eb7a463e" dependencies = [ "async-trait", "base64ct", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "event-listener", "fs-mistrust", @@ -6439,14 +6189,13 @@ dependencies = [ "oneshot-fused-workaround", "paste", "postage", - "rand 0.10.4", + "rand 0.10.2", "rusqlite", "safelog", - "saturating-time", "scopeguard", "serde", "serde_json", - "signature 3.0.0", + "signature", "static_assertions", "strum", "thiserror 2.0.20", @@ -6475,9 +6224,9 @@ dependencies = [ [[package]] name = "tor-error" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1caef18eb269eab70a6244cbfc003e92c8a28c4017fa5f7cb17be718787f151c" +checksum = "08f29e906f9f333a6e32e32afac9fb6712ac340191eb3292295b3337682b2dad" dependencies = [ "derive_more", "futures", @@ -6493,9 +6242,9 @@ dependencies = [ [[package]] name = "tor-general-addr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09068bc76af4da4bbf0f17be95693c02253b12ed0aa2b4979bee786a1c7f24b5" +checksum = "7b45ecd95dbf79070f9e477e1d84b22e47f03b2ab2f853abe31887daa9090cf0" dependencies = [ "derive_more", "thiserror 2.0.20", @@ -6504,9 +6253,9 @@ dependencies = [ [[package]] name = "tor-guardmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d430b1785b1e8f6569043b2ae2ca6c340ff5327f39ba3a19b7cfa9c99ad9a1d" +checksum = "3e84beedbf276ce4ea170206b38ca01c995dbf1b9f678e9708f50e2e71dbfef4" dependencies = [ "amplify", "base64ct", @@ -6523,9 +6272,8 @@ dependencies = [ "oneshot-fused-workaround", "pin-project", "postage", - "rand 0.10.4", + "rand 0.10.2", "safelog", - "saturating-time", "serde", "strum", "thiserror 2.0.20", @@ -6549,9 +6297,9 @@ dependencies = [ [[package]] name = "tor-hsclient" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa940dbbff0c4c9323623acb4a49ac40fa227a6a3a07236918f4723db6ab7f9c" +checksum = "3eba66be03b5eb899185e5b4416d8893fdb09a97b33db9e450042f06e2550f0e" dependencies = [ "async-trait", "cfg-if", @@ -6563,7 +6311,7 @@ dependencies = [ "itertools 0.15.0", "oneshot-fused-workaround", "postage", - "rand 0.10.4", + "rand 0.10.2", "retry-error", "safelog", "slotmap-careful", @@ -6595,23 +6343,23 @@ dependencies = [ [[package]] name = "tor-hscrypto" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a262916c319c77cd6dacb3c2aa1e1cdae1d2bf40dae18b1138cf9d544b927dc2" +checksum = "118ff6a69bfa111b6e8d087ffb107ea9cbcd5d4469295cd7ada1b3cf19ba5a0f" dependencies = [ "cipher 0.5.2", "data-encoding", "derive-deftly", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "hex", "humantime", "itertools 0.15.0", "paste", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", - "signature 3.0.0", + "signature", "subtle", "thiserror 2.0.20", "tor-basic-utils", @@ -6628,9 +6376,9 @@ dependencies = [ [[package]] name = "tor-hsservice" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfbd1aa7939e12a7dc56b6eefc1e44444de1f0bdf1a5fbd2eb897e4286733c9" +checksum = "d61a6b5217c14780f54fa1c8610514b1349c93f657304dec98bd8e3083e1a09f" dependencies = [ "amplify", "async-trait", @@ -6639,7 +6387,7 @@ dependencies = [ "derive-deftly", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "fs-mistrust", "futures", @@ -6651,7 +6399,7 @@ dependencies = [ "once_cell", "oneshot-fused-workaround", "postage", - "rand 0.10.4", + "rand 0.10.2", "rand_core 0.10.1", "retry-error", "safelog", @@ -6687,17 +6435,17 @@ dependencies = [ [[package]] name = "tor-key-forge" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2788d37b8b723a83da9c3f22ee44530ffef4bf0fb13588bd88f44c90cdaa9bae" +checksum = "1861b5eebab93515a0ab2401540f3d5a9fb376f1b1535d5793dcd697fb19f928" dependencies = [ "derive-deftly", "derive_more", "downcast-rs", "paste", - "rand 0.10.4", + "rand 0.10.2", "rsa", - "signature 3.0.0", + "signature", "ssh-key-fork-arti", "thiserror 2.0.20", "tor-bytes", @@ -6709,13 +6457,13 @@ dependencies = [ [[package]] name = "tor-keymgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119f0f26e6b2a11cd0868374a2287c786e97f22330cd8a8ff69cee96b08670cb" +checksum = "b3088a573dadebb34acacb30d686751e2a94d12ccf9d6647946ab6c6b4ad5a0e" dependencies = [ "amplify", + "arrayvec", "cfg-if", - "data-encoding", "derive-deftly", "derive_builder_fork_arti", "derive_more", @@ -6726,10 +6474,10 @@ dependencies = [ "humantime", "inventory", "itertools 0.15.0", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", - "signature 3.0.0", + "signature", "ssh-key-fork-arti", "thiserror 2.0.20", "tor-basic-utils", @@ -6750,9 +6498,9 @@ dependencies = [ [[package]] name = "tor-linkspec" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb55ea69084a82b1f69709059ecfcfb3097adaad6d522dff99d8c52735cb899" +checksum = "6d8d3a2aaf3bb67110218b9ff1718cd7d6c7e62226e2fee1a18efa6aa19ff07c" dependencies = [ "base64ct", "by_address", @@ -6777,25 +6525,25 @@ dependencies = [ [[package]] name = "tor-llcrypto" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1f114c13c14b0b2668304e2c9f102534ef95a2a004d1294ede969211c9bc60d" +checksum = "4fee81755528eb34f8352ca6987d5f5c66ebba6af2e4618da4b527f17b0e912e" dependencies = [ "aes 0.9.3", "base64ct", "ctr 0.10.1", - "curve25519-dalek 5.1.0", + "curve25519-dalek", "der-parser", "derive-deftly", "derive_more", - "digest 0.11.3", - "ed25519-dalek 3.0.0", + "digest 0.10.7", + "ed25519-dalek", "educe", "getrandom 0.2.17", "getrandom 0.3.4", "getrandom 0.4.3", "hex", - "rand 0.10.4", + "rand 0.10.2", "rand_chacha 0.10.0", "rand_core 0.10.1", "rand_core 0.6.4", @@ -6806,24 +6554,23 @@ dependencies = [ "safelog", "serde", "sha1", - "sha2 0.11.3", - "sha3 0.12.0", - "shake", - "signature 3.0.0", + "sha2", + "sha3 0.10.9", + "signature", "subtle", "thiserror 2.0.20", "tor-error", "tor-memquota-cost", "visibility", - "x25519-dalek 3.0.0", + "x25519-dalek", "zeroize", ] [[package]] name = "tor-log-ratelim" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea1296076775d399e0b750117c2e1cfba7fe9463add26f056b7c1397c9a3357" +checksum = "2f8696c8ea9090059d91eea287628b5df0b3b4fba433179d893e348857857544" dependencies = [ "futures", "humantime", @@ -6837,9 +6584,9 @@ dependencies = [ [[package]] name = "tor-memquota" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "075e39b9ac84cd15c8249df1499c642e2fbea2a02cc7f146f19df31d771be0dc" +checksum = "03786604757846a5f936285eef397e3fc0ed455893dc5012ceafdf455ada0d8d" dependencies = [ "cfg-if", "derive-deftly", @@ -6869,9 +6616,9 @@ dependencies = [ [[package]] name = "tor-memquota-cost" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7fc75adc50ee789c2ef1633f95647aefc10942bb8a9e6294343dfb574c616c" +checksum = "86d6f7e1d842e6272e414e1f866dc688306b788d368df42e47c4995e040c679c" dependencies = [ "derive-deftly", "itertools 0.15.0", @@ -6881,20 +6628,20 @@ dependencies = [ [[package]] name = "tor-netdir" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27eb00ecbb05d92471bf7ca386ac929ebca28e1034893045679645293bbddbd0" +checksum = "9d3b84edfe732b77fb1420347902c06d92a1e6992e378ad19da6bdadcb8cd798" dependencies = [ "async-trait", "bitflags 2.13.2", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "futures", "hex", "humantime", "itertools 0.15.0", "num_enum", - "rand 0.10.4", + "rand 0.10.2", "serde", "strum", "thiserror 2.0.20", @@ -6914,9 +6661,9 @@ dependencies = [ [[package]] name = "tor-netdoc" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4f3fdfb2e47f82c6a15c11fb9bfac8bd4ec9e4bbff786fc23a8f8438436f040" +checksum = "5b6abd7aaeb2bdbb3fbf760aab9aaa4e8e1a0f8b84d93a834df5a16882faa31e" dependencies = [ "amplify", "base64ct", @@ -6924,7 +6671,7 @@ dependencies = [ "derive-deftly", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "enumset", "extend", @@ -6937,12 +6684,12 @@ dependencies = [ "memchr", "paste", "phf", - "rand 0.10.4", + "rand 0.10.2", "rangemap", "saturating-time", "serde", "serde_with", - "signature 3.0.0", + "signature", "smallvec", "strum", "subtle", @@ -6967,9 +6714,9 @@ dependencies = [ [[package]] name = "tor-persist" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48567a8e69f69edc6cfc3a7bfcd83e9ffb8c16617e81b6a4fbe11c391bd6356f" +checksum = "e6f2a41d13a685e181361cfc3bdf25d319b96b56f5806594b6b8ed760d0099ed" dependencies = [ "amplify", "derive-deftly", @@ -6987,6 +6734,7 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "time", + "tor-async-utils", "tor-basic-utils", "tor-error", "tracing", @@ -6996,9 +6744,9 @@ dependencies = [ [[package]] name = "tor-proto" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ee0a62b16f6bde3e1dee30a20e6c6755c5cd912e781c01b96c9d451886848d" +checksum = "0ddf767335ae2e255025536d48384b92c6b4b8557e5b345be600e7ca2de1c880" dependencies = [ "aes 0.9.3", "amplify", @@ -7014,21 +6762,20 @@ dependencies = [ "derive-deftly", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "enum_dispatch", "futures", "futures-util", - "hkdf 0.13.0", - "hmac 0.13.0", + "hkdf", + "hmac", "itertools 0.15.0", - "metrics", "nonany", "oneshot-fused-workaround", "pin-project", "polyval 0.7.3", "postage", - "rand 0.10.4", + "rand 0.10.2", "rand_core 0.10.1", "safelog", "slotmap-careful", @@ -7054,6 +6801,7 @@ dependencies = [ "tor-memquota", "tor-protover", "tor-rtcompat", + "tor-rtmock", "tor-units", "tracing", "typenum", @@ -7065,14 +6813,12 @@ dependencies = [ [[package]] name = "tor-protover" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac0c7d7cc07222e72cc77231839d23259e4a1fdbbb02345c6c85d8ba142ad352" +checksum = "cab080a7551561bd56c0c2e3578b7114f0853700b96e43613fabc1fe06e5d885" dependencies = [ "caret", "derive-deftly", - "derive_more", - "itertools 0.15.0", "paste", "serde_with", "thiserror 2.0.20", @@ -7082,11 +6828,11 @@ dependencies = [ [[package]] name = "tor-relay-selection" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91947cd895147e04a4600103608a3e935541d399e1a0b1b400788ceb7583b6c5" +checksum = "07a5c22b7cfd59c40e38d4e111906793c0d65cf881e31efe3a83cac42887b1c9" dependencies = [ - "rand 0.10.4", + "rand 0.10.2", "serde", "tor-basic-utils", "tor-linkspec", @@ -7096,9 +6842,9 @@ dependencies = [ [[package]] name = "tor-rtcompat" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ecbaf82921338764c80b302abf5a75671400cc26d1daf3ee91826c653d5b9fc" +checksum = "542f4e13054bbba8d764ee24178fd889f77afb59dca7c6ae0a370604118c20b6" dependencies = [ "amplify", "async-native-tls", @@ -7134,11 +6880,42 @@ dependencies = [ ] [[package]] -name = "tor-socksproto" -version = "0.49.0" +name = "tor-rtmock" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "040951b4e279a0ac1b315a4845b69557f7d1ea1376fa911d482333b0693225a6" +checksum = "04cb78b3a39634e46c1bc795f62fca17b4d8a9404fead18750592a03216e1da3" dependencies = [ + "amplify", + "assert_matches", + "async-trait", + "derive-deftly", + "derive_more", + "educe", + "futures", + "humantime", + "itertools 0.15.0", + "oneshot-fused-workaround", + "pin-project", + "priority-queue", + "slotmap-careful", + "strum", + "thiserror 2.0.20", + "tor-error", + "tor-general-addr", + "tor-rtcompat", + "tracing", + "tracing-test", + "void", + "web-time-compat", +] + +[[package]] +name = "tor-socksproto" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f96e25e5d36b4aff59af40ec86f7ebb227a32b2f726ef1bc8cccf927f8fb31a" +dependencies = [ + "amplify", "caret", "derive-deftly", "educe", @@ -7151,9 +6928,9 @@ dependencies = [ [[package]] name = "tor-units" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475566f8ee463e219980befbdc7b46397c1db5a8f54bd6ac75c41563712c5903" +checksum = "9a562c031f6c1f9d22f7bbcfbe715840d0e2cfe5e59d1296cc26000c17130555" dependencies = [ "derive-deftly", "derive_more", @@ -7284,6 +7061,27 @@ dependencies = [ "tracing-log", ] +[[package]] +name = "tracing-test" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19a4c448db514d4f24c5ddb9f73f2ee71bfb24c526cf0c570ba142d1119e0051" +dependencies = [ + "tracing-core", + "tracing-subscriber", + "tracing-test-macro", +] + +[[package]] +name = "tracing-test-macro" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad06847b7afb65c7866a36664b75c40b895e318cea4f71299f013fb22965329d" +dependencies = [ + "quote", + "syn 2.0.119", +] + [[package]] name = "twox-hash" version = "2.1.4" @@ -7557,9 +7355,9 @@ dependencies = [ [[package]] name = "web-time-compat" -version = "0.3.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f854754465eaf0d17b96236f75c6ddfaebf5907dc31c24ecdc265ffe609756c5" +checksum = "b6ab47578e1cd38415489592da29326341e272bd281f4ddbc0c10b654a425ad7" dependencies = [ "web-time", ] @@ -7915,23 +7713,12 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "rand_core 0.6.4", "serde", "zeroize", ] -[[package]] -name = "x25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e8131a03190127fb2263afc72b322ecadae46b6ff8c6f399ff5d02f5559af6" -dependencies = [ - "curve25519-dalek 5.1.0", - "rand_core 0.10.1", - "zeroize", -] - [[package]] name = "xxhash-rust" version = "0.8.18" @@ -7940,9 +7727,9 @@ checksum = "aee1b19627c7c60102ab80d3a9cbe18de90bfe03bfa6c3715447681f0e8c8af6" [[package]] name = "yoke" -version = "0.8.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -7951,14 +7738,14 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.8.4" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn 3.0.5", - "synstructure 0.14.0", + "syn 2.0.119", + "synstructure", ] [[package]] @@ -7999,7 +7786,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.119", - "synstructure 0.13.2", + "synstructure", ] [[package]] @@ -8035,9 +7822,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.9" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" dependencies = [ "serde", "yoke", @@ -8047,9 +7834,9 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.7" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 7002734..d456e5a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "onionwire" version = "0.2.1" edition = "2024" -# 1.98, not 1.92. Arti 0.49 builds on 1.92, but the default feature set includes +# 1.98, not 1.91. Arti 0.46 builds on 1.91, but the default feature set includes # `cuprate-daemon`, and `tapes` (a Cuprate dep this repo cannot patch) calls # `VecDeque::pop_front_if`, stable only from 1.93. 1.98 is the release CI and # the Android workflows actually build that graph with. `--no-default-features` @@ -36,26 +36,26 @@ rustls = ["arti-client/rustls"] # Cuprate's own `arti` feature stays OFF (and is off in its default feature set, # which is why `default-features = false` is load-bearing): it would link a # second, older Tor stack (arti-client 0.44, which cannot unify with this -# crate's 0.49) next to OnionWire's. The in-process daemon runs clearnet-only; +# crate's 0.46) next to OnionWire's. The in-process daemon runs clearnet-only; # OnionWire's Arti is the only Tor in the process. cuprate-daemon = ["dep:cuprated", "dep:toml"] [dependencies] -arti-client = { version = "0.49", default-features = false, features = [ +arti-client = { version = "0.46", default-features = false, features = [ "tokio", "onion-service-client", "onion-service-service", "compression", ] } futures = "0.3" -safelog = "0.10" +safelog = "0.9" ed25519-dalek = { version = "2", features = ["rand_core"] } rand = "0.8" rusqlite = { version = "0.36", features = ["bundled-sqlcipher-vendored-openssl"] } tokio = { version = "1", features = ["rt-multi-thread", "macros", "io-util", "time", "net"] } -tor-cell = "0.49" -tor-hsservice = "0.49" -tor-rtcompat = { version = "0.49", features = ["tokio"] } +tor-cell = "0.46" +tor-hsservice = "0.46" +tor-rtcompat = { version = "0.46", features = ["tokio"] } # Direct dependency only to select rustls's crypto provider: Arti pulls rustls in # through `tor-rtcompat` with `default-features = false`, and rustls 0.23 # resolves its provider from its OWN `ring`/`aws-lc-rs` features, so without this @@ -75,10 +75,6 @@ sha2 = "0.10" md-5 = "0.10" rpassword = "7" zeroize = { version = "1", features = ["derive"] } -# ML-KEM-768 (FIPS 203). `zeroize` wipes the decapsulation key; `getrandom` -# is how 0.3's `generate_keypair` / `encapsulate` reach the OS RNG. This -# crate's `rand` 0.8 cannot: ml-kem speaks `rand_core` 0.10. -ml-kem = { version = "0.3", features = ["zeroize", "getrandom"] } qrcode = { version = "0.14", default-features = false } cuprated = { git = "https://github.com/Cuprate/cuprate", rev = "4f8fcd1bf468f566fcd89c460d50de4adb6825bf", default-features = false, optional = true } # `cuprated::config::Config` is deserialized, not built field by field: the diff --git a/README.md b/README.md index 21bc666..ec9baec 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,10 @@ Lean Tor messenger: one Rust process (ratatui + Noise IK + sqlite + in-process Arti). No hosted server. Identity is an ed25519 public key; the onion is only a locator. -Current tagged release: **v0.7.0**. Linux TUI + Android SDK/APK. Two people add -each other with an `onionwire:v2:…` invite string (`F2` share / `F3` paste; -~1.9 KB because it carries an ML-KEM-768 key). There is no invite QR graphic. -Chat is Noise IK over your own v3 onion; when the friend was added from a v2 -invite the session is **hybrid** (ML-KEM-768 prelude mixed into the Noise -prologue). A friend from a legacy `onionwire:v1` invite stays classical and the -roster labels them `classical`. Every chat message is ratcheted inside that -session. Unreachable chat peers go to a **local +Current tagged release: **v0.14.0**. Linux TUI + Android SDK/APK. Two people add +each other with an `onionwire:v1:…` invite string (`F2` share / `F3` paste). There +is no invite QR graphic. Chat is Noise IK over your own v3 onion; every chat +message is ratcheted inside that session. Unreachable chat peers go to a **local outbox** (device-only retry queue — no relay). File transfer and payment frames fail closed. Optional Monero: `/pay` invoices, `/tip` payments, and in-app wallet create/import (`F6`). Arti onion services are still experimental. The store is @@ -61,8 +57,8 @@ resulting hash) next to its `.sha256`. **x86_64:** ```bash -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.7.0/onionwire-x86_64-unknown-linux-gnu -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.7.0/onionwire-x86_64-unknown-linux-gnu.sha256 +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.14.0/onionwire-x86_64-unknown-linux-gnu +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.14.0/onionwire-x86_64-unknown-linux-gnu.sha256 sha256sum -c onionwire-x86_64-unknown-linux-gnu.sha256 chmod +x onionwire-x86_64-unknown-linux-gnu ./onionwire-x86_64-unknown-linux-gnu --version @@ -71,8 +67,8 @@ chmod +x onionwire-x86_64-unknown-linux-gnu **aarch64:** ```bash -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.7.0/onionwire-aarch64-unknown-linux-gnu -curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.7.0/onionwire-aarch64-unknown-linux-gnu.sha256 +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.14.0/onionwire-aarch64-unknown-linux-gnu +curl -fL -O https://forgejo.siriusdevops.com/sirius/onionwire/releases/download/v0.14.0/onionwire-aarch64-unknown-linux-gnu.sha256 sha256sum -c onionwire-aarch64-unknown-linux-gnu.sha256 chmod +x onionwire-aarch64-unknown-linux-gnu ./onionwire-aarch64-unknown-linux-gnu --version @@ -103,7 +99,7 @@ format (` onionwire-`). ### Option B — build from source Needs [Rust](https://rustup.rs/) **1.98+** (`edition = "2024"`; `Cargo.toml` -`rust-version = "1.98"`). Arti 0.49 itself builds on 1.92, but the default +`rust-version = "1.98"`). Arti 0.46 itself builds on 1.91, but the default feature set includes the in-process chain daemon, and that graph does not (`tapes` calls `VecDeque::pop_front_if`, stable since 1.93). Do not install `tor`. @@ -134,7 +130,7 @@ system OpenSSL headers or `pkg-config` are required — Arti's TLS backend is `rustls`. The crate version in `Cargo.toml` is **not** bumped by the release workflow. The -tag (`v0.7.0`) is the version users download; `onionwire --version` prints +tag (`v0.14.0`) is the version users download; `onionwire --version` prints `CARGO_PKG_VERSION` from the tree that was built. ### Two instances on one machine @@ -220,13 +216,13 @@ payload can contain `?`). | `j` `k` / `↑` `↓` | Move or scroll the focused pane | | `g` / `G` | Jump to top / bottom of the focused pane | | `?` | Keybinding help (`Esc` closes) | -| `F2` | Share invite (`onionwire:v2:…`, ~1.9 KB) | +| `F2` | Share invite (`onionwire:v1:…`) | | `F3` | Paste a friend's invite | | `F4` | Rotate **onion** (locator only) | | `F5` | Selected friend's profile (`/who`) | | `F6` | Wallet (receive QR, balance, transfers, create/import) | | `F7` | Node & wallet setup (wallet RPC endpoint, chain source, start/stop, live node state) | -| `F8` | Rotate **prekey and ML-KEM key** (hard cut: every friend re-pastes the invite) | +| `F8` | Rotate **prekey** (hard cut: every friend re-pastes the invite) | | `F9` | Wallets & settings menu (`/settings`) | | Enter | Send chat to the selected friend, or run a `/command` | | `Esc` | Close overlay / back to Main / clear composer | @@ -247,22 +243,10 @@ Composer `/commands` (`src/tui.rs` `parse_cmd`): `/wipe`, `/wipe-all`, `/profile There is no invite QR. `F2` opens the share screen with truncated fingerprint, current onion, and the full payload (wrapped, mouse-select to copy): -`onionwire:v2:k=…:o=…:spk=…:kem=…:sig=…` - -The `kem=` field is the 1184-byte ML-KEM-768 public key (base64url), so the -string is about 1.9 KB instead of a few hundred bytes; `C` copies the whole -payload even when the terminal is too short to display all of it. Decode still -accepts a legacy `onionwire:v1:…` invite (no `kem=`): that friend is added as a -**classical** peer and the roster says `classical` next to them. There is no -silent upgrade — only a new signed v2 invite changes that. +`onionwire:v1:k=…:o=…:spk=…:sig=…` Give that string to a friend. They `F3` paste it. Unknown `k` asks for approval. -Same `k` already in the roster updates `onion` (and prekey/KEM key) only. - -No PQ for a legacy v1 peer: they have no `kem_pk`, so the session uses the old -`onionwire-v1` prologue with no ML-KEM secret. A v2 friend always sends the -prelude; a peer that omits it is hard-failed with `prelude required`. A v1-only -build cannot talk to a v2 friend, and that break is intentional. +Same `k` already in the roster updates `onion` (and prekey) only. ## F4 rotate onion @@ -307,24 +291,12 @@ session carries. Wire format: [docs/PROTOCOL.md](docs/PROTOCOL.md). about it is transmitted. - **Only chat is ratcheted.** `loc`, `prf`, `inv`, `rcp`, `tip`, `png`, and `fil` keep the one-shot Noise shape. -- **Chat length is bucketed.** The chat line is padded inside the ratchet - ciphertext to one fixed ladder size (256 B to 32 KiB), so the wire shows a - bucket rather than the exact message length. Timing and retry cadence are - still observable; this hides length only. - Out-of-order delivery works (bounded skipped keys: 2000 per chain jump, 2000 stored). A queued chat message re-sends the *same* `rat ` frame. - `/wipe` clears chat, payments and outbox but **keeps** ratchet state. `/wipe-all` removes the data dir. -- There is no `/reset`. State drops when the friend's prekey or ML-KEM key - changes (you `F3`-paste a refreshed invite). -- **Ratchet steps are hybrid; epoch 0 is not.** Every rotation after the - bootstrap mixes an ML-KEM-768 secret into the chain KDF, so a later X25519 - break does not open a hybrid chain. The bootstrap epoch is still derived only - from the two X25519 prekeys — a per-session KEM secret cannot be folded in - without breaking both-send-first convergence — so messages sent before the - first rotation stay X25519-only at the ratchet layer, and classical (v1) - friends have no PQ layer at all. No full post-quantum forward secrecy is - claimed; see [docs/THREAT_MODEL.md](docs/THREAT_MODEL.md). +- There is no `/reset`. State drops when the friend's prekey changes (you + `F3`-paste a refreshed invite). - An inbound `rat ` frame that does not authenticate is logged as `rat dropped ()` on stderr and dropped. There is no in-app desync banner. @@ -433,9 +405,7 @@ invites interoperate. - **SDK** — `onionwire-sdk-.aar`. UniFFI Kotlin over the same Rust crate the TUI runs. See [crates/onionwire-sdk/README.md](crates/onionwire-sdk/README.md). - **APK** — `onionwire--android-arm64-v8a.apk`. Kotlin + Jetpack Compose. - Build notes: [android/README.md](android/README.md). The UI is a design-token - system (one accent, 16px cards, three-tab shell: Chats / Wallet / Node & - Settings) rather than per-screen styling; see *App shell* in that README. + Build notes: [android/README.md](android/README.md). The APK build is amd64-only. After the Linux `release` workflow finishes, dispatch `android-release` with that tag so the APK/AAR attach to the same @@ -443,7 +413,7 @@ Forgejo release. ```bash scripts/build-android-local.sh # -> dist/, with .sha256 -PUBLISH_TAG=v0.7.0 scripts/build-android-local.sh # + upload to that release +PUBLISH_TAG=v0.14.0 scripts/build-android-local.sh # + upload to that release ``` ## Releases (maintainers) @@ -463,7 +433,7 @@ Actions → **release** → Run workflow: Then dispatch **android-release** with `tag=` to attach the APK + AAR. ```bash -FORGEJO_TOKEN= scripts/build-release-local.sh v0.7.0 +FORGEJO_TOKEN= scripts/build-release-local.sh v0.14.0 ``` Do not run `cargo publish`; `publish = false`. diff --git a/android/README.md b/android/README.md index c3005e6..caa9440 100644 --- a/android/README.md +++ b/android/README.md @@ -61,7 +61,7 @@ Or from the repo root, with checksums and an optional publish step: ```bash scripts/build-android-local.sh # -> dist/onionwire--android-arm64-v8a.apk -PUBLISH_TAG=v0.5.0 scripts/build-android-local.sh +PUBLISH_TAG=v0.14.0 scripts/build-android-local.sh ``` The script re-verifies `android/monero-binaries.sha256` before Gradle, then @@ -310,7 +310,7 @@ workflow first): just created), `dry_run=false`. 2. The Android job **checks out that tag** (`ref:` is the tag, not `main`) and stamps `versionName` / `versionCode` from it. -3. `versionCode` is `major*10000 + minor*100 + patch` (so 0.5.0 → 500). +3. `versionCode` is `major*10000 + minor*100 + patch` (so 0.14.0 → 1400). 4. Publish is a second job on the Pi runner (`docker`). It attaches `onionwire--android-arm64-v8a.apk`, `onionwire-sdk-.aar`, and both `.sha256` files to **that same tag**. @@ -344,20 +344,6 @@ The cuprated graph is built with Rust 1.98 here, the same floor as `ci.yml` (`rust-version = "1.98"`). Job timeout is **90** minutes on `android-release.yml` and **120** on `android-ci.yml`. -## App shell - -Three top-level destinations, one persistent bottom tab bar -(`ui/components/BottomTabBar.kt`): **Chats** (default), **Wallet**, and **Node & -Settings**. Sub-screens (chat, invite share, add contact, rotate, profile, saved -wallets) keep a chevron back button and hide the bar. The rare and destructive -actions — rotate identity, delete message history, saved wallets — are behind the -`⋮` overflow and a typed confirmation, not on the home screen. - -Colours, radii and type live in `ui/Theme.kt` as `OwColors` / `OwRadius` / -`OwSize`; new UI takes tokens from there instead of `MaterialTheme` defaults. -Monospace is reserved for pubkeys, truncated onion locators, seeds, `host:port` -and block heights — never for a sentence. - ## Layout ``` @@ -377,33 +363,25 @@ android/ build.gradle.kts src/main/AndroidManifest.xml src/main/java/com/siriusdevops/onionwire/ - MainActivity.kt # app shell: bottom tabs + NavHost + MainActivity.kt # NavHost WireViewModel.kt # UI-side Wire handle; wallet-child poller crypto/ # Keystore-wrapped store passphrase keepalive/ # NodeHost, KeepAliveService, policy, lifetime wallet/ # ChainStorage, WalletChildBinaries ui/ # Compose screens (M3) - components/ # design system: OwButton, OwSegmentedControl, - # OwAlertBanner, OwCard, OwTopBar, OwBottomTabBar, - # OwConfirmDialog, OwQrCode, Identicon WalletScreen.kt - WalletManagerScreen.kt WalletChildStatusText.kt ChatScreen.kt - RosterScreen.kt # Chats tab: identity bar + roster - SettingsScreen.kt # Node & Settings tab - ProfileScreen.kt - InviteScreens.kt # share (QR + text) and paste-a-contact + RosterScreen.kt + InviteScreens.kt InviteAddFlow.kt OutboxDetail.kt MessageDelivery.kt UnlockScreen.kt UnlockSubmit.kt - SeedBackupGate.kt RotateScreen.kt - Insets.kt # systemBars ∪ ime, minus the tab-bar inset - Theme.kt # design tokens: palette, radii, sizes, typography - src/main/res/drawable/ic_ow_*.xml # single-colour design-system icons + Insets.kt + Theme.kt src/test/ # JVM: envelope, store, invite, outbox, keepalive, wallet line, refresh loop src/androidTest/ # device-only: AndroidKeyStore src/main/jniLibs/arm64-v8a/libmonerowalletrpc.so diff --git a/android/app/src/androidTest/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipherTest.kt b/android/app/src/androidTest/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipherTest.kt index fa1ec83..2763026 100644 --- a/android/app/src/androidTest/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipherTest.kt +++ b/android/app/src/androidTest/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipherTest.kt @@ -3,8 +3,6 @@ package com.siriusdevops.onionwire.crypto import android.content.Context import android.content.pm.PackageManager import android.os.Build -import android.security.keystore.KeyGenParameterSpec -import android.security.keystore.KeyProperties import android.util.Log import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.platform.app.InstrumentationRegistry @@ -14,13 +12,9 @@ import org.junit.Assert.assertFalse import org.junit.Assert.assertNotEquals import org.junit.Assert.assertTrue import org.junit.Assert.fail -import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import java.io.File -import java.security.KeyStore -import javax.crypto.KeyGenerator -import javax.crypto.SecretKey /** * The device half of the Keystore story. The unit-test JVM has no @@ -34,13 +28,6 @@ import javax.crypto.SecretKey * `KeyInfo`/`isInsideSecureHardware`/`securityLevel` report — the point of * [key_backing_is_reported_and_logged] is to print the truth, not to assert a * hardware-backed key on hardware that does not have one. - * - * The migration tests below are the device half of the device-unlock gate: - * a pre-gate key is retired **only** after the replacement blob opens under the - * new key, and an interrupted migration leaves an install that still unlocks. - * They also log `MANUFACTURER`/`MODEL`/`SDK_INT` and the branch taken, because - * `setUnlockedDeviceRequired` is an OEM-sensitive flag and a red test on a - * specific phone is only diagnosable with that line. */ @RunWith(AndroidJUnit4::class) class KeystorePassphraseCipherTest { @@ -52,20 +39,6 @@ class KeystorePassphraseCipherTest { private val passphrase = "correct horse battery staple".toCharArray() - @Before - fun cleanSlate() { - // Both aliases: a leftover gated key from an aborted run would hide a - // migration that never happened. - val store = keyStore() - for (alias in listOf(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED, KeystorePassphraseCipher.ALIAS)) { - try { - store.deleteEntry(alias) - } catch (_: Exception) { - // Nothing to delete. - } - } - } - @After fun tearDown() { cipher.deleteKey() @@ -120,14 +93,12 @@ class KeystorePassphraseCipherTest { val strongBoxAdvertised = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE) val backing = cipher.backing() - val gate = cipher.unlockGateReport() Log.i( - TAG, + "OnionWireKeystore", "alias=${KeystorePassphraseCipher.ALIAS} backing=$backing " + "strongBoxAdvertised=$strongBoxAdvertised " + - "sdk=${Build.VERSION.SDK_INT} device=${Build.MANUFACTURER} ${Build.MODEL} " + - "gate=${gate.describe()}", + "sdk=${Build.VERSION.SDK_INT} device=${Build.MANUFACTURER} ${Build.MODEL}", ) if (strongBoxAdvertised) { @@ -144,9 +115,7 @@ class KeystorePassphraseCipherTest { fun open_does_not_require_user_authentication() { // The card's contract: unlocking must not need a fingerprint. If the // key had been created with setUserAuthenticationRequired(true), this - // open() would throw UserNotAuthenticatedException. The device-unlock - // gate is a different flag: it only refuses while the lock screen is up, - // which is not the case while this test runs. + // open() would throw UserNotAuthenticatedException. val out = cipher.open(cipher.seal(passphrase)) StoreSecret.wipe(out) assertTrue(cipher.keyPresent()) @@ -178,273 +147,4 @@ class KeystorePassphraseCipherTest { } catch (_: SecretUnavailable) { } } - - // ------------------------------------------------------- device-unlock gate - - /** - * The upgrade path: an install that stored its passphrase before the gate - * landed has one pre-gate key and a blob wrapped by it. The next successful - * unlock re-wraps that blob under a newly generated unlock-gated key, proves - * it, and only then retires the old alias. - */ - @Test - fun a_pre_flag_key_is_migrated_to_the_unlock_gated_alias_on_unlock() { - val branch = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - "unlock-gated (API >= 28)" - } else { - "ungated (API < 28 — setUnlockedDeviceRequired unavailable)" - } - Log.i( - TAG, - "migration: manufacturer=${Build.MANUFACTURER} model=${Build.MODEL} " + - "sdk=${Build.VERSION.SDK_INT} branch=$branch", - ) - - val legacy = createPreFlagKey() - val dir = File(context.filesDir, "secrets-migration") - dir.mkdirs() - val store = StoredPassphraseStore(File(dir, "store-passphrase.bin"), cipher) - try { - val blob = StoreSecret.seal(legacy, passphrase) - try { - File(store.path).writeBytes(blob) - } finally { - StoreSecret.wipe(blob) - } - assertTrue("precondition: the pre-gate alias exists", hasAlias(KeystorePassphraseCipher.ALIAS)) - assertFalse( - "precondition: no gated key yet", - hasAlias(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED), - ) - - // The unlock path: load() is where the passphrase is in hand. - val loaded = store.load() as StoredPassphraseStore.Load.Loaded - try { - assertArrayEquals("the unlock must still return the passphrase", passphrase, loaded.passphrase) - } finally { - StoreSecret.wipe(loaded.passphrase) - } - - val gate = cipher.unlockGateReport() - Log.i(TAG, "migration: after=${gate.describe()} legacyPending=${gate.legacyKeyPending}") - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - assertTrue( - "expected a gated key after the re-wrap: ${gate.describe()}", - hasAlias(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED), - ) - assertFalse( - "the pre-gate key must be retired once the new blob verifies: ${gate.describe()}", - hasAlias(KeystorePassphraseCipher.ALIAS), - ) - assertTrue("the report must say the live key is gated: ${gate.describe()}", gate.keyIsUnlockGated) - assertFalse("nothing may stay pending: ${gate.describe()}", gate.legacyKeyPending) - - // The blob on disk must open under the NEW key alone — this is - // the proof the alias delete was allowed to happen. - val onDisk = File(store.path).readBytes() - val back = try { - StoreSecret.open(requireNotNull(gatedKey()), onDisk) - } finally { - StoreSecret.wipe(onDisk) - } - try { - assertArrayEquals(passphrase, back) - } finally { - StoreSecret.wipe(back) - } - } else { - assertFalse( - "API 26–27 has no flag, so no gated key may be invented", - hasAlias(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED), - ) - assertTrue("below API 28 the pre-gate key stays", hasAlias(KeystorePassphraseCipher.ALIAS)) - } - } finally { - store.forget() - dir.deleteRecursively() - } - } - - /** - * Every failure before "the new blob verified" must leave the previous blob - * and the pre-gate key in place. The simulated failure is the proof step - * itself, which is exactly the step that guards the alias delete. - */ - @Test - fun a_failed_re_wrap_keeps_the_pre_gate_key_and_the_previous_blob() { - val legacy = createPreFlagKey() - val dir = File(context.filesDir, "secrets-failed-migration") - dir.mkdirs() - val file = File(dir, "store-passphrase.bin") - try { - val oldBlob = StoreSecret.seal(legacy, passphrase) - try { - file.writeBytes(oldBlob) - } finally { - StoreSecret.wipe(oldBlob) - } - val before = file.readBytes() - try { - val doomed = StoredPassphraseStore(file, FailingVerifyCipher(cipher)) - try { - doomed.save(passphrase) - fail("expected the simulated verification failure") - } catch (e: SecretUnavailable) { - assertTrue( - "the reason must say the old copy was kept: ${e.message}", - e.message!!.contains("previous blob and key were kept"), - ) - } - - assertTrue( - "the pre-gate key must survive a failed re-wrap", - hasAlias(KeystorePassphraseCipher.ALIAS), - ) - assertFalse( - "a failed re-wrap must not leave a temp blob behind", - File(dir, "store-passphrase.bin.tmp").exists(), - ) - assertArrayEquals( - "the previous blob must be untouched by a failed re-wrap", - before, - file.readBytes(), - ) - } finally { - StoreSecret.wipe(before) - } - - // The previous blob is byte-for-byte intact and still opens with the - // pre-gate key: an install that has not migrated is still usable. - val untouched = file.readBytes() - try { - val back = StoreSecret.open(requireNotNull(legacyKey()), untouched) - try { - assertArrayEquals(passphrase, back) - } finally { - StoreSecret.wipe(back) - } - } finally { - StoreSecret.wipe(untouched) - } - - // A save that can verify finishes the migration on the spot. - StoredPassphraseStore(file, cipher).save(passphrase) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - assertFalse( - "the pre-gate key is retired as soon as the re-wrap verifies", - hasAlias(KeystorePassphraseCipher.ALIAS), - ) - assertTrue(hasAlias(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED)) - } - } finally { - cipher.deleteKey() - dir.deleteRecursively() - } - } - - /** - * The mirror of [a_pre_flag_key_is_migrated_to_the_unlock_gated_alias_on_unlock]: - * the proof step must use the gated key only. A fallback decrypt succeeding - * must never be mistaken for "the new blob is wrapped by the new key" — that - * is what would allow the alias delete to destroy the only working copy. - */ - @Test - fun the_gated_proof_refuses_a_blob_wrapped_by_the_pre_gate_key() { - val legacy = createPreFlagKey() - val blob = StoreSecret.seal(legacy, passphrase) - try { - cipher.seal(passphrase) // creates the gated key; the legacy key still exists - try { - cipher.openWithUnlockGate(blob) - fail("a pre-gate blob must not verify under the unlock-gated key") - } catch (_: SecretUnavailable) { - // On API 26–27 there is no gated key at all, so this is the - // "no key to prove against" refusal. Both are refusals. - } - } finally { - StoreSecret.wipe(blob) - } - } - - /** The crash window: gated key created, blob not yet replaced. Must still open. */ - @Test - fun a_blob_wrapped_by_the_pre_gate_key_still_opens_while_both_keys_exist() { - val legacy = createPreFlagKey() - val blob = StoreSecret.seal(legacy, passphrase) - try { - cipher.seal(passphrase) // gated key now exists too - - val out = cipher.open(blob) - try { - assertArrayEquals(passphrase, out) - } finally { - StoreSecret.wipe(out) - } - } finally { - StoreSecret.wipe(blob) - } - } - - // ------------------------------------------------------------------ helpers - - private fun keyStore(): KeyStore = - KeyStore.getInstance(KeystorePassphraseCipher.PROVIDER).apply { load(null) } - - private fun hasAlias(alias: String): Boolean = keyStore().containsAlias(alias) - - private fun key(alias: String): SecretKey? = keyStore().getKey(alias, null) as? SecretKey - - private fun gatedKey(): SecretKey? = key(KeystorePassphraseCipher.ALIAS_UNLOCK_GATED) - - private fun legacyKey(): SecretKey? = key(KeystorePassphraseCipher.ALIAS) - - /** - * Reproduces the key the app generated before the device-unlock gate - * existed: AES-256-GCM under [KeystorePassphraseCipher.ALIAS], no user-auth - * requirement, no unlock requirement. This is the install state the - * migration test starts from, not a new production path. - */ - private fun createPreFlagKey(): SecretKey { - val spec = KeyGenParameterSpec.Builder( - KeystorePassphraseCipher.ALIAS, - KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT, - ) - .setBlockModes(KeyProperties.BLOCK_MODE_GCM) - .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE) - .setKeySize(StoreSecret.KEY_BITS) - .setRandomizedEncryptionRequired(true) - .setUserAuthenticationRequired(false) - .build() - val generator = KeyGenerator.getInstance( - KeyProperties.KEY_ALGORITHM_AES, - KeystorePassphraseCipher.PROVIDER, - ) - generator.init(spec) - return generator.generateKey() - } - - /** - * Delegates to the real Keystore cipher except for the proof step, so the - * "the old key is deleted only after the new blob verifies" ordering can be - * asserted on a device without a way to corrupt a real Keystore blob. - */ - private class FailingVerifyCipher( - private val real: KeystorePassphraseCipher, - ) : PassphraseCipher by real, PassphraseKeyMigration { - override fun unlockGateInEffect(): Boolean = real.unlockGateInEffect() - - override fun legacyKeyPending(): Boolean = real.legacyKeyPending() - - override fun openWithUnlockGate(blob: ByteArray): CharArray = - throw SecretUnavailable("simulated verify failure") - - override fun retireLegacyKey() = real.retireLegacyKey() - - override fun noteMigrationFailure(reason: String) = real.noteMigrationFailure(reason) - } - - private companion object { - const val TAG = KeystorePassphraseCipher.TAG - } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt b/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt index 84d98a4..0cd7f57 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/MainActivity.kt @@ -8,61 +8,37 @@ import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.activity.result.contract.ActivityResultContracts -import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface +import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable -import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier -import androidx.core.view.WindowCompat import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.viewmodel.compose.viewModel -import androidx.navigation.NavHostController import androidx.navigation.NavType import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable -import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import androidx.navigation.navArgument import com.siriusdevops.onionwire.ui.ChatScreen -import com.siriusdevops.onionwire.ui.LocalBottomBarPresent -import com.siriusdevops.onionwire.ui.OnionWireTheme import com.siriusdevops.onionwire.ui.PasteInviteScreen import com.siriusdevops.onionwire.ui.ProfileScreen import com.siriusdevops.onionwire.ui.RosterScreen import com.siriusdevops.onionwire.ui.RotateScreen -import com.siriusdevops.onionwire.ui.SettingsScreen import com.siriusdevops.onionwire.ui.ShareInviteScreen import com.siriusdevops.onionwire.ui.UnlockScreen import com.siriusdevops.onionwire.ui.WalletManagerScreen import com.siriusdevops.onionwire.ui.WalletScreen -import com.siriusdevops.onionwire.ui.components.OwBottomTabBar -import com.siriusdevops.onionwire.ui.components.OwTab +import com.siriusdevops.onionwire.ui.OnionWireTheme import kotlinx.coroutines.launch class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() - // The shell paints the canvas to the bottom of the screen behind the tab - // bar; the system's translucent three-button scrim would draw a second, - // lighter band over it (edge-to-edge guidance, SDK 29+). - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - window.isNavigationBarContrastEnforced = false - } - // enableEdgeToEdge() from ComponentActivity sets the icon appearance from - // the system theme; the app is dark-only, so the bars are always dark with - // light icons. Re-assert it here in case the theme changes under us. - WindowCompat.getInsetsController(window, window.decorView).apply { - isAppearanceLightStatusBars = false - isAppearanceLightNavigationBars = false - } setContent { OnionWireTheme { Surface( @@ -85,7 +61,7 @@ private fun AppRoot(vm: WireViewModel = viewModel()) { // Asked in context: the notification is the keep-alive's only visible // trace, so the prompt lands when the node becomes reachable rather than at // first launch. Denial is not fatal — the service runs either way and the - // settings screen says the notice is hidden. + // roster says the notice is hidden. val askNotifications = rememberLauncherForActivityResult( ActivityResultContracts.RequestPermission(), ) { vm.onNotificationPermissionChanged() } @@ -111,167 +87,86 @@ private fun AppRoot(vm: WireViewModel = viewModel()) { } } -/** Top-level destinations. Everything else is a sub-screen with a chevron. */ -private object Routes { - const val Chats = "chats" - const val Wallet = "wallet" - const val Settings = "settings" - const val Share = "share" - const val Paste = "paste" - const val Rotate = "rotate" - const val Profile = "profile" - const val Wallets = "wallets" - const val Chat = "chat/{pk}" - - fun tabOf(route: String?): OwTab? = when (route) { - Chats -> OwTab.Chats - Wallet -> OwTab.Wallet - Settings -> OwTab.Settings - else -> null - } - - fun routeOf(tab: OwTab): String = when (tab) { - OwTab.Chats -> Chats - OwTab.Wallet -> Wallet - OwTab.Settings -> Settings - } -} - -/** - * The app shell. - * - * A `Scaffold` whose only job is the persistent bottom tab bar: it owns the - * navigation-bar inset, the screens keep owning their own top bars and system - * insets (see `screenContentInsets`), and `LocalBottomBarPresent` tells those - * screens not to pad for the bar a second time. - * - * Selecting a tab pops back to the start destination and restores that tab's - * saved state, so a chat left open behind the Wallet tab is still there when the - * user comes back — the standard bottom-nav contract. - */ @Composable private fun ReadyGraph(vm: WireViewModel, ready: Phase.Ready, keepAliveNote: String?) { val nav = rememberNavController() val friends by vm.friends.collectAsStateWithLifecycle() val scope = rememberCoroutineScope() - val entry by nav.currentBackStackEntryAsState() - val tab = Routes.tabOf(entry?.destination?.route) - Scaffold( - // Each screen's Scaffold applies its own bars; zeroing this one keeps the - // status bar from being padded twice and leaves the only inset this - // level owns — the tab bar's height — in `pad`. - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = MaterialTheme.colorScheme.background, - bottomBar = { - if (tab != null) { - OwBottomTabBar(selected = tab, onSelect = { nav.selectTab(it) }) - } - }, - ) { pad -> - CompositionLocalProvider(LocalBottomBarPresent provides (tab != null)) { - NavHost( - navController = nav, - startDestination = Routes.Chats, - modifier = Modifier.padding(bottom = pad.calculateBottomPadding()), - ) { - composable(Routes.Chats) { - RosterScreen( - fingerprint = ready.fingerprint, - friends = friends, - invite = vm::invite, - onOpenChat = { nav.navigate("chat/${it.pubkeyHex}") }, - onShare = { nav.navigate(Routes.Share) }, - onPaste = { nav.navigate(Routes.Paste) }, - onRotate = { nav.navigate(Routes.Rotate) }, - onWipe = { scope.launch { vm.wipeMessages() } }, - onOpenProfile = { nav.navigate(Routes.Profile) }, - onLock = vm::lock, - onOpenWallets = { nav.navigate(Routes.Wallets) }, - ) - } + NavHost(navController = nav, startDestination = "roster") { + composable("roster") { + RosterScreen( + fingerprint = ready.fingerprint, + onion = ready.onion, + sdkVersion = ready.sdkVersion, + friends = friends, + keepAliveNote = keepAliveNote, + onOpenChat = { nav.navigate("chat/${it.pubkeyHex}") }, + onShare = { nav.navigate("share") }, + onPaste = { nav.navigate("paste") }, + onRotate = { nav.navigate("rotate") }, + onWipe = { scope.launch { vm.wipeMessages() } }, + onOpenProfile = { nav.navigate("profile") }, + onLock = vm::lock, + onOpenWallet = { nav.navigate("wallet") }, + ) + } - composable(Routes.Wallet) { - // A top-level tab, so no back chevron — same shape as the - // Chats and Node & Settings destinations. The catalogue - // sub-screen still gets one from its own top bar. - WalletScreen( - vm = vm, - onOpenWallets = { nav.navigate(Routes.Wallets) }, - ) - } + composable("share") { + ShareInviteScreen(ownerInvite = vm::invite, onBack = { nav.popBackStack() }) + } - composable(Routes.Settings) { - SettingsScreen( - sdkVersion = ready.sdkVersion, - keepAliveNote = keepAliveNote, - onOpenProfile = { nav.navigate(Routes.Profile) }, - onOpenWallets = { nav.navigate(Routes.Wallets) }, - onRotate = { nav.navigate(Routes.Rotate) }, - onWipe = { scope.launch { vm.wipeMessages() } }, - onLock = vm::lock, - ) - } + composable("paste") { + PasteInviteScreen( + onDecode = vm::decode, + onAdd = vm::addFriend, + onBack = { nav.popBackStack() }, + ) + } - composable(Routes.Share) { - ShareInviteScreen(ownerInvite = vm::invite, onBack = { nav.popBackStack() }) - } + composable("rotate") { + RotateScreen( + currentOnion = ready.onion, + onRotate = { + val out = vm.rotateOnion() + out.notified.toInt() to out.friends.toInt() + }, + onBack = { nav.popBackStack() }, + ) + } - composable(Routes.Paste) { - PasteInviteScreen( - onDecode = vm::decode, - onAdd = vm::addFriend, - onBack = { nav.popBackStack() }, - ) - } + composable("wallet") { + WalletScreen( + vm = vm, + onBack = { nav.popBackStack() }, + onOpenWallets = { nav.navigate("wallets") }, + ) + } - composable(Routes.Rotate) { - RotateScreen( - currentOnion = ready.onion, - onRotate = { - val out = vm.rotateOnion() - out.notified.toInt() to out.friends.toInt() - }, - onBack = { nav.popBackStack() }, - ) - } + composable("wallets") { + WalletManagerScreen(vm = vm, onBack = { nav.popBackStack() }) + } - composable(Routes.Wallets) { - WalletManagerScreen(vm = vm, onBack = { nav.popBackStack() }) - } + composable("profile") { + ProfileScreen(vm = vm, onBack = { nav.popBackStack() }) + } - composable(Routes.Profile) { - ProfileScreen(vm = vm, onBack = { nav.popBackStack() }) - } - - composable( - route = Routes.Chat, - arguments = listOf(navArgument("pk") { type = NavType.StringType }), - ) { chatEntry -> - val pk = chatEntry.arguments?.getString("pk").orEmpty() - val friend = friends.firstOrNull { it.pubkeyHex == pk } - ChatScreen( - vm = vm, - peer = pk, - title = friend?.petname?.takeIf { it.isNotBlank() } - ?: friend?.fingerprint - ?: pk.take(16), - fingerprint = friend?.fingerprint ?: pk.take(16), - onion = friend?.onion.orEmpty(), - onBack = { nav.popBackStack() }, - ) - } - } + composable( + route = "chat/{pk}", + arguments = listOf(navArgument("pk") { type = NavType.StringType }), + ) { entry -> + val pk = entry.arguments?.getString("pk").orEmpty() + val friend = friends.firstOrNull { it.pubkeyHex == pk } + ChatScreen( + vm = vm, + peer = pk, + title = friend?.petname?.takeIf { it.isNotBlank() } + ?: friend?.fingerprint + ?: pk.take(16), + fingerprint = friend?.fingerprint ?: pk.take(16), + onion = friend?.onion.orEmpty(), + onBack = { nav.popBackStack() }, + ) } } } - -private fun NavHostController.selectTab(target: OwTab) { - val route = Routes.routeOf(target) - if (currentDestination?.route == route) return - navigate(route) { - popUpTo(graph.startDestinationId) { saveState = true } - launchSingleTop = true - restoreState = true - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt b/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt index 5da0390..cc16ef2 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.kt @@ -15,9 +15,6 @@ import com.siriusdevops.onionwire.keepalive.KeepAliveStatus import com.siriusdevops.onionwire.keepalive.NodeHost import com.siriusdevops.onionwire.ui.SeedBackupGate import com.siriusdevops.onionwire.ui.WalletKeyOrigin -import com.siriusdevops.onionwire.ui.NO_CHAIN_SOURCE_NOTICE -import com.siriusdevops.onionwire.ui.storedWalletBinBlockedReason -import com.siriusdevops.onionwire.ui.walletBinHealPath import com.siriusdevops.onionwire.ui.walletFailureText import com.siriusdevops.onionwire.wallet.ChainStorage import com.siriusdevops.onionwire.wallet.NO_WALLET_RPC_MESSAGE @@ -1018,72 +1015,10 @@ class WireViewModel(app: Application) : AndroidViewModel(app) { */ fun chainFreeBytes(): Long? = ChainStorage.freeBytes(home) - /** - * Repairs a stored `walletRpcBin` this device cannot execute, and reports - * whether it wrote anything back. - * - * A wallet-child record written by an older install can carry the bare name - * `monero-wallet-rpc` (or an empty string). Nothing in an APK sandbox - * resolves a bare name on `PATH`, so `start_wallet_child` spawns it and dies - * with `No such file or directory` — while the Start gate, which only ever - * looked at the *resolved* bundle, stayed green. This re-points the stored - * record at the absolute `nativeLibraryDir` path this install actually - * carries, before anything is spawned. - * - * What it deliberately does not do: - * - it never changes `kind`, host, port, mode, datadir or wallet filename — - * a repair of the binary is not a change of chain source; - * - it does nothing for receive-only (`ChainChoice.NONE`), which stores a - * bin it never spawns; - * - it never overwrites a stored path that exists and is executable, even - * when that path is not the bundled binary — a user who pointed at a real - * file keeps it; - * - it never fails loudly: a repair that cannot be made leaves the stored - * record alone, and the gate then names the path it will try to spawn. - */ - suspend fun healStoredWalletBin(bins: WalletChildBinaryPaths): Result = - withContext(Dispatchers.IO) { - runCatching { - val wire = requireWire() - val stored = runCatching { wire.chainSource() }.getOrNull() - ?: return@runCatching false - if (stored.kind == ChainChoice.NONE) return@runCatching false - val healed = walletBinHealPath(stored.walletRpcBin, bins.walletRpc) - ?: return@runCatching false - wire.setChainSource( - ChainConfig( - kind = stored.kind, - monerodBin = stored.monerodBin, - monerodDatadir = stored.monerodDatadir, - host = stored.host, - port = stored.port, - walletRpcBin = healed, - artiBin = stored.artiBin, - walletFilename = stored.walletFilename, - mainnet = stored.mainnet, - prune = stored.prune, - ), - ) - true - } - }.onSuccess { healed -> - if (healed) { - refreshChainSource() - refreshWalletChild() - } - } - /** * Kick off start on [viewModelScope] so leaving the composition does not * cancel Cuprate launch. Returns immediately; watch [walletChildStarting] * and [walletChildError]. Core status stays `off` until the node answers. - * - * Self-heals the stored binary first, then re-reads that stored record and - * refuses to spawn when it still names a path this device cannot run. The - * screen's gate is the primary door, but an auto-start from a mode tap is - * not the only caller: this is the last place that can stop a doomed spawn, - * and the reason it writes is the named path rather than the core's opaque - * `spawn monero-wallet-rpc: …`. */ fun startWalletChild() { if (!startInFlight.compareAndSet(false, true)) return @@ -1091,20 +1026,6 @@ class WireViewModel(app: Application) : AndroidViewModel(app) { _walletChildError.value = null viewModelScope.launch { try { - val bins = bundledBinaries() - healStoredWalletBin(bins) - val stored = withContext(Dispatchers.IO) { - runCatching { requireWire().chainSource() }.getOrNull() - } - if (stored == null || stored.kind == ChainChoice.NONE) { - _walletChildError.value = NO_CHAIN_SOURCE_NOTICE - return@launch - } - val blocked = storedWalletBinBlockedReason(stored.walletRpcBin, bins.walletRpc) - if (blocked != null) { - _walletChildError.value = blocked - return@launch - } val started = withContext(Dispatchers.IO) { runCatching { requireWire().startWalletChild() } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipher.kt b/android/app/src/main/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipher.kt index c40fce4..1153139 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipher.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/crypto/KeystorePassphraseCipher.kt @@ -1,15 +1,11 @@ package com.siriusdevops.onionwire.crypto -import android.app.KeyguardManager import android.content.Context import android.content.pm.PackageManager import android.os.Build import android.security.keystore.KeyGenParameterSpec import android.security.keystore.KeyInfo import android.security.keystore.KeyProperties -import android.security.keystore.UserNotAuthenticatedException -import android.util.Log -import java.security.GeneralSecurityException import java.security.KeyStore import java.security.ProviderException import javax.crypto.KeyGenerator @@ -17,7 +13,7 @@ import javax.crypto.SecretKey import javax.crypto.SecretKeyFactory /** - * AES-256-GCM key held by the Android Keystore, wrapping the store passphrase. + * AES-256-GCM key held by the Android Keystore under [ALIAS]. * * The key material is never readable by this process (`SecretKey.encoded` is * null for AndroidKeyStore keys) — that is the whole point: pulling @@ -32,99 +28,32 @@ import javax.crypto.SecretKeyFactory * fingerprint to unlock the node would turn "fail closed" into "unusable * unattended", and the SDK's contract is that an unlock either opens the node * or reports why it did not. - * - * ## Device-unlock gate (what this class adds on top of the flag above) - * - * The key is additionally bound to the device's lock state with - * `setUnlockedDeviceRequired(true)` (API 28+): while the lock screen is up, the - * key refuses to decrypt, so a blob lifted off a powered-on-but-locked device - * is not decryptable by the app's own process either. That is still not a - * fingerprint prompt — an unattended unlock on an unlocked device keeps - * working — it only refuses *while the device is locked*. - * - * Two aliases are in play because a Keystore key cannot be retrofitted and - * cannot be re-aliased: - * - * - [ALIAS] (`onionwire.store`) — the pre-gate key. Never generated by this - * class on API 28+; it exists only on installs that stored a passphrase - * before the gate landed. - * - [ALIAS_UNLOCK_GATED] (`onionwire.store.unlock-gated`) — generated with the - * device-unlock requirement. This is the only key a fresh install ever - * creates. - * - * At most one of the two is live after a migration; both exist only in the - * window between "the re-wrapped blob verified" and "the pre-gate key was - * deleted". [StoredPassphraseStore] drives that window, in that order, and is - * the only thing allowed to delete the pre-gate key. - * - * ## What can be *reported* about the gate, honestly - * - * `KeyInfo` on this API range exposes `isUserAuthenticationRequired` but has - * **no getter for the unlock requirement**, so no code here can ask the - * Keystore whether the flag stuck. [unlockGateReport] therefore reports our own - * bookkeeping — "the live key was generated under the unlock-gated alias" — and - * [UnlockGateReport.platformReportsGate] is a constant `false` saying so. On a - * device whose Keystore refuses the flag, the report shows - * `supported && !keyIsUnlockGated` plus the refusal reason; nothing pretends - * otherwise. */ -class KeystorePassphraseCipher(private val context: Context) : - PassphraseCipher, - PassphraseKeyMigration { +class KeystorePassphraseCipher(private val context: Context) : PassphraseCipher { - private var cached: ActiveKey? = null + private var cached: SecretKey? = null - /** Why this process's attempt at an unlock-gated key failed, if it did. */ - private var gateRefusal: String? = null - - /** Why the last re-wrap of the stored blob did not finish. Report-only. */ - private var migrationFailure: String? = null - - override fun seal(plaintext: CharArray): ByteArray { - val key = keyForSeal() - return try { - StoreSecret.seal(key.secret, plaintext) - } catch (e: SecretUnavailable) { - throw gateMessage(e, gatedKeyInPlay = key.gated) - } - } + override fun seal(plaintext: CharArray): ByteArray = + StoreSecret.seal(loadOrCreateKey(), plaintext) /** * Never creates a key. A freshly generated key cannot decrypt an old blob, * and generating one here would turn "the key is gone" into a confusing * GCM tag failure. The caller needs the real reason to tell the user. - * - * A blob written before the gate landed is wrapped by [ALIAS], so an - * unlock-gated key is tried first and the pre-gate key is the fallback — - * that ordering is what makes the crash window of the migration harmless. */ override fun open(blob: ByteArray): CharArray { - val active = activeKey() + val key = cached ?: existingKey() ?: throw SecretUnavailable("the device's Keystore key for OnionWire is gone") - try { - return StoreSecret.open(active.secret, blob) - } catch (first: SecretUnavailable) { - if (active.gated) { - val legacy = existingKey(ALIAS) - if (legacy != null) { - try { - return StoreSecret.open(legacy, blob) - } catch (_: SecretUnavailable) { - // Fall through to the honest report below. - } - } - } - throw gateMessage(first, gatedKeyInPlay = active.gated) - } + return StoreSecret.open(key, blob) } - override fun keyPresent(): Boolean = activeKey() != null + override fun keyPresent(): Boolean = (cached ?: existingKey()) != null override fun backing(): KeyBacking { - val key = activeKey() ?: return KeyBacking.UNKNOWN + val key = cached ?: existingKey() ?: return KeyBacking.UNKNOWN val info = try { - SecretKeyFactory.getInstance(key.secret.algorithm, PROVIDER) - .getKeySpec(key.secret, KeyInfo::class.java) as KeyInfo + SecretKeyFactory.getInstance(key.algorithm, PROVIDER) + .getKeySpec(key, KeyInfo::class.java) as KeyInfo } catch (_: Exception) { // Some OEM Keystore implementations refuse getKeySpec. Report // UNKNOWN rather than guessing hardware backing. @@ -142,189 +71,47 @@ class KeystorePassphraseCipher(private val context: Context) : return if (inSecureHardware) KeyBacking.HARDWARE else KeyBacking.SOFTWARE } - /** Deletes both aliases: `forget()` must leave nothing that can decrypt. */ override fun deleteKey() { cached = null - val store = try { - keyStore() - } catch (_: Exception) { - return - } - for (alias in listOf(ALIAS_UNLOCK_GATED, ALIAS)) { - try { - store.deleteEntry(alias) - } catch (_: Exception) { - // Nothing usable to delete under that alias. - } - } - } - - // ---------------------------------------------------------------- report - - /** - * What can honestly be said about the device-unlock gate on the live key. - * See the class doc: there is no platform getter for the flag itself. - */ - fun unlockGateReport(): UnlockGateReport { - val active = activeKey() - return UnlockGateReport( - supported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.P, - sdkInt = Build.VERSION.SDK_INT, - keyIsUnlockGated = active?.gated == true, - legacyKeyPending = existingKey(ALIAS) != null, - backing = if (active == null) KeyBacking.UNKNOWN else backing(), - gateRefusal = gateRefusal, - migrationFailure = migrationFailure, - ) - } - - private fun logBranch(branch: String) { - Log.i( - TAG, - "wrap key: branch=$branch sdk=${Build.VERSION.SDK_INT} " + - "manufacturer=${Build.MANUFACTURER} model=${Build.MODEL}", - ) - } - - // --------------------------------------------------- PassphraseKeyMigration - - /** - * True when the key [seal] just wrapped with is the unlock-gated one. False - * on API 26–27 and on a device whose Keystore refused the flag — in both - * cases there is nothing to migrate to, and the caller must not delete the - * pre-gate key. - */ - override fun unlockGateInEffect(): Boolean = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && existingKey(ALIAS_UNLOCK_GATED) != null - - override fun legacyKeyPending(): Boolean = existingKey(ALIAS) != null - - /** Decrypts [blob] with the unlock-gated key alone — never the fallback. */ - override fun openWithUnlockGate(blob: ByteArray): CharArray { - val key = existingKey(ALIAS_UNLOCK_GATED) - ?: throw SecretUnavailable("no unlock-gated key exists to prove the blob against") - return try { - StoreSecret.open(key, blob) - } catch (e: SecretUnavailable) { - throw gateMessage(e, gatedKeyInPlay = true) - } - } - - /** - * Deletes [ALIAS]. [StoredPassphraseStore] calls this only after the - * replacement blob is on disk and has been opened back under the new key; - * a blob wrapped by this alias becomes undecryptable the moment it runs. - */ - override fun retireLegacyKey() { - if (!legacyKeyPending()) return try { keyStore().deleteEntry(ALIAS) - } catch (e: Exception) { - noteMigrationFailure("could not delete the pre-gate key under $ALIAS (${e.message})") - return + } catch (_: Exception) { + // Nothing usable to delete. } - if (cached?.gated == false) cached = null - Log.i(TAG, "retired the pre-gate Keystore key under $ALIAS; only $ALIAS_UNLOCK_GATED remains") } - override fun noteMigrationFailure(reason: String) { - migrationFailure = reason - Log.w(TAG, "unlock-gated key migration did not complete: $reason (blob and pre-gate key kept)") - } - - // ------------------------------------------------------------------ keys - - private class ActiveKey(val secret: SecretKey, val gated: Boolean) - - /** Existing key we would decrypt with, unlock-gated first. Never creates. */ - private fun activeKey(): ActiveKey? { + private fun existingKey(): SecretKey? { cached?.let { return it } - existingKey(ALIAS_UNLOCK_GATED)?.let { return ActiveKey(it, gated = true).also { k -> cached = k } } - existingKey(ALIAS)?.let { return ActiveKey(it, gated = false).also { k -> cached = k } } - return null - } - - /** - * The key [seal] uses. Prefers the unlock-gated alias (creating it if the - * platform allows), which is what turns a pre-gate install into a gated one - * the next time a passphrase is stored. - */ - private fun keyForSeal(): ActiveKey { - val active = activeKey() - if (active?.gated == true) return active - return gatedKeyOrCreate() ?: active ?: legacyKeyOrCreate() - } - - private fun gatedKeyOrCreate(): ActiveKey? { - cached?.let { if (it.gated) return it } - existingKey(ALIAS_UNLOCK_GATED)?.let { return ActiveKey(it, gated = true).also { k -> cached = k } } - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) return null - // One attempt per process: a Keystore that refused the flag will refuse - // it again, and unlock must not retry key generation on every call. - if (gateRefusal != null) return null - return try { - val key = generateWithFallback(ALIAS_UNLOCK_GATED, unlockGated = true) - logBranch("unlock-gated alias=$ALIAS_UNLOCK_GATED") - ActiveKey(key, gated = true).also { cached = it } - } catch (e: GeneralSecurityException) { - recordGateRefusal(e) - null - } catch (e: ProviderException) { - recordGateRefusal(e) + val key = try { + keyStore().getKey(ALIAS, null) as? SecretKey + } catch (_: Exception) { null } + cached = key + return key } - private fun legacyKeyOrCreate(): ActiveKey { - cached?.let { if (!it.gated) return it } - existingKey(ALIAS)?.let { return ActiveKey(it, gated = false).also { k -> cached = k } } - val key = generateWithFallback(ALIAS, unlockGated = false) - logBranch( - "ungated alias=$ALIAS" + - (gateRefusal?.let { " (unlock gate refused: $it)" } ?: ""), - ) - return ActiveKey(key, gated = false).also { cached = it } - } + private fun loadOrCreateKey(): SecretKey = cached ?: existingKey() ?: createKey() - private fun recordGateRefusal(e: Exception) { - gateRefusal = "${e.javaClass.simpleName}: ${e.message}" - Log.w( - TAG, - "Keystore refused setUnlockedDeviceRequired(true) under $ALIAS_UNLOCK_GATED; " + - "falling back to the pre-gate alias $ALIAS (=$gateRefusal) " + - "sdk=${Build.VERSION.SDK_INT} manufacturer=${Build.MANUFACTURER} model=${Build.MODEL}", - ) - } - - private fun existingKey(alias: String): SecretKey? = try { - keyStore().getKey(alias, null) as? SecretKey - } catch (_: Exception) { - null - } - - private fun strongBoxAdvertised(): Boolean = - Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && - context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE) - - private fun generateWithFallback(alias: String, unlockGated: Boolean): SecretKey { - if (strongBoxAdvertised()) { + private fun createKey(): SecretKey { + val strongBoxAdvertised = + Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && + context.packageManager.hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE) + if (strongBoxAdvertised) { try { - return generate(alias, strongBox = true, unlockGated = unlockGated) - } catch (e: ProviderException) { + return generate(strongBox = true).also { cached = it } + } catch (_: ProviderException) { // StrongBoxUnavailableException is a ProviderException: the chip // exists but its slots are full, or it refuses AES-256. Fall // through to a normal Keystore key instead of failing unlock. - Log.i(TAG, "StrongBox refused a key under $alias (${e.javaClass.simpleName}: ${e.message})") - } catch (e: GeneralSecurityException) { - Log.i(TAG, "StrongBox refused a key under $alias (${e.javaClass.simpleName}: ${e.message})") } } - return generate(alias, strongBox = false, unlockGated = unlockGated) + return generate(strongBox = false).also { cached = it } } - private fun generate(alias: String, strongBox: Boolean, unlockGated: Boolean): SecretKey { + private fun generate(strongBox: Boolean): SecretKey { val builder = KeyGenParameterSpec.Builder( - alias, + ALIAS, KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT, ) .setBlockModes(KeyProperties.BLOCK_MODE_GCM) @@ -332,14 +119,7 @@ class KeystorePassphraseCipher(private val context: Context) : .setKeySize(StoreSecret.KEY_BITS) // Our IV comes from Cipher.init, and the Keystore supplies it. .setRandomizedEncryptionRequired(true) - // Locked decision: no fingerprint gate on an unattended node. .setUserAuthenticationRequired(false) - if (unlockGated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - // Refuses while the lock screen is up. No user-auth prompt is - // involved, so this does not turn "fail closed" into "unusable - // unattended" — it narrows *when* the key works, not who is awake. - builder.setUnlockedDeviceRequired(true) - } if (strongBox && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { builder.setIsStrongBoxBacked(true) } @@ -350,114 +130,10 @@ class KeystorePassphraseCipher(private val context: Context) : private fun keyStore(): KeyStore = KeyStore.getInstance(PROVIDER).apply { load(null) } - /** - * A gated key refuses to work while the lock screen is up, and the Keystore - * surfaces that as a plain crypto failure. "the stored secret did not - * authenticate" would read as a corrupt blob, so say what happened. - */ - private fun gateMessage(e: SecretUnavailable, gatedKeyInPlay: Boolean): SecretUnavailable { - if (!gatedKeyInPlay) return e - val lockRefusal = e.cause is UserNotAuthenticatedException || deviceLocked() - if (!lockRefusal) return e - return SecretUnavailable( - "the device is locked — the passphrase key is only usable while the device is unlocked", - e, - ) - } - - private fun deviceLocked(): Boolean = - context.getSystemService(KeyguardManager::class.java)?.isDeviceLocked == true - companion object { const val PROVIDER = "AndroidKeyStore" - /** Logcat tag; also what `adb logcat -s OnionWireKeystore` filters on. */ - const val TAG = "OnionWireKeystore" - - /** - * The pre-gate key's alias. Kept as the app's original name: a Keystore - * alias cannot be renamed, so an upgraded install keeps this one until - * [retireLegacyKey] deletes it. - */ + /** One key per app: the passphrase it wraps is the only secret here. */ const val ALIAS = "onionwire.store" - - /** The key that carries `setUnlockedDeviceRequired(true)`. */ - const val ALIAS_UNLOCK_GATED = "onionwire.store.unlock-gated" - } -} - -/** - * Re-wrapping a stored blob under a key that carries the device-unlock - * requirement. - * - * Deliberately **not** part of [PassphraseCipher]: an implementation without a - * Keystore (the JVM fakes in `StoredPassphraseStoreTest`) has nothing to - * migrate, and adding methods to the cipher interface would force every fake to - * grow a no-op. [StoredPassphraseStore] asks for this capability with a safe - * cast and skips migration entirely when it is absent. - */ -interface PassphraseKeyMigration { - - /** - * True when the key the cipher just sealed with is the unlock-gated one. - * When false — API 26/27, or a Keystore that refused the flag — there is - * nothing to migrate to and the pre-gate key must be left alone. - */ - fun unlockGateInEffect(): Boolean - - /** A pre-gate key still exists under [KeystorePassphraseCipher.ALIAS]. */ - fun legacyKeyPending(): Boolean - - /** - * Decrypts [blob] with the unlock-gated key **only**. Used to prove a - * freshly written blob before the pre-gate key is deleted, so a fallback - * decrypt cannot masquerade as proof. - * - * @throws SecretUnavailable when the blob is not wrapped by that key. - */ - fun openWithUnlockGate(blob: ByteArray): CharArray - - /** - * Deletes the pre-gate key. Only valid once the replacement blob is durable - * and [openWithUnlockGate] has proven it. - */ - fun retireLegacyKey() - - /** Records why a re-wrap attempt stopped, for logs and [unlockGateReport]. */ - fun noteMigrationFailure(reason: String) -} - -/** - * What we can honestly say about the device-unlock gate on the live key. - * - * [platformReportsGate] is always `false`: `KeyInfo` has no getter for - * `setUnlockedDeviceRequired`, so the gate state is our own bookkeeping about - * which alias the key was generated under, not a Keystore attestation. - */ -data class UnlockGateReport( - /** API 28+ can carry the flag at all. */ - val supported: Boolean, - val sdkInt: Int, - /** The live key was generated under the unlock-gated alias. */ - val keyIsUnlockGated: Boolean, - /** The pre-gate key still exists — a migration has not completed yet. */ - val legacyKeyPending: Boolean, - val backing: KeyBacking, - /** Set when this process's attempt at a gated key was refused. */ - val gateRefusal: String?, - /** Set when a re-wrap of the stored blob did not finish. */ - val migrationFailure: String?, - /** No platform getter exists for the unlock requirement. Always false. */ - val platformReportsGate: Boolean = false, -) { - /** One honest sentence for logcat / a status line. Never claims hardware proof. */ - fun describe(): String = when { - keyIsUnlockGated -> "key: ${backing.name.lowercase()}, unusable while the device is locked" - !supported -> "key: ${backing.name.lowercase()}, unlock gate unsupported on SDK $sdkInt" - gateRefusal != null -> - "key: ${backing.name.lowercase()}, NOT unlock-gated — the Keystore refused the flag" - legacyKeyPending -> - "key: ${backing.name.lowercase()}, NOT unlock-gated — pre-gate key, migrates on the next unlock" - else -> "key: ${backing.name.lowercase()}, NOT unlock-gated" } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStore.kt b/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStore.kt index 40c89fc..4b88fed 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStore.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/crypto/StoredPassphraseStore.kt @@ -11,27 +11,6 @@ import java.io.IOException * The blob is the envelope from [StoreSecret] — magic + IV + ciphertext + tag. * There is no second copy, no SharedPreferences mirror, and nothing outside the * app's data dir. - * - * ## Migrating the wrapping key to the device-unlock gate - * - * A Keystore key cannot be retrofitted with `setUnlockedDeviceRequired`, so an - * install that stored a passphrase before the gate landed keeps an ungated key - * until the passphrase is in hand again. The only two places that happens are - * the ones below, and both go through the same crash-safe order: - * - * 1. `cipher.seal()` wraps under the unlock-gated key, creating it if needed. - * 2. The new blob is written to `…bin.tmp`. - * 3. Those exact bytes are read back and opened with the unlock-gated key and - * compared to the passphrase in hand. Failure ⇒ temp file dropped, - * everything else untouched (a [SecretUnavailable] with the reason, not a - * bare "did not authenticate"). - * 4. Only then is the temp file renamed over the real blob. - * 5. Only then is the pre-gate Keystore alias deleted. - * - * A crash anywhere before 4 leaves the previous blob and the previous key - * intact; a crash between 4 and 5 leaves a working gated blob plus a stale - * alias that the next save/unlock retires. The pre-gate key is therefore never - * deleted before a blob that supersedes it is proven. */ class StoredPassphraseStore( private val file: File, @@ -47,53 +26,34 @@ class StoredPassphraseStore( /** * Something is stored but cannot be read: the Keystore key is gone or - * unusable, the device is locked, or the file is corrupt. Fall back to - * typing. + * invalidated, or the file is corrupt. Fall back to typing. */ data class Unavailable(val reason: String) : Load } - /** - * The optional key-migration capability. Absent for any cipher that is not - * the Keystore one (the JVM fakes in tests), which simply means there is - * nothing to migrate and the pre-gate order above does not apply. - */ - private fun migrator(): PassphraseKeyMigration? = cipher as? PassphraseKeyMigration - fun exists(): Boolean = file.isFile && file.length() > 0L /** Where the wrapping key actually lives. See [PassphraseCipher.backing]. */ fun backing(): KeyBacking = cipher.backing() - /** True when the stored blob is wrapped by a device-unlock-gated key. */ - fun unlockGated(): Boolean = migrator()?.unlockGateInEffect() == true - /** Path for diagnostics in tests. Never logged with its contents. */ val path: String get() = file.absolutePath /** - * Encrypts and replaces the stored blob, then retires a pre-gate key. - * - * Replaces the blob atomically: written to a sibling temp file, proven to - * open under the key that produced it, and only then renamed, so a crash - * mid-write cannot leave half a blob or a blob nobody can decrypt. - * - * @throws SecretUnavailable when the blob could not be written or could not - * be proven under the unlock-gated key. The previous blob is still in - * place in that case. + * Encrypts and replaces the stored blob. Atomic-ish: written to a sibling + * temp file and renamed, so a crash mid-write cannot leave half a blob. */ fun save(passphrase: CharArray) { require(passphrase.isNotEmpty()) { "refusing to store an empty passphrase" } - // seal() may create the unlock-gated key, so ask about the gate only - // afterwards — on a fresh install there is no gated key before this. val blob = cipher.seal(passphrase) try { - val migration = migrator() - val gated = migration?.unlockGateInEffect() == true - writeVerified(blob, passphrase, if (gated) migration else null) - // The replacement blob is durable and proven. Only now may the - // pre-gate alias go: deleting it earlier would strand a blob. - if (gated) migration?.retireLegacyKey() + file.parentFile?.mkdirs() + val tmp = File(file.parentFile, file.name + ".tmp") + tmp.writeBytes(blob) + if (!tmp.renameTo(file)) { + file.writeBytes(blob) + tmp.delete() + } } finally { StoreSecret.wipe(blob) } @@ -102,10 +62,6 @@ class StoredPassphraseStore( /** * Reads and decrypts the blob. The returned array is the caller's to wipe. * - * A successful read is also the moment the wrapping key can be upgraded: the - * passphrase is in hand, so a pre-gate key is re-wrapped here rather than - * asking the user to type it again. - * * A failed decrypt does **not** delete the blob: a transient Keystore * failure must not silently destroy the user's only copy. Use [forget] to * drop it deliberately. @@ -117,15 +73,13 @@ class StoredPassphraseStore( } catch (e: IOException) { return Load.Unavailable("the stored passphrase file could not be read (${e.message})") } - val passphrase = try { - cipher.open(blob) + return try { + Load.Loaded(cipher.open(blob)) } catch (e: SecretUnavailable) { - return Load.Unavailable(e.message ?: "the stored passphrase did not authenticate") + Load.Unavailable(e.message ?: "the stored passphrase did not authenticate") } finally { StoreSecret.wipe(blob) } - migrateOnSuccessfulUnlock(passphrase) - return Load.Loaded(passphrase) } /** Drops the ciphertext and the Keystore key. Irreversible. */ @@ -134,71 +88,4 @@ class StoredPassphraseStore( File(file.parentFile, file.name + ".tmp").delete() cipher.deleteKey() } - - /** - * Best effort, after a successful unlock. The unlock itself already - * succeeded, so a failed re-wrap must not fail it — but it must not be - * silent either: the reason goes to logcat and to - * [KeystorePassphraseCipher.unlockGateReport], and the install stays - * honestly "not unlock-gated" until a later save/unlock succeeds. - */ - private fun migrateOnSuccessfulUnlock(passphrase: CharArray) { - val migration = migrator() ?: return - if (!migration.unlockGateInEffect() || !migration.legacyKeyPending()) return - try { - save(passphrase) - } catch (e: Exception) { - migration.noteMigrationFailure(e.message ?: e.toString()) - } - } - - /** - * Writes [blob] to the temp file, proves the written bytes open under the - * unlock-gated key alone, and renames it into place. - * - * [verifier] is null when no unlock-gated key exists on this device (API - * 26–27, or a Keystore that refused the flag): the blob is then wrapped by - * the pre-gate key, which is the only key there is. - */ - private fun writeVerified( - blob: ByteArray, - passphrase: CharArray, - verifier: PassphraseKeyMigration?, - ) { - file.parentFile?.mkdirs() - val tmp = File(file.parentFile, file.name + ".tmp") - tmp.writeBytes(blob) - if (verifier != null) { - val written = tmp.readBytes() - try { - val back = try { - verifier.openWithUnlockGate(written) - } catch (e: SecretUnavailable) { - tmp.delete() - throw SecretUnavailable( - "the new passphrase blob did not open under the unlock-gated key; " + - "the previous blob and key were kept", - e, - ) - } - try { - if (!back.contentEquals(passphrase)) { - tmp.delete() - throw SecretUnavailable( - "the new passphrase blob did not read back identically; " + - "the previous blob and key were kept", - ) - } - } finally { - StoreSecret.wipe(back) - } - } finally { - StoreSecret.wipe(written) - } - } - if (!tmp.renameTo(file)) { - file.writeBytes(blob) - tmp.delete() - } - } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt index a5369b4..499b6f8 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt @@ -22,6 +22,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.IconButton @@ -50,9 +51,6 @@ import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwIconButton import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.siriusdevops.onionwire.WireViewModel import uniffi.onionwire_sdk.SendState @@ -61,7 +59,7 @@ import uniffi.onionwire_sdk.SendState @Composable fun ChatScreen( vm: WireViewModel, - /** The peer's public key, hex — the key the open chat's poller runs for. */ + /** The peer's ed25519 pubkey hex — the key the open chat's poller runs for. */ peer: String, title: String, fingerprint: String, @@ -186,11 +184,7 @@ fun ChatScreen( } }, navigationIcon = { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - ) + IconButton(onClick = onBack) { Text("<") } }, colors = TopAppBarDefaults.topAppBarColors( containerColor = MaterialTheme.colorScheme.background, @@ -388,8 +382,7 @@ fun ChatScreen( // Always drawn, never swapped out for a spinner: a button that // changes size under the thumb — or disappears — is how "I hit // send and nothing happened" gets reported. - OwButton( - text = "Send", + Button( enabled = draft.isNotBlank() && pending == null, onClick = send, modifier = Modifier.testTag("chat-send"), diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt index 88a7629..fd7802d 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt @@ -8,18 +8,8 @@ import androidx.compose.foundation.layout.systemBars import androidx.compose.foundation.layout.union import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.runtime.Composable -import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.Modifier -/** - * True while a screen is rendered inside the shell that owns the bottom tab bar. - * - * The tab bar applies the navigation-bar inset itself, so a screen inside the - * shell must not pad for it a second time — that is the difference between the - * list ending just above the tabs and the list floating 48dp above them. - */ -val LocalBottomBarPresent = staticCompositionLocalOf { false } - /** * The bottom + horizontal window insets one screen's content root must apply * itself. @@ -35,9 +25,7 @@ val LocalBottomBarPresent = staticCompositionLocalOf { false } * * The IME's bottom inset already covers the navigation bar, so the two are * unioned (per-side `max`), never summed: keyboard height while typing, - * navigation-bar height otherwise, and no double padding in between. Inside the - * tab shell the vertical bar inset is dropped entirely — see - * [LocalBottomBarPresent]. + * navigation-bar height otherwise, and no double padding in between. * * The `Top` side is deliberately excluded — a `Scaffold`'s `pad.top` is the app * bar's own measured height, and the app bar carries its own status-bar inset @@ -50,15 +38,8 @@ val LocalBottomBarPresent = staticCompositionLocalOf { false } * composable reads — call it from a composable (every call site is one). */ @Composable -fun Modifier.screenContentInsets(): Modifier { - val sides = if (LocalBottomBarPresent.current) { - WindowInsetsSides.Horizontal - } else { - WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom - } - return windowInsetsPadding( - WindowInsets.systemBars.only(sides) - .union(WindowInsets.ime) +fun Modifier.screenContentInsets(): Modifier = + windowInsetsPadding( + WindowInsets.systemBars.union(WindowInsets.ime) .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom), - ) -} + ) \ No newline at end of file diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt index a519bb7..4d67f52 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt @@ -1,9 +1,6 @@ package com.siriusdevops.onionwire.ui import android.content.ClipData -import android.content.ClipDescription -import android.os.Build -import android.os.PersistableBundle import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -14,13 +11,20 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue @@ -28,37 +32,15 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ClipEntry import androidx.compose.ui.platform.LocalClipboard -import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwAlertBanner -import com.siriusdevops.onionwire.ui.components.OwAlertVariant -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwQrCode -import com.siriusdevops.onionwire.ui.components.OwTopBar import kotlinx.coroutines.launch import uniffi.onionwire_sdk.FriendInfo import uniffi.onionwire_sdk.InviteInfo -/** - * Your invite, as a code and as text. - * - * The invite is the one artifact that leaves the device on purpose, so this - * screen is deliberately plain about what it is: one person, one trusted channel, - * nothing published. Both the QR and the text are here because a person pointing - * a camera at a screen and a person pasting into a chat client are different - * people, and neither is wrong. - */ +@OptIn(ExperimentalMaterial3Api::class) @Composable fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) { var invite by remember { mutableStateOf(null) } @@ -74,11 +56,18 @@ fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) { } Scaffold( - topBar = { OwTopBar(title = "Your invite", onBack = onBack) }, + topBar = { + TopAppBar( + title = { Text("Your invite") }, + navigationIcon = { IconButton(onClick = onBack) { Text("<") } }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.background, + ), + ) + }, // The root applies systemBars + IME itself (see `screenContentInsets`), // so Scaffold must not also pad for the navigation bar. contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, ) { pad -> Column( Modifier @@ -86,123 +75,70 @@ fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) { .fillMaxSize() .screenContentInsets() .verticalScroll(rememberScrollState()) - .padding(horizontal = 16.dp), + .padding(16.dp), ) { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Not published anywhere", - description = "Hand this to one person over a channel you already " + - "trust. There is no directory and no lookup — that is the point.", + Text( + "Hand this to one person, over a channel you already trust. " + + "It is not published anywhere and cannot be looked up.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, ) - Spacer(Modifier.height(16.dp)) + Spacer(Modifier.height(12.dp)) when { - error != null -> OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Could not read your invite", - description = error, + error != null -> Text( + error!!, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, ) - invite == null -> Row( - Modifier.fillMaxWidth().padding(vertical = 32.dp), - horizontalArrangement = Arrangement.Center, - ) { CircularProgressIndicator(color = OwColors.Accent) } + invite == null -> CircularProgressIndicator() else -> { - val payload = invite!! - Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.Center) { - OwQrCode(payload = payload, size = 220.dp) - } - Spacer(Modifier.height(16.dp)) - // Four lines, ellipsised: the payload is ~1 KB, and a card - // that grows to fill the screen pushes Copy and Done out of - // reach — the copyable text is a fallback for the QR, not - // the main event. `Copy invite` always carries the whole - // string. - OwCard(Modifier.fillMaxWidth(), padding = 12.dp) { + Card( + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { Text( - payload, - style = MonoStyle.copy(color = OwColors.TextSecondary), - textAlign = TextAlign.Start, - maxLines = 4, - overflow = TextOverflow.Ellipsis, + invite!!, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(12.dp), ) } Spacer(Modifier.height(12.dp)) - Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { - OwButton( - text = if (copied) "Copied" else "Copy invite", - onClick = { - scope.launch { - val clip = ClipData.newPlainText("onionwire invite", payload) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - clip.description.extras = PersistableBundle().apply { - putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true) - } - } - clipboard.setClipEntry(ClipEntry(clip)) - copied = true - } - }, - leadingIconRes = R.drawable.ic_ow_copy, - ) - OwButton( - text = "Done", - variant = OwButtonVariant.Outline, - onClick = onBack, - ) + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + Button(onClick = { + scope.launch { + clipboard.setClipEntry( + ClipEntry(ClipData.newPlainText("onionwire invite", invite!!)), + ) + copied = true + } + }) { Text(if (copied) "Copied" else "Copy") } } - Spacer(Modifier.height(24.dp)) - OwCard(Modifier.fillMaxWidth()) { - Text( - "What is in it", - style = MaterialTheme.typography.titleSmall, - color = OwColors.TextPrimary, - ) - Spacer(Modifier.height(8.dp)) - InviteField("k", "ed25519 identity pubkey — who you are") - InviteField("o", "current onion locator — where you are now") - InviteField("spk", "x25519 signed prekey — session start material") - InviteField("sig", "signature over k‖o‖spk — reject if it fails") - Spacer(Modifier.height(10.dp)) - OwDivider() - Spacer(Modifier.height(10.dp)) - Text( - "The onion in here goes stale when you rotate. The key does " + - "not. If you re-share later, the same k updates their entry — " + - "it never creates a second friend.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } - Spacer(Modifier.height(24.dp)) + Spacer(Modifier.height(20.dp)) + Text("What is in it", style = MaterialTheme.typography.titleSmall) + Spacer(Modifier.height(6.dp)) + Mono("k ed25519 identity pubkey — who you are") + Mono("o current onion locator — where you are now") + Mono("spk x25519 signed prekey — session start material") + Mono("sig signature over k‖o‖spk — reject if it fails") + Spacer(Modifier.height(12.dp)) + Text( + "The onion in here goes stale when you rotate. The key does not. " + + "If you re-share later, the same k updates their entry — it never " + + "creates a second friend.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) } } } } } -@Composable -private fun InviteField(key: String, meaning: String) { - Row(Modifier.padding(vertical = 2.dp), verticalAlignment = Alignment.CenterVertically) { - Text( - key, - style = MonoStyle.copy(color = OwColors.Accent), - modifier = Modifier.padding(end = 10.dp), - ) - Label(meaning) - } -} - -/** - * Paste someone else's invite. - * - * Verification is a separate, explicit step from adding: the preview shows who - * they are and where they are reachable *before* anything is written to the - * roster, because a mistyped or swapped invite is the one thing a human can - * still catch. - */ +@OptIn(ExperimentalMaterial3Api::class) @Composable fun PasteInviteScreen( onDecode: suspend (String) -> InviteInfo, @@ -219,12 +155,19 @@ fun PasteInviteScreen( val adding = flow.adding Scaffold( - topBar = { OwTopBar(title = "Add contact", onBack = onBack) }, + topBar = { + TopAppBar( + title = { Text("Add a friend") }, + navigationIcon = { IconButton(onClick = onBack) { Text("<") } }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.background, + ), + ) + }, // Same inset handoff as the chat composer: with the keyboard up, the // Verify / Approve buttons under the invite field must still be // reachable by scrolling, not by dismissing the keyboard. contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, ) { pad -> Column( Modifier @@ -232,83 +175,90 @@ fun PasteInviteScreen( .fillMaxSize() .screenContentInsets() .verticalScroll(rememberScrollState()) - .padding(horizontal = 16.dp), + .padding(16.dp), ) { - Spacer(Modifier.height(8.dp)) OutlinedTextField( value = raw, onValueChange = { raw = it flow.clear() }, - label = { Text("onionwire:v2:…") }, + label = { Text("onionwire:v1:…") }, minLines = 4, - shape = RoundedCornerShape(OwRadius.Control), modifier = Modifier.fillMaxWidth(), ) Spacer(Modifier.height(12.dp)) - Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) { - OwButton( - text = "Verify", + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + Button( enabled = raw.isNotBlank() && !verifying && !adding, onClick = { scope.launch { flow.verify(raw) } }, - ) + ) { Text("Verify") } if (added != null) { - OwButton(text = "Done", variant = OwButtonVariant.Outline, onClick = onBack) + TextButton(onClick = onBack) { Text("Done") } } } Spacer(Modifier.height(16.dp)) error?.let { - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "That invite was not accepted", - description = "$it — unsigned or tampered invites are rejected " + - "here, before anything is stored.", + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + ) + Spacer(Modifier.height(8.dp)) + Text( + "Unsigned or tampered invites are rejected here, before anything is stored.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, ) - Spacer(Modifier.height(12.dp)) } preview?.let { p -> - OwCard(Modifier.fillMaxWidth()) { - Label("THEY ARE") - Spacer(Modifier.height(2.dp)) - Mono(shortId(p.pubkeyHex, head = 12, tail = 8)) - Spacer(Modifier.height(6.dp)) - Text( - "Compare this fingerprint with them over a second channel " + - "before you trust it.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(10.dp)) - OwDivider() - Spacer(Modifier.height(10.dp)) - Label("REACHABLE AT") - Spacer(Modifier.height(2.dp)) - Mono(shortOnion(p.onion)) + Card( + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + modifier = Modifier.fillMaxWidth(), + ) { + Column(Modifier.padding(12.dp)) { + Label("THEY ARE") + Mono(p.pubkeyHex) + Spacer(Modifier.height(8.dp)) + Text( + "fingerprint ${p.pubkeyHex.take(16)}… — compare this with them " + + "over a second channel before you trust it.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + Spacer(Modifier.height(8.dp)) + Label("REACHABLE AT") + Mono(p.onion) + } } Spacer(Modifier.height(12.dp)) - OwButton( - text = "Approve & add", + Button( enabled = !adding && added == null, onClick = { scope.launch { flow.add(raw) } }, - leadingIconRes = R.drawable.ic_ow_add, - ) + ) { Text("Approve & add") } } added?.let { f -> Spacer(Modifier.height(16.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Added ${f.petname ?: shortId(f.fingerprint)}", - description = "If that key was already in your roster, only the " + - "locator was updated. One key is always one friend.", + Text( + "Added ${f.petname ?: f.fingerprint}", + style = MaterialTheme.typography.titleSmall, + color = MaterialTheme.colorScheme.primary, + ) + Spacer(Modifier.height(4.dp)) + Text( + "If that key was already in your roster, only the locator was updated. " + + "One key is always one friend.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, ) } - Spacer(Modifier.height(24.dp)) } } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt index 5ef799d..b3b41c3 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ProfileScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button import androidx.compose.material3.Card import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api @@ -32,9 +33,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwIconButton import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.siriusdevops.onionwire.WireViewModel import kotlinx.coroutines.launch @@ -56,7 +54,7 @@ import uniffi.onionwire_sdk.checkAddress * store error after it. * - An **empty** address is a real, allowed value: it clears the profile * address. It is labelled with its consequence, because with no profile - * address and no running wallet the core has nothing to hand a payer + * address and no running wallet child the core has nothing to hand a payer * (`Node::wallet_receive_address`) and the invoice path fails. * - The bio is carried, not owned: a save that did not touch the bio field * writes back the value read from the store immediately before the write, so @@ -102,11 +100,7 @@ fun ProfileScreen( TopAppBar( title = { Text("Profile") }, navigationIcon = { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - ) + TextButton(onClick = onBack) { Text("Back") } }, colors = TopAppBarDefaults.topAppBarColors( containerColor = MaterialTheme.colorScheme.background, @@ -211,7 +205,7 @@ fun ProfileScreen( supportingText = { Text( // The consequence, on the screen, before a payment fails: - // `Node::wallet_receive_address` uses the wallet process's + // `Node::wallet_receive_address` uses the wallet child's // subaddress while it is up and this address otherwise, // and with neither there is nothing to be paid to. profileAddressNotice(form.address), @@ -240,8 +234,7 @@ fun ProfileScreen( .padding(12.dp), horizontalArrangement = Arrangement.End, ) { - OwButton( - text = if (busy) "Saving…" else "Save", + Button( onClick = { addressError = null saveError = null @@ -254,7 +247,7 @@ fun ProfileScreen( } if (problem != null) { addressError = problem - return@OwButton + return@Button } scope.launch { busy = true @@ -301,7 +294,9 @@ fun ProfileScreen( }, enabled = !busy && profileSaveEnabled(loaded, form), modifier = Modifier.testTag("profile-save"), - ) + ) { + Text(if (busy) "Saving…" else "Save") + } } status?.let { @@ -437,7 +432,7 @@ internal const val PROFILE_SAVED: String = "profile saved" /** * What an empty address means, stated where the address is typed. * - * `Node::wallet_receive_address` answers with the wallet process's own subaddress + * `Node::wallet_receive_address` answers with the wallet child's own subaddress * while it is up, and this address otherwise; with neither, the invoice path * fails outright. The user should read that here, not after a friend's payment * bounces. @@ -445,7 +440,7 @@ internal const val PROFILE_SAVED: String = "profile saved" internal fun profileAddressNotice(address: String): String = if (address.trim().isEmpty()) { "Empty is allowed, and it clears the profile address. Your receive address " + - "then comes from the running wallet — with no address " + + "then comes from the wallet child while it is running — with no address " + "here and no wallet running, nobody can send you an invoice." } else { "What friends pay to. Validated before it is saved; an invalid address is " + diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt index edfae7a..b1575ca 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RosterScreen.kt @@ -1,14 +1,8 @@ package com.siriusdevops.onionwire.ui -import android.content.ClipData -import android.content.ClipDescription -import android.os.Build -import android.os.PersistableBundle -import android.widget.Toast import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -18,71 +12,38 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width -import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items -import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.platform.ClipEntry -import androidx.compose.ui.platform.Clipboard -import androidx.compose.ui.platform.LocalClipboard -import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Identicon -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonRow -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwConfirmDialog -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwIcon -import com.siriusdevops.onionwire.ui.components.OwIconButton -import com.siriusdevops.onionwire.ui.components.OwOverflowMenu -import com.siriusdevops.onionwire.ui.components.OwStatusDot -import com.siriusdevops.onionwire.ui.components.OwTopBar -import com.siriusdevops.onionwire.ui.components.TorStatusPill -import kotlinx.coroutines.launch import uniffi.onionwire_sdk.FriendInfo -/** - * Home: your identity, and the roster. - * - * Three things changed from the alpha build and they are deliberate: - * - * - The identity block is one compact bar. The old expandable card, the version - * and key-type footnote and the keep-alive paragraph are gone from here: the - * technical lines moved to Node & Settings, and reachability is a status row - * there too. A home screen does not explain the transport before it shows the - * people. - * - The five text-link actions are gone. Invite and Add are the two first-class - * actions (in the empty state, and in the bar); the rare and destructive ones - * live behind the overflow menu. - * - The empty state says what to do next, with the two buttons that do it. - * - * Behaviour is unchanged: every callback here is the ViewModel call the old - * screen made — this screen only decides where the entry points sit. - */ +@OptIn(ExperimentalMaterial3Api::class) @Composable fun RosterScreen( fingerprint: String, + onion: String, + sdkVersion: String, friends: List, - invite: suspend () -> String, + keepAliveNote: String?, onOpenChat: (FriendInfo) -> Unit, onShare: () -> Unit, onPaste: () -> Unit, @@ -90,290 +51,245 @@ fun RosterScreen( onWipe: () -> Unit, onOpenProfile: () -> Unit, onLock: () -> Unit, - onOpenWallets: () -> Unit, + onOpenWallet: () -> Unit, ) { - val context = LocalContext.current - val clipboard = LocalClipboard.current - val scope = rememberCoroutineScope() - var confirmDeleteAll by remember { mutableStateOf(false) } + var confirmWipe by remember { mutableStateOf(false) } + // Closed by default; `rememberSaveable` so a rotation keeps whatever the + // user chose instead of snapping back to (or away from) the summary. + // Nothing about this is worth persisting to the store. + var identityExpanded by rememberSaveable { mutableStateOf(false) } Scaffold( // The content root below consumes systemBars ∪ ime itself (see - // `screenContentInsets`), and the tab bar above this screen consumes the - // navigation-bar inset; zeroing the Scaffold's own insets is what keeps - // the list from being padded twice. + // `screenContentInsets`); zeroing the Scaffold's own insets keeps the + // navigation bar from being applied twice and lets the wipe-confirm + // strip sit above the keyboard instead of under it. contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, topBar = { - OwTopBar( - title = "OnionWire", - status = { TorStatusPill() }, + TopAppBar( + title = { Text("OnionWire") }, actions = { - OwIconButton( - iconRes = R.drawable.ic_ow_lock, - contentDescription = "Lock and stop the node", - onClick = onLock, - ) - OwOverflowMenu( - onOpenProfile = onOpenProfile, - onOpenWallets = onOpenWallets, - onRotate = onRotate, - onWipe = { confirmDeleteAll = true }, - ) + TextButton(onClick = onOpenProfile) { Text("Profile") } + TextButton(onClick = onLock) { Text("Lock") } }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.background, + ), ) }, ) { pad -> Column(Modifier.padding(pad).fillMaxSize().screenContentInsets()) { - IdentityBar( - fingerprint = fingerprint, - onCopyInvite = { - scope.launch { - runCatching { invite() } - .onSuccess { payload -> - copyInvite(clipboard, payload) - Toast.makeText(context, "Invite address copied", Toast.LENGTH_SHORT).show() - } - .onFailure { - Toast.makeText(context, "Could not read the invite", Toast.LENGTH_SHORT).show() - } + + Card( + modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { + Column(Modifier.padding(12.dp)) { + // The disclosure header. Collapsed, this one line *is* the + // identity block: the label, the abbreviated fingerprint, + // and a chevron saying there is more behind it. + Row( + modifier = Modifier + .fillMaxWidth() + .clickable { identityExpanded = !identityExpanded }, + verticalAlignment = Alignment.CenterVertically, + ) { + Label("YOU (stable forever)") + if (!identityExpanded) { + Spacer(Modifier.width(8.dp)) + Mono(shortId(fingerprint)) + } + Spacer(Modifier.weight(1f)) + Text( + if (identityExpanded) "▾" else "▸", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) } - }, - onShare = onShare, - ) - - Spacer(Modifier.height(12.dp)) - - if (friends.isEmpty()) { - EmptyRoster( - modifier = Modifier.weight(1f), - onPaste = onPaste, - onShare = onShare, - ) - } else { - LazyColumn(Modifier.weight(1f).fillMaxWidth()) { - items(friends, key = { it.pubkeyHex }) { f -> - FriendRow(f) { onOpenChat(f) } - OwDivider(Modifier.padding(horizontal = 16.dp)) + if (identityExpanded) { + Mono(fingerprint) + Spacer(Modifier.height(10.dp)) + Label("ONION (locator — rotates)") + Mono(onion) + } + Spacer(Modifier.height(10.dp)) + Text( + "sdk $sdkVersion · identity = ed25519 pubkey", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + if (keepAliveNote != null) { + Spacer(Modifier.height(10.dp)) + Text( + keepAliveNote, + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.primary, + ) } } } - } - } - if (confirmDeleteAll) { - OwConfirmDialog( - title = "Delete all message history?", - body = "Every message body on this device is deleted. Your identity, " + - "your friends and the pending queue are untouched.", - confirmationWord = "DELETE", - confirmLabel = "Delete history", - destructive = true, - onConfirm = { - confirmDeleteAll = false - onWipe() - }, - onDismiss = { confirmDeleteAll = false }, - ) - } -} - -/** - * Your identity, as one bar: identicon, label, truncated pubkey, then the two - * actions a person actually performs here — copy the invite, show it as a code. - */ -@Composable -private fun IdentityBar( - fingerprint: String, - onCopyInvite: () -> Unit, - onShare: () -> Unit, -) { - OwCard( - modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp), - padding = 12.dp, - ) { - Row(verticalAlignment = Alignment.CenterVertically) { - Identicon(seed = fingerprint, size = 40.dp) - Spacer(Modifier.width(12.dp)) - Column(Modifier.weight(1f)) { - Label("Your identity") - Spacer(Modifier.height(2.dp)) - Mono(shortId(fingerprint)) + Spacer(Modifier.height(8.dp)) + Row( + modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp), + horizontalArrangement = Arrangement.SpaceEvenly, + ) { + TextButton(onClick = onShare) { Text("Invite") } + TextButton(onClick = onPaste) { Text("Add") } + TextButton(onClick = onRotate) { Text("Rotate") } + TextButton(onClick = onOpenWallet) { Text("Wallet") } + TextButton(onClick = { confirmWipe = true }) { Text("Wipe chat") } } - OwIconButton( - iconRes = R.drawable.ic_ow_copy, - contentDescription = "Copy invite address", - onClick = onCopyInvite, - ) - Spacer(Modifier.width(8.dp)) - OwIconButton( - iconRes = R.drawable.ic_ow_qr, - contentDescription = "Show your invite", - onClick = onShare, - ) - } - } -} -/** - * The empty roster. - * - * The honest sentence stays: invites are not discoverable, nothing is published. - * The two buttons are the two ways out of this state, in the order that helps — - * paste a peer's invite, or hand yours out. - */ -@Composable -private fun EmptyRoster( - modifier: Modifier = Modifier, - onPaste: () -> Unit, - onShare: () -> Unit, -) { - Column( - modifier = modifier.fillMaxWidth().padding(horizontal = 24.dp), - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally, - ) { - Box( - Modifier - .width(64.dp) - .height(64.dp) - .clip(CircleShape) - .background(OwColors.Surface), - contentAlignment = Alignment.Center, - ) { - // Muted on purpose: the empty state is an invitation, not an alarm. - // The accent stays reserved for the one primary action below it. - OwIcon( - iconRes = R.drawable.ic_ow_shield, - contentDescription = null, - tint = OwColors.TextSecondary, - size = 30.dp, - ) - } - Spacer(Modifier.height(16.dp)) - Text( - "No contacts yet", - style = MaterialTheme.typography.titleMedium.copy(fontSize = 18.sp, lineHeight = 24.sp), - color = OwColors.TextPrimary, - ) - Spacer(Modifier.height(8.dp)) - Text( - "Share your invite over a channel you already trust, or paste a peer's " + - "invite to start an end-to-end encrypted chat. Invites are not " + - "discoverable — nothing is published.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - textAlign = TextAlign.Center, - modifier = Modifier.widthIn(max = 280.dp), - ) - Spacer(Modifier.height(20.dp)) - OwButtonRow(Modifier.widthIn(max = 320.dp)) { - OwButton( - text = "Add contact", - onClick = onPaste, - variant = OwButtonVariant.Primary, - modifier = Modifier.weight(1f), - leadingIconRes = R.drawable.ic_ow_add, - ) - OwButton( - text = "Share my invite", - onClick = onShare, - variant = OwButtonVariant.Secondary, - modifier = Modifier.weight(1f), - ) + if (confirmWipe) { + ConfirmStrip( + text = "Delete every message body? Identity and friends stay.", + confirm = "WIPE", + onConfirm = { confirmWipe = false; onWipe() }, + onCancel = { confirmWipe = false }, + ) + } + + HorizontalDivider(Modifier.padding(vertical = 8.dp)) + + if (friends.isEmpty()) { + Column( + Modifier.fillMaxSize().padding(24.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally, + ) { + Text("No friends yet", style = MaterialTheme.typography.titleMedium) + Spacer(Modifier.height(8.dp)) + Text( + "Share your invite over a channel you already trust, or paste " + + "someone else's. Invites are not discoverable — nothing is published.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + } else { + // weight(1f), not fillMaxSize(): the list must yield height to + // its siblings (the action row and the wipe-confirm strip above + // it) when the IME shrinks the window, instead of claiming all + // of it and pushing them off the bottom. + LazyColumn(Modifier.weight(1f).fillMaxWidth()) { + items(friends, key = { it.pubkeyHex }) { f -> + FriendRow(f) { onOpenChat(f) } + HorizontalDivider() + } + } + } } } } @Composable private fun FriendRow(f: FriendInfo, onClick: () -> Unit) { - Row( + Column( Modifier .fillMaxWidth() .clickable(onClick = onClick) + .background(MaterialTheme.colorScheme.background) .padding(horizontal = 16.dp, vertical = 12.dp), - verticalAlignment = Alignment.CenterVertically, ) { - Column(Modifier.weight(1f)) { - Row(verticalAlignment = Alignment.CenterVertically) { + Row(verticalAlignment = Alignment.CenterVertically) { + Text( + f.petname?.takeIf { it.isNotBlank() } ?: f.fingerprint, + style = MaterialTheme.typography.titleSmall, + ) + if (!f.lastConnectOk) { + Spacer(Modifier.height(0.dp)) Text( - f.petname?.takeIf { it.isNotBlank() } ?: f.fingerprint, - style = MaterialTheme.typography.titleSmall, - color = OwColors.TextPrimary, + " locator stale", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.error, ) - if (!f.lastConnectOk) { - Spacer(Modifier.width(8.dp)) - OwStatusDot(OwColors.Warning) - Spacer(Modifier.width(6.dp)) - Text( - "locator stale", - style = MaterialTheme.typography.labelSmall, - color = OwColors.Warning, - ) - } } - Spacer(Modifier.height(3.dp)) - Text( - shortId(f.fingerprint), - style = MonoStyle, - color = OwColors.TextSecondary, - ) - Text( - shortOnion(f.onion), - style = MonoStyle.copy(color = OwColors.TextMuted), - ) } - Text("›", style = MaterialTheme.typography.titleMedium, color = OwColors.TextMuted) + Spacer(Modifier.height(2.dp)) + Text( + f.fingerprint, + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colorScheme.primary, + ) + Text( + f.onion, + style = MaterialTheme.typography.labelSmall, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) } } -/** - * Clipboard handling for the invite. - * - * The invite is a locator plus a prekey: it is a secret-ish string that opens a - * conversation with you, so the clip is marked sensitive (API 33+) — it will not - * be previewed on the lock screen or indexed by the clipboard UI. Nothing here - * is logged, persisted, or drawn anywhere but the share sheet. - */ -private suspend fun copyInvite(clipboard: Clipboard, text: String) { - val clip = ClipData.newPlainText("onionwire invite", text) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - clip.description.extras = PersistableBundle().apply { - putBoolean(ClipDescription.EXTRA_IS_SENSITIVE, true) - } - } - clipboard.setClipEntry(ClipEntry(clip)) -} - /** * The compact stand-in for a long identity string: `head` characters, an - * ellipsis, then `tail` characters. Pure, so the roster's line and its unit test - * agree on what "short" means. + * ellipsis, then `tail` characters. Pure, so the roster's collapsed line and + * its unit test agree on what "short" means. * * A string no longer than the abbreviation is returned unchanged — the * abbreviation must never grow a value, and a short value must never come back - * mangled. Kotlin strings are UTF-16, but these IDs are hex, so `take`/`takeLast` - * cannot split a surrogate pair here. + * mangled. Kotlin strings are UTF-16, but these IDs are hex, so `take`/ + * `takeLast` cannot split a surrogate pair here. */ fun shortId(id: String, head: Int = 6, tail: Int = 4): String { if (id.length < head + tail + 1) return id return id.take(head) + "…" + id.takeLast(tail) } -/** - * A v3 onion locator shortened for a roster row, with the `.onion` suffix kept - * visible: `abcdefghij…uvwxyz.onion`. - * - * The suffix is the part that tells a reader this is an onion address at all, so - * it is never the part that gets truncated. The full value lives on the profile - * and invite screens, and a v3 locator is never soft-wrapped — a wrapped address - * cannot be copied reliably. - */ -fun shortOnion(onion: String, head: Int = 10, tail: Int = 6): String { - val suffix = ".onion" - if (onion.isEmpty()) return onion - if (!onion.endsWith(suffix)) return onion - val body = onion.removeSuffix(suffix) - if (body.length <= head + tail + 1) return onion - return body.take(head) + "…" + body.takeLast(tail) + suffix +@Composable +fun Label(text: String) { + Text( + text, + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) +} + +@Composable +fun Mono(text: String) { + Text( + text, + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colorScheme.onSurface, + ) +} + +@Composable +fun ConfirmStrip( + text: String, + confirm: String, + onConfirm: () -> Unit, + onCancel: () -> Unit, +) { + var typed by remember { mutableStateOf("") } + Card( + modifier = Modifier.fillMaxWidth().padding(12.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { + Column(Modifier.padding(12.dp)) { + Text(text, style = MaterialTheme.typography.bodySmall) + Spacer(Modifier.height(8.dp)) + androidx.compose.material3.OutlinedTextField( + value = typed, + onValueChange = { typed = it }, + singleLine = true, + label = { Text("Type $confirm") }, + modifier = Modifier.fillMaxWidth(), + ) + Spacer(Modifier.height(8.dp)) + Row(horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth()) { + TextButton(onClick = onCancel) { Text("Cancel") } + TextButton( + onClick = onConfirm, + enabled = typed.trim().equals(confirm, ignoreCase = true), + ) { Text("Confirm") } + } + } + } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt index b84dd11..b1f99b5 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.IconButton @@ -28,12 +29,6 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwIconButton /** * Rotating publishes a brand new onion service and hard-cuts the old one. @@ -59,13 +54,7 @@ fun RotateScreen( topBar = { TopAppBar( title = { Text("Rotate onion") }, - navigationIcon = { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - ) - }, + navigationIcon = { IconButton(onClick = onBack) { Text("<") } }, colors = TopAppBarDefaults.topAppBarColors( containerColor = MaterialTheme.colorScheme.background, ), @@ -110,13 +99,11 @@ fun RotateScreen( ) Spacer(Modifier.height(12.dp)) Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { - OwButton( - text = "Rotate", - variant = OwButtonVariant.Destructive, + Button( enabled = typed.trim().equals("ROTATE", ignoreCase = true) && !busy, onClick = { busy = true; error = null }, - ) + ) { Text("Rotate") } if (busy) CircularProgressIndicator() } } @@ -154,11 +141,7 @@ fun RotateScreen( color = MaterialTheme.colorScheme.onSurfaceVariant, ) Spacer(Modifier.height(16.dp)) - OwButton( - text = "Share the new invite", - variant = OwButtonVariant.Secondary, - onClick = onBack, - ) + Button(onClick = onBack) { Text("Back — share the new invite") } } } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/SettingsScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/SettingsScreen.kt deleted file mode 100644 index c5e5c68..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/SettingsScreen.kt +++ /dev/null @@ -1,215 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwConfirmDialog -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwIconButton -import com.siriusdevops.onionwire.ui.components.OwSectionTitle -import com.siriusdevops.onionwire.ui.components.OwTopBar -import com.siriusdevops.onionwire.ui.components.TorStatusPill - -/** - * The third tab: everything that is not a conversation or a balance. - * - * This is where the alpha build's honest-but-noisy bits went — the SDK line, the - * keep-alive paragraph, the identity rotation and the history wipe. They are not - * hidden; they are one tap away instead of on the screen a person opens twenty - * times a day. No behaviour lives here: every callback is a ViewModel call the - * old roster made. - */ -@Composable -fun SettingsScreen( - sdkVersion: String, - keepAliveNote: String?, - onOpenProfile: () -> Unit, - onOpenWallets: () -> Unit, - onRotate: () -> Unit, - onWipe: () -> Unit, - onLock: () -> Unit, -) { - var confirmDeleteAll by remember { mutableStateOf(false) } - - Scaffold( - contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, - topBar = { - OwTopBar( - title = "Node & Settings", - status = { TorStatusPill() }, - actions = { - OwIconButton( - iconRes = R.drawable.ic_ow_lock, - contentDescription = "Lock and stop the node", - onClick = onLock, - ) - }, - ) - }, - ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()) - .padding(horizontal = 16.dp), - ) { - Spacer(Modifier.height(8.dp)) - - OwCard(Modifier.fillMaxWidth()) { - Label("ACCOUNT") - Spacer(Modifier.height(4.dp)) - SettingsRow( - title = "Your profile", - subtitle = "Name, bio and Monero address", - onClick = onOpenProfile, - ) - OwDivider() - SettingsRow( - title = "Saved wallets", - subtitle = "Open a wallet file, or check its backup", - onClick = onOpenWallets, - ) - } - - Spacer(Modifier.height(12.dp)) - - OwCard(Modifier.fillMaxWidth()) { - Label("REACHABILITY") - Spacer(Modifier.height(6.dp)) - Text( - keepAliveNote ?: "Checking how this app is kept reachable…", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } - - Spacer(Modifier.height(12.dp)) - - OwCard(Modifier.fillMaxWidth()) { - Label("SECURITY & DATA") - Spacer(Modifier.height(4.dp)) - SettingsRow( - title = "Rotate identity", - subtitle = "New onion address. Offline contacts must re-scan your invite.", - onClick = onRotate, - ) - OwDivider() - SettingsRow( - title = "Delete message history", - subtitle = "Removes every message body on this device. Identity and contacts stay.", - danger = true, - onClick = { confirmDeleteAll = true }, - ) - } - - Spacer(Modifier.height(12.dp)) - - OwCard(Modifier.fillMaxWidth()) { - OwSectionTitle("About") - Spacer(Modifier.height(8.dp)) - Row(verticalAlignment = Alignment.CenterVertically) { - Label("IDENTITY") - Spacer(Modifier.width(10.dp)) - Mono("ed25519") - } - Spacer(Modifier.height(4.dp)) - Row(verticalAlignment = Alignment.CenterVertically) { - Label("SDK") - Spacer(Modifier.width(10.dp)) - Mono(sdkVersion) - } - Spacer(Modifier.height(10.dp)) - Text( - "Tor and the chain node run in-process. The wallet is an RPC the app " + - "owns and starts itself.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - } - - Spacer(Modifier.height(24.dp)) - } - } - - if (confirmDeleteAll) { - OwConfirmDialog( - title = "Delete all message history?", - body = "Every message body on this device is deleted. Your identity, " + - "your friends and the pending queue are untouched.", - confirmationWord = "DELETE", - confirmLabel = "Delete history", - destructive = true, - onConfirm = { - confirmDeleteAll = false - onWipe() - }, - onDismiss = { confirmDeleteAll = false }, - ) - } -} - -@Composable -private fun SettingsRow( - title: String, - subtitle: String, - onClick: () -> Unit, - danger: Boolean = false, -) { - Row( - Modifier - .fillMaxWidth() - .clickable(onClick = onClick) - .padding(vertical = 12.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Column(Modifier.weight(1f)) { - Text( - title, - style = MaterialTheme.typography.titleSmall, - color = if (danger) OwColors.Danger else OwColors.TextPrimary, - ) - Spacer(Modifier.height(2.dp)) - Text( - subtitle, - style = MaterialTheme.typography.bodySmall, - color = if (danger) Color(0xCCFF5C5C) else OwColors.TextSecondary, - ) - } - Spacer(Modifier.width(12.dp)) - Text( - "›", - style = MaterialTheme.typography.titleMedium, - color = if (danger) OwColors.Danger else OwColors.TextMuted, - ) - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt index 7133a98..b04565b 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Theme.kt @@ -1,149 +1,34 @@ package com.siriusdevops.onionwire.ui import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Typography import androidx.compose.material3.darkColorScheme import androidx.compose.runtime.Composable import androidx.compose.ui.graphics.Color -import androidx.compose.ui.text.TextStyle -import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -/** - * OnionWire design tokens. - * - * One canvas, two surfaces, one accent. The palette is deliberately small: - * every screen used to invent its own pill and its own grey, which is what made - * the alpha build read as a debug harness. - * - * Typography rule — the reason this file carries a [MonoStyle]: monospace is - * reserved for cryptographic material and numbers (pubkeys, truncated onion - * locators, seeds, `host:port`, block heights). Chrome is sans. A screen that - * sets `fontFamily = FontFamily.Monospace` on a sentence is a bug. - */ -object OwColors { - /** App canvas. */ - val Canvas = Color(0xFF0A0C0E) +private val OnionViolet = Color(0xFF7C4DFF) +private val WireCyan = Color(0xFF38F2C7) +private val DeepVoid = Color(0xFF0B0B10) +private val PanelVoid = Color(0xFF15151C) - /** Cards and elevated surfaces. */ - val Surface = Color(0xFF12161A) - - /** Inputs, secondary buttons, segmented-control track. */ - val SurfaceInteractive = Color(0xFF1C2228) - - /** The one border. 1dp, never a gradient. */ - val Border = Color(0xFF262E36) - - /** Primary brand / accent. Text on top of it is [Canvas], semibold. */ - val Accent = Color(0xFF2EE59D) - - val TextPrimary = Color(0xFFF3F5F7) - val TextSecondary = Color(0xFF9BA3AE) - val TextMuted = Color(0xFF5E6773) - - /** Success / connected is the accent — there is no second green. */ - val Success = Accent - - /** Warning / syncing. Text, 12% tint, 30% border. */ - val Warning = Color(0xFFF5A623) - val WarningTint = Color(0x1FF5A623) - val WarningBorder = Color(0x4DF5A623) - - /** Danger / error / destructive. */ - val Danger = Color(0xFFFF5C5C) - val DangerTint = Color(0x1FFF5C5C) - val DangerBorder = Color(0x4DFF5C5C) - - /** Info banner — the accent at banner tints, no third hue. */ - val InfoTint = Color(0x142EE59D) - val InfoBorder = Color(0x3D2EE59D) -} - -/** Geometry. Buttons and inputs are 12dp squircles, never 999dp pills. */ -object OwRadius { - /** Cards and the identity bar. */ - val Card = 16.dp - - /** Buttons, inputs, icon surfaces, segmented control. */ - val Control = 12.dp - - /** Small status badges and address chips only. */ - val Pill = 999.dp -} - -/** Fixed sizes from the spec. */ -object OwSize { - val Button = 48.dp - val ButtonCompact = 44.dp - val IconButton = 36.dp - val TabBar = 64.dp - val TabBarBorder = 1.dp - val ProgressTrack = 6.dp -} - -/** The only monospace style in the app. */ -val MonoStyle: TextStyle = TextStyle( - fontFamily = FontFamily.Monospace, - fontSize = 13.sp, - lineHeight = 18.sp, - color = OwColors.TextPrimary, -) - -private val OnionWireTypography = Typography( - // Chrome: system sans. No display face, no bundled grotesque. - displaySmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Bold, fontSize = 28.sp, lineHeight = 34.sp), - headlineSmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 22.sp, lineHeight = 28.sp), - titleLarge = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 20.sp, lineHeight = 26.sp), - titleMedium = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 16.sp, lineHeight = 22.sp), - titleSmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Medium, fontSize = 15.sp, lineHeight = 20.sp), - bodyLarge = TextStyle(fontFamily = FontFamily.SansSerif, fontSize = 16.sp, lineHeight = 24.sp), - bodyMedium = TextStyle(fontFamily = FontFamily.SansSerif, fontSize = 14.sp, lineHeight = 20.sp), - bodySmall = TextStyle(fontFamily = FontFamily.SansSerif, fontSize = 13.sp, lineHeight = 18.sp), - labelLarge = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.SemiBold, fontSize = 14.sp, lineHeight = 18.sp), - labelMedium = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Medium, fontSize = 12.sp, lineHeight = 16.sp), - labelSmall = TextStyle(fontFamily = FontFamily.SansSerif, fontWeight = FontWeight.Medium, fontSize = 11.sp, lineHeight = 14.sp, letterSpacing = 0.6.sp), -) - -/** - * The scheme Material components (text fields, dialogs, dividers) still read - * from. New UI should take tokens from [OwColors] directly; `surfaceVariant` - * and `onSurfaceVariant` are mapped so untouched Material defaults do not fall - * back to purple. - */ private val OnionWireColors = darkColorScheme( - primary = OwColors.Accent, - onPrimary = OwColors.Canvas, - primaryContainer = OwColors.SurfaceInteractive, - onPrimaryContainer = OwColors.TextPrimary, - secondary = OwColors.SurfaceInteractive, - onSecondary = OwColors.TextPrimary, - tertiary = OwColors.TextSecondary, - onTertiary = OwColors.Canvas, - background = OwColors.Canvas, - onBackground = OwColors.TextPrimary, - surface = OwColors.Canvas, - onSurface = OwColors.TextPrimary, - surfaceVariant = OwColors.Surface, - onSurfaceVariant = OwColors.TextSecondary, - surfaceContainer = OwColors.Surface, - surfaceContainerHigh = OwColors.SurfaceInteractive, - surfaceContainerLow = OwColors.Surface, - outline = OwColors.Border, - outlineVariant = OwColors.Border, - error = OwColors.Danger, - onError = OwColors.Canvas, - errorContainer = OwColors.DangerTint, - onErrorContainer = OwColors.Danger, - scrim = Color(0xCC000000), + primary = WireCyan, + onPrimary = DeepVoid, + primaryContainer = OnionViolet, + onPrimaryContainer = Color.White, + secondary = OnionViolet, + onSecondary = Color.White, + background = DeepVoid, + onBackground = Color(0xFFE6E6F0), + surface = DeepVoid, + onSurface = Color(0xFFE6E6F0), + surfaceVariant = PanelVoid, + onSurfaceVariant = Color(0xFFB9B9CC), + outline = Color(0xFF3A3A4A), + error = Color(0xFFFF6B6B), + onError = DeepVoid, ) @Composable fun OnionWireTheme(content: @Composable () -> Unit) { - MaterialTheme( - colorScheme = OnionWireColors, - typography = OnionWireTypography, - content = content, - ) + MaterialTheme(colorScheme = OnionWireColors, content = content) } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt index 2f15281..f9804fd 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt @@ -2,11 +2,10 @@ package com.siriusdevops.onionwire.ui import com.siriusdevops.onionwire.wallet.NO_WALLET_RPC_MESSAGE import com.siriusdevops.onionwire.wallet.WalletChildBinaryPaths -import java.io.File import java.util.Locale /** - * One snapshot of the app-owned wallet process, as the wallet screen sees it. + * One snapshot of the app-owned wallet child, as the wallet screen sees it. * * A plain mirror of the fields `WalletChildStatus` carries over UniFFI * (`state`, `running`, `configured`, `chain_source`, `last_error`) — the same @@ -98,7 +97,7 @@ sealed interface WalletChildPhase { data object Unread : WalletChildPhase { override val testTag: String = "child-unread" override val label: String = "reading…" - override val contentDescription: String = "Reading the wallet status" + override val contentDescription: String = "Reading the wallet child status" override val live: Boolean = false override val dead: Boolean = false } @@ -107,7 +106,7 @@ sealed interface WalletChildPhase { data object Off : WalletChildPhase { override val testTag: String = "child-off" override val label: String = "off" - override val contentDescription: String = "The wallet is off" + override val contentDescription: String = "The wallet child is off" override val live: Boolean = false override val dead: Boolean = false } @@ -117,7 +116,7 @@ sealed interface WalletChildPhase { override val testTag: String = "child-connecting" override val label: String = "connecting" override val contentDescription: String = - "The wallet is starting; its RPC has not answered yet" + "The wallet child is up; its wallet RPC has not answered yet" override val live: Boolean = true override val dead: Boolean = false } @@ -136,7 +135,7 @@ sealed interface WalletChildPhase { data object Ready : WalletChildPhase { override val testTag: String = "child-ready" override val label: String = "ready" - override val contentDescription: String = "The wallet is ready" + override val contentDescription: String = "The wallet child is ready" override val live: Boolean = true override val dead: Boolean = false } @@ -145,7 +144,7 @@ sealed interface WalletChildPhase { data class Exited(val reason: String?) : WalletChildPhase { override val testTag: String = "child-exited" override val label: String = "exited" - override val contentDescription: String = "The wallet process exited" + override val contentDescription: String = "The wallet child exited" override val live: Boolean = false override val dead: Boolean = true } @@ -159,7 +158,7 @@ sealed interface WalletChildPhase { override val testTag: String = "child-unrecognised" override val label: String = "unknown (${shortSendReason(raw, UNRECOGNISED_BUDGET)})" override val contentDescription: String = - "The wallet reported a state this build does not know" + "The wallet child reported a state this build does not know" override val live: Boolean = false override val dead: Boolean = false } @@ -337,26 +336,25 @@ const val ONION_NEEDS_ARTI_NOTICE: String = "A .onion daemon needs the arti SOCKS child, which this build does not bundle." /** Shown while the first `wallet_status()` read is still in flight. */ -const val READING_CHILD_NOTICE: String = "Reading the wallet status…" +const val READING_CHILD_NOTICE: String = "Reading the wallet child status…" const val STARTING_CHILD_NOTICE: String = "Start is running. Status stays off until the on-device node answers — that can take a minute, and is not a dead button." /** - * The alert banner the on-device node is offered with, **before** Start. + * The caveat the on-device node is offered with, **before** Start. * * Cuprate's own user book says *"do NOT use cuprated for any serious purposes"*, * its `monerod` RPC parity is incomplete (Cuprate issue #278, and the four gaps - * measured in this repo are in `docs/cuprate-launch-spike.md`), and mainnet is - * unvalidated. The title is the banner's; the two sentences are the body — one - * copy of the caveat, never a second one elsewhere on the screen, so the two - * can never drift apart. + * measured in this repo are in `docs/cuprate-launch-spike.md`), and the daemon + * this app launches is pinned to **testnet** (`src/cuprate.rs`). One sentence, not + * a glyph: the choice is opt-in and never a default, and a user who reads only + * this line still knows what they picked. */ -const val CUPRATE_ON_DEVICE_TITLE: String = "Experimental On-Device Node (Cuprate)" -const val CUPRATE_ON_DEVICE_BODY: String = - "Pre-production software with incomplete RPC parity (#278). Do not use for significant " + - "funds. Mainnet is unvalidated, and Cuprate's own user book says do NOT use cuprated " + - "for any serious purposes." +const val CUPRATE_PREPRODUCTION_WARNING: String = + "On-device node is Cuprate, which is pre-production: its own user book says do NOT use " + + "cuprated for any serious purposes, mainnet is unvalidated, and its monerod RPC parity " + + "is incomplete (Cuprate issue #278). Try the in-process path; do not hold funds on it." /** * This build was compiled without the `cuprate-daemon` feature, so the stored @@ -447,21 +445,13 @@ fun selectedCuprateMode(inProcess: Boolean, mainnet: Boolean, prune: Boolean): C /** * Tapping a mode used to only persist `ChainConfig`, which looked like a no-op - * besides the storage line. Start when the storage floor would allow Start, - * **the Start gate itself would allow it**, and a launch is not already in - * flight. - * - * [startBlocked] is the same reason the Start button is disabled by - * (`startGateReason`). A mode tap stores the source either way, but persisting - * a choice must never launch a child the gate would refuse — the old - * storage-only predicate is exactly how an auto-start slipped past a stored - * binary that could not run. + * besides the storage line. Start when the storage floor would allow Start and + * a launch is not already in flight. */ fun shouldStartAfterSelectingChain( storageBlocked: String?, starting: Boolean, - startBlocked: String? = null, -): Boolean = storageBlocked == null && startBlocked == null && !starting +): Boolean = storageBlocked == null && !starting /** * Bytes as a screen-sized string. Binary units (a "GB" that is really a GiB is how @@ -473,131 +463,6 @@ fun formatBytes(bytes: Long): String = when { else -> "$bytes B" } -/** - * A block height with thousands separators: `3794383` → `3,794,383`. - * - * Hand-grouped rather than `String.format("%,d")` on purpose: the grouped - * format is locale-dependent (some locales use a period or a non-breaking - * space), and a block height is a number in a monospace column, not prose. The - * screen and its test must print the same string everywhere. - */ -fun formatBlockCount(blocks: ULong): String { - val digits = blocks.toString() - val out = StringBuilder(digits.length + digits.length / 3) - digits.forEachIndexed { i, c -> - if (i > 0 && (digits.length - i) % 3 == 0) out.append(',') - out.append(c) - } - return out.toString() -} - -/** - * What the node card's progress header renders for one height / target pair. - * - * [percentText] and [blockText] are null when there is nothing honest to say — - * and `target == 0` is exactly that: the daemon reporting **no target** is not - * evidence of being caught up (`src/wallet.rs` returns `0` for a height it does - * not have, and Cuprate omits the target even at the tip). A percentage invented - * from a zero target would read as progress; an unknown target is said in words. - */ -data class SyncProgress( - /** 0f..1f of the track to fill. `0f` whenever the target is unknown. */ - val fraction: Float, - /** `12.8%`, or null when the daemon reported no target. */ - val percentText: String?, - /** `Block 485,253 of 3,794,383`, or null when neither number is known. */ - val blockText: String?, -) - -fun syncProgress(height: ULong, target: ULong): SyncProgress { - if (height == 0uL && target == 0uL) return SyncProgress(0f, null, null) - if (target == 0uL) { - return SyncProgress( - fraction = 0f, - percentText = null, - blockText = "Block ${formatBlockCount(height)} of an unknown target", - ) - } - val fraction = (height.toDouble() / target.toDouble()).coerceIn(0.0, 1.0) - return SyncProgress( - fraction = fraction.toFloat(), - percentText = String.format(Locale.US, "%.1f%%", fraction * 100.0), - blockText = "Block ${formatBlockCount(height)} of ${formatBlockCount(target)}", - ) -} - -/** - * The balance line, with the core's two sentinels translated into words. - * - * `walletBalance()` does not throw: it answers `off` (no chain source is - * configured at all) or `err` (configured, but the read failed — no wallet file - * open, or the process is down) and a formatted amount otherwise. Printing - * either sentinel raw is what put the string `wallet off` on the wallet screen; - * printing the same word for both is worse, because they are fixed in different - * places. The sentinels themselves are the core's contract and are not touched - * here — this is the display only. - */ -fun noWalletBalanceHeadline(balance: String?): String = when (balance) { - null -> "…" - "off" -> "No Wallet Loaded" - "err" -> "Balance unavailable" - else -> balance -} - -/** `Mainnet Pruned` / `Mainnet Full` / `Testnet` — the three stored modes, as words. */ -fun chainModeLabel(mainnet: Boolean, prune: Boolean): String = when { - !mainnet -> "Testnet" - prune -> "Mainnet Pruned" - else -> "Mainnet Full" -} - -/** - * How the node card's header reads. [tone] is the status dot's colour class, not - * a decoration: it is the caller's statement about the core's own word. - */ -enum class NodeStatusTone { - /** Nothing is running, and nothing is wrong. */ - Idle, - - /** Up, or on its way up. */ - Busy, - - /** Answered and at the tip. */ - Good, - - /** A state the app cannot read, or a process that is gone. */ - Bad, -} - -data class NodeStatusHead(val title: String, val tone: NodeStatusTone) - -/** - * The header sentence for the node card, from the core's `state` alone. - * - * Fail-closed exactly as [walletChildPhase] is: an unrecognised state gets - * [NodeStatusTone.Bad] and never reads as ready. A running child that has not - * answered is `Connecting…`, not `Ready` — the RPC has not spoken yet. - */ -fun nodeStatusHead( - input: WalletChildInput?, - inProcess: Boolean = false, - mainnet: Boolean = false, - prune: Boolean = false, -): NodeStatusHead { - val mode = if (inProcess) " (${chainModeLabel(mainnet, prune)})" else "" - return when (walletChildPhase(input)) { - WalletChildPhase.Unread -> NodeStatusHead("Reading wallet status", NodeStatusTone.Idle) - WalletChildPhase.Off -> - NodeStatusHead(if (inProcess) "Node Idle$mode" else "Wallet Offline", NodeStatusTone.Idle) - WalletChildPhase.Connecting -> NodeStatusHead("Connecting…", NodeStatusTone.Busy) - WalletChildPhase.Syncing -> - NodeStatusHead(if (inProcess) "Syncing Node$mode" else "Syncing Wallet", NodeStatusTone.Busy) - WalletChildPhase.Ready -> NodeStatusHead("Wallet Ready", NodeStatusTone.Good) - is WalletChildPhase.Exited -> NodeStatusHead("Wallet Stopped", NodeStatusTone.Bad) - is WalletChildPhase.Unrecognised -> NodeStatusHead("Unknown wallet state", NodeStatusTone.Bad) - } -} - /** * Why **Start** is not actionable, or `null` when it is. * @@ -614,11 +479,8 @@ fun startBlockedReason( bins.walletRpc == null -> NO_WALLET_RPC_MESSAGE starting -> STARTING_CHILD_NOTICE input == null -> READING_CHILD_NOTICE - // Unreachable from the wallet screen: while the wallet runs the lifecycle - // control *is* Stop, so Start is never offered. Kept as a pure predicate so - // a stale status read cannot turn the one control into a no-op tap. - input.running -> "The wallet is already running." - !input.configured -> NO_CHAIN_SOURCE_NOTICE + input.running -> "The wallet child is already running." + !input.configured -> "No chain source yet: a wallet child needs a daemon to dial." // The stored source is the app's own node but this build has no daemon: the // option is readable and unstoppable, so say it before the user presses Start. input.chainInProcess && !input.nodeAvailable -> CUPRATE_NOT_IN_BUILD_NOTICE @@ -626,179 +488,13 @@ fun startBlockedReason( else -> null } -/** The stored config names no chain source, so there is no daemon to dial. */ -const val NO_CHAIN_SOURCE_NOTICE: String = - "No chain source yet: the wallet needs a daemon to dial." - -/** - * Whether [path] is a file this process may `exec`, measured the way the kernel - * will measure it at spawn time. A missing file and an existing file without - * the execute bit are both "cannot run here" — they differ only in errno. - * - * Never throws: a path the filesystem refuses to answer for is not executable. - */ -fun isExecutableWalletBin(path: String): Boolean = - runCatching { File(path).let { it.isFile && it.canExecute() } }.getOrDefault(false) - -/** - * The absolute path the stored config should keep instead of [storedBin], or - * `null` when the stored path is already runnable here (or there is nothing - * better to offer). - * - * This is the repair rule behind the self-heal. A record written by an older - * install can carry the bare name `monero-wallet-rpc` (or nothing at all), - * which nothing in an APK sandbox resolves on `PATH`; the spawn then dies with - * `ENOENT` and the screen had no way to say why. When this build *does* carry - * the binary at a resolved absolute path, that path replaces the unusable one. - * - * It never overwrites a path the user pointed at that actually runs: an - * existing, executable file is left alone even when it is not the bundled one. - */ -fun walletBinHealPath( - storedBin: String?, - resolvedBin: String?, - executable: (String) -> Boolean = ::isExecutableWalletBin, -): String? { - val resolved = resolvedBin?.takeIf { it.isNotBlank() } ?: return null - val stored = storedBin?.trim().orEmpty() - if (stored.isNotEmpty() && executable(stored)) return null - return resolved -} - -/** - * Why the **stored** `ChainConfig.walletRpcBin` will not produce a child, or - * `null` when it will. [startBlockedReason] only ever sees the *resolved* - * binaries, so a stale path saved by an older install passed that gate and - * then failed inside `spawn`. - * - * The reason always names the path it is about, so the next failure report - * carries its own cause instead of the opaque `spawn monero-wallet-rpc: No such - * file or directory`. A store that holds no path at all is named as such — - * "stored bin missing" is a distinct condition from "this build ships none". - */ -fun storedWalletBinBlockedReason( - storedBin: String?, - resolvedBin: String?, - executable: (String) -> Boolean = ::isExecutableWalletBin, -): String? { - if (resolvedBin.isNullOrBlank()) return NO_WALLET_RPC_MESSAGE - val stored = storedBin?.trim().orEmpty() - if (stored.isEmpty()) { - return "No wallet binary path is stored for this chain source, so there is nothing to " + - "spawn. This build ships $resolvedBin — pick a chain source to store it." - } - if (executable(stored)) return null - return "The stored wallet binary cannot be run on this device: $stored. " + - "This build ships $resolvedBin." -} - -/** - * The full **Start** gate: the eligibility rules above plus the stored binary. - * - * [startBlockedReason] runs first so its established copy and ordering (no - * binary in this build, start in flight, no chain source) is unchanged; the - * stored-path check is the new second half. Together they make a populated - * `bins` insufficient on its own — which was the hole that let a bare stored - * name through. - */ -fun startGateReason( - bins: WalletChildBinaryPaths, - input: WalletChildInput?, - storedWalletBin: String?, - onionDaemon: Boolean = false, - starting: Boolean = false, - executable: (String) -> Boolean = ::isExecutableWalletBin, -): String? = - startBlockedReason(bins, input, onionDaemon, starting) - ?: storedWalletBinBlockedReason(storedWalletBin, bins.walletRpc, executable) - -/** - * Why **Create wallet** / **Import wallet** cannot be offered yet, or `null` - * when they can. - * - * Both are RPC calls (`create_wallet` / `restore_deterministic_wallet`) against - * the running child. With no child the call cannot succeed, and the core's - * refusal is the desktop TUI's `wallet not configured — open F7 …` — a key that - * does not exist on a phone. Collecting a passphrase only to print that is the - * second dead end this screen must not offer. - */ -fun walletSetupBlockedReason(input: WalletChildInput?): String? = - when (walletChildPhase(input)) { - WalletChildPhase.Unread -> READING_CHILD_NOTICE - WalletChildPhase.Off -> WALLET_SETUP_NEEDS_CHILD - WalletChildPhase.Connecting -> WALLET_SETUP_STARTING - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> WALLET_SETUP_NEEDS_CHILD - WalletChildPhase.Syncing, WalletChildPhase.Ready -> null - } - -/** Shown on the disabled Create / Import controls when no wallet process is up. */ -const val WALLET_SETUP_NEEDS_CHILD: String = - "Create and Import need the wallet process running. Start it on the node card first." - -/** Shown while the child is up but its RPC has not answered yet. */ -const val WALLET_SETUP_STARTING: String = - "The wallet is still starting. Wait until it answers, then create or import." - -/** Tone of the one failure banner a card may paint. */ -enum class WalletFailureTone { - /** Information about a state the app is in, not a failed call. */ - Info, - - /** A call actually failed. */ - Error, -} - -/** - * The banner a card should paint for a display-ready failure string, or `null` - * when it should paint none. - * - * [WALLET_NOT_OPEN_TEXT] is documented as a *state*, not a failure — a running - * child with no wallet file open answers every read with the daemon's `-13`, - * and that is exactly what first-run looks like. It nevertheless reached the - * node card's red `Wallet error` banner, duplicating the `No wallet open` info - * banner directly above it. This decision is keyed on the *mapped* text only: - * the mapping in [walletFailureText] is untouched, so nothing raw becomes - * visible, and only the paint changes. - * - * - [walletOpen] true: the state has ended, so a stale no-wallet sentence is - * dropped entirely. - * - [openHintVisible] true: the info banner above already says it — one - * sentence, once. - * - otherwise the sentence is still information, so it is painted as - * [WalletFailureTone.Info] rather than red. - */ -fun walletFailureBanner( - text: String?, - openHintVisible: Boolean, - walletOpen: Boolean, -): WalletFailureBanner? { - val shown = text?.takeIf { it.isNotBlank() } ?: return null - return if (shown == WALLET_NOT_OPEN_TEXT) { - when { - walletOpen -> null - openHintVisible -> null - else -> WalletFailureBanner(shown, WalletFailureTone.Info, "No wallet open") - } - } else { - WalletFailureBanner(shown, WalletFailureTone.Error, "Wallet error") - } -} - -/** One banner: its sentence, its tone, and its title. */ -data class WalletFailureBanner( - val text: String, - val tone: WalletFailureTone, - val title: String, -) - - /** * Why **Stop** is not actionable, or `null` when it is. `stop_wallet_child` is * idempotent in the core, so this is only about not offering a no-op button. */ fun stopBlockedReason(input: WalletChildInput?): String? = when { input == null -> READING_CHILD_NOTICE - !input.running -> "No wallet is running." + !input.running -> "No wallet child is running." else -> null } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletManagerScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletManagerScreen.kt index 214394d..ac5e5b9 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletManagerScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletManagerScreen.kt @@ -14,13 +14,20 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -33,21 +40,11 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalView import androidx.compose.ui.platform.testTag +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.input.PasswordVisualTransformation import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.siriusdevops.onionwire.WireViewModel -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwAlertBanner -import com.siriusdevops.onionwire.ui.components.OwAlertVariant -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonRow -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwPill -import com.siriusdevops.onionwire.ui.components.OwSectionTitle -import com.siriusdevops.onionwire.ui.components.OwTopBar import kotlinx.coroutines.launch import uniffi.onionwire_sdk.WalletKeys import uniffi.onionwire_sdk.WalletRow @@ -86,7 +83,7 @@ internal fun walletRowDate(createdAt: Long): String { } /** - * Whether the wallet process has a wallet open that the RPC answers for. + * Whether the wallet child has a wallet open that the RPC answers for. * * The core's `state` is the only honest signal available here: `connecting` * means its wallet RPC has not answered, `off`/`exited` mean there is no child @@ -129,8 +126,8 @@ internal fun walletSecretsBlockedReason( isActive: Boolean, walletReadable: Boolean, ): String? = when { - !isActive -> "Open this wallet to view its backup." - !walletReadable -> "The wallet is not running — start it on the wallet screen to read the backup." + !isActive -> "open this wallet to view its backup" + !walletReadable -> "the wallet child is not running — start it on the wallet screen to read the backup" else -> null } @@ -162,45 +159,16 @@ private val RAW_RPC_CODE = Regex("""(? null - // Before the JSON / -13 filters: the TUI's refusal is a plain sentence - // the raw pass-through would otherwise let reach the phone verbatim. - TUI_WALLET_NOT_CONFIGURED.containsMatchIn(text) -> WALLET_RPC_NOT_RUNNING_TEXT NO_WALLET_FILE.containsMatchIn(text) || RAW_RPC_CODE.containsMatchIn(text) -> WALLET_NOT_OPEN_TEXT RAW_JSON.containsMatchIn(text) -> WALLET_DAEMON_REFUSED_TEXT @@ -286,7 +251,7 @@ internal fun walletPassphrasePromptVisible(needsPassphrase: Boolean, walletOpen: * A file name is required because the open is per-file (`open_wallet` on the * file the child is pointed at); a blank passphrase is refused by the core * anyway, so the button stays dead rather than round-tripping a guaranteed - * failure. An in-flight open is not re-submitted: it restarts the wallet process. + * failure. An in-flight open is not re-submitted: it restarts the wallet child. */ internal fun walletPassphraseSubmitEnabled( activeFilename: String?, @@ -305,14 +270,14 @@ internal fun walletPassphraseBlockedReason( typed: String, ): String? = when { activeFilename == null -> - "No wallet file is open yet — open one from the list below." - typed.isEmpty() -> "Type the passphrase for this wallet file." + "the wallet child is not pointed at a wallet file yet — open one from the list below" + typed.isEmpty() -> "type the passphrase for this wallet file" else -> null } /** - * Why the wallet process has nothing open, in this app's words — or `null` when - * it has a wallet open, or nothing is running to hold one. + * Why the wallet child has nothing open, in this app's words — or `null` when + * it has a wallet open, or no child is running to hold one. * * A live `monero-wallet-rpc` is not a usable wallet: it starts with no wallet * file open, and every read then answers `-13 No wallet file`. The status line @@ -329,10 +294,11 @@ internal fun walletChildOpenHint( ): String? = when { !childRunning || walletOpen -> null needsPassphrase -> - "The wallet needs its passphrase: open it on the Saved wallets screen, where the " + - "prompt is." + "No wallet is open in the wallet child: it needs the passphrase for the file it is " + + "pointed at. Open it on the Saved wallets screen, where the prompt is." else -> - "Select a saved wallet or create a new one to view your balance and transact." + "No wallet is open in the wallet child yet. Open a saved wallet on the Saved wallets " + + "screen, or create or import one here." } /** @@ -353,6 +319,7 @@ internal fun walletChildOpenHint( * in saved state (`remember`, not `rememberSaveable`, and cleared on * dispose). */ +@OptIn(ExperimentalMaterial3Api::class) @Composable fun WalletManagerScreen( vm: WireViewModel, @@ -536,24 +503,25 @@ fun WalletManagerScreen( // Root owns systemBars ∪ ime, exactly as the wallet screen does (see // `screenContentInsets`). contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, topBar = { - OwTopBar( - title = "Saved wallets", - // A pushed sub-screen, so the chevron — never the word "Back". - onBack = onBack, + TopAppBar( + title = { Text("Saved wallets") }, + navigationIcon = { + TextButton(onClick = onBack) { Text("Back") } + }, actions = { - OwButton( - text = "Refresh", - variant = OwButtonVariant.Outline, + TextButton( onClick = { scope.launch { vm.refreshWalletChild() reload() } }, - ) + ) { Text("Refresh") } }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.background, + ), ) }, ) { pad -> @@ -591,21 +559,22 @@ fun WalletManagerScreen( ) } keysError?.let { message -> - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Could not read the open wallet's private keys", - description = message, + Card( modifier = Modifier - .padding(horizontal = 16.dp, vertical = 8.dp) - .testTag("wallet-keys-error"), - action = { - OwButton( - text = "Dismiss", - variant = OwButtonVariant.Outline, - onClick = { keysError = null }, - ) - }, - ) + .fillMaxWidth() + .padding(horizontal = 12.dp, vertical = 8.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.errorContainer, + ), + ) { + Column(Modifier.padding(12.dp)) { + Text("could not read the open wallet's private keys") + Spacer(Modifier.height(4.dp)) + Text(message, style = MaterialTheme.typography.bodySmall) + Spacer(Modifier.height(8.dp)) + TextButton(onClick = { keysError = null }) { Text("Dismiss") } + } + } } actionError?.let { ErrorText(it) } @@ -639,55 +608,46 @@ fun WalletManagerScreen( // A read failure is not an empty catalogue, and the two must // not read alike: one is "the store did not answer", the other // is "you have no wallets yet". - listError != null -> OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Could not read the wallet catalogue", - description = listError ?: "", - modifier = Modifier - .padding(horizontal = 16.dp, vertical = 8.dp) - .testTag("wallet-list-error"), - action = { - OwButton( - text = "Retry", - variant = OwButtonVariant.Outline, - onClick = { scope.launch { reload() } }, - ) - }, - ) + listError != null -> Column(Modifier.padding(12.dp)) { + Text( + "could not read the wallet catalogue", + style = MaterialTheme.typography.titleSmall, + color = MaterialTheme.colorScheme.error, + ) + Spacer(Modifier.height(4.dp)) + Text( + listError ?: "", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + ) + Spacer(Modifier.height(8.dp)) + TextButton(onClick = { scope.launch { reload() } }) { Text("Retry") } + } listed == null -> Text( - "Loading…", + "loading…", style = MaterialTheme.typography.bodyMedium, - color = OwColors.TextSecondary, - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), + modifier = Modifier.padding(12.dp), ) - listed.isEmpty() -> OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - ) { - OwSectionTitle("No saved wallets yet") - Spacer(Modifier.height(6.dp)) + listed.isEmpty() -> Column(Modifier.padding(12.dp)) { + Text("No saved wallets yet", style = MaterialTheme.typography.titleSmall) + Spacer(Modifier.height(4.dp)) Text( "Wallets this install remembers show up here. Create or import one " + "on the wallet screen and it appears on the next look.", style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(12.dp)) - OwButton( - text = "Create or import a wallet", - variant = OwButtonVariant.Primary, - onClick = onBack, - modifier = Modifier.fillMaxWidth(), ) + Spacer(Modifier.height(8.dp)) + Button(onClick = onBack) { Text("Create or import a wallet") } } else -> { - Label( - "${listed.size} SAVED ${if (listed.size == 1) "WALLET" else "WALLETS"}", - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), + Text( + "${listed.size} saved ${if (listed.size == 1) "wallet" else "wallets"}", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), ) listed.forEach { row -> val isActive = active != null && active == row.walletFilename @@ -720,7 +680,7 @@ fun WalletManagerScreen( * and whether it is the open one. * * The open row is not tappable. Re-opening it would stop and restart a running - * wallet process onto the file it already has open — a slow no-op whose only + * wallet child onto the file it already has open — a slow no-op whose only * effect is to make the screen look like it did something. */ @Composable @@ -734,70 +694,72 @@ private fun WalletRowCard( onShowPhrase: () -> Unit, onShowKeys: () -> Unit, ) { - OwCard( + Card( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 6.dp) + .padding(horizontal = 12.dp, vertical = 6.dp) .then(if (isActive) Modifier else Modifier.clickable(enabled = !opening, onClick = onOpen)), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), ) { - Row( - Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Text( - walletRowLabel(row.name, row.walletFilename), - style = MaterialTheme.typography.titleMedium, - color = OwColors.TextPrimary, - modifier = Modifier.weight(1f), - ) - Spacer(Modifier.width(8.dp)) - when { - isActive -> OwPill( - text = "In use", - textColor = OwColors.Accent, - container = OwColors.InfoTint, - borderColor = OwColors.InfoBorder, - dotColor = OwColors.Accent, + Column(Modifier.padding(12.dp)) { + Row( + Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.SpaceBetween, + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + walletRowLabel(row.name, row.walletFilename), + style = MaterialTheme.typography.titleSmall, ) - opening -> OwPill(text = "Opening…", textColor = OwColors.TextSecondary) - else -> OwPill(text = "Tap to open", textColor = OwColors.TextSecondary) + when { + isActive -> Text( + "in use", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.primary, + ) + opening -> Text( + "opening…", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + else -> Text( + "tap to open", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } } - } - Spacer(Modifier.height(8.dp)) - Label("FILE") - Mono(row.walletFilename) - Spacer(Modifier.height(4.dp)) - Text( - "Created ${walletRowDate(row.createdAt)}", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - - Spacer(Modifier.height(10.dp)) - OwButtonRow { - OwButton( - text = "Recovery phrase", - variant = OwButtonVariant.Outline, - enabled = secretsEnabled, - onClick = onShowPhrase, - modifier = Modifier.weight(1f), - ) - OwButton( - text = "Private keys", - variant = OwButtonVariant.Outline, - enabled = secretsEnabled, - onClick = onShowKeys, - modifier = Modifier.weight(1f), - ) - } - blockedReason?.let { - Spacer(Modifier.height(6.dp)) + Spacer(Modifier.height(4.dp)) Text( - it, - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextMuted, + "file ${row.walletFilename}", + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, ) + Text( + "created ${walletRowDate(row.createdAt)}", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + + Spacer(Modifier.height(8.dp)) + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + OutlinedButton(onClick = onShowPhrase, enabled = secretsEnabled) { + Text("Recovery phrase") + } + OutlinedButton(onClick = onShowKeys, enabled = secretsEnabled) { + Text("Private keys") + } + } + blockedReason?.let { + Spacer(Modifier.height(4.dp)) + Text( + it, + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } } } } @@ -812,10 +774,10 @@ private fun WalletRowCard( * wallet file. It is never logged, never persisted, and the caller drops it when * the screen goes. * - * Submit is dead while the wallet is not running: the core verifies a + * Submit is dead while the wallet child is not running: the core verifies a * passphrase against a live daemon and refuses to seal an unverified one, so a - * tap there could only fail. When it *is* up — including `connecting`, whose RPC - * has not answered yet — the core restarts it onto the file with this + * tap there could only fail. When the child *is* up — including `connecting`, + * whose RPC has not answered yet — the core restarts it onto the file with this * passphrase, which is exactly the fix. */ @Composable @@ -829,74 +791,77 @@ private fun WalletPassphraseCard( error: String?, onSubmit: () -> Unit, ) { - OwCard( + Card( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp) + .padding(horizontal = 12.dp, vertical = 8.dp) .testTag("wallet-passphrase-card"), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), ) { - OwSectionTitle("This wallet needs its passphrase") - Spacer(Modifier.height(6.dp)) - Text( - "The wallet is pointed at ${filename ?: "a wallet file"} but this install " + - "holds no passphrase that opens it — the wallet was created before the " + - "passphrase was stored, or on another device. Type it once: the wallet " + - "opens, and later starts reopen it on their own.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(12.dp)) - OutlinedTextField( - value = typed, - onValueChange = onTyped, - singleLine = true, - // Masked on screen: this string opens a spend-capable wallet. - visualTransformation = PasswordVisualTransformation(), - label = { Text("wallet passphrase") }, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-passphrase-input"), - ) - Spacer(Modifier.height(6.dp)) - Text( - "Never copied to the clipboard, never logged, and dropped when you leave this screen.", - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - ) - if (!childRunning) { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "The wallet is not running", - description = "Start it on the wallet screen, then come back.", + Column(Modifier.padding(12.dp)) { + Text("This wallet needs its passphrase", style = MaterialTheme.typography.titleSmall) + Spacer(Modifier.height(4.dp)) + Text( + "The wallet child is pointed at ${filename ?: "a wallet file"} but this install " + + "holds no passphrase that opens it — the wallet was created before the " + + "passphrase was stored, or on another device. Type it once: the wallet " + + "opens, and later starts reopen it on their own.", + style = MaterialTheme.typography.bodySmall, ) - } - error?.let { Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Could not open this wallet", - description = it, + OutlinedTextField( + value = typed, + onValueChange = onTyped, + singleLine = true, + // Masked on screen: this string opens a spend-capable wallet. + visualTransformation = PasswordVisualTransformation(), + label = { Text("wallet passphrase") }, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-passphrase-input"), ) - } - blockedReason?.let { + Spacer(Modifier.height(4.dp)) + Text( + "Never copied to the clipboard, never logged, and dropped when you leave this screen.", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + if (!childRunning) { + Spacer(Modifier.height(4.dp)) + Text( + "the wallet child is not running — start it on the wallet screen, then come back", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + error?.let { + Spacer(Modifier.height(6.dp)) + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + ) + } + blockedReason?.let { + Spacer(Modifier.height(4.dp)) + Text( + it, + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Not ready to open", - description = it, - ) + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { + Button( + onClick = onSubmit, + enabled = childRunning && + walletPassphraseSubmitEnabled(filename, typed, inFlight), + modifier = Modifier.testTag("wallet-passphrase-submit"), + ) { Text(if (inFlight) "Opening…" else "Open this wallet") } + } } - Spacer(Modifier.height(12.dp)) - OwButton( - text = if (inFlight) "Opening…" else "Open this wallet", - variant = OwButtonVariant.Primary, - enabled = childRunning && walletPassphraseSubmitEnabled(filename, typed, inFlight), - onClick = onSubmit, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-passphrase-submit"), - ) } } @@ -915,57 +880,64 @@ private fun PrivateKeysCard( warning: String, onDone: () -> Unit, ) { - OwCard( + Card( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp) - .testTag("wallet-private-keys-card"), + .padding(horizontal = 12.dp, vertical = 8.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.errorContainer, + ), ) { - OwSectionTitle("Private keys of the open wallet") - Spacer(Modifier.height(6.dp)) - Text(warning, style = MaterialTheme.typography.bodySmall, color = OwColors.Danger) - Spacer(Modifier.height(12.dp)) - Label("VIEW KEY") - // Mono, and deliberately no testTag: a handle on a spend secret is a - // handle an automation can read back. - Mono(keys.viewKey, modifier = Modifier.fillMaxWidth()) - Spacer(Modifier.height(10.dp)) - val spend = keys.spendKey - if (spend != null) { - Label("SPEND KEY") - Mono(spend, modifier = Modifier.fillMaxWidth()) - } else { + Column(Modifier.padding(12.dp)) { + Text("Private keys of the open wallet", style = MaterialTheme.typography.titleSmall) + Spacer(Modifier.height(4.dp)) + Text(warning, style = MaterialTheme.typography.bodySmall) + Spacer(Modifier.height(8.dp)) Text( - "View-only wallet — no spend key.", - style = MaterialTheme.typography.bodyMedium, - color = OwColors.TextSecondary, + "view key", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, ) + Text( + keys.viewKey, + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + ) + Spacer(Modifier.height(8.dp)) + val spend = keys.spendKey + if (spend != null) { + Text( + "spend key", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + Text( + spend, + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + ) + } else { + Text( + "view-only wallet — no spend key", + style = MaterialTheme.typography.bodyMedium, + ) + } + Spacer(Modifier.height(8.dp)) + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { + Button(onClick = onDone) { Text("Done") } + } } - Spacer(Modifier.height(12.dp)) - OwButton( - text = "Done", - variant = OwButtonVariant.Outline, - onClick = onDone, - modifier = Modifier.fillMaxWidth(), - ) } } -/** - * A display-ready failure line, as a banner. Never carries a secret; callers - * pass errors. - * - * "No wallet is open" is not a failure — it is a state the app is in, and it - * gets the info banner and its own title. Only a real refusal is red. - */ +/** A display-ready failure line. Never carries a secret; callers pass errors. */ @Composable private fun ErrorText(text: String) { - val notOpen = text == WALLET_NOT_OPEN_TEXT - OwAlertBanner( - variant = if (notOpen) OwAlertVariant.Info else OwAlertVariant.Error, - title = if (notOpen) "No wallet open" else "Something went wrong", - description = text, - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), + Text( + text, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), ) } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt index 4299cc2..258b666 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt @@ -3,7 +3,6 @@ package com.siriusdevops.onionwire.ui import android.graphics.Bitmap import android.graphics.Color import androidx.compose.foundation.Image -import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -16,15 +15,21 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.Button +import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.material3.TextButton +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect @@ -35,15 +40,13 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.testTag import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.zxing.BarcodeFormat import com.google.zxing.EncodeHintType @@ -51,20 +54,6 @@ import com.google.zxing.qrcode.QRCodeWriter import com.siriusdevops.onionwire.WireViewModel import com.siriusdevops.onionwire.wallet.NO_WALLET_RPC_MESSAGE import com.siriusdevops.onionwire.wallet.WalletChildBinaryPaths -import com.siriusdevops.onionwire.ui.components.Label -import com.siriusdevops.onionwire.ui.components.Mono -import com.siriusdevops.onionwire.ui.components.OwAlertBanner -import com.siriusdevops.onionwire.ui.components.OwAlertVariant -import com.siriusdevops.onionwire.ui.components.OwButton -import com.siriusdevops.onionwire.ui.components.OwButtonRow -import com.siriusdevops.onionwire.ui.components.OwButtonVariant -import com.siriusdevops.onionwire.ui.components.OwCard -import com.siriusdevops.onionwire.ui.components.OwDivider -import com.siriusdevops.onionwire.ui.components.OwPill -import com.siriusdevops.onionwire.ui.components.OwSectionTitle -import com.siriusdevops.onionwire.ui.components.OwSegmentedControl -import com.siriusdevops.onionwire.ui.components.OwStatusDot -import com.siriusdevops.onionwire.ui.components.OwTopBar import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import uniffi.onionwire_sdk.ChainChoice @@ -76,31 +65,11 @@ import uniffi.onionwire_sdk.WalletChildStatus private enum class PayKind { Invoice, Tip } private enum class SetupKind { Create, Import } -/** - * The wallet tab. - * - * Three things changed from the alpha build, and each one is the plan's: - * - * - The page is a hero card and a node card, not a stack of nine equal boxes. - * The balance, the receive address and the two payment actions are the top - * card; the daemon, the network mode and the lifecycle are the second one. - * - Create / Import are the *first* thing on the page while no wallet is open, - * instead of two more outlined twins at the bottom of a long scroll. - * - The raw telemetry is gone from the surface: no daemon-process jargon, no - * `connecting · in-process mainnet pruned · node starting · sync 485253/…` - * string. What is left is a status sentence, a percentage, a progress track - * and two formatted block counts. The full line is still spoken — it is the - * header's `contentDescription` — so nothing an operator needs was deleted, - * it moved behind progressive disclosure. - * - * Behaviour is unchanged. Every callback below is the ViewModel call the old - * screen made; the gate on the seed card, the `shouldReloadWalletReads` key on - * the reload effect and the `openWalletChild` lifetime are untouched, because - * they are state, not layout. - */ +@OptIn(ExperimentalMaterial3Api::class) @Composable fun WalletScreen( vm: WireViewModel, + onBack: () -> Unit, onOpenWallets: () -> Unit, ) { val friends by vm.friends.collectAsStateWithLifecycle() @@ -126,18 +95,12 @@ fun WalletScreen( var composer by remember { mutableStateOf(null) } var setup by remember { mutableStateOf(null) } // The seed currently on the blocking card: set by a successful create, or by - // "Back up seed" re-reading it from the wallet process. Null means no card. + // "Back up seed" re-reading it from the wallet child. Null means no card. // Never persisted and never logged — it is a spend key. var pendingSeed by remember { mutableStateOf(null) } var seedConfirm by remember { mutableStateOf("") } var daemonText by remember { mutableStateOf("") } var daemonError by remember { mutableStateOf(null) } - // Which pane of the node card's connection selector is open. `null` means - // "follow the stored chain source", which is the honest default: the pane is - // a view of what is configured, not a configuration of its own. It is reset - // whenever the stored source changes, so a started on-device node snaps the - // selector back to its own pane. - var remotePane by remember { mutableStateOf(null) } suspend fun reload() { runCatching { balance = vm.walletBalance() } @@ -147,10 +110,10 @@ fun WalletScreen( } /** - * "Back up seed": re-read the open wallet's seed from the wallet process and + * "Back up seed": re-read the open wallet's seed from the wallet child and * put it on the blocking card. This is the only path to a seed that was * created before this screen existed, so the failure is shown rather than - * swallowed — it is the difference between "the wallet is not running" and + * swallowed — it is the difference between "the child is not running" and * "there is nothing to recover". */ fun openSeedBackup() { @@ -169,28 +132,23 @@ fun WalletScreen( LaunchedEffect(Unit) { reload() vm.refreshChainSource() - // Self-heal before the gate is asked: a stored `wallet_rpc_bin` left by - // an older install can point at a path this device cannot execute, and - // the bundled binary is the right answer for it. The gate below then - // names the path only when no repair was possible. - vm.healStoredWalletBin(bins) } - // The same reads again, once the wallet has actually answered. They are + // The same reads again, once the child has actually answered. They are // keyed on `state` alone, never on the whole status record: the 2s poller // rewrites `height` every tick, and keying on the record would fire this on // every tick instead of on the one transition that matters. `LaunchedEffect` // re-runs only when the key changes, so `syncing` → `syncing` does not // reload. Not while `connecting`: `walletBalance()` answers the string // `"err"` (it does not throw), and that call is what pins the headline to - // `Balance unavailable`. + // `balance —`. LaunchedEffect(childInput?.state) { if (shouldReloadWalletReads(childInput?.state)) { reload() } } - // The wallet's 2s refresh loop lives in the ViewModel (like the chat + // The wallet child's 2s refresh loop lives in the ViewModel (like the chat // poller); this screen only owns its lifetime, so leaving the wallet and // coming back cannot stack a second loop on the first. DisposableEffect(Unit) { @@ -198,11 +156,8 @@ fun WalletScreen( onDispose { vm.closeWalletChild() } } - // Prefill the daemon field from the stored config, never over typing — and - // drop the connection-pane override, so the selector follows the source that - // was just stored. + // Prefill the daemon field from the stored config, never over typing. LaunchedEffect(chain) { - remotePane = null val stored = chain if (stored != null && stored.kind == ChainChoice.REMOTE && daemonText.isBlank()) { daemonText = "${stored.host}:${stored.port}" @@ -215,12 +170,22 @@ fun WalletScreen( // navigation bar from being applied twice, and keeps the IME inset out // of the Scaffold's inner padding. contentWindowInsets = WindowInsets(0, 0, 0, 0), - containerColor = OwColors.Canvas, topBar = { - // No actions: the catalogue's entry point is in the hero card's - // header, where the plan puts it. A second "Saved wallets" button - // here would be two doors to one screen on the same page. - OwTopBar(title = "Wallet") + TopAppBar( + title = { Text("Wallet") }, + navigationIcon = { + TextButton(onClick = onBack) { Text("Back") } + }, + // The saved-wallet catalogue is its own screen: this one is the + // open wallet, and switching wallets restarts the child, so the + // picker does not belong in this page's scroll. + actions = { + TextButton(onClick = onOpenWallets) { Text("Wallets") } + }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.background, + ), + ) }, ) { pad -> Column( @@ -234,10 +199,11 @@ fun WalletScreen( ) { // The blocking seed step. While a seed is on screen this card is the // whole body: no Cancel, and Done stays dead until the confirm word - // is typed, so the one-shot seed cannot be dismissed unread. Leaving - // the tab costs nothing now, because leaving no longer loses the - // seed: the wallet stays unbacked (warning up, receive address - // hidden) until "Back up seed" puts this card back on screen. + // is typed, so the one-shot seed cannot be dismissed unread. The + // app-bar Back still leaves the screen — that is the TUI's `Esc` — + // and it costs nothing now, because leaving no longer loses the + // seed: the wallet stays unbacked (strip up, receive address hidden) + // until "Back up seed" puts this card back on screen. val seed = pendingSeed if (seed != null) { SeedBackupCard( @@ -257,56 +223,97 @@ fun WalletScreen( } // The persistent unbacked strip, above everything else on the page. - // `walletReadable` is the core's own evidence that the wallet has a + // `walletReadable` is the core's own evidence that the child has a // wallet open: `wallet_balance` returns exactly "off" for a chain // source that was never configured, "err" for a configured one whose - // read failed (no wallet file open yet, or the process is down), and - // a real amount otherwise. The gate uses it only for an install that + // read failed (no wallet file open yet, or the child is down), and a + // real amount otherwise. The gate uses it only for an install that // has never created a wallet here, so a first-run user who has // configured a daemon but not yet created anything is not nagged // about a seed they do not have. val walletReadable = balance != null && balance != "off" && balance != "err" - val walletOpen = child?.walletOpen == true - // A sticky failure captured while no wallet was open is not a - // failure once one is: drop it, so the red line does not outlive - // the state that produced it. - LaunchedEffect(walletOpen) { - if (walletOpen) vm.clearWalletChildError() - } val unbacked = SeedBackupGate.warningVisible(seedConfirmed, walletReadable) if (unbacked) { UnbackedSeedCard(error = error, onBackUpSeed = { openSeedBackup() }) } - val phase = walletChildPhase(childInput) - // Create and Import are RPC calls against the running child. With no - // child up they can only fail, and the failure is the TUI's `open F7` - // copy — so the controls stay dead and say why instead. - val setupBlocked = walletSetupBlockedReason(childInput) - WalletHeroCard( - balance = balance, - address = address, - walletOpen = walletOpen, - phase = phase, - showQr = showQr, - setupBlocked = setupBlocked, - onToggleQr = { showQr = !showQr }, - onOpenWallets = onOpenWallets, - onCreate = { if (setupBlocked == null) setup = SetupKind.Create }, - onImport = { if (setupBlocked == null) setup = SetupKind.Import }, - onInvoice = { composer = PayKind.Invoice }, - onTip = { composer = PayKind.Tip }, - onBackUpSeed = if ( - walletReadable && !SeedBackupGate.warningVisible(seedConfirmed, walletReadable) + Card( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 12.dp, vertical = 8.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { + Column( + Modifier.padding(16.dp), + horizontalAlignment = Alignment.CenterHorizontally, ) { - { openSeedBackup() } - } else { - null - }, - onLock = { scope.launch { vm.stopWalletChild() } }, - ) + Text( + when (balance) { + null -> "loading…" + "off" -> "wallet off" + "err" -> "balance —" + else -> balance ?: "" + }, + style = MaterialTheme.typography.headlineSmall, + fontFamily = FontFamily.Monospace, + ) + // Hidden until the seed is confirmed written down: XMR into a + // wallet whose 25 words were never recorded is unrecoverable, + // so the address and its QR are gated, not just warned about. + val addr = address?.takeIf { + SeedBackupGate.receiveAddressVisible(seedConfirmed, walletReadable) + } + if (addr != null) { + Spacer(Modifier.height(8.dp)) + Text( + "receive address", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + Spacer(Modifier.height(4.dp)) + Text( + addr, + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + modifier = Modifier.fillMaxWidth(), + ) + TextButton(onClick = { showQr = !showQr }) { + Text(if (showQr) "Hide QR" else "Show QR") + } + if (showQr) { + val qr = remember(addr) { generateQrBitmap(addr) } + qr?.let { bm -> + Box( + modifier = Modifier + .fillMaxWidth() + .aspectRatio(1f) + .border( + 1.dp, + MaterialTheme.colorScheme.outline, + RoundedCornerShape(8.dp), + ) + .padding(8.dp), + contentAlignment = Alignment.Center, + ) { + Image( + bitmap = bm.asImageBitmap(), + contentDescription = "QR code for receive address", + modifier = Modifier.fillMaxSize(), + contentScale = ContentScale.Fit, + ) + } + } + } + } + } + } - NodeCard( + // The app-owned `monero-wallet-rpc` control. Above the existing + // Create / Import / Invoice / Tip actions, which are untouched: the + // daemon is what makes the balance and the sends mean anything. + WalletChildCard( bins = bins, input = childInput, chain = chain, @@ -314,14 +321,8 @@ fun WalletScreen( actionError = childError, daemonText = daemonText, daemonError = daemonError, - walletOpen = walletOpen, + walletOpen = child?.walletOpen == true, needsPassphrase = child?.needsPassphrase == true, - starting = starting, - remotePane = remotePane ?: !isInProcessSource(childInput, chain), - onSelectPane = { wantsRemote -> - remotePane = wantsRemote - daemonError = null - }, onDaemonText = { daemonText = it daemonError = null @@ -351,13 +352,10 @@ fun WalletScreen( vm.setInProcessCuprate(bins, mainnet, prune) .onFailure { daemonError = walletFailureText(it.message ?: it.toString()) } .onSuccess { - // Selecting a mode stores it and, when the - // storage floor *and* the Start gate would allow - // a launch, starts the node. The stored binary is - // what the just-saved config holds; the gate - // asks it the same question Start does, so a - // mode tap can never launch a child Start would - // have refused. + // The mode buttons used to only persist the choice, + // which read as a no-op besides the storage line. + // Start is still the core launch; tapping a mode + // fires it when the storage gate would allow Start. if (shouldStartAfterSelectingChain( chainStorageBlockedReason( vm.chainFreeBytes(), @@ -365,10 +363,6 @@ fun WalletScreen( prune = prune, ), starting = starting, - startBlocked = storedWalletBinBlockedReason( - bins.walletRpc, - bins.walletRpc, - ), ) ) { vm.startWalletChild() @@ -376,24 +370,35 @@ fun WalletScreen( } } }, + starting = starting, onStart = { vm.startWalletChild() }, onStop = { scope.launch { vm.stopWalletChild() } }, ) if (transfers.isNotEmpty()) { - Column(Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp)) { - Label("RECENT TRANSFERS") - Spacer(Modifier.height(8.dp)) - Column(verticalArrangement = Arrangement.spacedBy(8.dp)) { - transfers.forEach { t -> TransferCard(t) } - } + Text( + "recent transfers", + style = MaterialTheme.typography.titleSmall, + modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), + ) + // Plain Column, not a LazyColumn: the root is a scrolling + // container now, so a nested lazy list would either throw on the + // unbounded height or need an arbitrary cap. `walletRecentTransfers` + // is bounded (25 rows), and the page scrolls as one gesture. + Column( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 12.dp), + verticalArrangement = Arrangement.spacedBy(4.dp), + ) { + transfers.forEach { t -> TransferCard(t) } } } val kind = composer val setupKind = setup - when { - kind != null -> PayComposer( + if (kind != null) { + PayComposer( kind = kind, friends = friends, onCancel = { composer = null }, @@ -414,8 +419,8 @@ fun WalletScreen( } }, ) - - setupKind != null -> WalletSetupCard( + } else if (setupKind != null) { + WalletSetupCard( kind = setupKind, warning = vm.spendAuthorityWarning(), onCancel = { setup = null }, @@ -435,646 +440,72 @@ fun WalletScreen( importWallet = { pw, seed -> vm.importWallet(pw, seed) }, scope = scope, ) + } else { + Column(Modifier.fillMaxWidth().padding(12.dp)) { + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + OutlinedButton( + onClick = { composer = PayKind.Invoice }, + modifier = Modifier.weight(1f), + ) { Text("Invoice") } + OutlinedButton( + onClick = { composer = PayKind.Tip }, + modifier = Modifier.weight(1f), + ) { Text("Tip") } + } + Spacer(Modifier.height(8.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + OutlinedButton( + onClick = { setup = SetupKind.Create }, + modifier = Modifier.weight(1f), + ) { Text("Create") } + OutlinedButton( + onClick = { setup = SetupKind.Import }, + modifier = Modifier.weight(1f), + ) { Text("Import") } + } + // The recovery path for a wallet whose seed was missed. The + // strip above carries its own copy of this button while the + // seed is unconfirmed, so exactly one is ever on screen — + // and this copy is only offered once the child can actually + // read a wallet, which is the only state in which the seed + // read can succeed. + if (walletReadable && !SeedBackupGate.warningVisible(seedConfirmed, walletReadable)) { + Spacer(Modifier.height(8.dp)) + OutlinedButton( + onClick = { openSeedBackup() }, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-seed-backup-action"), + ) { Text("Back up seed") } + } + } } // While the strip is up the error belongs next to the button that - // caused it: this page is one long scroll and the node card sits + // caused it: this page is one long scroll and the daemon card sits // between the strip and the bottom, so a failed `wallet_seed` read // would otherwise land off-screen. if (!unbacked) { error?.let { ErrorLine(it) } } - - Spacer(Modifier.height(16.dp)) } } } -/** - * The wallet at a glance: a balance, a receive address, and the four things a - * person actually does here. - * - * Two states, and the switch is the core's own `wallet_open` — not "is a chain - * source configured", which is a different question and answers yes for a - * receive-only install that has no wallet file at all. - */ -@Composable -private fun WalletHeroCard( - balance: String?, - address: String?, - walletOpen: Boolean, - phase: WalletChildPhase, - showQr: Boolean, - /** - * Why Create / Import cannot be offered yet, or `null` when they can. From - * [walletSetupBlockedReason]: both flows are RPC calls against a running - * wallet child, so a stopped child is a dead end the screen may not offer. - */ - setupBlocked: String?, - onToggleQr: () -> Unit, - onOpenWallets: () -> Unit, - onCreate: () -> Unit, - onImport: () -> Unit, - onInvoice: () -> Unit, - onTip: () -> Unit, - onBackUpSeed: (() -> Unit)?, - onLock: () -> Unit, -) { - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - ) { - Row( - Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, - ) { - Row(verticalAlignment = Alignment.CenterVertically) { - OwStatusDot( - when { - !walletOpen -> OwColors.TextMuted - phase is WalletChildPhase.Ready -> OwColors.Accent - else -> OwColors.Warning - }, - ) - Spacer(Modifier.width(8.dp)) - OwSectionTitle(if (walletOpen) "Wallet" else "No Wallet Active") - } - OwButton( - text = "Saved wallets", - variant = OwButtonVariant.Outline, - onClick = onOpenWallets, - ) - } - Spacer(Modifier.height(12.dp)) - - if (!walletOpen) { - // The §4.1 replacement for the old `wallet off` string, kept as a - // value line rather than a second heading: the card already says - // "No Wallet Active", and "off" vs "err" is the difference between - // "nothing is configured" and "configured, but the read failed". - Text( - noWalletBalanceHeadline(balance), - style = MaterialTheme.typography.titleMedium, - color = OwColors.TextSecondary, - modifier = Modifier.testTag("wallet-balance"), - ) - Spacer(Modifier.height(6.dp)) - Text( - "Create a new Monero wallet or restore an existing seed.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(16.dp)) - OwButtonRow { - OwButton( - text = "Create Wallet", - variant = OwButtonVariant.Primary, - enabled = setupBlocked == null, - onClick = onCreate, - modifier = Modifier.weight(1f).testTag("wallet-create"), - ) - OwButton( - text = "Import Wallet", - variant = OwButtonVariant.Secondary, - enabled = setupBlocked == null, - onClick = onImport, - modifier = Modifier.weight(1f).testTag("wallet-import"), - ) - } - // Why the two flows are dead, in a sentence rather than a grey pair - // of buttons. The only fix is on the node card below, so the copy - // points there. - setupBlocked?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Wallet not running", - description = it, - modifier = Modifier.testTag("wallet-setup-blocked"), - ) - } - // Invoicing does not need a wallet file: the core resolves the payee - // address from the profile (`no receive address — set profile xmr or - // ONIONWIRE_WALLET_RPC` is the both-missing case). Hiding the action - // in this state would remove a path that works, so it stays — as a - // text action, not a third button competing with Create. A tip - // genuinely needs the wallet (it calls `Wallet::transfer`), so it - // only appears once one is open. - TextButton(onClick = onInvoice) { Text("Send an invoice") } - return@OwCard - } - - // A wallet is open: the balance is the headline, 28sp bold, sans — it is - // money, not cryptographic material, so it is not monospaced. - Text( - noWalletBalanceHeadline(balance), - style = MaterialTheme.typography.displaySmall, - color = OwColors.TextPrimary, - modifier = Modifier.testTag("wallet-balance"), - ) - Spacer(Modifier.height(6.dp)) - OwPill( - text = phase.label, - textColor = when (phase) { - WalletChildPhase.Ready -> OwColors.Accent - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> OwColors.Danger - else -> OwColors.Warning - }, - container = when (phase) { - WalletChildPhase.Ready -> OwColors.InfoTint - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> OwColors.DangerTint - else -> OwColors.WarningTint - }, - borderColor = when (phase) { - WalletChildPhase.Ready -> OwColors.InfoBorder - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> OwColors.DangerBorder - else -> OwColors.WarningBorder - }, - dotColor = when (phase) { - WalletChildPhase.Ready -> OwColors.Accent - is WalletChildPhase.Exited, is WalletChildPhase.Unrecognised -> OwColors.Danger - else -> OwColors.Warning - }, - ) - - // Hidden until the seed is confirmed written down: XMR into a wallet - // whose 25 words were never recorded is unrecoverable, so the address - // and its QR are gated, not just warned about. - val addr = address - if (addr != null) { - Spacer(Modifier.height(16.dp)) - OwDivider() - Spacer(Modifier.height(12.dp)) - Label("RECEIVE ADDRESS") - Spacer(Modifier.height(4.dp)) - Mono(addr, modifier = Modifier.fillMaxWidth(), color = OwColors.TextPrimary) - TextButton(onClick = onToggleQr) { Text(if (showQr) "Hide QR" else "Show QR") } - if (showQr) { - val qr = remember(addr) { generateQrBitmap(addr) } - qr?.let { bm -> - Box( - modifier = Modifier - .fillMaxWidth() - .aspectRatio(1f) - .border(1.dp, OwColors.Border, RoundedCornerShape(OwRadius.Control)) - .padding(8.dp), - contentAlignment = Alignment.Center, - ) { - Image( - bitmap = bm.asImageBitmap(), - contentDescription = "QR code for receive address", - modifier = Modifier.fillMaxSize(), - contentScale = ContentScale.Fit, - ) - } - } - } - } - - Spacer(Modifier.height(16.dp)) - OwButtonRow { - OwButton( - text = "Receive / Invoice", - variant = OwButtonVariant.Primary, - onClick = onInvoice, - modifier = Modifier.weight(1f), - ) - OwButton( - text = "Send / Tip", - variant = OwButtonVariant.Secondary, - onClick = onTip, - modifier = Modifier.weight(1f), - ) - } - Spacer(Modifier.height(8.dp)) - OwButtonRow { - // Creating a second wallet and importing a third are real flows - // (each wallet gets its own file, and the catalogue lists them), so - // both stay reachable once the first one is open — they just stop - // being the loudest thing on the page. - OwButton( - text = "New wallet", - variant = OwButtonVariant.Outline, - enabled = setupBlocked == null, - onClick = onCreate, - modifier = Modifier.weight(1f).testTag("wallet-create"), - ) - OwButton( - text = "Import wallet", - variant = OwButtonVariant.Outline, - enabled = setupBlocked == null, - onClick = onImport, - modifier = Modifier.weight(1f).testTag("wallet-import"), - ) - } - setupBlocked?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Wallet not running", - description = it, - modifier = Modifier.testTag("wallet-setup-blocked"), - ) - } - // The recovery path for a wallet whose seed was missed: a quiet action, - // because a healthy wallet needs it rarely and a seed is a spend key. - // While the seed is unconfirmed the strip above carries the button - // instead, so exactly one is ever on screen. - if (onBackUpSeed != null) { - TextButton( - onClick = onBackUpSeed, - modifier = Modifier.testTag("wallet-seed-backup-action"), - ) { Text("Back up seed") } - } - Spacer(Modifier.height(8.dp)) - OwButton( - text = "Lock Wallet", - variant = OwButtonVariant.Destructive, - onClick = onLock, - modifier = Modifier.fillMaxWidth().testTag("wallet-lock"), - ) - } -} - -/** - * The node and the daemon: one status header, one progress track, one choice of - * where the chain comes from, and one lifecycle control. - * - * The single most important property of this card is that it never asserts a - * state the core did not report. `target_height == 0` prints no percentage, an - * unrecognised state is never green, and a running process whose RPC has not - * answered is `Connecting…`, not `Wallet Ready`. - */ -@Composable -private fun NodeCard( - bins: WalletChildBinaryPaths, - input: WalletChildInput?, - chain: ChainConfig?, - nodeFreeBytes: Long?, - actionError: String?, - daemonText: String, - daemonError: String?, - /** - * The core's `wallet_open` / `needs_passphrase`, straight off the same - * `WalletChildStatus` the status header is drawn from — not a second idea of - * which wallet is open. - */ - walletOpen: Boolean, - needsPassphrase: Boolean, - starting: Boolean, - /** Which pane the connection selector shows; the caller owns the override. */ - remotePane: Boolean, - onSelectPane: (Boolean) -> Unit, - onDaemonText: (String) -> Unit, - onSaveDaemon: () -> Unit, - onReceiveOnly: () -> Unit, - onInProcessNode: (mainnet: Boolean, prune: Boolean) -> Unit, - onStart: () -> Unit, - onStop: () -> Unit, -) { - val inProcess = isInProcessSource(input, chain) - val head = nodeStatusHead( - input, - inProcess = inProcess, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ) - val progress = syncProgress(input?.height ?: 0uL, input?.targetHeight ?: 0uL) - val node = nodePhase(input) - val onionDaemon = chain?.kind == ChainChoice.REMOTE && isOnionHost(chain.host) - // The full gate: eligibility *and* the stored binary this build will - // actually spawn. A populated `bins` alone used to pass, which is how a - // stored bare name got as far as `spawn` and failed with ENOENT. - val startWhy = startGateReason(bins, input, chain?.walletRpcBin, onionDaemon, starting) - ?: if (inProcess) { - chainStorageBlockedReason( - nodeFreeBytes, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ) - } else { - null - } - val stopWhy = stopBlockedReason(input) - // A live wallet with no wallet file open answers every read with the - // daemon's own `-13 No wallet file`. Say that in this app's words, here, - // rather than letting the raw string arrive later on whichever card asked. - val openHint = walletChildOpenHint( - childRunning = input?.running == true, - walletOpen = walletOpen, - needsPassphrase = needsPassphrase, - ) - val running = input?.running == true - - OwCard( - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), - ) { - // --- the status header ------------------------------------------------ - Row( - Modifier - .fillMaxWidth() - .testTag(walletChildPhase(input).testTag) - .semantics(mergeDescendants = true) { - // The whole raw line — `syncing · in-process mainnet pruned - // · node syncing · sync 485253/3794383` — is still spoken. - // A screen reader is never told less than the sighted user. - contentDescription = walletChildStatusDescription(input) - }, - verticalAlignment = Alignment.CenterVertically, - ) { - OwStatusDot( - when (head.tone) { - NodeStatusTone.Idle -> OwColors.TextMuted - NodeStatusTone.Busy -> OwColors.Warning - NodeStatusTone.Good -> OwColors.Accent - NodeStatusTone.Bad -> OwColors.Danger - }, - ) - Spacer(Modifier.width(8.dp)) - Text( - head.title, - style = MaterialTheme.typography.titleMedium, - color = OwColors.TextPrimary, - modifier = Modifier.weight(1f), - ) - progress.percentText?.let { pct -> - Mono(pct, color = OwColors.TextSecondary) - } - } - - // --- the progress track ---------------------------------------------- - if (progress.blockText != null) { - Spacer(Modifier.height(10.dp)) - Box( - Modifier - .fillMaxWidth() - .height(OwSize.ProgressTrack) - .clip(RoundedCornerShape(OwRadius.Pill)) - .background(OwColors.SurfaceInteractive), - ) { - Box( - Modifier - .fillMaxWidth(progress.fraction) - .height(OwSize.ProgressTrack) - .clip(RoundedCornerShape(OwRadius.Pill)) - .background(OwColors.Accent), - ) - } - Spacer(Modifier.height(6.dp)) - Row( - Modifier.fillMaxWidth().testTag("wallet-chain-progress"), - horizontalArrangement = Arrangement.SpaceBetween, - ) { - Text( - progress.blockText, - style = MonoStyle.copy(fontSize = 12.sp, color = OwColors.TextSecondary), - ) - Text( - nodeFreeBytes?.let { "${formatBytes(it)} free" } ?: "free space unknown", - style = MonoStyle.copy(fontSize = 12.sp, color = OwColors.TextSecondary), - ) - } - } - - // The node's own word, when there is one, as its own assertable line: - // an unrecognised node state can never be read as ready. - if (node !is NodePhase.Absent) { - Spacer(Modifier.height(6.dp)) - Text( - "node: ${node.label}", - style = MonoStyle.copy(fontSize = 12.sp, color = OwColors.TextSecondary), - modifier = Modifier - .fillMaxWidth() - .testTag(node.testTag) - .semantics(mergeDescendants = true) { - contentDescription = node.contentDescription - }, - ) - } - - Spacer(Modifier.height(12.dp)) - OwDivider() - Spacer(Modifier.height(12.dp)) - - // --- where the chain comes from --------------------------------------- - Label("CONNECTION TYPE") - Spacer(Modifier.height(8.dp)) - OwSegmentedControl( - options = listOf("Remote Node", "On-Device Node"), - selectedIndex = if (remotePane) 0 else 1, - onSelect = { onSelectPane(it == 0) }, - testTags = listOf("wallet-connection-remote", "wallet-connection-on-device"), - ) - - if (remotePane) { - Spacer(Modifier.height(12.dp)) - OutlinedTextField( - value = daemonText, - onValueChange = onDaemonText, - singleLine = true, - label = { Text("daemon host:port") }, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-daemon-input"), - ) - Spacer(Modifier.height(4.dp)) - Text( - "LAN (e.g. 192.168.1.20:18089) or a public clearnet node.", - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(10.dp)) - OwButtonRow { - OwButton( - text = "Save Daemon", - variant = OwButtonVariant.Secondary, - onClick = onSaveDaemon, - enabled = bins.walletRpcBundled, - modifier = Modifier.weight(1f).testTag("wallet-daemon-save"), - ) - OwButton( - text = "Receive-Only", - variant = OwButtonVariant.Outline, - onClick = onReceiveOnly, - modifier = Modifier.weight(1f).testTag("wallet-daemon-receive-only"), - ) - } - } else { - Spacer(Modifier.height(12.dp)) - Label("NETWORK MODE") - Spacer(Modifier.height(8.dp)) - val mode = selectedCuprateMode( - inProcess = true, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ) - OwSegmentedControl( - options = listOf("Pruned", "Full", "Testnet"), - selectedIndex = when (mode) { - CuprateMode.MainnetFull -> 1 - CuprateMode.Testnet -> 2 - // MainnetPruned, and the not-in-process case before anything - // is stored: the pruned store is the conservative default. - else -> 0 - }, - onSelect = { index -> - when (index) { - 0 -> onInProcessNode(true, true) - 1 -> onInProcessNode(true, false) - else -> onInProcessNode(false, false) - } - }, - testTags = listOf( - "wallet-chain-mainnet-pruned", - "wallet-chain-mainnet-full", - "wallet-chain-in-process", - ), - ) - Spacer(Modifier.height(10.dp)) - OwAlertBanner( - variant = OwAlertVariant.Warning, - title = CUPRATE_ON_DEVICE_TITLE, - description = CUPRATE_ON_DEVICE_BODY, - modifier = Modifier.testTag("wallet-cuprate-warning"), - ) - Spacer(Modifier.height(8.dp)) - Text( - chainStorageLine( - nodeFreeBytes, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ), - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-chain-storage"), - ) - } - - // --- the lifecycle ---------------------------------------------------- - Spacer(Modifier.height(16.dp)) - if (starting) { - OwButton( - text = "Starting…", - variant = OwButtonVariant.Primary, - enabled = false, - onClick = {}, - modifier = Modifier.fillMaxWidth().testTag("wallet-child-start"), - ) - } else if (running) { - OwButton( - text = "Stop Node", - variant = OwButtonVariant.Destructive, - enabled = stopWhy == null, - onClick = onStop, - modifier = Modifier.fillMaxWidth().testTag("wallet-child-stop"), - ) - } else { - OwButton( - text = "Start Node & Wallet", - variant = OwButtonVariant.Primary, - enabled = startWhy == null, - onClick = onStart, - modifier = Modifier.fillMaxWidth().testTag("wallet-child-start"), - ) - } - - // --- what is wrong, in banners rather than paragraphs ----------------- - if (starting) { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Starting", - description = STARTING_CHILD_NOTICE, - ) - } - - // Why Start is dead, in the core's terms rather than a grey button. - if (!starting && !running) { - startWhy?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "Not ready to start", - description = it, - modifier = Modifier.testTag("wallet-child-start-blocked"), - ) - } - } - - if (!bins.walletRpcBundled) { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "No wallet binary", - description = NO_WALLET_RPC_MESSAGE, - ) - } - - // "No wallet file open" is a state of a live wallet, not a failure of - // the last call, so it is said here rather than left to surface as the - // daemon's `-13` on whichever card asked for a read. - openHint?.let { - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = OwAlertVariant.Info, - title = "No wallet open", - description = it, - modifier = Modifier.testTag("wallet-child-no-wallet"), - ) - } - - // The last thing the core or the RPC call said. Sticky until the user - // acts, like the chat screen's load error. Filtered through - // `walletFailureText`: the daemon's own `-13 No wallet file` / JSON - // answer is not a sentence about this app and never reaches the screen. - // - // "No wallet open" is a state, not a failure: the info banner above - // already owns it, so it is not painted red and not printed twice. - val failure = walletFailureText(input?.lastError) ?: actionError ?: daemonError - failure?.let { - walletFailureBanner( - text = it, - openHintVisible = openHint != null, - walletOpen = walletOpen, - )?.let { banner -> - Spacer(Modifier.height(8.dp)) - OwAlertBanner( - variant = if (banner.tone == WalletFailureTone.Info) { - OwAlertVariant.Info - } else { - OwAlertVariant.Error - }, - title = banner.title, - description = banner.text, - modifier = Modifier.testTag("wallet-child-error"), - ) - } - } - } -} - -/** - * True when the stored chain source (or the live status, before the store is - * re-read) is the app's own node. The connection selector and the network-mode - * control both key off this one predicate. - */ -private fun isInProcessSource(input: WalletChildInput?, chain: ChainConfig?): Boolean = - input?.chainInProcess == true || chain?.kind == ChainChoice.IN_PROCESS_CUPRATE - -/** The one error line every wallet action shares, as a banner. */ +/** The one error line every wallet action shares. */ @Composable private fun ErrorLine(text: String) { - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "Something went wrong", - description = text, - modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp), + Text( + text, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.padding(horizontal = 12.dp, vertical = 4.dp), ) } @@ -1092,23 +523,38 @@ private fun UnbackedSeedCard( error: String?, onBackUpSeed: () -> Unit, ) { - OwAlertBanner( - variant = OwAlertVariant.Error, - title = "This wallet is not backed up", - description = SeedBackupGate.WARNING, + Card( modifier = Modifier - .padding(horizontal = 16.dp, vertical = 8.dp) + .fillMaxWidth() + .padding(horizontal = 12.dp, vertical = 8.dp) .testTag("wallet-seed-warning"), - action = { - OwButton( - text = "Back up seed", - variant = OwButtonVariant.Outline, - onClick = onBackUpSeed, - modifier = Modifier.testTag("wallet-seed-backup-action"), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.errorContainer, + ), + ) { + Column(Modifier.padding(12.dp)) { + Text( + SeedBackupGate.WARNING, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onErrorContainer, ) - }, - ) - error?.let { ErrorLine(it) } + Spacer(Modifier.height(8.dp)) + OutlinedButton( + onClick = onBackUpSeed, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-seed-backup-action"), + ) { Text("Back up seed") } + error?.let { + Spacer(Modifier.height(6.dp)) + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + ) + } + } + } } /** @@ -1138,76 +584,91 @@ internal fun SeedBackupCard( onTyped: (String) -> Unit, onDone: () -> Unit, ) { - OwCard( + Card( modifier = Modifier .fillMaxWidth() - .padding(16.dp) + .padding(12.dp) .testTag("wallet-seed-card"), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), ) { - OwSectionTitle("Back up this seed") - Spacer(Modifier.height(8.dp)) - Text( - "These 25 words are the only way to recover this wallet, and anyone who " + - "reads them can spend it. Write them down now — this is the only copy.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(12.dp)) - Mono( - seed, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-seed-words"), - ) - Spacer(Modifier.height(16.dp)) - Text( - "Type ${SeedBackupGate.CONFIRM_WORD} to confirm you have written it down.", - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - ) - Spacer(Modifier.height(4.dp)) - OutlinedTextField( - value = typed, - onValueChange = onTyped, - singleLine = true, - label = { Text("type ${SeedBackupGate.CONFIRM_WORD}") }, - modifier = Modifier - .fillMaxWidth() - .testTag("wallet-seed-confirm-input"), - ) - Spacer(Modifier.height(10.dp)) - OwButton( - text = "Done", - variant = OwButtonVariant.Primary, - enabled = SeedBackupGate.confirmEnabled(typed), - onClick = onDone, - modifier = Modifier.testTag("wallet-seed-confirm-done"), - ) + Column(Modifier.padding(12.dp)) { + Text("Back up this seed", style = MaterialTheme.typography.titleSmall) + Spacer(Modifier.height(8.dp)) + Text( + "These 25 words are the only way to recover this wallet, and anyone who " + + "reads them can spend it. Write them down now — this is the only copy.", + style = MaterialTheme.typography.bodySmall, + ) + Spacer(Modifier.height(8.dp)) + Text( + seed, + style = MaterialTheme.typography.bodyMedium, + fontFamily = FontFamily.Monospace, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-seed-words"), + ) + Spacer(Modifier.height(12.dp)) + Text( + "Type ${SeedBackupGate.CONFIRM_WORD} to confirm you have written it down.", + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + Spacer(Modifier.height(4.dp)) + OutlinedTextField( + value = typed, + onValueChange = onTyped, + singleLine = true, + label = { Text("type ${SeedBackupGate.CONFIRM_WORD}") }, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-seed-confirm-input"), + ) + Spacer(Modifier.height(8.dp)) + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { + Button( + onClick = onDone, + enabled = SeedBackupGate.confirmEnabled(typed), + modifier = Modifier.testTag("wallet-seed-confirm-done"), + ) { Text("Done") } + } + } } } @Composable private fun TransferCard(t: TransferRow) { - OwCard(modifier = Modifier.fillMaxWidth(), padding = 12.dp) { + Card( + modifier = Modifier.fillMaxWidth(), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { Row( - Modifier.fillMaxWidth(), + modifier = Modifier + .fillMaxWidth() + .padding(12.dp), horizontalArrangement = Arrangement.SpaceBetween, - verticalAlignment = Alignment.CenterVertically, ) { - Column(Modifier.weight(1f)) { - Mono(t.txid.take(16) + "…", color = OwColors.TextSecondary) - Spacer(Modifier.height(2.dp)) - Mono( - t.address.take(12) + "…" + t.address.takeLast(4), - color = OwColors.TextMuted, + Column(modifier = Modifier.weight(1f)) { + Text( + t.txid.take(16) + "…", + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + ) + Text( + t.address, + style = MaterialTheme.typography.labelSmall, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colorScheme.onSurfaceVariant, ) } - Spacer(Modifier.width(12.dp)) Text( t.amount, - style = MaterialTheme.typography.titleSmall, - color = OwColors.TextPrimary, - textAlign = TextAlign.End, + style = MaterialTheme.typography.bodyMedium, + fontFamily = FontFamily.Monospace, ) } } @@ -1227,64 +688,64 @@ private fun PayComposer( var memo by remember { mutableStateOf("") } val ready = selected != null && amount.trim().isNotEmpty() - OwCard( + Card( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), + .padding(12.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), ) { - OwSectionTitle(if (kind == PayKind.Invoice) "Send invoice" else "Send tip") - Spacer(Modifier.height(8.dp)) - if (friends.isEmpty()) { + Column(Modifier.padding(12.dp)) { Text( - "Add a contact first. Invoice and tip are one-shot to a peer onion.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, + if (kind == PayKind.Invoice) "Send invoice" else "Send tip", + style = MaterialTheme.typography.titleSmall, ) - } else { - Label("TO") - friends.forEach { f -> - val label = f.petname?.takeIf { it.isNotBlank() } ?: f.fingerprint - TextButton(onClick = { selected = f.pubkeyHex }) { - Text(if (selected == f.pubkeyHex) "• $label" else label) + Spacer(Modifier.height(8.dp)) + if (friends.isEmpty()) { + Text( + "Add a friend first. Invoice and tip are one-shot to a peer onion.", + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } else { + Text("to", style = MaterialTheme.typography.labelSmall) + friends.forEach { f -> + val label = f.petname?.takeIf { it.isNotBlank() } ?: f.fingerprint + TextButton(onClick = { selected = f.pubkeyHex }) { + Text(if (selected == f.pubkeyHex) "• $label" else label) + } } } - } - Spacer(Modifier.height(4.dp)) - OutlinedTextField( - value = amount, - onValueChange = { amount = it }, - singleLine = true, - label = { Text("amount XMR") }, - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(8.dp)) - OutlinedTextField( - value = memo, - onValueChange = { memo = it }, - singleLine = true, - label = { Text("memo (optional)") }, - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(12.dp)) - OwButtonRow { - OwButton( - text = "Cancel", - variant = OwButtonVariant.Outline, - onClick = onCancel, - modifier = Modifier.weight(1f), + OutlinedTextField( + value = amount, + onValueChange = { amount = it }, + singleLine = true, + label = { Text("amount XMR") }, + modifier = Modifier.fillMaxWidth(), ) - OwButton( - text = "Send", - variant = OwButtonVariant.Primary, - enabled = ready, - onClick = { - // Dead button without a recipient, and `ready` says so; the - // null check is only here because `selected` is nullable. - val pk = selected - if (pk != null) onSend(pk, amount.trim(), memo.trim()) - }, - modifier = Modifier.weight(1f), + Spacer(Modifier.height(8.dp)) + OutlinedTextField( + value = memo, + onValueChange = { memo = it }, + singleLine = true, + label = { Text("memo (optional)") }, + modifier = Modifier.fillMaxWidth(), ) + Spacer(Modifier.height(8.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.End, + ) { + TextButton(onClick = onCancel) { Text("Cancel") } + Button( + onClick = { + val pk = selected ?: return@Button + onSend(pk, amount.trim(), memo.trim()) + }, + enabled = ready, + ) { Text("Send") } + } } } } @@ -1306,86 +767,380 @@ private fun WalletSetupCard( var seed by remember { mutableStateOf("") } val ready = password.isNotEmpty() && (kind == SetupKind.Create || seed.isNotBlank()) - OwCard( + Card( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), + .padding(12.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), ) { - OwSectionTitle(if (kind == SetupKind.Create) "Create wallet" else "Import wallet") - Spacer(Modifier.height(8.dp)) - if (kind == SetupKind.Create && !accepted) { - Text(warning, style = MaterialTheme.typography.bodySmall, color = OwColors.TextSecondary) - Spacer(Modifier.height(12.dp)) - OwButtonRow { - OwButton( - text = "Cancel", - variant = OwButtonVariant.Outline, - onClick = onCancel, - modifier = Modifier.weight(1f), - ) - OwButton( - text = "I accept spend authority", - variant = OwButtonVariant.Primary, - onClick = { accepted = true }, - modifier = Modifier.weight(1f), - ) - } - return@OwCard - } - if (kind == SetupKind.Import) { + Column(Modifier.padding(12.dp)) { Text( - "Paste the 25-word seed. Create does not need a key.", - style = MaterialTheme.typography.bodySmall, - color = OwColors.TextSecondary, + if (kind == SetupKind.Create) "Create wallet" else "Import wallet", + style = MaterialTheme.typography.titleSmall, ) Spacer(Modifier.height(8.dp)) + if (kind == SetupKind.Create && !accepted) { + Text(warning, style = MaterialTheme.typography.bodySmall) + Spacer(Modifier.height(8.dp)) + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { + TextButton(onClick = onCancel) { Text("Cancel") } + Button(onClick = { accepted = true }) { Text("I accept spend authority") } + } + return@Column + } + if (kind == SetupKind.Import) { + Text( + "Paste the 25-word seed. Create does not need a key.", + style = MaterialTheme.typography.bodySmall, + ) + Spacer(Modifier.height(8.dp)) + OutlinedTextField( + value = seed, + onValueChange = { seed = it }, + label = { Text("seed") }, + modifier = Modifier.fillMaxWidth(), + ) + Spacer(Modifier.height(8.dp)) + } OutlinedTextField( - value = seed, - onValueChange = { seed = it }, - label = { Text("seed") }, + value = password, + onValueChange = { password = it }, + singleLine = true, + label = { Text("wallet passphrase") }, modifier = Modifier.fillMaxWidth(), ) Spacer(Modifier.height(8.dp)) - } - OutlinedTextField( - value = password, - onValueChange = { password = it }, - singleLine = true, - label = { Text("wallet passphrase") }, - modifier = Modifier.fillMaxWidth(), - ) - Spacer(Modifier.height(12.dp)) - OwButtonRow { - OwButton( - text = "Cancel", - variant = OwButtonVariant.Outline, - onClick = onCancel, - modifier = Modifier.weight(1f), - ) - OwButton( - text = if (kind == SetupKind.Create) "Create" else "Import", - variant = OwButtonVariant.Primary, - enabled = ready, - onClick = { - scope.launch { - when (kind) { - SetupKind.Create -> create(password).fold( - onSuccess = onCreated, - onFailure = { onError(it.message ?: it.toString()) }, - ) - SetupKind.Import -> importWallet(password, seed.trim()).fold( - onSuccess = { onImported() }, - onFailure = { onError(it.message ?: it.toString()) }, - ) + Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.End) { + TextButton(onClick = onCancel) { Text("Cancel") } + Button( + onClick = { + scope.launch { + when (kind) { + SetupKind.Create -> create(password).fold( + onSuccess = onCreated, + onFailure = { onError(it.message ?: it.toString()) }, + ) + SetupKind.Import -> importWallet(password, seed.trim()).fold( + onSuccess = { onImported() }, + onFailure = { onError(it.message ?: it.toString()) }, + ) + } } - } - }, - modifier = Modifier.weight(1f), - ) + }, + enabled = ready, + ) { Text(if (kind == SetupKind.Create) "Create" else "Import") } + } } } } +/** + * The app-owned `monero-wallet-rpc` control (issue #107), now with the third chain + * source: the chain daemon **inside this app** (Cuprate). + * + * **Start** / **Stop** drive `Wire::start_wallet_child` / `stop_wallet_child` + * through [WireViewModel]; the status line is `Wire::wallet_status()` rendered + * verbatim, so a child that died reads `exited` and never `off`, and an in-process + * source grows a `node ` segment that is the core's own `node_state`. + * + * The card is deliberately talkative about what it *cannot* do: no bundled + * binary, no chain source, a `.onion` daemon with no bundled `arti` SOCKS child, + * or a build without `cuprate-daemon` each get their own sentence, because a Start + * button that can only fail is worse than no button. There is no "starting…" state + * to hide behind — the only spinner-free words on screen are the core's own. + * + * The on-device node is opt-in and carries its pre-production warning **above the + * Start button**, plus the free space on the filesystem its fjall store grows + * into. A device that cannot hold the chain is told before it commits, not left to + * fail at sync time. + */ +@Composable +private fun WalletChildCard( + bins: WalletChildBinaryPaths, + input: WalletChildInput?, + chain: ChainConfig?, + nodeFreeBytes: Long?, + actionError: String?, + daemonText: String, + daemonError: String?, + /** + * The core's `wallet_open` / `needs_passphrase`, straight off the same + * `WalletChildStatus` the status line is drawn from — not a second idea of + * which wallet is open. + */ + walletOpen: Boolean, + needsPassphrase: Boolean, + onDaemonText: (String) -> Unit, + onSaveDaemon: () -> Unit, + onReceiveOnly: () -> Unit, + onInProcessNode: (mainnet: Boolean, prune: Boolean) -> Unit, + starting: Boolean = false, + onStart: () -> Unit, + onStop: () -> Unit, +) { + val phase = walletChildPhase(input) + val node = nodePhase(input) + val onionDaemon = chain?.kind == ChainChoice.REMOTE && isOnionHost(chain.host) + // The selection is in-process as soon as it is stored, before the first status + // read comes back: the warning and the storage line must not wait for the + // poller, or the user would press Start having seen neither. + val inProcess = input?.chainInProcess == true || chain?.kind == ChainChoice.IN_PROCESS_CUPRATE + val startWhy = startBlockedReason(bins, input, onionDaemon, starting) + ?: if (inProcess) { + chainStorageBlockedReason( + nodeFreeBytes, + mainnet = chain?.mainnet == true, + prune = chain?.prune == true, + ) + } else { + null + } + val stopWhy = stopBlockedReason(input) + // A live child with no wallet file open answers every read with the daemon's + // own `-13 No wallet file`. Say that in this app's words, here, rather than + // letting the raw string arrive later on whichever card asked. + val openHint = walletChildOpenHint( + childRunning = input?.running == true, + walletOpen = walletOpen, + needsPassphrase = needsPassphrase, + ) + + Card( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 12.dp, vertical = 8.dp), + colors = CardDefaults.cardColors( + containerColor = MaterialTheme.colorScheme.surfaceVariant, + ), + ) { + Column(Modifier.padding(12.dp)) { + Text("wallet daemon", style = MaterialTheme.typography.titleSmall) + Spacer(Modifier.height(6.dp)) + + // The core's own words: `ready · remote onion daemon`, plus + // `· node syncing` for the in-process source. Tagged with the phase so + // a UI test can assert `exited` is never `off`. + Text( + walletChildLine(input), + style = MaterialTheme.typography.bodySmall, + fontFamily = FontFamily.Monospace, + modifier = Modifier + .fillMaxWidth() + .testTag(phase.testTag) + .semantics(mergeDescendants = true) { + contentDescription = walletChildStatusDescription(input) + }, + ) + + // The node's own word, when there is one, as its own assertable line: + // an unrecognised node state can never be read as ready. + if (node !is NodePhase.Absent) { + Text( + "node: ${node.label}", + style = MaterialTheme.typography.labelSmall, + fontFamily = FontFamily.Monospace, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier + .fillMaxWidth() + .testTag(node.testTag) + .semantics(mergeDescendants = true) { + contentDescription = node.contentDescription + }, + ) + } + + if (!bins.walletRpcBundled) { + Spacer(Modifier.height(6.dp)) + Text( + NO_WALLET_RPC_MESSAGE, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier.fillMaxWidth(), + ) + } + + // "No wallet file open" is a state of a live child, not a failure of + // the last call, so it is said here rather than left to surface as + // the daemon's `-13` on whichever card asked for a read. + openHint?.let { + Spacer(Modifier.height(6.dp)) + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-child-no-wallet"), + ) + } + + // What the user can fix from here: which daemon the child dials. + Spacer(Modifier.height(8.dp)) + OutlinedTextField( + value = daemonText, + onValueChange = onDaemonText, + singleLine = true, + label = { Text("daemon host:port") }, + supportingText = { + Text( + "A daemon on your LAN (e.g. 192.168.1.20:18089) or a public node's " + + "clearnet address. A phone cannot run monerod — for a chain with no " + + "daemon at all, use the on-device node below.", + style = MaterialTheme.typography.labelSmall, + ) + }, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-daemon-input"), + ) + Spacer(Modifier.height(4.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + OutlinedButton( + onClick = onSaveDaemon, + enabled = bins.walletRpcBundled, + modifier = Modifier + .weight(1f) + .testTag("wallet-daemon-save"), + ) { Text("Save daemon") } + OutlinedButton( + onClick = onReceiveOnly, + modifier = Modifier + .weight(1f) + .testTag("wallet-daemon-receive-only"), + ) { Text("Receive-only") } + } + + // Tapping a mode stores it and, when the storage floor allows, + // starts the node. Filled = the stored choice. + Spacer(Modifier.height(8.dp)) + val mode = selectedCuprateMode( + inProcess = inProcess, + mainnet = chain?.mainnet == true, + prune = chain?.prune == true, + ) + CuprateModeButton( + label = "Mainnet pruned", + selected = mode == CuprateMode.MainnetPruned, + testTag = "wallet-chain-mainnet-pruned", + onClick = { onInProcessNode(true, true) }, + ) + Spacer(Modifier.height(4.dp)) + CuprateModeButton( + label = "Mainnet full", + selected = mode == CuprateMode.MainnetFull, + testTag = "wallet-chain-mainnet-full", + onClick = { onInProcessNode(true, false) }, + ) + Spacer(Modifier.height(4.dp)) + CuprateModeButton( + label = "Testnet (experimental)", + selected = mode == CuprateMode.Testnet, + testTag = "wallet-chain-in-process", + onClick = { onInProcessNode(false, false) }, + ) + + if (inProcess) { + Spacer(Modifier.height(8.dp)) + Text( + CUPRATE_PREPRODUCTION_WARNING, + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-cuprate-warning"), + ) + Spacer(Modifier.height(4.dp)) + Text( + chainStorageLine( + nodeFreeBytes, + mainnet = chain?.mainnet == true, + prune = chain?.prune == true, + ), + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-chain-storage"), + ) + } + + Spacer(Modifier.height(8.dp)) + Row( + modifier = Modifier.fillMaxWidth(), + horizontalArrangement = Arrangement.spacedBy(8.dp), + ) { + Button( + onClick = onStart, + enabled = startWhy == null, + modifier = Modifier + .weight(1f) + .testTag("wallet-child-start"), + ) { Text("Start wallet") } + OutlinedButton( + onClick = onStop, + enabled = stopWhy == null, + modifier = Modifier + .weight(1f) + .testTag("wallet-child-stop"), + ) { Text("Stop wallet") } + } + + // Why Start is dead, in the core's terms rather than a grey button. + startWhy?.let { + Spacer(Modifier.height(6.dp)) + Text( + it, + style = MaterialTheme.typography.labelSmall, + color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-child-start-blocked"), + ) + } + + // The last thing the core or the RPC call said. Sticky until the + // user acts, like the chat screen's load error. Filtered through + // `walletFailureText`: the daemon's own `-13 No wallet file` / JSON + // answer is not a sentence about this app and never reaches the + // screen. + val failure = walletFailureText(input?.lastError) ?: actionError ?: daemonError + failure?.let { + Spacer(Modifier.height(6.dp)) + Text( + it, + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.error, + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-child-error"), + ) + } + } + } +} + +@Composable +private fun CuprateModeButton( + label: String, + selected: Boolean, + testTag: String, + onClick: () -> Unit, +) { + val modifier = Modifier + .fillMaxWidth() + .testTag(testTag) + if (selected) { + Button(onClick = onClick, modifier = modifier) { Text(label) } + } else { + OutlinedButton(onClick = onClick, modifier = modifier) { Text(label) } + } +} + /** * Whether the wallet screen's reads (balance, address, recent transfers) should * be reloaded for a given child state. @@ -1394,7 +1149,7 @@ private fun WalletSetupCard( * `walletBalance()` returns the string `"err"` rather than throwing when it * cannot read, so a reload during `connecting` / `off` / `exited` is not a * no-op — it is what writes that `err` into the headline and leaves it stuck on - * `Balance unavailable` after the wallet comes up. + * `balance —` after the child comes up. */ internal fun shouldReloadWalletReads(state: String?): Boolean { val s = state?.trim()?.lowercase() @@ -1407,16 +1162,16 @@ internal fun shouldReloadWalletReads(state: String?): Boolean { * * `lastError` is the one field that is not verbatim. It is the core's * `wallet_status().last_error`, which is the *daemon's* own words on the path - * this screen exists for: a live wallet with no wallet file open answers `-13 - * No wallet file`, and `parse_json_rpc` strips the envelope and keeps that bare - * sentence. A probe that dialled a port the wallet had not bound yet can also + * this screen exists for: a live child with no wallet open answers `-13 No + * wallet file`, and `parse_json_rpc` strips the envelope and keeps that bare + * sentence. A probe that dialled a port the child had not bound yet can also * land here (`wallet connect: Connection refused`) — [displayLastError] drops - * that one while the wallet is still `connecting`. The status header renders - * this field through `walletChildStatusDescription` for the screen reader — so - * the filter belongs here, at the seam where the SDK record becomes the Kotlin - * model, rather than at one of the render sites. `walletFailureText` is - * idempotent on its own replacement texts, so the second pass on the sticky - * error card is stable. + * that one while the child is still `connecting`. The status line renders this + * field — `walletChildLine`, and through it `walletChildStatusDescription` for + * the screen reader — so the filter belongs here, at the seam where the SDK + * record becomes the Kotlin model, rather than at one of the render sites. + * `walletFailureText` is idempotent on its own replacement texts, so the + * second pass on the sticky error card is stable. */ internal fun WalletChildStatus.toInput(): WalletChildInput = WalletChildInput( state = state, diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AlertBanner.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AlertBanner.kt deleted file mode 100644 index a7cbb3f..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AlertBanner.kt +++ /dev/null @@ -1,103 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** Banner severity. Three states, matching the status colours exactly. */ -enum class OwAlertVariant { Warning, Error, Info } - -/** - * A contextual banner: status icon, one-line title, one- or two-line body. - * - * Replaces the raw red and grey paragraphs that used to trail the wallet and - * invite screens. A state the app is *in* (no wallet open, node experimental) is - * an info or warning banner; only a real failure gets [OwAlertVariant.Error]. - */ -@Composable -fun OwAlertBanner( - variant: OwAlertVariant, - title: String, - description: String? = null, - modifier: Modifier = Modifier, - action: (@Composable () -> Unit)? = null, -) { - val text: Color = when (variant) { - OwAlertVariant.Warning -> OwColors.Warning - OwAlertVariant.Error -> OwColors.Danger - OwAlertVariant.Info -> OwColors.TextPrimary - } - val tint: Color = when (variant) { - OwAlertVariant.Warning -> OwColors.WarningTint - OwAlertVariant.Error -> OwColors.DangerTint - OwAlertVariant.Info -> OwColors.InfoTint - } - val border: Color = when (variant) { - OwAlertVariant.Warning -> OwColors.WarningBorder - OwAlertVariant.Error -> OwColors.DangerBorder - OwAlertVariant.Info -> OwColors.InfoBorder - } - val iconRes = when (variant) { - OwAlertVariant.Warning -> R.drawable.ic_ow_warning - OwAlertVariant.Error -> R.drawable.ic_ow_warning - OwAlertVariant.Info -> R.drawable.ic_ow_info - } - val iconTint = when (variant) { - OwAlertVariant.Info -> OwColors.Accent - else -> text - } - - Row( - modifier = modifier - .fillMaxWidth() - .clip(RoundedCornerShape(OwRadius.Control)) - .background(tint) - .border(1.dp, border, RoundedCornerShape(OwRadius.Control)) - .padding(horizontal = 14.dp, vertical = 12.dp), - horizontalArrangement = Arrangement.Start, - ) { - Icon( - painter = painterResource(iconRes), - contentDescription = null, - tint = iconTint, - modifier = Modifier.padding(top = 1.dp).size(18.dp), - ) - Spacer(Modifier.width(10.dp)) - Column(Modifier.weight(1f)) { - Text(title, style = MaterialTheme.typography.titleSmall, color = text) - if (!description.isNullOrBlank()) { - Spacer(Modifier.height(3.dp)) - Text( - description, - style = MaterialTheme.typography.bodySmall, - color = if (variant == OwAlertVariant.Info) OwColors.TextSecondary else text, - ) - } - if (action != null) { - Spacer(Modifier.height(10.dp)) - action() - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AppTopBar.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AppTopBar.kt deleted file mode 100644 index 3c3e1c7..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/AppTopBar.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.RowScope -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.statusBarsPadding -import androidx.compose.foundation.layout.width -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors - -/** - * The app's one top bar. - * - * Deliberately not `TopAppBar`: that component is a fixed height single line, and - * this header carries a second row (the `● Tor active` pill). A custom column - * also keeps the status-bar inset inside the bar's own background instead of - * padding the screen underneath it. - * - * On a sub-screen the navigation slot is a chevron icon button, never the word - * "Back". - */ -@Composable -fun OwTopBar( - title: String, - modifier: Modifier = Modifier, - onBack: (() -> Unit)? = null, - status: (@Composable () -> Unit)? = null, - actions: @Composable RowScope.() -> Unit = {}, -) { - Column( - modifier = modifier - .fillMaxWidth() - .background(OwColors.Canvas) - .statusBarsPadding() - .padding(start = 16.dp, end = 16.dp, top = 10.dp, bottom = 10.dp), - ) { - Row(verticalAlignment = Alignment.CenterVertically) { - if (onBack != null) { - OwIconButton( - iconRes = R.drawable.ic_ow_chevron_left, - contentDescription = "Back", - onClick = onBack, - tint = OwColors.TextPrimary, - background = OwColors.SurfaceInteractive, - ) - Spacer(Modifier.width(12.dp)) - } - Text( - title, - style = MaterialTheme.typography.titleLarge, - fontWeight = FontWeight.Bold, - color = OwColors.TextPrimary, - modifier = Modifier.weight(1f), - ) - Row( - horizontalArrangement = Arrangement.spacedBy(8.dp), - verticalAlignment = Alignment.CenterVertically, - content = actions, - ) - } - if (status != null) { - Spacer(Modifier.height(8.dp)) - status() - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/BottomTabBar.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/BottomTabBar.kt deleted file mode 100644 index f0127a0..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/BottomTabBar.kt +++ /dev/null @@ -1,127 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.annotation.DrawableRes -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.navigationBarsPadding -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.role -import androidx.compose.ui.semantics.selected -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwSize - -/** - * The three top-level destinations. - * - * Chats is home. The node lives inside Wallet (that is where its card already - * is), so the third tab is the security/settings surface: identity, saved - * wallets, rotation, wipe, and — behind progressive disclosure — the SDK line - * that used to sit under the roster. - */ -enum class OwTab(val label: String, @param:DrawableRes val icon: Int) { - Chats("Chats", R.drawable.ic_ow_chat), - Wallet("Wallet", R.drawable.ic_ow_wallet), - // Tab labels stay short: the destination is Node & Settings (that is the - // screen title), but a 10sp label in a third of the bar has no room for it. - Settings("Settings", R.drawable.ic_ow_sliders), -} - -/** - * Persistent bottom navigation. - * - * 64dp of canvas with a single 1dp top border — no elevation shadow, no - * translucent scrim. The navigation-bar inset is applied here, so screens inside - * the shell must not also pad for it (see `LocalBottomBarPresent`). - */ -@Composable -fun OwBottomTabBar( - selected: OwTab, - onSelect: (OwTab) -> Unit, - modifier: Modifier = Modifier, -) { - Column( - modifier = modifier - .fillMaxWidth() - .background(OwColors.Canvas), - ) { - OwDivider() - Row( - modifier = Modifier - .fillMaxWidth() - .navigationBarsPadding() - .height(OwSize.TabBar), - horizontalArrangement = Arrangement.SpaceEvenly, - verticalAlignment = Alignment.CenterVertically, - ) { - OwTab.entries.forEach { tab -> - TabItem( - tab = tab, - selected = tab == selected, - onClick = { onSelect(tab) }, - modifier = Modifier.weight(1f), - ) - } - } - } -} - -@Composable -private fun TabItem( - tab: OwTab, - selected: Boolean, - onClick: () -> Unit, - modifier: Modifier = Modifier, -) { - val tint: Color = if (selected) OwColors.Accent else OwColors.TextMuted - Column( - modifier = modifier - .fillMaxWidth() - .clickable(onClick = onClick) - .semantics { - role = Role.Tab - this.selected = selected - } - .padding(vertical = 8.dp), - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.Center, - ) { - Box(contentAlignment = Alignment.Center) { - Icon( - painter = painterResource(tab.icon), - contentDescription = null, - tint = tint, - modifier = Modifier.size(22.dp), - ) - } - Spacer(Modifier.height(4.dp)) - Text( - tab.label, - style = MaterialTheme.typography.labelSmall, - fontSize = 10.sp, - fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Medium, - color = tint, - ) - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Buttons.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Buttons.kt deleted file mode 100644 index 7ff42b6..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Buttons.kt +++ /dev/null @@ -1,145 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.layout.width -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Button -import androidx.compose.material3.ButtonDefaults -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius -import com.siriusdevops.onionwire.ui.OwSize - -/** - * The four button tiers. There is no fifth: a screen that needs something - * quieter than [Outline] uses a text action, not a new shape. - */ -enum class OwButtonVariant { - /** Solid accent, canvas-coloured semibold text. One per screen region. */ - Primary, - - /** Solid interactive surface, no border. */ - Secondary, - - /** Transparent with the one border. */ - Outline, - - /** Tinted crimson with a crimson border. Destructive actions only. */ - Destructive, -} - -/** - * The app's button. - * - * Heights and radii come from the spec, not from Material's 40dp default: a - * 48dp target is comfortable and consistent, and a 12dp squircle replaces the - * 999dp pill that made every alpha action look identical. - */ -@Composable -fun OwButton( - text: String, - onClick: () -> Unit, - modifier: Modifier = Modifier, - variant: OwButtonVariant = OwButtonVariant.Primary, - enabled: Boolean = true, - leadingIconRes: Int? = null, - content: (@Composable androidx.compose.foundation.layout.RowScope.() -> Unit)? = null, -) { - val height = when (variant) { - OwButtonVariant.Outline -> OwSize.ButtonCompact - else -> OwSize.Button - } - val container = when (variant) { - OwButtonVariant.Primary -> OwColors.Accent - OwButtonVariant.Secondary -> OwColors.SurfaceInteractive - OwButtonVariant.Outline -> Color.Transparent - OwButtonVariant.Destructive -> OwColors.DangerTint - } - val contentColor = when (variant) { - OwButtonVariant.Primary -> OwColors.Canvas - OwButtonVariant.Secondary -> OwColors.TextPrimary - OwButtonVariant.Outline -> OwColors.TextPrimary - OwButtonVariant.Destructive -> OwColors.Danger - } - val weight = if (variant == OwButtonVariant.Primary) FontWeight.SemiBold else FontWeight.Medium - // A local val, not the parameter: a parameter captured by the Button's - // content lambda cannot be smart-cast, and the nullable-call error reads as - // a Compose problem when it is only a Kotlin capture rule. - val customContent = content - - Button( - onClick = onClick, - enabled = enabled, - modifier = modifier.height(height), - shape = RoundedCornerShape(OwRadius.Control), - border = when (variant) { - OwButtonVariant.Outline -> BorderStroke(1.dp, OwColors.Border) - OwButtonVariant.Destructive -> BorderStroke(1.dp, OwColors.DangerBorder) - else -> null - }, - colors = ButtonDefaults.buttonColors( - containerColor = container, - contentColor = contentColor, - disabledContainerColor = when (variant) { - OwButtonVariant.Outline -> Color.Transparent - OwButtonVariant.Primary -> OwColors.SurfaceInteractive - OwButtonVariant.Secondary -> OwColors.Surface - OwButtonVariant.Destructive -> OwColors.Surface - }, - disabledContentColor = OwColors.TextMuted, - ), - elevation = ButtonDefaults.buttonElevation(defaultElevation = 0.dp, pressedElevation = 0.dp), - contentPadding = ButtonDefaults.ContentPadding, - ) { - if (customContent != null) { - customContent() - } else { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center, - ) { - if (leadingIconRes != null) { - Icon( - painter = painterResource(leadingIconRes), - contentDescription = null, - modifier = Modifier.size(18.dp), - ) - Spacer(Modifier.width(8.dp)) - } - Text(text, style = MaterialTheme.typography.labelLarge, fontWeight = weight) - } - } - } -} - -/** - * Two buttons sharing a row: the primary action takes the space, the secondary - * one takes what it needs. Used by the identity bar and the empty state. - */ -@Composable -fun OwButtonRow( - modifier: Modifier = Modifier, - content: @Composable androidx.compose.foundation.layout.RowScope.() -> Unit, -) { - Row( - modifier = modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(12.dp), - verticalAlignment = Alignment.CenterVertically, - content = content, - ) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Dialogs.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Dialogs.kt deleted file mode 100644 index cb8d1ea..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Dialogs.kt +++ /dev/null @@ -1,93 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.AlertDialog -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.OutlinedTextField -import androidx.compose.material3.Text -import androidx.compose.material3.TextButton -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * A typed-confirmation dialog for an irreversible action. - * - * The typed word is not theatre: "Rotate identity" cuts every friend who is - * offline off the current locator, and "Wipe all chats" deletes every message - * body. Both are one stray tap away from a menu, so the dialog asks for the - * word the user is about to lose. - * - * [confirmationWord] is echoed in the field label; the confirm button stays - * disabled until it is typed (case-insensitively) — same contract the old inline - * confirm strip had, now with a real scrim behind it. - */ -@Composable -fun OwConfirmDialog( - title: String, - body: String, - confirmationWord: String, - confirmLabel: String, - destructive: Boolean, - onConfirm: () -> Unit, - onDismiss: () -> Unit, -) { - var typed by remember { mutableStateOf("") } - val armed = typed.trim().equals(confirmationWord, ignoreCase = true) - - AlertDialog( - onDismissRequest = onDismiss, - shape = RoundedCornerShape(OwRadius.Card), - containerColor = OwColors.Surface, - titleContentColor = OwColors.TextPrimary, - textContentColor = OwColors.TextSecondary, - title = { Text(title, style = MaterialTheme.typography.titleMedium) }, - text = { - Column { - Text(body, style = MaterialTheme.typography.bodyMedium) - Spacer(Modifier.height(14.dp)) - OutlinedTextField( - value = typed, - onValueChange = { typed = it }, - singleLine = true, - label = { Text("Type $confirmationWord") }, - modifier = Modifier.fillMaxWidth(), - ) - } - }, - confirmButton = { - Row(horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth()) { - TextButton(onClick = onDismiss) { - Text("Cancel", color = OwColors.TextSecondary) - } - TextButton( - onClick = onConfirm, - enabled = armed, - ) { - Text( - confirmLabel, - color = when { - !armed -> OwColors.TextMuted - destructive -> OwColors.Danger - else -> OwColors.Accent - }, - ) - } - } - }, - modifier = Modifier.padding(horizontal = 8.dp), - ) -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/OverflowMenu.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/OverflowMenu.kt deleted file mode 100644 index f467049..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/OverflowMenu.kt +++ /dev/null @@ -1,69 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.layout.Box -import androidx.compose.material3.DropdownMenu -import androidx.compose.material3.DropdownMenuItem -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.unit.dp -import com.siriusdevops.onionwire.R -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * The `⋮` overflow on the messenger and settings bars. - * - * Serious and rare actions live here instead of on the home screen: rotating the - * identity cuts every offline friend off the current locator, and deleting the - * message history is irreversible. Neither belongs next to "Invite". - * - * The menu is a component rather than inline code so the destructive verbs have - * exactly one home — a new screen that wants the overflow gets the same list, - * not a second copy with different wording. - */ -@Composable -fun OwOverflowMenu( - onOpenProfile: () -> Unit, - onOpenWallets: () -> Unit, - onRotate: () -> Unit, - onWipe: () -> Unit, - modifier: Modifier = Modifier, -) { - var open by remember { mutableStateOf(false) } - - Box(modifier) { - OwIconButton( - iconRes = R.drawable.ic_ow_more_vert, - contentDescription = "More actions", - onClick = { open = true }, - ) - DropdownMenu( - expanded = open, - onDismissRequest = { open = false }, - containerColor = OwColors.SurfaceInteractive, - shape = androidx.compose.foundation.shape.RoundedCornerShape(OwRadius.Control), - ) { - DropdownMenuItem( - text = { Text("Your profile", color = OwColors.TextPrimary) }, - onClick = { open = false; onOpenProfile() }, - ) - DropdownMenuItem( - text = { Text("Saved wallets", color = OwColors.TextPrimary) }, - onClick = { open = false; onOpenWallets() }, - ) - DropdownMenuItem( - text = { Text("Rotate identity", color = OwColors.TextPrimary) }, - onClick = { open = false; onRotate() }, - ) - DropdownMenuItem( - text = { Text("Delete message history", color = OwColors.Danger) }, - onClick = { open = false; onWipe() }, - ) - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/QrCode.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/QrCode.kt deleted file mode 100644 index 9e3fb3d..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/QrCode.kt +++ /dev/null @@ -1,78 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.Canvas -import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.runtime.Composable -import androidx.compose.runtime.remember -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.geometry.Size -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import com.google.zxing.BarcodeFormat -import com.google.zxing.EncodeHintType -import com.google.zxing.qrcode.QRCodeWriter -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * Renders [payload] as a QR code. - * - * The invite is a locator plus a prekey — long, and it has to survive a person - * pointing a phone at a screen, so the modules are drawn at full contrast on a - * light plate rather than tinted to match the dark theme. - * - * A payload zxing cannot encode (too long for version 40) renders as an empty - * plate; callers always show the copyable text as well, so a failed encode is - * degraded, not fatal. - */ -@Composable -fun OwQrCode( - payload: String, - modifier: Modifier = Modifier, - size: Dp = 200.dp, -) { - val matrix = remember(payload) { - runCatching { - QRCodeWriter().encode( - payload, - BarcodeFormat.QR_CODE, - 0, - 0, - mapOf(EncodeHintType.MARGIN to 0), - ) - }.getOrNull() - } - Box( - modifier = modifier - .size(size) - .clip(RoundedCornerShape(OwRadius.Control)) - .background(OwColors.TextPrimary), - contentAlignment = Alignment.Center, - ) { - if (matrix != null) { - Canvas(Modifier.size(size)) { - val cells = matrix.width.toFloat() - val cellW = this.size.width / cells - val cellH = this.size.height / matrix.height.toFloat() - for (y in 0 until matrix.height) { - for (x in 0 until matrix.width) { - if (matrix.get(x, y)) { - drawRect( - color = Color(0xFF0A0C0E), - topLeft = Offset(x * cellW, y * cellH), - size = Size(cellW + 0.5f, cellH + 0.5f), - ) - } - } - } - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/SegmentedControl.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/SegmentedControl.kt deleted file mode 100644 index c5f2f2b..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/SegmentedControl.kt +++ /dev/null @@ -1,104 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.animation.animateColorAsState -import androidx.compose.animation.core.tween -import androidx.compose.foundation.background -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.platform.testTag -import androidx.compose.ui.semantics.Role -import androidx.compose.ui.semantics.role -import androidx.compose.ui.semantics.selected -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.text.font.FontWeight -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius - -/** - * Horizontal segmented control: one track, [OwColors.SurfaceInteractive], 4dp of - * inside padding, 12dp radius. - * - * This replaces the stacks of full-width pill buttons that made "Pruned / Full / - * Testnet" read as three unrelated actions rather than one choice with three - * values. The selected segment is an accent fill with canvas text. - */ -@Composable -fun OwSegmentedControl( - options: List, - selectedIndex: Int, - onSelect: (Int) -> Unit, - modifier: Modifier = Modifier, - enabled: Boolean = true, - /** - * Optional per-segment `testTag`s, one per option. Additive: omitted (the - * default) leaves every existing call site byte-identical. It exists because - * a merged "Pruned / Full / Testnet" track has no per-value handle otherwise, - * and the wallet screen's tests address each segment by the tag it had when - * the three options were three stacked buttons. - */ - testTags: List = emptyList(), -) { - Row( - modifier = modifier - .fillMaxWidth() - .clip(RoundedCornerShape(OwRadius.Control)) - .background(OwColors.SurfaceInteractive) - .padding(4.dp), - verticalAlignment = Alignment.CenterVertically, - ) { - options.forEachIndexed { index, label -> - val selected = index == selectedIndex - val container by animateColorAsState( - targetValue = if (selected) OwColors.Accent else OwColors.SurfaceInteractive, - animationSpec = tween(durationMillis = 160), - label = "segment-container", - ) - val textColor by animateColorAsState( - targetValue = when { - selected -> OwColors.Canvas - enabled -> OwColors.TextSecondary - else -> OwColors.TextMuted - }, - animationSpec = tween(durationMillis = 160), - label = "segment-text", - ) - val tag = testTags.getOrNull(index) - Box( - modifier = Modifier - .weight(1f) - .height(36.dp) - .clip(RoundedCornerShape(9.dp)) - .background(container) - .then(if (tag != null) Modifier.testTag(tag) else Modifier) - .clickable(enabled = enabled && !selected) { onSelect(index) } - .semantics { - role = Role.Tab - this.selected = selected - }, - contentAlignment = Alignment.Center, - ) { - Text( - label, - style = MaterialTheme.typography.labelLarge, - fontSize = 13.sp, - fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Medium, - color = textColor, - ) - } - } - } -} diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Surfaces.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Surfaces.kt deleted file mode 100644 index 57bdfde..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/components/Surfaces.kt +++ /dev/null @@ -1,260 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import androidx.compose.foundation.BorderStroke -import androidx.compose.foundation.Canvas -import androidx.compose.foundation.background -import androidx.compose.foundation.border -import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.ColumnScope -import androidx.compose.foundation.layout.Row -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.size -import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.Icon -import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment -import androidx.compose.ui.Modifier -import androidx.compose.ui.draw.clip -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.geometry.Size -import androidx.compose.ui.graphics.Color -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.semantics.contentDescription -import androidx.compose.ui.semantics.semantics -import androidx.compose.ui.unit.Dp -import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp -import com.siriusdevops.onionwire.ui.MonoStyle -import com.siriusdevops.onionwire.ui.OwColors -import com.siriusdevops.onionwire.ui.OwRadius -import com.siriusdevops.onionwire.ui.OwSize - -/** - * A section card: [OwColors.Surface], 16dp radius, one 1dp border, 16dp of - * padding. Every non-list block on every screen is one of these. - */ -@Composable -fun OwCard( - modifier: Modifier = Modifier, - padding: Dp = 16.dp, - content: @Composable ColumnScope.() -> Unit, -) { - Column( - modifier = modifier - .clip(RoundedCornerShape(OwRadius.Card)) - .background(OwColors.Surface) - .border(1.dp, OwColors.Border, RoundedCornerShape(OwRadius.Card)) - .padding(padding), - content = content, - ) -} - -/** Small tracked label, secondary colour. Never monospace. */ -@Composable -fun Label(text: String, modifier: Modifier = Modifier) { - Text( - text, - modifier = modifier, - style = MaterialTheme.typography.labelSmall, - color = OwColors.TextSecondary, - ) -} - -/** - * Cryptographic material and numbers only: pubkeys, truncated locators, seeds, - * `host:port`, block heights. Never a sentence. - */ -@Composable -fun Mono(text: String, modifier: Modifier = Modifier, color: Color = OwColors.TextPrimary) { - Text(text, modifier = modifier, style = MonoStyle.copy(color = color)) -} - -/** Section heading inside a card. */ -@Composable -fun OwSectionTitle(text: String, modifier: Modifier = Modifier) { - Text( - text, - modifier = modifier, - style = MaterialTheme.typography.titleMedium, - color = OwColors.TextPrimary, - ) -} - -/** A 7dp status dot. Colour is the caller's statement, not decoration. */ -@Composable -fun OwStatusDot(color: Color, modifier: Modifier = Modifier) { - Box(modifier.size(7.dp).clip(CircleShape).background(color)) -} - -/** Small status badge — the one place a 999dp radius is correct. */ -@Composable -fun OwPill( - text: String, - modifier: Modifier = Modifier, - textColor: Color = OwColors.TextSecondary, - container: Color = OwColors.SurfaceInteractive, - borderColor: Color? = null, - dotColor: Color? = null, -) { - Row( - modifier = modifier - .clip(RoundedCornerShape(OwRadius.Pill)) - .background(container) - .then( - if (borderColor != null) { - Modifier.border(1.dp, borderColor, RoundedCornerShape(OwRadius.Pill)) - } else { - Modifier - }, - ) - .padding(horizontal = 10.dp, vertical = 4.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(6.dp), - ) { - if (dotColor != null) OwStatusDot(dotColor) - Text(text, style = MaterialTheme.typography.labelSmall, color = textColor, fontSize = 11.sp) - } -} - -/** - * The header status pill: `● Tor active`. - * - * Shown while the app is in `Phase.Ready`, which is exactly when the node (and - * therefore Arti) is up. It says nothing about reachability after the app - * leaves the foreground — the keep-alive state is a separate row on the - * settings screen, because that is the honest place for it. - */ -@Composable -fun TorStatusPill(modifier: Modifier = Modifier) { - OwPill( - text = "Tor active", - modifier = modifier, - textColor = OwColors.Accent, - container = OwColors.InfoTint, - borderColor = OwColors.InfoBorder, - dotColor = OwColors.Accent, - ) -} - -/** - * A 36x36 icon button on an interactive surface. Used for Lock, back chevrons - * and the overflow trigger. - */ -@Composable -fun OwIconButton( - iconRes: Int, - contentDescription: String, - onClick: () -> Unit, - modifier: Modifier = Modifier, - tint: Color = OwColors.TextPrimary, - background: Color = OwColors.SurfaceInteractive, - size: Dp = OwSize.IconButton, -) { - Box( - modifier = modifier - .size(size) - .clip(RoundedCornerShape(OwRadius.Control)) - .background(background) - .clickable(onClick = onClick) - .semantics { this.contentDescription = contentDescription }, - contentAlignment = Alignment.Center, - ) { - Icon( - painter = painterResource(iconRes), - contentDescription = null, - tint = tint, - modifier = Modifier.size(18.dp), - ) - } -} - -/** - * A deterministic 5x5 identicon derived from the identity fingerprint. - * - * Not a security feature: it is a stable visual handle so "your identity" is - * recognisable at a glance without reading 64 hex characters. It renders the - * seed it was given — it never invents a value, and two devices showing the - * same fingerprint show the same picture. - */ -@Composable -fun Identicon(seed: String, modifier: Modifier = Modifier, size: Dp = 40.dp) { - val palette = listOf(OwColors.Accent, OwColors.TextSecondary, OwColors.TextMuted) - val cells = identiconCells(seed) - Box( - modifier = modifier - .size(size) - .clip(CircleShape) - .background(OwColors.SurfaceInteractive), - contentAlignment = Alignment.Center, - ) { - Canvas(Modifier.size(size * 0.62f)) { - val cell = this.size.minDimension / 5f - val pad = (this.size.minDimension - cell * 5f) / 2f - cells.forEach { (x, y, tone) -> - drawRect( - color = palette[tone % palette.size], - topLeft = Offset(pad + x * cell, pad + y * cell), - size = Size(cell, cell), - ) - } - } - } -} - -/** - * The left half of a 5-wide grid plus its mirror, as (column, row, tone) - * triples. Pure and cheap: the same seed always yields the same picture. - */ -internal fun identiconCells(seed: String): List> { - if (seed.isEmpty()) return emptyList() - val bytes = seed.map { it.code }.toIntArray() - var i = 0 - val out = mutableListOf>() - for (row in 0 until 5) { - for (col in 0 until 3) { - val v = bytes[i % bytes.size] - i++ - // A cell exists when the byte says so; tone varies the shade. - if (v % 3 != 0) { - val tone = (v / 3) % 3 - out += Triple(col, row, tone) - val mirrored = 4 - col - if (mirrored != col) out += Triple(mirrored, row, tone) - } - } - } - return out -} - -/** The one hairline rule. */ -@Composable -fun OwDivider(modifier: Modifier = Modifier, color: Color = OwColors.Border) { - Box(modifier.fillMaxWidth().height(1.dp).background(color)) -} - -/** Border stroke helper so screens never hardcode the token twice. */ -val OwCardBorder: BorderStroke = BorderStroke(1.dp, OwColors.Border) - -/** Convenience for the many `Icon(painterResource(...))` call sites. */ -@Composable -fun OwIcon( - iconRes: Int, - contentDescription: String?, - tint: Color = OwColors.TextPrimary, - size: Dp = 20.dp, -) { - Icon( - painter = painterResource(iconRes), - contentDescription = contentDescription, - tint = tint, - modifier = Modifier.size(size), - ) -} diff --git a/android/app/src/main/res/drawable/ic_ow_add.xml b/android/app/src/main/res/drawable/ic_ow_add.xml deleted file mode 100644 index 3f91af8..0000000 --- a/android/app/src/main/res/drawable/ic_ow_add.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_chat.xml b/android/app/src/main/res/drawable/ic_ow_chat.xml deleted file mode 100644 index e673602..0000000 --- a/android/app/src/main/res/drawable/ic_ow_chat.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_chevron_left.xml b/android/app/src/main/res/drawable/ic_ow_chevron_left.xml deleted file mode 100644 index b235eaa..0000000 --- a/android/app/src/main/res/drawable/ic_ow_chevron_left.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_copy.xml b/android/app/src/main/res/drawable/ic_ow_copy.xml deleted file mode 100644 index d52c3fb..0000000 --- a/android/app/src/main/res/drawable/ic_ow_copy.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_info.xml b/android/app/src/main/res/drawable/ic_ow_info.xml deleted file mode 100644 index 2a5d106..0000000 --- a/android/app/src/main/res/drawable/ic_ow_info.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_lock.xml b/android/app/src/main/res/drawable/ic_ow_lock.xml deleted file mode 100644 index fce7ee1..0000000 --- a/android/app/src/main/res/drawable/ic_ow_lock.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_more_vert.xml b/android/app/src/main/res/drawable/ic_ow_more_vert.xml deleted file mode 100644 index bcd27db..0000000 --- a/android/app/src/main/res/drawable/ic_ow_more_vert.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_person.xml b/android/app/src/main/res/drawable/ic_ow_person.xml deleted file mode 100644 index 7bc0b35..0000000 --- a/android/app/src/main/res/drawable/ic_ow_person.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_qr.xml b/android/app/src/main/res/drawable/ic_ow_qr.xml deleted file mode 100644 index 7e43c96..0000000 --- a/android/app/src/main/res/drawable/ic_ow_qr.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_share.xml b/android/app/src/main/res/drawable/ic_ow_share.xml deleted file mode 100644 index dc49c02..0000000 --- a/android/app/src/main/res/drawable/ic_ow_share.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_shield.xml b/android/app/src/main/res/drawable/ic_ow_shield.xml deleted file mode 100644 index 2aab4a8..0000000 --- a/android/app/src/main/res/drawable/ic_ow_shield.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_sliders.xml b/android/app/src/main/res/drawable/ic_ow_sliders.xml deleted file mode 100644 index d16a838..0000000 --- a/android/app/src/main/res/drawable/ic_ow_sliders.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_wallet.xml b/android/app/src/main/res/drawable/ic_ow_wallet.xml deleted file mode 100644 index ed74045..0000000 --- a/android/app/src/main/res/drawable/ic_ow_wallet.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - diff --git a/android/app/src/main/res/drawable/ic_ow_warning.xml b/android/app/src/main/res/drawable/ic_ow_warning.xml deleted file mode 100644 index 234711a..0000000 --- a/android/app/src/main/res/drawable/ic_ow_warning.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/ProfileDraftTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/ProfileDraftTest.kt index aa7f9b2..f112b91 100644 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/ProfileDraftTest.kt +++ b/android/app/src/test/java/com/siriusdevops/onionwire/ui/ProfileDraftTest.kt @@ -239,9 +239,7 @@ class ProfileDraftTest { fun an_empty_address_says_nobody_can_pay() { val text = profileAddressNotice("") assertTrue(text.contains("clears the profile address")) - // The consequence, not the process name: the copy no longer says - // "wallet child" anywhere a user can read it. - assertTrue(text.contains("running wallet")) + assertTrue(text.contains("wallet child")) assertTrue(text.contains("nobody can send you an invoice")) } diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterOnionTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterOnionTest.kt deleted file mode 100644 index 0fa45bf..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/RosterOnionTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import org.junit.Assert.assertEquals -import org.junit.Test - -/** - * `shortOnion`, the roster's locator abbreviation, on the JVM. - * - * A v3 onion locator must never be soft-wrapped or reduced to a middle slice - * that hides `.onion`: the suffix is what tells a reader this is an onion - * address at all, and the full value is available on the profile and invite - * screens. Pure logic, no Robolectric — same shape as `RosterIdTest`. - */ -class RosterOnionTest { - - private val v3 = - "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwxyz234567.onion" - - @Test - fun a_v3_locator_keeps_its_suffix() { - val short = shortOnion(v3) - assertEquals(true, short.endsWith(".onion")) - assertEquals(v3.take(10), short.substringBefore("\u2026")) - assertEquals(v3.removeSuffix(".onion").takeLast(6), short.removeSuffix(".onion").substringAfter("\u2026")) - } - - @Test - fun the_suffix_is_never_the_part_that_is_cut() { - // Even with an aggressive abbreviation the reader still sees `….onion`. - val body = v3.removeSuffix(".onion") - val short = shortOnion(v3, head = 3, tail = 2) - assertEquals(body.take(3) + "\u2026" + body.takeLast(2) + ".onion", short) - } - - @Test - fun a_short_value_is_returned_unchanged() { - assertEquals("abc.onion", shortOnion("abc.onion")) - assertEquals("", shortOnion("")) - } - - @Test - fun a_value_with_no_suffix_is_not_mangled() { - assertEquals("not-an-onion", shortOnion("not-an-onion")) - } -} diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt index 255c217..aa92f6c 100644 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt +++ b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt @@ -207,8 +207,8 @@ class WalletChildStatusTextTest { @Test fun stop_is_blocked_when_nothing_is_running() { - assertTrue(stopBlockedReason(input("off"))!!.contains("No wallet is running")) - assertTrue(stopBlockedReason(input("exited"))!!.contains("No wallet is running")) + assertTrue(stopBlockedReason(input("off"))!!.contains("No wallet child")) + assertTrue(stopBlockedReason(input("exited"))!!.contains("No wallet child")) assertEquals(READING_CHILD_NOTICE, stopBlockedReason(null)) } @@ -397,7 +397,7 @@ class WalletChildStatusTextTest { "a screen reader is told the same as the eye", spoken.endsWith(walletChildLine(input)), ) - assertTrue("it is still a sentence", spoken.startsWith("The wallet is starting")) + assertTrue("it is still a sentence", spoken.startsWith("The wallet child is up")) } @Test @@ -417,17 +417,14 @@ class WalletChildStatusTextTest { } @Test - fun the_on_device_banner_is_titled_and_says_what_it_costs() { - // The banner's title is the plan's exact string; the body keeps every - // honesty bound the old single-sentence warning carried. - assertEquals("Experimental On-Device Node (Cuprate)", CUPRATE_ON_DEVICE_TITLE) - val body = CUPRATE_ON_DEVICE_BODY - assertTrue("it names the software", body.contains("Cuprate")) - assertTrue("it names the parity gap", body.contains("#278")) - assertTrue("it quotes the user book", body.contains("do NOT use cuprated")) - assertTrue("it says mainnet is unvalidated", body.contains("Mainnet is unvalidated")) - assertTrue("it says not to hold funds", body.contains("Do not use for significant funds")) - assertTrue("it is a sentence, not a glyph", body.trim().endsWith(".")) + fun the_preproduction_warning_is_a_sentence_a_user_can_act_on() { + val warning = CUPRATE_PREPRODUCTION_WARNING + assertTrue("it names the software", warning.contains("Cuprate")) + assertTrue("it quotes the user book", warning.contains("do NOT use cuprated")) + assertTrue("it names the parity gap", warning.contains("Cuprate issue #278")) + assertTrue("it says mainnet is unvalidated", warning.contains("mainnet is unvalidated")) + assertTrue("it is a sentence, not a glyph", warning.trim().endsWith(".")) + assertTrue("it is long enough to be a sentence", warning.length > 80) } // --- storage honesty ---------------------------------------------------- @@ -522,239 +519,4 @@ class WalletChildStatusTextTest { assertEquals("1.5 GiB", formatBytes(3L * 1024 * 1024 * 1024 / 2)) assertEquals("3.0 GiB", formatBytes(CHAIN_FREE_SPACE_FLOOR_BYTES)) } - - // --- the node card's progress header (plan P4.3) ------------------------- - - @Test - fun block_counts_group_by_three_regardless_of_locale() { - assertEquals("0", formatBlockCount(0uL)) - assertEquals("999", formatBlockCount(999uL)) - assertEquals("1,000", formatBlockCount(1_000uL)) - assertEquals("485,253", formatBlockCount(485_253uL)) - assertEquals("3,794,383", formatBlockCount(3_794_383uL)) - assertEquals("12,345,678", formatBlockCount(12_345_678uL)) - } - - @Test - fun the_progress_header_says_percent_and_formatted_blocks() { - val p = syncProgress(485_253uL, 3_794_383uL) - assertEquals("12.8%", p.percentText) - assertEquals("Block 485,253 of 3,794,383", p.blockText) - assertTrue("a fraction of the track", p.fraction > 0.12f && p.fraction < 0.13f) - } - - @Test - fun a_caught_up_node_fills_the_track_and_does_not_overflow() { - val atTip = syncProgress(3_794_383uL, 3_794_383uL) - assertEquals("100.0%", atTip.percentText) - assertEquals(1f, atTip.fraction) - // A daemon one block ahead of the target it reported must not render - // 108% — the bar clamps and the text is the clamped number. - val ahead = syncProgress(4_100_000uL, 3_794_383uL) - assertEquals("100.0%", ahead.percentText) - assertEquals(1f, ahead.fraction) - } - - @Test - fun an_unknown_target_is_never_a_percentage() { - // `target_height == 0` is "the daemon reported no target" — Cuprate - // omits it even at the tip. Printing 100% there would claim synced. - val p = syncProgress(4_549uL, 0uL) - assertNull("no percent from a zero target", p.percentText) - assertEquals(0f, p.fraction) - assertEquals("Block 4,549 of an unknown target", p.blockText) - assertFalse("no percent string leaks", p.blockText!!.contains("%")) - } - - @Test - fun no_numbers_means_no_progress_row() { - val p = syncProgress(0uL, 0uL) - assertNull(p.percentText) - assertNull(p.blockText) - assertEquals(0f, p.fraction) - } - - @Test - fun the_three_modes_are_named_the_way_the_stored_choice_reads() { - assertEquals("Mainnet Pruned", chainModeLabel(mainnet = true, prune = true)) - assertEquals("Mainnet Full", chainModeLabel(mainnet = true, prune = false)) - assertEquals("Testnet", chainModeLabel(mainnet = false, prune = false)) - } - - @Test - fun the_node_header_never_reads_ready_without_the_cores_word() { - assertEquals("Wallet Offline", nodeStatusHead(input("off", configured = false)).title) - assertEquals("Connecting…", nodeStatusHead(input("connecting", running = true)).title) - assertEquals(NodeStatusTone.Busy, nodeStatusHead(input("connecting", running = true)).tone) - assertTrue( - "a running child that has not answered is not ready", - nodeStatusHead(input("connecting", running = true)).tone != NodeStatusTone.Good, - ) - assertEquals(NodeStatusTone.Good, nodeStatusHead(input("ready", running = true)).tone) - assertEquals(NodeStatusTone.Bad, nodeStatusHead(input("mining", running = true)).tone) - assertEquals( - "an unknown state is never green", - NodeStatusTone.Bad, - nodeStatusHead(input("mining", running = true)).tone, - ) - assertEquals("Wallet Stopped", nodeStatusHead(input("exited")).title) - assertEquals("Reading wallet status", nodeStatusHead(null).title) - } - - @Test - fun the_node_header_names_the_mode_only_for_the_on_device_node() { - assertEquals( - "Syncing Node (Mainnet Pruned)", - nodeStatusHead( - node(state = "syncing", chainSource = "in-process mainnet pruned", nodeState = "syncing"), - inProcess = true, - mainnet = true, - prune = true, - ).title, - ) - assertEquals( - "Node Idle (Testnet)", - nodeStatusHead(input("off", configured = false), inProcess = true, mainnet = false).title, - ) - assertEquals( - "Syncing Wallet", - nodeStatusHead(input("syncing", running = true, chainSource = "remote daemon")).title, - ) - } - - // --- the stored wallet binary: heal before spawn, then gate on it ------- - - private val hostsBundled = "/data/app/~~abc/onionwire-1/lib/arm64/libmonerowalletrpc.so" - - @Test - fun a_stored_bare_name_is_repaired_to_the_bundled_absolute_path() { - // A record written by an older install: a bare name nothing in an APK - // sandbox resolves on PATH. The repair is the absolute path this - // install actually carries. - assertEquals(hostsBundled, walletBinHealPath("monero-wallet-rpc", hostsBundled) { false }) - assertEquals("an empty stored bin is healed too", hostsBundled, walletBinHealPath("", hostsBundled) { false }) - assertEquals("and a missing field", hostsBundled, walletBinHealPath(null, hostsBundled) { false }) - } - - @Test - fun a_stored_path_that_actually_runs_is_never_overwritten() { - val userBin = "/data/user/0/com.siriusdevops.onionwire/files/monero-wallet-rpc" - assertNull( - "a real executable file the user pointed at is left alone", - walletBinHealPath(userBin, hostsBundled) { it == userBin }, - ) - assertNull( - "a bundled path already stored needs no write", - walletBinHealPath(hostsBundled, hostsBundled) { it == hostsBundled }, - ) - } - - @Test - fun no_bundled_binary_means_there_is_nothing_to_repair_with() { - assertNull(walletBinHealPath("monero-wallet-rpc", null) { false }) - assertNull(walletBinHealPath("monero-wallet-rpc", " ") { false }) - } - - @Test - fun a_stored_bin_missing_on_the_device_blocks_start_and_names_the_path() { - val why = startGateReason(bundled, input("off"), "monero-wallet-rpc") { false } - assertNotNull("a stored path that cannot run must block Start", why) - assertTrue("the reason names the stored path it is about", why!!.contains("monero-wallet-rpc")) - assertTrue("and the path this build does carry", why.contains(bundled.walletRpc!!)) - assertTrue("and says it cannot run", why.contains("cannot be run")) - assertFalse( - "a gate that refuses never lets a mode tap auto-start", - shouldStartAfterSelectingChain(storageBlocked = null, starting = false, startBlocked = why), - ) - } - - @Test - fun an_absent_resolved_bin_blocks_with_the_resolved_absence_message() { - // Nothing in this build to spawn: the established string, unchanged. - val why = startGateReason(noBinary, input("off"), "/stale/libmonerowalletrpc.so") { false } - assertEquals(NO_WALLET_RPC_MESSAGE, why) - assertFalse(shouldStartAfterSelectingChain(null, false, why)) - } - - @Test - fun a_runnable_stored_bin_passes_the_gate() { - assertNull(startGateReason(bundled, input("off"), bundled.walletRpc) { it == bundled.walletRpc }) - assertNull(storedWalletBinBlockedReason(bundled.walletRpc, bundled.walletRpc) { true }) - } - - @Test - fun the_gate_keeps_the_established_start_ordering() { - // Reading the status still wins over a stored-path complaint: the - // existing copy and its order were not rewritten to make room. - assertEquals(READING_CHILD_NOTICE, startGateReason(bundled, null, null) { false }) - assertEquals( - NO_CHAIN_SOURCE_NOTICE, - startGateReason(bundled, input("off", configured = false, chainSource = "receive-only"), null) { false }, - ) - } - - @Test - fun a_mode_tap_stores_the_source_but_cannot_auto_start_what_the_gate_refuses() { - assertTrue(shouldStartAfterSelectingChain(storageBlocked = null, starting = false)) - assertTrue( - shouldStartAfterSelectingChain(storageBlocked = null, starting = false, startBlocked = null), - ) - assertFalse( - shouldStartAfterSelectingChain( - storageBlocked = null, - starting = false, - startBlocked = "The stored wallet binary cannot be run on this device: …", - ), - ) - } - - @Test - fun create_and_import_are_blocked_without_a_running_child() { - assertEquals(WALLET_SETUP_NEEDS_CHILD, walletSetupBlockedReason(input("off"))) - assertEquals(WALLET_SETUP_NEEDS_CHILD, walletSetupBlockedReason(input("exited", lastError = "spawn …"))) - assertEquals(WALLET_SETUP_NEEDS_CHILD, walletSetupBlockedReason(input("mining"))) - assertEquals(WALLET_SETUP_STARTING, walletSetupBlockedReason(input("connecting", running = true))) - assertEquals(READING_CHILD_NOTICE, walletSetupBlockedReason(null)) - assertNull( - "a syncing wallet answers RPC, so a create is fine", - walletSetupBlockedReason(input("syncing", running = true)), - ) - assertNull(walletSetupBlockedReason(input("ready", running = true))) - } - - // --- the no-wallet-open state is information, not a failure ------------ - - @Test - fun the_no_wallet_open_state_is_information_never_the_red_failure() { - // The `No wallet open` info banner owns this sentence; printing it a - // second time in red is the duplicate the device report caught. - assertNull( - "already said once by the info banner above", - walletFailureBanner(WALLET_NOT_OPEN_TEXT, openHintVisible = true, walletOpen = false), - ) - val alone = walletFailureBanner(WALLET_NOT_OPEN_TEXT, openHintVisible = false, walletOpen = false) - assertNotNull(alone) - assertEquals(WalletFailureTone.Info, alone!!.tone) - assertEquals("No wallet open", alone.title) - assertEquals(WALLET_NOT_OPEN_TEXT, alone.text) - assertNull( - "the state ended when a wallet was opened", - walletFailureBanner(WALLET_NOT_OPEN_TEXT, openHintVisible = false, walletOpen = true), - ) - } - - @Test - fun a_real_failure_still_paints_red() { - val refused = walletFailureText("wallet connect: Connection refused (os error 111)")!! - val banner = walletFailureBanner(refused, openHintVisible = true, walletOpen = false)!! - assertEquals("a refusal is still a failure", WalletFailureTone.Error, banner.tone) - assertEquals("Wallet error", banner.title) - assertEquals(refused, banner.text) - - val exited = walletFailureText("spawn monero-wallet-rpc: No such file or directory (os error 2)")!! - assertEquals(WalletFailureTone.Error, walletFailureBanner(exited, false, false)!!.tone) - - assertNull(walletFailureBanner(null, true, false)) - assertNull(walletFailureBanner(" ", true, false)) - } } diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletManagerTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletManagerTest.kt index aab4313..7fc60c9 100644 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletManagerTest.kt +++ b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletManagerTest.kt @@ -117,7 +117,7 @@ class WalletManagerTest { @Test fun a_row_that_is_not_open_says_to_open_it() { val why = walletSecretsBlockedReason(isActive = false, walletReadable = readable) - assertEquals("Open this wallet to view its backup.", why) + assertEquals("open this wallet to view its backup", why) } @Test @@ -212,7 +212,7 @@ class WalletManagerTest { walletPassphraseSubmitEnabled(activeFilename = null, typed = "pw", inFlight = false), ) val why = walletPassphraseBlockedReason(activeFilename = null, typed = "pw") - assertTrue("got '$why'", why != null && why.contains("No wallet file is open yet")) + assertTrue("got '$why'", why != null && why.contains("not pointed at")) // The two reasons are different fixes and must not read alike. assertFalse(why == walletPassphraseBlockedReason(activeFilename = openFile, typed = "")) } @@ -225,7 +225,7 @@ class WalletManagerTest { @Test fun nothing_typed_is_the_other_reason() { val why = walletPassphraseBlockedReason(activeFilename = openFile, typed = "") - assertTrue("got '$why'", why != null && why.contains("Type the passphrase")) + assertTrue("got '$why'", why != null && why.contains("type the passphrase")) } // --- the daemon's own words never reach the screen ----------------------- @@ -348,12 +348,7 @@ class WalletManagerTest { walletOpen = false, needsPassphrase = false, ) - // The §4.1 replacement copy, verbatim: a live wallet with no file open - // is a state, not an error. - assertEquals( - "Select a saved wallet or create a new one to view your balance and transact.", - hint, - ) + assertTrue("got '$hint'", hint != null && hint.contains("No wallet is open")) assertNoRawRpc(hint!!) } @@ -468,7 +463,7 @@ class WalletManagerTest { fun wallet_reads_reload_only_once_the_child_is_answering() { // `walletBalance()` answers `"err"` — it does not throw — while the // child is still dialling, so reloading in that window is what pins the - // headline on `Balance unavailable`. Reload only when the child has answered. + // headline on `balance —`. Reload only when the child has answered. assertFalse(shouldReloadWalletReads(null)) assertFalse(shouldReloadWalletReads("off")) assertFalse(shouldReloadWalletReads("connecting")) @@ -477,27 +472,4 @@ class WalletManagerTest { assertTrue(shouldReloadWalletReads("ready")) assertTrue(shouldReloadWalletReads(" Ready ")) } - - @Test - fun the_tui_not_configured_copy_is_mapped_and_never_rendered_verbatim() { - // `src/wallet.rs::NOT_CONFIGURED_MSG` is the desktop TUI's refusal. A - // phone has no F7 key and no ONIONWIRE_WALLET_RPC, so that sentence is - // the second dead end the device report caught: a passphrase was typed - // into Create, and the screen answered with a keyboard shortcut. - val tui = "wallet not configured — open F7 to set it up, or set ONIONWIRE_WALLET_RPC" - val shown = walletFailureText(tui) - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, shown) - assertFalse("no F7 reaches the screen", shown!!.contains("F7")) - assertFalse("no env var name either", shown.contains("ONIONWIRE_WALLET_RPC")) - assertTrue("the phone sentence says what to do", shown.contains("Start it on the node card")) - - // Each fragment alone is the same fact and is mapped too; case and - // spacing are not load-bearing. - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, walletFailureText("Open F7")) - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, walletFailureText("Wallet Not Configured")) - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, walletFailureText("set ONIONWIRE_WALLET_RPC")) - - // And it is idempotent: the sticky error card re-filters its own text. - assertEquals(WALLET_RPC_NOT_RUNNING_TEXT, walletFailureText(shown)) - } } diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/components/IdenticonTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/components/IdenticonTest.kt deleted file mode 100644 index 38d6424..0000000 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/components/IdenticonTest.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.siriusdevops.onionwire.ui.components - -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test - -/** - * The identicon is a rendering of the identity fingerprint, so it has to be a - * function of that value and nothing else: same fingerprint, same picture, on - * every device and every launch. Pure (a list of cells), no Compose runtime. - */ -class IdenticonTest { - - private val fingerprint = - "9f2c41ab77de03b5c8e1f0a6d4b39c2e5a7f81c0d3e6b492af17c5d80e3b6a49" - - @Test - fun the_same_seed_always_produces_the_same_cells() { - assertEquals(identiconCells(fingerprint), identiconCells(fingerprint)) - } - - @Test - fun the_picture_is_mirrored_about_the_middle_column() { - val cells = identiconCells(fingerprint) - val columns = cells.map { it.first } - cells.forEach { (col, row, tone) -> - assertTrue( - "column $col row $row is not mirrored", - cells.any { it.first == 4 - col && it.second == row && it.third == tone }, - ) - } - assertTrue(columns.all { it in 0..4 }) - } - - @Test - fun a_different_seed_produces_a_different_picture() { - val other = fingerprint.reversed() - assertTrue(identiconCells(fingerprint) != identiconCells(other)) - } - - @Test - fun an_empty_seed_draws_nothing() { - assertEquals(emptyList>(), identiconCells("")) - } -} diff --git a/crates/onionwire-sdk/Cargo.lock b/crates/onionwire-sdk/Cargo.lock index c327104..fa1d2d2 100644 --- a/crates/onionwire-sdk/Cargo.lock +++ b/crates/onionwire-sdk/Cargo.lock @@ -175,9 +175,9 @@ checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" [[package]] name = "arti-client" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b3624d7bee91f821b04fe5412f561671e5500677781d3f070a2fa101a128b0" +checksum = "aafcbc506657d886b27ef2d8e06a99edd9014b28130c798a3013935b46983097" dependencies = [ "async-trait", "cfg-if", @@ -193,9 +193,10 @@ dependencies = [ "libc", "once_cell", "postage", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", + "tempfile", "thiserror 2.0.20", "time", "tor-async-utils", @@ -309,7 +310,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.119", - "synstructure 0.13.2", + "synstructure", ] [[package]] @@ -323,6 +324,12 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + [[package]] name = "async-compat" version = "0.2.6" @@ -338,9 +345,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.54" +version = "0.4.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c31224bd2c09447484a1143f2fc1d871eb405789859c8e5470a3e7f95f40a18" +checksum = "4f10dafd0c8d2e51ae9a748805777613ed0bbe17bf586b76c8311f45c020a32f" dependencies = [ "compression-codecs", "compression-core", @@ -708,9 +715,9 @@ dependencies = [ [[package]] name = "caret" -version = "0.11.2" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3f1a1c7fa296eb2367469e6226783ed07cb778d75d13f7b6ee3f1de593ba7f4" +checksum = "23a6f83e57018d15e7615a6f8e5e2c6b6b0226e24a1c562cd705f855a2bc751a" [[package]] name = "cargo-platform" @@ -759,9 +766,9 @@ dependencies = [ [[package]] name = "cfg-if" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "cfg_aliases" @@ -896,9 +903,9 @@ checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" [[package]] name = "coarsetime" -version = "0.1.38" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae63702c5627c75addbfb1ea9d1b3842205a6ffd43e4cce884a2a9eb1828fd7" +checksum = "e58eb270476aa4fc7843849f8a35063e8743b4dbcdf6dd0f8ea0886980c204c2" dependencies = [ "libc", "wasix", @@ -927,9 +934,9 @@ checksum = "ea0095f6103c2a8b44acd6fd15960c801dafebf02e21940360833e0673f48ba7" [[package]] name = "compression-codecs" -version = "0.4.49" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f938fc0d88fbe2c8d6f0e1ba96ba1165d89ff698e98468cd019d92cff2ecd367" +checksum = "58a6d0db8759036a783bc7c3f7a07f8cef3bf9470eb1db3bc86e8bcd1c5d0fe8" dependencies = [ "compression-core", "flate2", @@ -940,9 +947,9 @@ dependencies = [ [[package]] name = "compression-core" -version = "0.4.34" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ebdda89edc534bf8d5dd2857562633b6495557e5846552ade994b99ed13c36a" +checksum = "6e8ccc4ea9f6acc32d102c0f6d471d11d913ad15f20c04de743374861fa1d414" [[package]] name = "const-oid" @@ -1174,9 +1181,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" dependencies = [ - "getrandom 0.4.3", "hybrid-array", - "rand_core 0.10.1", ] [[package]] @@ -1315,7 +1320,7 @@ dependencies = [ "cuprate-cryptonight", "cuprate-helper", "cuprate-types", - "curve25519-dalek 4.1.3", + "curve25519-dalek", "hex", "hex-literal 1.1.0", "indexmap 2.14.2", @@ -1417,8 +1422,8 @@ source = "git+https://github.com/Cuprate/cuprate?rev=4f8fcd1bf468f566fcd89c460d5 dependencies = [ "chrono", "cuprate-constants", - "curve25519-dalek 4.1.3", - "dirs 6.0.0", + "curve25519-dalek", + "dirs", "futures", "libc", "monero-oxide", @@ -1682,7 +1687,7 @@ dependencies = [ "thiserror 2.0.20", "tokio", "tokio-util", - "toml 1.2.3+spec-1.1.0", + "toml 1.1.6+spec-1.1.0", "toml_edit 0.25.14+spec-1.1.0", "tower", "tower-http", @@ -1701,24 +1706,7 @@ dependencies = [ "cpufeatures 0.2.17", "curve25519-dalek-derive", "digest 0.10.7", - "fiat-crypto 0.2.9", - "rustc_version", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "5.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94c1aa5a9b7626ed65ac0cf5ea9d4f1547af89017fbac20bd4de40022fff516f" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "curve25519-dalek-derive", - "digest 0.11.3", - "fiat-crypto 0.3.0", - "rand_core 0.10.1", + "fiat-crypto", "rustc_version", "subtle", "zeroize", @@ -1900,16 +1888,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "der" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a" -dependencies = [ - "const-oid 0.10.2", - "zeroize", -] - [[package]] name = "der-parser" version = "10.0.0" @@ -1935,9 +1913,9 @@ dependencies = [ [[package]] name = "derive-deftly" -version = "1.14.0" +version = "1.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "724949bdda5310709ca2f97bf69c2b01e3362f44fef1fb47913445db4c1debb5" +checksum = "98e02cd118058400797c74550dca132b57cf2e6af0e9ea0672a83eb186fd655e" dependencies = [ "derive-deftly-macros", "heck", @@ -1945,9 +1923,9 @@ dependencies = [ [[package]] name = "derive-deftly-macros" -version = "1.14.0" +version = "1.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17933e749f2502cfcd1c27519292fbbea22e8fc64ce680e863f855e8cd8cce23" +checksum = "ba91f619216e76a5eb2515783f7ec2e271938b51aadac592f4930517f4626863" dependencies = [ "heck", "indexmap 2.14.2", @@ -2034,10 +2012,8 @@ version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ - "block-buffer 0.12.1", "const-oid 0.10.2", "crypto-common 0.2.2", - "ctutils", ] [[package]] @@ -2058,15 +2034,6 @@ dependencies = [ "dirs-sys", ] -[[package]] -name = "dirs" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" -dependencies = [ - "dirs-sys", -] - [[package]] name = "dirs-sys" version = "0.5.0" @@ -2117,12 +2084,12 @@ version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ - "der 0.7.10", + "der", "digest 0.10.7", "elliptic-curve", "rfc6979", - "signature 2.2.0", - "spki 0.7.3", + "signature", + "spki", ] [[package]] @@ -2131,18 +2098,8 @@ version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ - "pkcs8 0.10.2", - "signature 2.2.0", -] - -[[package]] -name = "ed25519" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a" -dependencies = [ - "pkcs8 0.11.0", - "signature 3.0.0", + "pkcs8", + "signature", ] [[package]] @@ -2151,29 +2108,12 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" dependencies = [ - "curve25519-dalek 4.1.3", - "ed25519 2.2.3", + "curve25519-dalek", + "ed25519", + "merlin", "rand_core 0.6.4", "serde", - "sha2 0.10.9", - "subtle", - "zeroize", -] - -[[package]] -name = "ed25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de" -dependencies = [ - "curve25519-dalek 5.1.0", - "ed25519 3.0.0", - "keccak 0.2.2", - "rand_core 0.10.1", - "serde", - "sha2 0.11.3", - "signature 3.0.0", - "strobe-rs", + "sha2", "subtle", "zeroize", ] @@ -2208,7 +2148,7 @@ dependencies = [ "ff", "generic-array", "group", - "pkcs8 0.10.2", + "pkcs8", "rand_core 0.6.4", "sec1", "subtle", @@ -2332,12 +2272,6 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" -[[package]] -name = "fiat-crypto" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24" - [[package]] name = "figment" version = "0.10.19" @@ -2448,12 +2382,12 @@ dependencies = [ [[package]] name = "fs-mistrust" -version = "0.16.2" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1628799db8c034e020e48ee393c271f423aa749fde1c3195bd3bbc8bb5cfcbe8" +checksum = "9b2c81a5a0e7d67644309a15694eb7f414a4d6556c64c1ece1e5969aa609c8a9" dependencies = [ "derive_builder_fork_arti", - "dirs 7.0.0", + "dirs", "extend", "libc", "pwd-grp", @@ -2465,9 +2399,9 @@ dependencies = [ [[package]] name = "fslock-guard" -version = "0.9.2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba455a614874a0b1814cf3e30f8a6d4c8858e2bc38569bd293e3ff8cbad49032" +checksum = "d10ce5036d49f8add4a11d08bc1b1afb0e3cefdd88778ab87fb4202d47b765e1" dependencies = [ "libc", "thiserror 2.0.20", @@ -2792,16 +2726,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" dependencies = [ - "hmac 0.12.1", -] - -[[package]] -name = "hkdf" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4aaa26c720c68b866f2c96ef5c1264b3e6f473fe5d4ce61cd44bbe913e553018" -dependencies = [ - "hmac 0.13.0", + "hmac", ] [[package]] @@ -2813,15 +2738,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "hmac" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" -dependencies = [ - "digest 0.11.3", -] - [[package]] name = "hostname-validator" version = "1.1.1" @@ -2895,7 +2811,6 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" dependencies = [ - "ctutils", "typenum", "zeroize", ] @@ -3174,9 +3089,9 @@ dependencies = [ [[package]] name = "inventory" -version = "0.3.25" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +checksum = "a4f0c30c76f2f4ccee3fe55a2435f691ca00c0e4bd87abe4f4a851b1d4dac39b" dependencies = [ "rustversion", ] @@ -3238,25 +3153,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "668b7183bd07af9a4885f5c35b0cc5c83c4607a913c16b7e17291832910d2dcc" dependencies = [ "defmt", - "jiff-core 0.1.0", - "jiff-static 0.2.35", - "jiff-tzdb-platform 0.1.3", - "log", - "portable-atomic", - "portable-atomic-util", - "serde_core", - "windows-link", -] - -[[package]] -name = "jiff" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379ed44bd4e16d3926160e2b3a78b79ca0952ef5c037f124f554842ba272ef92" -dependencies = [ - "jiff-core 1.1.0", - "jiff-static 1.1.0", - "jiff-tzdb-platform 1.0.0", + "jiff-core", + "jiff-static", + "jiff-tzdb-platform", "log", "portable-atomic", "portable-atomic-util", @@ -3273,67 +3172,31 @@ dependencies = [ "defmt", ] -[[package]] -name = "jiff-core" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df46fc314b4f458aee614afcd8676ed6cb3637413aa359d47d2646cbc038b79" -dependencies = [ - "log", -] - [[package]] name = "jiff-static" version = "0.2.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a69dcb3a21cfb32ce1cd056169337ca284af0766dd766e7878819b251a49204" dependencies = [ - "jiff-core 0.1.0", + "jiff-core", "proc-macro2", "quote", "syn 2.0.119", ] -[[package]] -name = "jiff-static" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b729c549d3efb5855b3c80b0ee8ee1850d56330a127382fe2760965741c1f3" -dependencies = [ - "jiff-core 1.1.0", - "proc-macro2", - "quote", - "syn 3.0.5", -] - [[package]] name = "jiff-tzdb" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "142bd39932ad231f10513df9ab62661fead8719872150b7ad02a2df79f4e141e" -[[package]] -name = "jiff-tzdb" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e71a1b68a875a44a33bb7a1dd84392cb77145a3367a552a3cfe6a4f5cf3afc" - [[package]] name = "jiff-tzdb-platform" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "875a5a69ac2bab1a891711cf5eccbec1ce0341ea805560dcd90b7a2e925132e8" dependencies = [ - "jiff-tzdb 0.1.8", -] - -[[package]] -name = "jiff-tzdb-platform" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc65b284afcfa8f6cf189c7274c805505314a7ab975c60e1f548bff56525420e" -dependencies = [ - "jiff-tzdb 1.0.0", + "jiff-tzdb", ] [[package]] @@ -3359,13 +3222,12 @@ dependencies = [ [[package]] name = "k12" -version = "0.5.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a8cc72399dffa4a445bc5f5a84d4af4d441c76604231bc52e9c529c1d47693" +checksum = "f4dc5fdb62af2f520116927304f15d25b3c2667b4817b90efdc045194c912c54" dependencies = [ - "digest 0.11.3", - "keccak 0.2.2", - "sponge-cursor", + "digest 0.10.7", + "sha3 0.10.9", ] [[package]] @@ -3396,17 +3258,6 @@ checksum = "d8f198d1db720e4940b5a493201d199d9f24f568f8f746bd13706243a2f71598" dependencies = [ "cfg-if", "cpufeatures 0.3.1", - "hybrid-array", -] - -[[package]] -name = "kem" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01737161ba802849cfd486b5bd209d38ba4943494c249a8126005170c7621edd" -dependencies = [ - "crypto-common 0.2.2", - "rand_core 0.10.1", ] [[package]] @@ -3588,6 +3439,15 @@ dependencies = [ "twox-hash", ] +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + [[package]] name = "matchit" version = "0.8.4" @@ -3612,21 +3472,23 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "memmap2" -version = "0.9.12" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +checksum = "d1219ed1b7f229ee7104d281dd01d6802fe28bb6e95d292942c4daacdeb798c0" dependencies = [ "libc", ] [[package]] -name = "metrics" -version = "0.24.6" +name = "merlin" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89550ee9f79e88fef3119de263694973a8adb26c21d75322164fb8c493039fe2" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" dependencies = [ - "portable-atomic", - "rapidhash", + "byteorder", + "keccak 0.1.6", + "rand_core 0.6.4", + "zeroize", ] [[package]] @@ -3663,34 +3525,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "ml-kem" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9ba01ebcf90f6aff8e9b9f55bb69b19e6250e4ade5787d0040eaa27dd226238" -dependencies = [ - "hybrid-array", - "kem", - "module-lattice", - "pkcs8 0.11.0", - "rand_core 0.10.1", - "sha3 0.12.0", - "shake", - "zeroize", -] - -[[package]] -name = "module-lattice" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c61b87c9683ab7cb1c6871d261ad5479b6b10ceb52c4352aaca3b5d35a8febe" -dependencies = [ - "ctutils", - "hybrid-array", - "num-traits", - "zeroize", -] - [[package]] name = "monero-address" version = "0.1.0" @@ -3718,7 +3552,7 @@ name = "monero-borromean" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-ed25519", "monero-io", "std-shims", @@ -3730,7 +3564,7 @@ name = "monero-bulletproofs" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-bulletproofs-generators", "monero-ed25519", "monero-io", @@ -3746,7 +3580,7 @@ name = "monero-bulletproofs-generators" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-ed25519", "monero-io", "monero-primitives", @@ -3758,7 +3592,7 @@ name = "monero-clsag" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "group", "monero-ed25519", "monero-io", @@ -3776,7 +3610,7 @@ version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ "crypto-bigint 0.5.5", - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-io", "rand_core 0.6.4", "sha3 0.10.9", @@ -3798,7 +3632,7 @@ name = "monero-mlsag" version = "0.1.0" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "monero-ed25519", "monero-io", "std-shims", @@ -3811,7 +3645,7 @@ name = "monero-oxide" version = "0.1.4-alpha" source = "git+https://github.com/monero-oxide/monero-oxide.git?rev=946ec5f#946ec5f00ff071b129758ee8cba5528539fccfe4" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "hex-literal 1.1.0", "monero-borromean", "monero-bulletproofs", @@ -4011,9 +3845,9 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" [[package]] name = "oneshot-fused-workaround" -version = "0.8.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f851210432a7498257e0f1675c25b95131308f157b87821b70df756b01aa1dbc" +checksum = "56892f7dcba21c5eb4181b8de221620855805891ee55ef960aad7cac3b5d88b2" dependencies = [ "futures", ] @@ -4026,12 +3860,11 @@ dependencies = [ "arti-client", "chacha20poly1305", "cuprated", - "ed25519-dalek 2.2.0", + "ed25519-dalek", "futures", - "hkdf 0.12.4", - "hmac 0.12.1", + "hkdf", + "hmac", "md-5", - "ml-kem", "qrcode", "rand 0.8.8", "ratatui", @@ -4040,7 +3873,7 @@ dependencies = [ "rustls", "safelog", "serde_json", - "sha2 0.10.9", + "sha2", "sha3 0.10.9", "snow", "tokio", @@ -4048,7 +3881,7 @@ dependencies = [ "tor-cell", "tor-hsservice", "tor-rtcompat", - "x25519-dalek 2.0.1", + "x25519-dalek", "zeroize", ] @@ -4125,7 +3958,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -4137,7 +3970,7 @@ dependencies = [ "ecdsa", "elliptic-curve", "primeorder", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -4151,7 +3984,7 @@ dependencies = [ "elliptic-curve", "primeorder", "rand_core 0.6.4", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -4323,9 +4156,9 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" dependencies = [ - "der 0.7.10", - "pkcs8 0.10.2", - "spki 0.7.3", + "der", + "pkcs8", + "spki", ] [[package]] @@ -4334,18 +4167,8 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" dependencies = [ - "der 0.7.10", - "spki 0.7.3", -] - -[[package]] -name = "pkcs8" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7" -dependencies = [ - "der 0.8.2", - "spki 0.8.1", + "der", + "spki", ] [[package]] @@ -4457,6 +4280,17 @@ dependencies = [ "elliptic-curve", ] +[[package]] +name = "priority-queue" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93980406f12d9f8140ed5abe7155acb10bb1e69ea55c88960b9c2f117445ef96" +dependencies = [ + "equivalent", + "indexmap 2.14.2", + "serde", +] + [[package]] name = "proc-macro-crate" version = "3.5.0" @@ -4589,9 +4423,9 @@ dependencies = [ [[package]] name = "rand" -version = "0.10.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6fa277c67e6ea590466f04c3fe82cb509f0864fe470643e5570de9514a9b11" +checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" dependencies = [ "chacha20 0.10.2", "getrandom 0.4.3", @@ -4700,15 +4534,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a611d15b50743feb4c76b7d03edcb0e64f399c26961e4efe6975bc398be6aa3d" -[[package]] -name = "rapidhash" -version = "4.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5da7e78a036ce858e8d55b7e7dc8ba3a88b78350fd2155d3591bbd966b58589e" -dependencies = [ - "rustversion", -] - [[package]] name = "ratatui" version = "0.30.2" @@ -4885,9 +4710,9 @@ dependencies = [ [[package]] name = "retry-error" -version = "0.14.2" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67f26b5caa81adf9b23ab230ce975acbf46aec461bc357f9fb51cfd4f2bfaebf" +checksum = "d350ad359aca3414f7261cdcc763e37ccc9fa56fe40ca30a9758c28a295bcad0" dependencies = [ "humantime", "web-time", @@ -4899,7 +4724,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" dependencies = [ - "hmac 0.12.1", + "hmac", "subtle", ] @@ -4940,11 +4765,11 @@ dependencies = [ "num-integer", "num-traits", "pkcs1", - "pkcs8 0.10.2", + "pkcs8", "rand_core 0.6.4", - "sha2 0.10.9", - "signature 2.2.0", - "spki 0.7.3", + "sha2", + "signature", + "spki", "subtle", "zeroize", ] @@ -5013,9 +4838,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.46" +version = "0.23.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +checksum = "6725596c3f2c3a0aef021139e145d4eafe314a6623e4680ca83852b2c67ab2ba" dependencies = [ "log", "once_cell", @@ -5037,9 +4862,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.17" +version = "0.103.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a0760a887c14823fca5a1c970b01d47c328c696c0c64829d1df50e8f853fd5" +checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2" dependencies = [ "ring", "rustls-pki-types", @@ -5072,9 +4897,9 @@ checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "safelog" -version = "0.10.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c090399e87e5eaec9515d6b859fdb7ec417c269c2e7564c169a8963df75a2ce" +checksum = "73ef1d6e273fc8ce5cc1376cf498c06d23b786e80e4a7679a643bb0a838b0029" dependencies = [ "derive_more", "educe", @@ -5103,12 +4928,9 @@ dependencies = [ [[package]] name = "saturating-time" -version = "0.6.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950f7f265dc6fc082387eccf710b1adbf22d75f17c4ee0db4648c9b6959b50d" -dependencies = [ - "web-time-compat", -] +checksum = "802bdbfcca9a239cb46eeaaedea507e37bb13ba1a673762d2e2ef7a9dac63144" [[package]] name = "schemars" @@ -5167,9 +4989,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" dependencies = [ "base16ct", - "der 0.7.10", + "der", "generic-array", - "pkcs8 0.10.2", + "pkcs8", "subtle", "zeroize", ] @@ -5258,9 +5080,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.154" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "itoa", "memchr", @@ -5291,18 +5113,18 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.1.3" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" dependencies = [ "serde_core", ] [[package]] name = "serde_with" -version = "3.25.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56cb1ca7c93ae63d6439b5250f6b6b040f7e121f32e5dd2f5d523dd4149b3204" +checksum = "935177bb8c0cd8ca1a4e6d1a2ac8988bea69cab4f9d3a31311e012ad27868ea4" dependencies = [ "base64", "bs58", @@ -5310,8 +5132,7 @@ dependencies = [ "hex", "indexmap 1.9.3", "indexmap 2.14.2", - "jiff 0.2.35", - "jiff 1.1.0", + "jiff", "schemars 0.9.0", "schemars 1.2.2", "serde_core", @@ -5322,9 +5143,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.25.0" +version = "3.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff15a7c864bbec77d9586ca6822bc7c369bdf19e9243134a62b0b51ce26b31f" +checksum = "1d607aa01a3cb0ad757d6fd216136910db3c97b102fe686585689615a02dbcdc" dependencies = [ "darling 0.24.1", "proc-macro2", @@ -5345,13 +5166,13 @@ dependencies = [ [[package]] name = "sha1" -version = "0.11.0" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aacc4cc499359472b4abe1bf11d0b12e688af9a805fa5e3016f9a386dc2d0214" +checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8" dependencies = [ "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", + "cpufeatures 0.2.17", + "digest 0.10.7", ] [[package]] @@ -5365,17 +5186,6 @@ dependencies = [ "digest 0.10.7", ] -[[package]] -name = "sha2" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "820083d430c52864bf834423fc988cbcf61685d6f9d22a765a64e3f6cfe3521c" -dependencies = [ - "cfg-if", - "cpufeatures 0.3.1", - "digest 0.11.3", -] - [[package]] name = "sha3" version = "0.10.9" @@ -5397,17 +5207,6 @@ dependencies = [ "sponge-cursor", ] -[[package]] -name = "shake" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09057cb2149ad4cbd2da1e26b351f9a4c354219421229c69c3063e6f61947c4a" -dependencies = [ - "digest 0.11.3", - "keccak 0.2.2", - "sponge-cursor", -] - [[package]] name = "sharded-slab" version = "0.1.7" @@ -5424,7 +5223,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32824fab5e16e6c4d86dc1ba84489390419a39f97699852b66480bb87d297ed8" dependencies = [ "bstr", - "dirs 6.0.0", + "dirs", "os_str_bytes", ] @@ -5475,15 +5274,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "signature" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" -dependencies = [ - "rand_core 0.10.1", -] - [[package]] name = "simd-adler32" version = "0.3.10" @@ -5524,14 +5314,15 @@ dependencies = [ [[package]] name = "slotmap-careful" -version = "0.9.2" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e13aa7333b92ad3a6d3136abaa7fb5d8c19cc121441fcb435f6947d6ef2f8f7" +checksum = "ba7bcbd01d9b495f4509e74f660ebaf3315219b2f8a81753667ee7d6d8a199ac" dependencies = [ "paste", "serde", "slotmap", "thiserror 2.0.20", + "void", ] [[package]] @@ -5555,11 +5346,11 @@ dependencies = [ "aes-gcm", "blake2", "chacha20poly1305", - "curve25519-dalek 4.1.3", + "curve25519-dalek", "getrandom 0.3.4", "ring", "rustc_version", - "sha2 0.10.9", + "sha2", "subtle", ] @@ -5595,17 +5386,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der 0.7.10", -] - -[[package]] -name = "spki" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef958a98b9d5da290cfc78946e9f3e61e1e62a18db0d92cac0b83cc161491a9" -dependencies = [ - "base64ct", - "der 0.8.2", + "der", ] [[package]] @@ -5632,7 +5413,7 @@ checksum = "e0cf03c3a7ea88451ff83a129a79451fd9891d44fc76c25e916a11848b81814c" dependencies = [ "base64ct", "pem-rfc7468", - "sha2 0.10.9", + "sha2", ] [[package]] @@ -5648,8 +5429,8 @@ dependencies = [ "rand_core 0.6.4", "rsa", "sec1", - "sha2 0.10.9", - "signature 2.2.0", + "sha2", + "signature", "ssh-cipher-fork-arti", "ssh-encoding-fork-arti", "subtle", @@ -5679,19 +5460,6 @@ dependencies = [ "spin 0.10.1", ] -[[package]] -name = "strobe-rs" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83561175f0a962dea437885589480d216d8741debf853e0d36edd526344fd273" -dependencies = [ - "bitflags 2.13.2", - "byteorder", - "keccak 0.2.2", - "subtle", - "zeroize", -] - [[package]] name = "strsim" version = "0.10.0" @@ -5787,17 +5555,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "synstructure" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.5", -] - [[package]] name = "sysinfo" version = "0.38.4" @@ -5850,7 +5607,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "230a1b821ccbd75b185820a1f1ff7b14d21da1e442e22c0863ea5f08771a8874" dependencies = [ "rustix", - "windows-sys 0.61.2", + "windows-sys 0.59.0", ] [[package]] @@ -5952,9 +5709,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.8.5" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643" dependencies = [ "displaydoc", "serde_core", @@ -5978,9 +5735,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.54.1" +version = "1.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" dependencies = [ "bytes", "libc", @@ -6029,9 +5786,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.20" +version = "0.7.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e464cf451ba96ebfc6f9b6542f17ee8b8956e33f1e40d9690624e59d7a7f8a4b" +checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52" dependencies = [ "bytes", "futures-core", @@ -6059,14 +5816,14 @@ dependencies = [ [[package]] name = "toml" -version = "1.2.3+spec-1.1.0" +version = "1.1.6+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b1f26e9485c1fa43ee89fe76e9f3fb9e2e52bb227f8594b4d687496b83d073" +checksum = "920602543f0911ab71da12c50d59701da54c196d1a2bf5cb4b75667f137a406a" dependencies = [ "indexmap 2.14.2", "serde_core", - "serde_spanned 1.1.3", - "toml_datetime 1.1.3+spec-1.1.0", + "serde_spanned 1.1.1", + "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", "toml_writer", "winnow 1.0.4", @@ -6083,9 +5840,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "1.1.3+spec-1.1.0" +version = "1.1.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" dependencies = [ "serde_core", ] @@ -6111,7 +5868,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2195eec204e2764644a4ea619704f9fbe5e0673038eded55ad9956f24fca0cc" dependencies = [ "indexmap 2.14.2", - "toml_datetime 1.1.3+spec-1.1.0", + "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", "toml_writer", "winnow 1.0.4", @@ -6119,9 +5876,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.1.7+spec-1.1.0" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bb28d6e049a9766c3bd91a8326e6179f5b132dec87906bb97018ef7a2f3431a" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" dependencies = [ "winnow 1.0.4", ] @@ -6134,15 +5891,15 @@ checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" [[package]] name = "toml_writer" -version = "1.2.0+spec-1.1.0" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" [[package]] name = "tor-async-utils" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea51881be51a4dff308071d7cf6489445fd658e821a8bf35c47a4830effd1ab" +checksum = "31d9f28de36ed7646f0f03835ce2e306e2c5df8a1784a2cac27bd549cdc07599" dependencies = [ "cfg-if", "derive-deftly", @@ -6166,9 +5923,9 @@ dependencies = [ [[package]] name = "tor-basic-utils" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "235993fcf72e09e597e6b609d52b4cfc2f28bfa8ca827ed304127889639d5776" +checksum = "1a2bd42110ae0faea1d446b35899aa5c3591cd31a94b593aa9264f00baba41da" dependencies = [ "derive-deftly", "derive_more", @@ -6179,7 +5936,7 @@ dependencies = [ "itertools 0.15.0", "libc", "paste", - "rand 0.10.4", + "rand 0.10.2", "rand_chacha 0.10.0", "serde", "slab", @@ -6192,13 +5949,13 @@ dependencies = [ [[package]] name = "tor-bytes" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb3c0504ae2bca19b92e55c869fe58f68688505737ce2ddae85b60b9806ed4c" +checksum = "73de2ba54a125c27a440616f2d806a171bcb4e30013de166c7dc0a79bde44ab4" dependencies = [ "bytes", "derive-deftly", - "digest 0.11.3", + "digest 0.10.7", "educe", "getrandom 0.4.3", "safelog", @@ -6210,9 +5967,9 @@ dependencies = [ [[package]] name = "tor-cell" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6a814400b9bd2a8d07ee89057db816eed53b2b2719066f77630698f0bd2cb0" +checksum = "118f2b6a56605bedd077003ee5678fda215965d550dd0aef21ce8e10dd082750" dependencies = [ "amplify", "bitflags 2.13.2", @@ -6223,7 +5980,7 @@ dependencies = [ "educe", "itertools 0.15.0", "paste", - "rand 0.10.4", + "rand 0.10.2", "smallvec", "thiserror 2.0.20", "tor-basic-utils", @@ -6241,14 +5998,15 @@ dependencies = [ [[package]] name = "tor-cert" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68df0747b5d218cfb2c481b2a267bbdbf89dda2849911630e966eed3dc630f7b" +checksum = "b2cec6ae3abafc382e126a26e74f000bffbbf2c9b1a8c9ec26bb84463f0120b4" dependencies = [ "caret", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", + "saturating-time", "thiserror 2.0.20", "tor-bytes", "tor-checkable", @@ -6259,9 +6017,9 @@ dependencies = [ [[package]] name = "tor-chanmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66b5dec2bf27e75dd65bfe9289f24eee230c49ac4a65f85f0ead3b3b3c19f51d" +checksum = "6cef673b170f10790ff81d2f190e0a8150e5c9683c2c8f4c09652a6954c0e5ab" dependencies = [ "async-trait", "base64ct", @@ -6275,7 +6033,7 @@ dependencies = [ "oneshot-fused-workaround", "percent-encoding", "postage", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", "serde_with", @@ -6302,13 +6060,13 @@ dependencies = [ [[package]] name = "tor-checkable" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bee5237cfbec5e4e7860b6579932072e2dd3dfa91a950a3d2c4c8c253f405c4a" +checksum = "d3872a5bda49647ad4c4a822c58774995ad3acd02327f1cabe6cfc019d714535" dependencies = [ "humantime", "itertools 0.15.0", - "signature 3.0.0", + "signature", "thiserror 2.0.20", "tor-llcrypto", "web-time-compat", @@ -6316,9 +6074,9 @@ dependencies = [ [[package]] name = "tor-circmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bead875b0e3876110dbfa584ea65af47ed44ebc7ffebb32c460723837aa4843" +checksum = "2cf1eb6c2e3184c9e51c746df81f1a890ba7b663ac418debe2dac3756d840c8a" dependencies = [ "amplify", "async-trait", @@ -6335,7 +6093,7 @@ dependencies = [ "once_cell", "oneshot-fused-workaround", "pin-project", - "rand 0.10.4", + "rand 0.10.2", "retry-error", "safelog", "serde", @@ -6366,9 +6124,9 @@ dependencies = [ [[package]] name = "tor-config" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9788a9af2a0303e4c05a9bdbf08efbba485c4e92978f140713bc5e201f14580" +checksum = "dd8ca5684100c9223590c11685f3f39c4e4c0037c65daddc26927b3ae4cc893d" dependencies = [ "amplify", "cfg-if", @@ -6391,7 +6149,7 @@ dependencies = [ "serde_ignored", "strum", "thiserror 2.0.20", - "toml 1.2.3+spec-1.1.0", + "toml 1.1.6+spec-1.1.0", "tor-basic-utils", "tor-error", "tor-rtcompat", @@ -6401,9 +6159,9 @@ dependencies = [ [[package]] name = "tor-config-path" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83d165d5b36b7518e8cf0a51a9ed831019cf9d02afd88b408f2ca8d922710565" +checksum = "cbed06099bacbdbb1d91cfff1032863896d6097c33eece067ab20756e4a6fa2b" dependencies = [ "directories", "serde", @@ -6415,12 +6173,12 @@ dependencies = [ [[package]] name = "tor-consdiff" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "543cd2e0796c7959fe89a2c264ea09ebbb0d1bb70ce4870a2b394ee8d099bbea" +checksum = "9760d0051159a257b1d0065615ad6bc023da4e178d41ff5640222a29852de848" dependencies = [ "derive_more", - "digest 0.11.3", + "digest 0.10.7", "hex", "imara-diff", "static_assertions", @@ -6432,9 +6190,9 @@ dependencies = [ [[package]] name = "tor-dirclient" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d683861c37ff8c0c522c5cdfed94a8f43d8c07fc9ae6ce3622ca29ec1b76db2" +checksum = "403a79a0d00de6c78f15773a284e790459cff6983449e8578490e6b5dfb2afcd" dependencies = [ "async-compression", "base64ct", @@ -6445,6 +6203,7 @@ dependencies = [ "httparse", "httpdate", "itertools 0.15.0", + "memchr", "thiserror 2.0.20", "tor-circmgr", "tor-error", @@ -6460,9 +6219,9 @@ dependencies = [ [[package]] name = "tor-dircommon" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c9d4239fe25e4797edc7cf7b6efb4935bcec4552d7fe1ed1b61a30b165736b6" +checksum = "dd5cd2a4f641ecb007cc50914bb1b46128de0975aba08baa56497c8e03c71c71" dependencies = [ "base64ct", "derive-deftly", @@ -6481,15 +6240,15 @@ dependencies = [ [[package]] name = "tor-dirmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed9e6665621160a7065f3bb56f7bbc77b85aff362f0950415dd882e8c22af9" +checksum = "805da4e947311285ce0782ab129df318701c2c08046c316086cb6bb3eb7a463e" dependencies = [ "async-trait", "base64ct", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "event-listener", "fs-mistrust", @@ -6503,14 +6262,13 @@ dependencies = [ "oneshot-fused-workaround", "paste", "postage", - "rand 0.10.4", + "rand 0.10.2", "rusqlite", "safelog", - "saturating-time", "scopeguard", "serde", "serde_json", - "signature 3.0.0", + "signature", "static_assertions", "strum", "thiserror 2.0.20", @@ -6539,9 +6297,9 @@ dependencies = [ [[package]] name = "tor-error" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1caef18eb269eab70a6244cbfc003e92c8a28c4017fa5f7cb17be718787f151c" +checksum = "08f29e906f9f333a6e32e32afac9fb6712ac340191eb3292295b3337682b2dad" dependencies = [ "derive_more", "futures", @@ -6557,9 +6315,9 @@ dependencies = [ [[package]] name = "tor-general-addr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09068bc76af4da4bbf0f17be95693c02253b12ed0aa2b4979bee786a1c7f24b5" +checksum = "7b45ecd95dbf79070f9e477e1d84b22e47f03b2ab2f853abe31887daa9090cf0" dependencies = [ "derive_more", "thiserror 2.0.20", @@ -6568,9 +6326,9 @@ dependencies = [ [[package]] name = "tor-guardmgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d430b1785b1e8f6569043b2ae2ca6c340ff5327f39ba3a19b7cfa9c99ad9a1d" +checksum = "3e84beedbf276ce4ea170206b38ca01c995dbf1b9f678e9708f50e2e71dbfef4" dependencies = [ "amplify", "base64ct", @@ -6587,9 +6345,8 @@ dependencies = [ "oneshot-fused-workaround", "pin-project", "postage", - "rand 0.10.4", + "rand 0.10.2", "safelog", - "saturating-time", "serde", "strum", "thiserror 2.0.20", @@ -6613,9 +6370,9 @@ dependencies = [ [[package]] name = "tor-hsclient" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa940dbbff0c4c9323623acb4a49ac40fa227a6a3a07236918f4723db6ab7f9c" +checksum = "3eba66be03b5eb899185e5b4416d8893fdb09a97b33db9e450042f06e2550f0e" dependencies = [ "async-trait", "cfg-if", @@ -6627,7 +6384,7 @@ dependencies = [ "itertools 0.15.0", "oneshot-fused-workaround", "postage", - "rand 0.10.4", + "rand 0.10.2", "retry-error", "safelog", "slotmap-careful", @@ -6659,23 +6416,23 @@ dependencies = [ [[package]] name = "tor-hscrypto" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a262916c319c77cd6dacb3c2aa1e1cdae1d2bf40dae18b1138cf9d544b927dc2" +checksum = "118ff6a69bfa111b6e8d087ffb107ea9cbcd5d4469295cd7ada1b3cf19ba5a0f" dependencies = [ "cipher 0.5.2", "data-encoding", "derive-deftly", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "hex", "humantime", "itertools 0.15.0", "paste", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", - "signature 3.0.0", + "signature", "subtle", "thiserror 2.0.20", "tor-basic-utils", @@ -6692,9 +6449,9 @@ dependencies = [ [[package]] name = "tor-hsservice" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cfbd1aa7939e12a7dc56b6eefc1e44444de1f0bdf1a5fbd2eb897e4286733c9" +checksum = "d61a6b5217c14780f54fa1c8610514b1349c93f657304dec98bd8e3083e1a09f" dependencies = [ "amplify", "async-trait", @@ -6703,7 +6460,7 @@ dependencies = [ "derive-deftly", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "fs-mistrust", "futures", @@ -6715,7 +6472,7 @@ dependencies = [ "once_cell", "oneshot-fused-workaround", "postage", - "rand 0.10.4", + "rand 0.10.2", "rand_core 0.10.1", "retry-error", "safelog", @@ -6751,17 +6508,17 @@ dependencies = [ [[package]] name = "tor-key-forge" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2788d37b8b723a83da9c3f22ee44530ffef4bf0fb13588bd88f44c90cdaa9bae" +checksum = "1861b5eebab93515a0ab2401540f3d5a9fb376f1b1535d5793dcd697fb19f928" dependencies = [ "derive-deftly", "derive_more", "downcast-rs", "paste", - "rand 0.10.4", + "rand 0.10.2", "rsa", - "signature 3.0.0", + "signature", "ssh-key-fork-arti", "thiserror 2.0.20", "tor-bytes", @@ -6773,13 +6530,13 @@ dependencies = [ [[package]] name = "tor-keymgr" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119f0f26e6b2a11cd0868374a2287c786e97f22330cd8a8ff69cee96b08670cb" +checksum = "b3088a573dadebb34acacb30d686751e2a94d12ccf9d6647946ab6c6b4ad5a0e" dependencies = [ "amplify", + "arrayvec", "cfg-if", - "data-encoding", "derive-deftly", "derive_builder_fork_arti", "derive_more", @@ -6790,10 +6547,10 @@ dependencies = [ "humantime", "inventory", "itertools 0.15.0", - "rand 0.10.4", + "rand 0.10.2", "safelog", "serde", - "signature 3.0.0", + "signature", "ssh-key-fork-arti", "thiserror 2.0.20", "tor-basic-utils", @@ -6814,9 +6571,9 @@ dependencies = [ [[package]] name = "tor-linkspec" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb55ea69084a82b1f69709059ecfcfb3097adaad6d522dff99d8c52735cb899" +checksum = "6d8d3a2aaf3bb67110218b9ff1718cd7d6c7e62226e2fee1a18efa6aa19ff07c" dependencies = [ "base64ct", "by_address", @@ -6841,25 +6598,25 @@ dependencies = [ [[package]] name = "tor-llcrypto" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1f114c13c14b0b2668304e2c9f102534ef95a2a004d1294ede969211c9bc60d" +checksum = "4fee81755528eb34f8352ca6987d5f5c66ebba6af2e4618da4b527f17b0e912e" dependencies = [ "aes 0.9.3", "base64ct", "ctr 0.10.1", - "curve25519-dalek 5.1.0", + "curve25519-dalek", "der-parser", "derive-deftly", "derive_more", - "digest 0.11.3", - "ed25519-dalek 3.0.0", + "digest 0.10.7", + "ed25519-dalek", "educe", "getrandom 0.2.17", "getrandom 0.3.4", "getrandom 0.4.3", "hex", - "rand 0.10.4", + "rand 0.10.2", "rand_chacha 0.10.0", "rand_core 0.10.1", "rand_core 0.6.4", @@ -6870,24 +6627,23 @@ dependencies = [ "safelog", "serde", "sha1", - "sha2 0.11.3", - "sha3 0.12.0", - "shake", - "signature 3.0.0", + "sha2", + "sha3 0.10.9", + "signature", "subtle", "thiserror 2.0.20", "tor-error", "tor-memquota-cost", "visibility", - "x25519-dalek 3.0.0", + "x25519-dalek", "zeroize", ] [[package]] name = "tor-log-ratelim" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea1296076775d399e0b750117c2e1cfba7fe9463add26f056b7c1397c9a3357" +checksum = "2f8696c8ea9090059d91eea287628b5df0b3b4fba433179d893e348857857544" dependencies = [ "futures", "humantime", @@ -6901,9 +6657,9 @@ dependencies = [ [[package]] name = "tor-memquota" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "075e39b9ac84cd15c8249df1499c642e2fbea2a02cc7f146f19df31d771be0dc" +checksum = "03786604757846a5f936285eef397e3fc0ed455893dc5012ceafdf455ada0d8d" dependencies = [ "cfg-if", "derive-deftly", @@ -6933,9 +6689,9 @@ dependencies = [ [[package]] name = "tor-memquota-cost" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c7fc75adc50ee789c2ef1633f95647aefc10942bb8a9e6294343dfb574c616c" +checksum = "86d6f7e1d842e6272e414e1f866dc688306b788d368df42e47c4995e040c679c" dependencies = [ "derive-deftly", "itertools 0.15.0", @@ -6945,20 +6701,20 @@ dependencies = [ [[package]] name = "tor-netdir" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27eb00ecbb05d92471bf7ca386ac929ebca28e1034893045679645293bbddbd0" +checksum = "9d3b84edfe732b77fb1420347902c06d92a1e6992e378ad19da6bdadcb8cd798" dependencies = [ "async-trait", "bitflags 2.13.2", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "futures", "hex", "humantime", "itertools 0.15.0", "num_enum", - "rand 0.10.4", + "rand 0.10.2", "serde", "strum", "thiserror 2.0.20", @@ -6978,9 +6734,9 @@ dependencies = [ [[package]] name = "tor-netdoc" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4f3fdfb2e47f82c6a15c11fb9bfac8bd4ec9e4bbff786fc23a8f8438436f040" +checksum = "5b6abd7aaeb2bdbb3fbf760aab9aaa4e8e1a0f8b84d93a834df5a16882faa31e" dependencies = [ "amplify", "base64ct", @@ -6988,7 +6744,7 @@ dependencies = [ "derive-deftly", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "enumset", "extend", @@ -7001,12 +6757,12 @@ dependencies = [ "memchr", "paste", "phf", - "rand 0.10.4", + "rand 0.10.2", "rangemap", "saturating-time", "serde", "serde_with", - "signature 3.0.0", + "signature", "smallvec", "strum", "subtle", @@ -7031,9 +6787,9 @@ dependencies = [ [[package]] name = "tor-persist" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48567a8e69f69edc6cfc3a7bfcd83e9ffb8c16617e81b6a4fbe11c391bd6356f" +checksum = "e6f2a41d13a685e181361cfc3bdf25d319b96b56f5806594b6b8ed760d0099ed" dependencies = [ "amplify", "derive-deftly", @@ -7051,6 +6807,7 @@ dependencies = [ "serde_json", "thiserror 2.0.20", "time", + "tor-async-utils", "tor-basic-utils", "tor-error", "tracing", @@ -7060,9 +6817,9 @@ dependencies = [ [[package]] name = "tor-proto" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ee0a62b16f6bde3e1dee30a20e6c6755c5cd912e781c01b96c9d451886848d" +checksum = "0ddf767335ae2e255025536d48384b92c6b4b8557e5b345be600e7ca2de1c880" dependencies = [ "aes 0.9.3", "amplify", @@ -7078,21 +6835,20 @@ dependencies = [ "derive-deftly", "derive_builder_fork_arti", "derive_more", - "digest 0.11.3", + "digest 0.10.7", "educe", "enum_dispatch", "futures", "futures-util", - "hkdf 0.13.0", - "hmac 0.13.0", + "hkdf", + "hmac", "itertools 0.15.0", - "metrics", "nonany", "oneshot-fused-workaround", "pin-project", "polyval 0.7.3", "postage", - "rand 0.10.4", + "rand 0.10.2", "rand_core 0.10.1", "safelog", "slotmap-careful", @@ -7118,6 +6874,7 @@ dependencies = [ "tor-memquota", "tor-protover", "tor-rtcompat", + "tor-rtmock", "tor-units", "tracing", "typenum", @@ -7129,14 +6886,12 @@ dependencies = [ [[package]] name = "tor-protover" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac0c7d7cc07222e72cc77231839d23259e4a1fdbbb02345c6c85d8ba142ad352" +checksum = "cab080a7551561bd56c0c2e3578b7114f0853700b96e43613fabc1fe06e5d885" dependencies = [ "caret", "derive-deftly", - "derive_more", - "itertools 0.15.0", "paste", "serde_with", "thiserror 2.0.20", @@ -7146,11 +6901,11 @@ dependencies = [ [[package]] name = "tor-relay-selection" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91947cd895147e04a4600103608a3e935541d399e1a0b1b400788ceb7583b6c5" +checksum = "07a5c22b7cfd59c40e38d4e111906793c0d65cf881e31efe3a83cac42887b1c9" dependencies = [ - "rand 0.10.4", + "rand 0.10.2", "serde", "tor-basic-utils", "tor-linkspec", @@ -7160,9 +6915,9 @@ dependencies = [ [[package]] name = "tor-rtcompat" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ecbaf82921338764c80b302abf5a75671400cc26d1daf3ee91826c653d5b9fc" +checksum = "542f4e13054bbba8d764ee24178fd889f77afb59dca7c6ae0a370604118c20b6" dependencies = [ "amplify", "async-trait", @@ -7196,11 +6951,42 @@ dependencies = [ ] [[package]] -name = "tor-socksproto" -version = "0.49.0" +name = "tor-rtmock" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "040951b4e279a0ac1b315a4845b69557f7d1ea1376fa911d482333b0693225a6" +checksum = "04cb78b3a39634e46c1bc795f62fca17b4d8a9404fead18750592a03216e1da3" dependencies = [ + "amplify", + "assert_matches", + "async-trait", + "derive-deftly", + "derive_more", + "educe", + "futures", + "humantime", + "itertools 0.15.0", + "oneshot-fused-workaround", + "pin-project", + "priority-queue", + "slotmap-careful", + "strum", + "thiserror 2.0.20", + "tor-error", + "tor-general-addr", + "tor-rtcompat", + "tracing", + "tracing-test", + "void", + "web-time-compat", +] + +[[package]] +name = "tor-socksproto" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f96e25e5d36b4aff59af40ec86f7ebb227a32b2f726ef1bc8cccf927f8fb31a" +dependencies = [ + "amplify", "caret", "derive-deftly", "educe", @@ -7213,9 +6999,9 @@ dependencies = [ [[package]] name = "tor-units" -version = "0.49.0" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "475566f8ee463e219980befbdc7b46397c1db5a8f54bd6ac75c41563712c5903" +checksum = "9a562c031f6c1f9d22f7bbcfbe715840d0e2cfe5e59d1296cc26000c17130555" dependencies = [ "derive-deftly", "derive_more", @@ -7334,14 +7120,39 @@ version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" dependencies = [ + "matchers", "nu-ansi-term", + "once_cell", + "regex-automata", "sharded-slab", "smallvec", "thread_local", + "tracing", "tracing-core", "tracing-log", ] +[[package]] +name = "tracing-test" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19a4c448db514d4f24c5ddb9f73f2ee71bfb24c526cf0c570ba142d1119e0051" +dependencies = [ + "tracing-core", + "tracing-subscriber", + "tracing-test-macro", +] + +[[package]] +name = "tracing-test-macro" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad06847b7afb65c7866a36664b75c40b895e318cea4f71299f013fb22965329d" +dependencies = [ + "quote", + "syn 2.0.119", +] + [[package]] name = "twox-hash" version = "2.1.4" @@ -7449,7 +7260,7 @@ dependencies = [ "serde", "tempfile", "textwrap", - "toml 1.2.3+spec-1.1.0", + "toml 1.1.6+spec-1.1.0", "uniffi_internal_macros", "uniffi_meta", "uniffi_pipeline", @@ -7495,7 +7306,7 @@ dependencies = [ "quote", "serde", "syn 2.0.119", - "toml 1.2.3+spec-1.1.0", + "toml 1.1.6+spec-1.1.0", "uniffi_meta", ] @@ -7737,9 +7548,9 @@ dependencies = [ [[package]] name = "web-time-compat" -version = "0.3.1" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f854754465eaf0d17b96236f75c6ddfaebf5907dc31c24ecdc265ffe609756c5" +checksum = "b6ab47578e1cd38415489592da29326341e272bd281f4ddbc0c10b654a425ad7" dependencies = [ "web-time", ] @@ -8104,23 +7915,12 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" dependencies = [ - "curve25519-dalek 4.1.3", + "curve25519-dalek", "rand_core 0.6.4", "serde", "zeroize", ] -[[package]] -name = "x25519-dalek" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7e8131a03190127fb2263afc72b322ecadae46b6ff8c6f399ff5d02f5559af6" -dependencies = [ - "curve25519-dalek 5.1.0", - "rand_core 0.10.1", - "zeroize", -] - [[package]] name = "xxhash-rust" version = "0.8.18" @@ -8129,9 +7929,9 @@ checksum = "aee1b19627c7c60102ab80d3a9cbe18de90bfe03bfa6c3715447681f0e8c8af6" [[package]] name = "yoke" -version = "0.8.4" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -8140,14 +7940,14 @@ dependencies = [ [[package]] name = "yoke-derive" -version = "0.8.4" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn 3.0.5", - "synstructure 0.14.0", + "syn 2.0.119", + "synstructure", ] [[package]] @@ -8188,7 +7988,7 @@ dependencies = [ "proc-macro2", "quote", "syn 2.0.119", - "synstructure 0.13.2", + "synstructure", ] [[package]] @@ -8224,9 +8024,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.9" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8" dependencies = [ "serde", "yoke", @@ -8236,9 +8036,9 @@ dependencies = [ [[package]] name = "zerovec-derive" -version = "0.11.7" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da" dependencies = [ "proc-macro2", "quote", diff --git a/crates/onionwire-sdk/Cargo.toml b/crates/onionwire-sdk/Cargo.toml index ff24a3a..9c36942 100644 --- a/crates/onionwire-sdk/Cargo.toml +++ b/crates/onionwire-sdk/Cargo.toml @@ -33,7 +33,7 @@ cuprate-daemon = ["onionwire/cuprate-daemon"] [dependencies] onionwire = { path = "../..", default-features = false, features = ["rustls"] } # `static-sqlite`: Android has no system libsqlite3 to link against. -arti-client = { version = "0.49", default-features = false, features = [ +arti-client = { version = "0.46", default-features = false, features = [ "tokio", "onion-service-client", "onion-service-service", diff --git a/crates/onionwire-sdk/README.md b/crates/onionwire-sdk/README.md index 545263b..d025eda 100644 --- a/crates/onionwire-sdk/README.md +++ b/crates/onionwire-sdk/README.md @@ -5,7 +5,7 @@ runs on. An Android peer and a Linux peer that exchange invites interoperate — there is one protocol, not two. This is **not** a WebView wrapper and **not** a client for a hosted service. -Each install runs Arti in-process (`arti-client` 0.49, `onion-service-client` + +Each install runs Arti in-process (`arti-client` 0.46, `onion-service-client` + `onion-service-service`), hosts its own v3 onion service, and dials friends' onions directly. There is no `tor` binary, no torrc, no Orbot as the pipe. diff --git a/crates/onionwire-sdk/src/lib.rs b/crates/onionwire-sdk/src/lib.rs index 390d653..35d4b70 100644 --- a/crates/onionwire-sdk/src/lib.rs +++ b/crates/onionwire-sdk/src/lib.rs @@ -103,10 +103,6 @@ pub struct FriendInfo { /// Current locator. May be stale if the peer rotated while you were down. pub onion: String, pub last_connect_ok: bool, - /// True when the friend was added from `onionwire:v2` (has an ML-KEM key), - /// so sessions are hybrid. False is a legacy v1 friend: classical - /// transport, and the UI must say so. - pub pq: bool, } /// What `send()` did with the message. @@ -194,8 +190,6 @@ pub struct RotateOutcome { pub struct InviteInfo { pub pubkey_hex: String, pub onion: String, - /// `onionwire:v2` (ML-KEM key present) vs a legacy v1 invite. - pub pq: bool, } /// Observable lifecycle state of the node's onion service. @@ -306,7 +300,6 @@ pub fn decode_invite(invite: String) -> WResult { Ok(InviteInfo { pubkey_hex: hex(&p.pubkey), onion: p.onion, - pq: p.kem_pk.is_some(), }) } @@ -395,7 +388,6 @@ impl Wire { petname: f.petname, onion: f.onion, last_connect_ok: f.last_connect_ok, - pq: f.kem_pk.is_some(), }) .collect()) } @@ -413,7 +405,6 @@ impl Wire { petname: f.petname, onion: f.onion, last_connect_ok: f.last_connect_ok, - pq: f.kem_pk.is_some(), }) } @@ -1665,17 +1656,6 @@ mod tests { .block_on(f) } - #[test] - fn a_v2_invite_round_trips_through_decode_invite() { - let onion = "abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion"; - let invite = onionwire::qr::encode(&[7u8; 32], onion, &[1u8; 32], &[9u8; 1184]) - .expect("encode v2"); - let info = decode_invite(invite).expect("decode v2"); - assert_eq!(info.onion, onion); - assert_eq!(info.pubkey_hex.len(), 64); - assert!(info.pq, "a v2 invite carries the ML-KEM key"); - } - #[test] fn tor_state_of_a_stopped_handle_is_stopped() { assert_eq!(stopped_wire().tor_state(), TorState::Stopped); diff --git a/docs/ARTI_UPGRADE.md b/docs/ARTI_UPGRADE.md index 7045e62..defc59e 100644 --- a/docs/ARTI_UPGRADE.md +++ b/docs/ARTI_UPGRADE.md @@ -12,19 +12,13 @@ Direct dependencies that come from the Arti repository, exactly as | crate | requirement | features in `Cargo.toml` | |---|---|---| -| `arti-client` | `0.49` | `default-features = false`; `tokio`, `onion-service-client`, `onion-service-service`, `compression` | -| `tor-cell` | `0.49` | — | -| `tor-hsservice` | `0.49` | — | -| `tor-rtcompat` | `0.49` | `tokio` | -| `safelog` | `0.10` | — | +| `arti-client` | `0.46` | `default-features = false`; `tokio`, `onion-service-client`, `onion-service-service`, `compression` | +| `tor-cell` | `0.46` | — | +| `tor-hsservice` | `0.46` | — | +| `tor-rtcompat` | `0.46` | `tokio` | `snow`, `rusqlite`, `ratatui`, and the rest are unrelated to Arti and are not -part of a Tor upgrade. `safelog` lives in the Arti repository and moves in -lockstep with the `tor-*` set: a stale direct `safelog` pin puts two copies in -the graph, and `HsId::display_redacted` then resolves against the wrong trait -(`error[E0599]: no method named display_redacted`). The SDK workspace -(`crates/onionwire-sdk`) has its own `arti-client` pin and lockfile; bump it -too. +part of a Tor upgrade. Two crate features re-expose Arti's TLS backends, which Arti marks **non-additive** — exactly one may be selected per build graph: @@ -35,16 +29,16 @@ Two crate features re-expose Arti's TLS backends, which Arti marks features (without it the rustls backend compiles with no provider). * `native-tls` → opt-in only, via OpenSSL. -Published Arti releases move all of the crates above together in lockstep. -Bump them as **one set**. A mixed set (e.g. `arti-client` 0.47 with -`tor-hsservice` 0.49) is not a configuration anyone tests upstream, and cargo -will usually refuse or silently pick one `tor-*` version and mismatched -`tor-*` internals fail at runtime. +Published Arti releases move all four crates together in lockstep. Bump them as +**one set**. A mixed set (e.g. `arti-client` 0.47 with `tor-hsservice` 0.46) is +not a configuration anyone tests upstream, and cargo will usually refuse or +silently pick one `tor-*` version and mismatched `tor-*` internals fail at +runtime. ## Toolchain floor **rustc 1.98+.** `Cargo.toml` sets `edition = "2024"` and `rust-version = "1.98"`. -Arti 0.49 itself requires only 1.92; the higher floor is the default +Arti 0.46 itself requires only 1.91; the higher floor is the default `cuprate-daemon` feature (`tapes` calls `VecDeque::pop_front_if`, stable since 1.93). CI builds inside `rust:1.98-bookworm` (`RUST_IMAGE` in `.forgejo/workflows/ci.yml` and `release.yml`). @@ -85,22 +79,16 @@ issue the watcher files. 1. Read the upstream release notes (Arti tags: ) and the CHANGELOG for breaking API changes. Check the new MSRV. -2. Branch from `main`; bump every Arti-repository pin in `[dependencies]` of - `Cargo.toml` together (`arti-client`, `tor-cell`, `tor-hsservice`, - `tor-rtcompat`, and `safelog`), the matching `arti-client` pin in - `crates/onionwire-sdk/Cargo.toml`, and `rust-version` if the floor moved. +2. Branch from `main`; bump all four requirements in `[dependencies]` of + `Cargo.toml` together, and `rust-version` if the floor moved. 3. Refresh the lockfile (CI builds with `--locked` and `Cargo.lock` is committed): ``` - cargo update -p arti-client -p tor-cell -p tor-hsservice -p tor-rtcompat -p safelog + cargo update -p arti-client -p tor-cell -p tor-hsservice -p tor-rtcompat git diff --stat Cargo.lock ``` Expect the whole `tor-*` family to move in the diff. A single `tor-*` crate moving alone is a sign the set is not actually lockstep — stop and look. - Then refresh the SDK workspace's separate lockfile: - ``` - ( cd crates/onionwire-sdk && cargo update -p arti-client ) - ``` 4. Build and run the offline suite: ``` cargo test --locked diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md index bec89a8..07c07fd 100644 --- a/docs/PROTOCOL.md +++ b/docs/PROTOCOL.md @@ -4,9 +4,8 @@ This is the wire protocol. A second implementation should be able to interoperate from this document without reading the Rust. It is **not** an IETF RFC. It describes what this repository speaks today -(frame versions 1 and 2, invite schemes `onionwire:v2` (emit) and -`onionwire:v1` (decode only)). There has been no public third-party audit. -Arti onion services are experimental upstream. +(frame version 1, invite scheme `onionwire:v1`). There has been no public +third-party audit. Arti onion services are experimental upstream. Related: [threat model](THREAT_MODEL.md), [audit notes](SECURITY_AUDIT.md). @@ -33,20 +32,13 @@ Each install holds: - **Identity** — ed25519 keypair. The 32-byte public key **is** the person. Roster primary key. Displayed as 64 lowercase hex chars (the fingerprint). - **Prekey** — x25519 keypair. This is the Noise IK *static*. It is long-lived - — rotate it with `F8`, which hard-cuts every stored session. Rotating the - onion (`F4`) does **not** rotate it. -- **KEM key** — ML-KEM-768 (FIPS 203) keypair. The 1184-byte encapsulation key - travels in a v2 invite as `kem=`; the 64-byte decapsulation seed lives in the - SQLCipher store beside `identity_sk`. `F8` rotates it together with the - prekey, with the same hard cut (stored ratchet state is dropped and every - friend re-pastes the invite). + in v1 — rotate it with `F8`, which hard-cuts every stored session. Rotating + the onion (`F4`) does **not** rotate it. - **Onion** — Tor v3 address. Locator only. Disposable. -A friend is `{identity_pk, current_onion, current_prekey_pk, kem_pk?}`. Pasting -the same identity `k` updates the locator, prekey and KEM key on that row. It -never creates a second person. `kem_pk` is absent only for a friend added from -a legacy `onionwire:v1` invite; such a friend is **classical** (see -[No downgrade](#no-downgrade)). +A friend is `{identity_pk, current_onion, current_prekey_pk}`. Pasting the same +identity `k` updates the locator (and prekey) on that row. It never creates a +second person. Petnames, chat history, and the optional Monero wallet RPC are local. They are not on the wire. @@ -80,154 +72,34 @@ Excess is dropped before handshake. That is availability, not anonymity. Every Noise handshake message and every ciphertext is wrapped: ``` -uint8 version = 1 (normal) | 2 (PQ handshake prelude) +uint8 version = 1 uint32 length = big-endian body length uint8 body[length] ``` -- `version = 1` is Noise msg 1, msg 2, an identity proof, or one application - ciphertext. It is unchanged from v1 of this document. -- `version = 2` is the **PQ handshake prelude**. Its body is `uint16 ct_len` - (big-endian) followed by exactly `ct_len` bytes of ML-KEM-768 ciphertext. - `ct_len` MUST be 1088. The prelude may only be the first frame of a session; - the initiator sends exactly one, then Noise msg 1 with `version = 1`. - `read_frame` (used after the opening frame) rejects `version = 2`. - `length` MUST be ≤ 65535. Check the length **before** allocating the body. - Other `version` values are a hard fail (close the stream). - Length that does not match the bytes on the wire is a hard fail. -`length` still reveals the exact ciphertext size. Chat hides it by padding the -plaintext to a bucket before encryption (see [Length buckets](#length-buckets)). -Other frame types are not padded. - -## Length buckets - -Normative for chat. A chat line is padded to one fixed ladder **before** the -ratchet encrypts it, so the padding is inside ChaCha20-Poly1305, inside the -Noise session, and authenticated by both. An observer sees a ciphertext whose -length is one of the ladder values (plus constant overhead), never the body -length. - -Ladder — padded-plaintext sizes in bytes: - -``` -256, 512, 1024, 2048, 4096, 8192, 16384, 32768 -``` - -Ratchet plaintext encoding: - -``` -uint16 pad_len big-endian -uint8 body[..] the chat line -uint8 fill[pad_len] random bytes, contents ignored -``` - -- The padded plaintext MUST be exactly the smallest ladder value that is at - least `2 + body_len`. `pad_len = bucket - 2 - body_len`. -- Empty and short bodies both pad to 256; a 254-byte body fits the 256 bucket - with `pad_len = 0`. -- `fill` is fresh random bytes. Its contents carry no meaning. -- A body larger than 32766 bytes does not fit the ladder and MUST fail closed - (it is a protocol error, never queued). - -Receiver rules: - -- The total decrypted length is **not** required to be a ladder value. Only the - header is normative, so a peer with a different ladder still interoperates. -- `pad_len` is the only authority for the body length. A receiver MUST NOT trim - trailing zeros, strip a repeated fill byte, or otherwise infer the boundary - from content: a body that legitimately ends in the same byte as the fill - round-trips unchanged. -- A plaintext shorter than 2 bytes, or one whose `pad_len` exceeds - `len - 2`, MUST be rejected as a hard failure before anything is appended, - rendered, or persisted. The ratchet state is not advanced. -- Unpadded frames are not accepted as if they were a bucket: if the first two - bytes do not describe a consistent `pad_len`, the frame fails closed. -- Padding is a plaintext-layer change and is independent of the `rat ` frame - version: a classical (`0x01`) and a hybrid (`0x02`) frame carry the same - padded plaintext. See [Ratchet (chat layer)](#ratchet-chat-layer) for the - header each version adds. - -The ladder floor stays at **256** even though a hybrid frame's floor is over -2.6 KB. The ladder schedules the *plaintext*, and a hybrid step's size is -dominated by its 2312-byte header — the 256 bucket is a rounding error there, -so raising the floor would not conceal the header and would only inflate -classical (`0x01`) chat, which is still the epoch-0 and legacy-friend path. A -second, version-specific ladder would double the normative surface for no -privacy gain; the bucket boundaries remain observable within each size class -either way. - -Minimum observable size depends on the `rat ` header version: - -- Classical (`0x01`): `rat ` 4 + version 1 + header 40 + nonce 12 + bucket 256 - + tag 16 = **329-byte `rat ` frame**; the Noise transport adds its 16-byte - tag and the framing header adds 5 bytes, so the smallest classical chat frame - on the wire is **350 bytes**. -- Hybrid (`0x02`): `rat ` 4 + version 1 + header 2312 + nonce 12 + bucket 256 - + tag 16 = **2601-byte `rat ` frame**, i.e. **2622 bytes on the wire**. The - 2272 extra header bytes are the sender's ML-KEM-768 ratchet key and the - ciphertext to the receiver's; the 256-byte bucket applies unchanged inside - them. - -Both floors hold whatever the body length. The 32768 bucket yields a -32862-byte classical frame and a 35113-byte hybrid frame, both under the 65535 -Noise body cap. - -The ML-KEM-768 ciphertext appears in two places: the one-shot handshake prelude -(`version = 2`, 1095 bytes once per session), and every `rat ` header after the -first hybrid ratchet step (`kem_pub[1184] || kem_ct[1088]`). Epoch 0 of a chat -is always classical, so the first `rat ` frame of a friend relationship uses -the 40-byte header. - -`fil ` chunks are deliberately **not** padded. They are raw file bytes paced -through the accept token bucket, and padding them would either cut the usable -chunk size or spend the 65535 frame cap on fill; the chunk size stays as -specified under `fil ` — file chunk. - -This hides length, not timing: one Noise session per message, retry cadence and -circuit timing are unchanged and remain accepted costs (see -`docs/THREAT_MODEL.md`). - ## Handshake Noise pattern: `Noise_IK_25519_ChaChaPoly_BLAKE2s` -Prologue (both sides, before the first Noise handshake message): - -- **Classical** (no PQ prelude, friend row has no `kem_pk`): `onionwire-v1` - (12 ASCII bytes, no NUL). -- **Hybrid** (a PQ prelude was sent/received): the exact byte layout - - ``` - "onionwire-v2" || 0x00 || ct || 0x00 || ss_kem - ``` - - where `onionwire-v2` is 12 ASCII bytes, `ct` is the 1088-byte ML-KEM-768 - ciphertext from the prelude, and `ss_kem` is the 32-byte shared secret. - Initiator: `(ct, ss_kem) = ML-KEM-768.Encapsulate(friend.kem_pk)`. - Responder: `ss_kem = ML-KEM-768.Decapsulate(own_dk, ct)`. Both therefore - commit to the ciphertext and to the PQ secret: a modified `ct` changes the - prologue (and decapsulates to implicit-rejection garbage), so the Noise - handshake fails before msg 2. +Prologue (both sides, before the first handshake message): `onionwire-v1` +(13 ASCII bytes, no NUL). Handshake payloads are empty. A non-empty decrypted handshake payload is a hard fail. ### Sequence -Initiator knows the responder’s identity pubkey (pinned), x25519 prekey and -(if `kem_pk` is present) ML-KEM key from the invite (or roster). +Initiator knows the responder’s identity pubkey (pinned) and x25519 prekey +from the invite (or roster). -0. **PQ prelude** — only when the responder’s roster row has `kem_pk`: - initiator → responder, one `version = 2` frame carrying the ML-KEM - ciphertext. If the row has no `kem_pk`, no prelude is sent and the prologue - is `onionwire-v1`. -1. **IK msg 1** — initiator → responder (framed, `version = 1`). Responder’s - Noise static is the invite `spk`. +1. **IK msg 1** — initiator → responder (framed). Responder’s Noise static is + the invite `spk`. 2. Responder looks up the remote static in the roster **by prekey**. Unknown prekey → close. This is how the answerer learns who is calling. - It then compares the friend row with how the session opened (see - [No downgrade](#no-downgrade)) and only then sends msg 2. 3. **IK msg 2** — responder → initiator (framed). 4. Both sides enter transport mode. Handshake hash `h` is 32 bytes (BLAKE2s). 5. **Identity proof, initiator first** — transport-encrypt a 96-byte proof, @@ -257,27 +129,6 @@ ciphertext and closes. The responder decrypts that one frame and closes. Compromise of the long-term x25519 prekey does not decrypt past transport (IK + ephemeral). It does allow future impersonation at the Noise layer until the peer notices the identity proof failing — so the proof is not optional. -With a PQ prelude, the transport secrets also mix `ss_kem`; a later -cryptographically relevant quantum adversary that recorded the session still -needs ML-KEM-768 broken to recover the Noise transport keys. - -### No downgrade - -The rule comes from the roster row, never from what arrives on the wire: - -- friend row has `kem_pk` → **always** send the prelude; the responder requires - one. A `version = 1` opening from that peer is rejected with `prelude - required` before msg 2, the identity proofs, and any application frame. -- friend row has no `kem_pk` (added from a legacy v1 invite) → classical - session with the `onionwire-v1` prologue. The UI labels the friend as lacking - PQ protection. -- A prelude is not accepted for a friend row with no `kem_pk`: the responder - rejects it with `unexpected prelude` before msg 2, so the wire cannot upgrade - a classical row. `kem_pk` only enters a row from a signed v2 invite. - -A v1-only build dialling a v2 install cannot parse `version = 2` as an opening -frame and hard-fails, and a v2 build will not send a prelude to a v1 peer. -That mixed-fleet break is accepted; there is no fallback path. ## Application plaintext @@ -312,42 +163,20 @@ prefix. ### Application-frame signatures -`loc`, `prf`, `inv`, `rcp`, and `tip` each carry an ed25519 signature over the +`loc`, `prf`, `inv`, and `rcp` each carry an ed25519 signature over the **fields**, not the 4-byte typed prefix. Encode MUST sign the domain-separated form (type tag, then each field, `0x00` separators). Verify MUST accept that form and, for mixed-version peers, the legacy untagged LF-joined layout. Anything else fails closed. Do not emit the legacy layout. -The invite string is separate and uses `onionwire-invite-v2` (see Invite). +`tip` is signed over the LF-joined fields only (no domain tag on encode today). +The `tip ` prefix is not signed. -Legacy acceptance is one switch, `LEGACY_SIGS`, default **on**. Every fallback -listed below reads it; with it off, verification accepts only the emitted -(tagged) form. It is a local capability constant, not a wire field: it is never -sent, and a peer cannot negotiate it. +The invite string is separate and keeps `onionwire-invite-v1` (see Invite). -| frame | emitted | accepted inbound | -| --- | --- | --- | -| invite | `onionwire-invite-v2`, `0x00`-separated over `k`, `o`, `spk`, `kem` | same; `onionwire:v1` over `onionwire-invite-v1` `0x00`-separated `k`,`o`,`spk`, or over `k \|\| o \|\| spk` (legacy only) | -| `loc ` | `"onionwire-loc-v1"` `0x00` `onion` `0x00` `ts` | same; `onion \|\| LF \|\| ts` (legacy only) | -| `prf ` | `"onionwire-prf-v1"` `0x00` `name` `0x00` `bio` `0x00` `xmr_addr` `0x00` `ts` | same; the four fields joined by LF (not yet gated — see below) | -| `inv ` | `"onionwire-inv-v1"` `0x00` `amount_atomic` `0x00` `address` `0x00` `memo` `0x00` `ts` | same; the four fields joined by LF (legacy only) | -| `rcp ` | `"onionwire-rcp-v1"` `0x00` `txid` `0x00` `amount_atomic` `0x00` `address` `0x00` `ts` | same; the four fields joined by LF (legacy only) | -| `tip ` | `"onionwire-tip-v1"` `0x00` `txid` `0x00` `amount_atomic` `0x00` `address` `0x00` `memo` `0x00` `ts` | same; the five fields joined by LF (legacy only) | - -The tag suffixes do say `-v1`; that is the tag's own version, not the invite -string version. - -`prf ` is the one frame whose legacy fallback is not yet gated: it is accepted -unconditionally in this revision and moving it under `LEGACY_SIGS` is a -separate change. - -**Mixed-fleet consequence.** Older builds verify only the untagged bytes, so -they reject every tagged signature from a new sender — including `tip `, which -older builds emitted and verified untagged. That direction needs the peer -updated before tips flow. The reverse works while `LEGACY_SIGS` is on: a new -build verifies an old sender's untagged `loc`/`prf`/`inv`/`rcp`/`tip` and an -`onionwire:v1` invite. Turning the switch off is a fleet-wide cutover, not a -per-peer choice. +Older builds verify only the untagged bytes, so they reject tagged signatures +(fail closed, no downgrade). Mixed-version fleets break outbound application +frames from a new sender to an old receiver until both sides are updated. ### `loc ` — locator update @@ -370,8 +199,8 @@ ed25519_sign(identity_sk, ``` **Legacy accept:** a signature over `onion || LF || ascii(ts)` is still -accepted on verify while `LEGACY_SIGS` is on, so old loc frames verify. New loc -frames MUST use the domain-separated form. Do not emit legacy. +accepted on verify so old loc frames verify. New loc frames MUST use the +domain-separated form. Do not emit legacy. Apply only if **all** of: @@ -402,7 +231,7 @@ ed25519_sign(identity_sk, **Legacy accept:** a signature over the four fields joined by LF is still accepted on verify. New profile frames MUST use the domain-separated form. -Do not emit legacy. This fallback is not yet read through `LEGACY_SIGS`. +Do not emit legacy. Apply only for an existing friend, valid signature, newer `ts`. Not a public profile. Not a directory. @@ -425,8 +254,8 @@ ed25519_sign(identity_sk, ``` **Legacy accept:** a signature over the four fields joined by LF is still -accepted on verify while `LEGACY_SIGS` is on. New invoices MUST use the -domain-separated form. Do not emit legacy. +accepted on verify. New invoices MUST use the domain-separated form. Do not +emit legacy. The frame is a signed claim, not a payment. It is one-shot: if the peer onion is down, the send fails. There is no queued invoice. @@ -447,8 +276,8 @@ ed25519_sign(identity_sk, ``` **Legacy accept:** a signature over the four fields joined by LF is still -accepted on verify while `LEGACY_SIGS` is on. New receipts MUST use the -domain-separated form. Do not emit legacy. +accepted on verify. New receipts MUST use the domain-separated form. Do not +emit legacy. Signature proves which friend sent the claim. It does **not** prove money moved. Local `verified=1` only if a user-hosted `monero-wallet-rpc` returns @@ -464,20 +293,13 @@ Sent after a chain transfer, together with `rcp `. One-shot. tip \n\n
\n\n\n ``` -The `tip ` prefix is **not** signed. - -**Current signature (encode this):** +The `tip ` prefix is **not** signed. Encode signs the LF-joined fields: ``` ed25519_sign(identity_sk, - "onionwire-tip-v1" || 0x00 || txid || 0x00 || amount_atomic || 0x00 || - address || 0x00 || memo || 0x00 || ascii(ts)) + txid || LF || amount_atomic || LF || address || LF || memo || LF || ascii(ts)) ``` -**Legacy accept:** a signature over the five fields joined by LF is still -accepted on verify while `LEGACY_SIGS` is on. New tips MUST use the -domain-separated form. Do not emit legacy. - `memo` MUST NOT contain newlines. Same address and amount rules as invoices. A peer that does not implement `tip ` MUST drop it as an unknown typed prefix, not render it as chat. @@ -516,10 +338,9 @@ is a chat line `[file] name (N bytes)`, never the raw frame. ### Chat A chat send is ratcheted: the wire form of a chat message is a `rat ` frame -(see “Ratchet (chat layer)”), and the plaintext inside that frame is the chat -line below, padded to a length bucket first (see -[Length buckets](#length-buckets)). A bare chat frame with no typed prefix is -still accepted inbound as a chat line (older peers), but MUST NOT be emitted. +(see “Ratchet (v1 chat layer)”), and the plaintext inside that frame is the chat +line below. A bare chat frame with no typed prefix is still accepted inbound as +a chat line (older peers), but MUST NOT be emitted. UTF-8 is not enforced for chat text: invalid bytes become U+FFFD (the implementation does not drop the row). Control and bidi formatting @@ -528,11 +349,9 @@ tab and newline, DEL (0x7F), C1 U+0080–U+009F, U+202A–U+202E, U+2066–U+2069, U+200E, U+200F, U+200B, U+200C. U+200D (ZWJ) is kept so emoji sequences stay intact. `fil ` filenames must not contain those characters (tab and newline included). Displayed as a line. -A chat line is at most 32766 bytes (the largest bucket minus the 2-byte -`pad_len` header); a longer body is a protocol error, not a queued message. See -[Length buckets](#length-buckets). +No length limit beyond the frame cap. -## Ratchet (chat layer) +## Ratchet (v1 chat layer) Chat is the only application payload that is ratcheted. A chat send is Double-Ratchet encrypted first, and the resulting `rat ` frame is the @@ -550,53 +369,26 @@ instead. ``` "rat " 4 bytes (0x72 0x61 0x74 0x20) -version 1 byte 0x01 (classical) or 0x02 (hybrid) --- version 0x01: classical header, 40 bytes -header 40 bytes dh_pub[32] || N uint32 BE || PN uint32 BE -nonce 12 bytes random, per message -ciphertext n+16 ChaCha20-Poly1305 ciphertext || tag - --- version 0x02: hybrid header, 2312 bytes -header 2312 bytes dh_pub[32] || N uint32 BE || PN uint32 BE - || kem_pub[1184] || kem_ct[1088] -nonce 12 bytes random, per message +version 1 byte 0x01 +header 40 bytes dh_pub[32] || N uint32 BE || PN uint32 BE +nonce 12 bytes random, per message ciphertext n+16 ChaCha20-Poly1305 ciphertext || tag ``` -- `dh_pub` — the sender's current X25519 ratchet public key (32 bytes). +- `dh_pub` — the sender's current ratchet public key (X25519, 32 bytes). - `N` — the index of this message in the sender's current sending chain, counting from 0. - `PN` — how many messages the sender sent in its *previous* sending chain. -- `kem_pub` — the sender's current ML-KEM-768 ratchet encapsulation key - (1184 bytes). -- `kem_ct` — an ML-KEM-768 ciphertext (1088 bytes) that the sender - encapsulated to the *receiver's current* ratchet KEM key. It is repeated on - every frame of a chain a hybrid step established, so a lost first frame does - not wedge the chain. -- Associated data is the whole header for the version in use, exactly as - serialized above. A tampered `dh_pub`, `N`, `PN`, `kem_pub` or `kem_ct` +- Associated data is the 40-byte header, exactly as serialized above + (`dh_pub || N as u32 BE || PN as u32 BE`). A tampered `dh_pub`, `N` or `PN` therefore fails closed. - The ChaCha20-Poly1305 key is the message key from `KDF_CK`. The 12-byte nonce is random per message, not a chain counter. -- A chat frame's minimum size depends on the header version, not the body: an - empty chat line still pads to the 256-byte bucket. Version `0x01` is 329 - bytes (5 + 40 + 12 + 256 + 16); version `0x02` is 2601 bytes - (5 + 2312 + 12 + 256 + 16). A hybrid message therefore carries 2272 more - header bytes than a classical one. See [Length buckets](#length-buckets). -- On the wire those become 350 bytes for `0x01` (329 + the Noise 16-byte tag + - the 5-byte framing header) and 2622 bytes for `0x02`. The 350-byte floor is - the classical case only. -- A `rat ` frame with no padding at all cannot occur for chat; the bare frame - overhead (empty ciphertext plaintext) is 73 bytes for `0x01` - (5 + 40 + 12 + 16) and 2345 bytes for `0x02` (5 + 2312 + 12 + 16). +- Minimum frame (empty plaintext) is 73 bytes: 5 + 40 + 12 + 16. - A receiver MUST reject a frame without the `rat ` prefix, a version other than - `0x01`/`0x02`, or a frame shorter than its version's minimum. + `0x01`, or less than 73 bytes. - The frame must fit the Noise body cap (65535 bytes, including the 16-byte - Poly1305 tag), so a `rat ` frame is at most 65519 bytes. A maximal hybrid - plaintext is therefore 63174 bytes, still far above the chat line limit. -- A `rat ` frame is one Noise body: the `fil ` chunk-pacing rules do not apply, - and the receive token bucket counts rendezvous accepts, not bytes, so the - larger hybrid header changes neither. + Poly1305 tag), so a `rat ` frame is at most 65519 bytes. Because the header rides inside Noise, an observer sees one opaque ciphertext per message: no message counts, no ratchet keys, and nothing that marks a first @@ -604,45 +396,28 @@ message of a chain versus a later one. ### KDFs -Signal's constructions, with a second domain for hybrid steps: +Signal's constructions, unchanged: ``` -KDF_RK(root, dh_out): # v1: epoch 0, classical friends +KDF_RK(root, dh_out): okm = HKDF-SHA256(salt = root, ikm = dh_out, info = "onionwire-ratchet-v1-kdfrk", L = 64) new_root = okm[0..32] chain_key = okm[32..64] -KDF_RK_hybrid(root, dh_out, ss_kem): # v2: every hybrid ratchet step - okm = HKDF-SHA256(salt = root, ikm = dh_out || ss_kem, - info = "onionwire-ratchet-v2-kdfrk", L = 64) - new_root = okm[0..32] - chain_key = okm[32..64] - KDF_CK(chain_key): message_key = HMAC-SHA256(chain_key, 0x01) next_chain_key = HMAC-SHA256(chain_key, 0x02) ``` -`HKDF` is RFC 5869 with SHA-256, `HMAC` is SHA-256. The two `KDF_RK` forms -differ in **both** input shape and info string on purpose: `ikm` is 32 bytes for -v1 and `dh_out || ss_kem` (64 bytes) for v2, and the domain strings are -distinct. There is no way to derive a v2 chain without a real `ss_kem`, and a -classical derivation can never be mistaken for a hybrid one. - -Each side of an epoch derives its chains from one shared input with `KDF_RK` -called **twice**: +`HKDF` is RFC 5869 with SHA-256, `HMAC` is SHA-256. Each side of an epoch +derives its chains from one shared DH output with `KDF_RK` called **twice**: ``` -epoch_chains(root, shared) -> (new_root, ck_lo, ck_hi): # v1 +epoch_chains(root, shared) -> (new_root, ck_lo, ck_hi): (root1, ck_lo) = KDF_RK(root, shared) (root2, ck_hi) = KDF_RK(root1, shared) new_root = root2 - -epoch_chains_hybrid(root, dh_out, ss_kem) -> (new_root, ck_lo, ck_hi): # v2 - (root1, ck_lo) = KDF_RK_hybrid(root, dh_out, ss_kem) - (root2, ck_hi) = KDF_RK_hybrid(root1, dh_out, ss_kem) - new_root = root2 ``` `lo` is the lexicographically lower of the pair's two ratchet public keys and @@ -666,30 +441,16 @@ root_key = hk.expand("root", 32) my_secret = hk.expand("ratchet-key" || my_identity_pk, 32) peer_secret = hk.expand("ratchet-key" || peer_identity_pk, 32) -my_ratchet = keypair(my_secret) // x25519 secret/public + ML-KEM-768 -peer_ratchet = keypair(peer_secret) // derived by both sides, same values - -state = bootstrap(root_key, my_ratchet, - peer_ratchet.x25519_pub, - peer_ratchet.kem_pub if the friend row carries kem_pk else None) +state = bootstrap(root_key, my_keypair(my_secret), X25519_pub(peer_secret)) ``` `HKDF.expand` above is the RFC 5869 expand step (no second extract). The two identity public keys are public (invite/roster), so either peer computes its own -secrets and the peer's, and both agree with no new wire field. The ML-KEM half of -each initial ratchet keypair is derived from that keypair's X25519 secret, so the -peer's KEM ratchet public key needs no wire field either: - -``` -kem_seed = HKDF-SHA256(salt = "ratchet-kem", ikm = x25519_secret).expand("seed", 64) -kem_pub = ML-KEM-768 encapsulation key from kem_seed -``` - -Then: +secrets and the peer's, and both agree with no new wire field. Then: ``` shared = DH(my_secret, remote_pub) -(new_root, ck_lo, ck_hi) = epoch_chains(root_key, shared) // v1: epoch 0 is classical +(new_root, ck_lo, ck_hi) = epoch_chains(root_key, shared) send_ck = chain_for(my_pub, remote_pub) // ck_lo or ck_hi recv_ck = chain_for(remote_pub, my_pub) send_n = recv_n = 0, PN = 0, established = false @@ -698,52 +459,6 @@ send_n = recv_n = 0, PN = 0, established = false Fresh entropy enters at the first DH ratchet step; the bootstrap epoch itself is prekey-bound (see [THREAT_MODEL.md](THREAT_MODEL.md)). -### Hybrid ratchet steps, and why epoch 0 stays classical - -Every ratchet keypair is now `{x25519, ML-KEM-768}`. On a step the peer that -rotates encapsulates to the receiver's **current** ratchet KEM key and puts -`kem_pub` (its new key) and `kem_ct` (that ciphertext) in the header. The -receiver decapsulates with the key it already holds, so both sides feed -`KDF_RK_hybrid` the same `(X25519 DH, ss_kem)` pair and derive the same chains. -No extra round trip is added: the KEM material rides on the rotation frame -itself, and is repeated on every later frame of that chain so a lost first frame -is harmless. - -**Epoch 0 cannot be per-session, so it stays classical.** Epoch 0's root is -derived from the two long-lived signed prekeys precisely so that neither side -needs a wire field and both converge even when both send first. The hybrid Noise -session does carry an `ss_kem` (see Transport), but each chat message is its own -one-shot Noise session: a fresh encapsulation, therefore a different `ss_kem` for -every dial, and *different* sessions for the two peers' first sends. Binding the -epoch-0 root to that secret would make the root a function of which session -carried which message, so: - -- two peers sending first would derive different epoch-0 roots and could not - read each other at all, and -- even a single direction would break at the second message, because message 2 - would arrive on a different Noise session with a different `ss_kem` while the - receiver still holds the root from message 1. - -There is no way to keep both "no wire field, both-send-first convergence" and a -per-session secret in epoch 0 without replacing the one-shot session model, which -is out of scope. Epoch 0 is therefore derived exactly as before, with the v1 -`KDF_RK`, and the KEM secret enters at the **first rotation after -`established`**. The first rotation is hybrid even for the bootstrap tie-break -rotation: that is what closes the window two round trips in. - -Consequences, stated exactly: - -- Every frame sent before the first hybrid step (the whole of epoch 0, in both - directions, plus any outbox row encoded on it) is protected by X25519 only. A - harvest-now adversary who later breaks X25519 can read those frames. This is - the residual window and it does not shrink with more messages, only with the - first rotation. -- Every frame on a chain established by a hybrid step additionally requires the - ML-KEM-768 secret. Breaking X25519 alone does not open it. -- A frame that carries a new `dh_pub` but no KEM section is **rejected** - (`hybrid step required`); a KEM section on a non-KEM friend is rejected too. - There is no classical fallback once a session has KEM material. - **Convergence when both peers send first.** Either peer may send immediately on the bootstrap epoch, so two peers can each build a sending chain before either has received anything. Because the epoch's two chains come from the unordered @@ -766,8 +481,7 @@ rotation first, so at most one rotation is ever in flight, and both peers feed On a decrypted `rat ` frame (the outer Noise session has already been verified, so the peer identity is pinned): -1. Parse; reject a bad prefix or version, and a frame shorter than its - version's minimum (73 bytes for `0x01`, 2345 for `0x02`). +1. Parse; reject bad prefix, version or a frame under 73 bytes. 2. If `(dh_pub, N)` is in the skipped-key store: open with that key, **delete it** from the store, deliver. A replay of the same frame then fails closed because the key is gone. @@ -778,15 +492,11 @@ so the peer identity is pinned): - Derive message keys for `recv_n .. N` into the skipped store, derive the key for `N`, open, set `recv_n = N + 1`. - On the *first* frame received in this state (`established == false`): set - `established`, and if `my_pub < remote_pub`, rotate the sending chain — - fresh `{x25519, ml-kem}` keypair; for a hybrid friend encapsulate to - `remote_kem_pub` and derive with `epoch_chains_hybrid(root, DH(new_secret, - remote_pub), ss)`, for a classical friend `epoch_chains(root, DH(...))`; - new sending chain for `new_pub → remote_pub`; `PN = old send_n`; - `send_n = 0`. The receiving chain is untouched. -4. Else it is a ratchet key not adopted yet: run a full DH ratchet step. A - session that holds `remote_kem_pub` rejects a frame with no KEM section, and - a session without KEM material rejects a frame that has one. + `established`, and if `my_pub < remote_pub`, rotate the sending chain + (fresh keypair; `epoch_chains(root, DH(new_secret, remote_pub))`; new + sending chain for `new_pub → remote_pub`; `PN = old send_n`; `send_n = 0`). + The receiving chain is untouched. +4. Else it is a ratchet key not adopted yet: run a full DH ratchet step. ### DH ratchet step @@ -799,26 +509,18 @@ On a frame whose `dh_pub` differs from the adopted remote public key: - Derive `recv_n .. PN` into the skipped store, tagged with the retired remote public key, so stragglers of the old chain still decrypt. 2. **Receiving half of the step**, on the pair `(my current secret, frame.dh_pub)`: - `shared = DH(my_secret, frame.dh_pub)`. For a hybrid step also - `ss_kem = ML-KEM.Decaps(my_current_ratchet_kem_secret, frame.kem_ct)`, then - `(root_a, ck_lo, ck_hi) = epoch_chains_hybrid(root, shared, ss_kem)`; - otherwise `(root_a, ck_lo, ck_hi) = epoch_chains(root, shared)`. + `shared = DH(my_secret, frame.dh_pub)`, + `(root_a, ck_lo, ck_hi) = epoch_chains(root, shared)`, `recv_ck = chain_for(frame.dh_pub, my_pub)`, then open the frame with this chain exactly as in step 3 above (it must be within `MAX_SKIP` of index 0). -3. **Sending half:** generate a fresh ratchet keypair `{x25519, ml-kem}`. For a - hybrid step encapsulate to `frame.kem_pub` (`(kem_ct, ss_kem) = - ML-KEM.Encaps(frame.kem_pub)`), derive - `(root, ck_lo, ck_hi) = epoch_chains_hybrid(root_a, DH(new_secret, - frame.dh_pub), ss_kem)` and keep `kem_ct` in the state so every frame of the - new sending chain carries it; otherwise `epoch_chains(root_a, DH(...))`. +3. **Sending half:** generate a fresh ratchet keypair, + `shared = DH(new_secret, frame.dh_pub)`, + `(root, ck_lo, ck_hi) = epoch_chains(root_a, shared)`, `send_ck = chain_for(new_pub, frame.dh_pub)`, `remote_pub = frame.dh_pub`, - `remote_kem_pub = frame.kem_pub`, `PN = old send_n`, `send_n = 0`, - `established = true`, `recv_hybrid = frame has a KEM section`. + `PN = old send_n`, `send_n = 0`, `established = true`. 4. The frame is opened with the *new* receiving chain's message key. If the AEAD open fails, nothing is applied: the state must be byte-identical to before - the frame. (A tampered `kem_ct` yields a different `ss_kem` through ML-KEM's - implicit rejection, and the AEAD then fails; a tampered `kem_pub` is inside - the AAD, so it fails the same way.) + the frame. The next frame this side sends therefore carries the new `dh_pub`, which is what lets the peer step too. @@ -840,32 +542,10 @@ lets the peer step too. `ratchet_sessions` in the SQLCipher store: one row per friend (`friend_id` primary key, `FOREIGN KEY` → `friends.id` `ON DELETE CASCADE`, -`state BLOB NOT NULL`, `updated_at`). The blob is version byte `0x02` followed by -the implementation's serialized ratchet state: - -``` -0 version 0x02 -1..211 fixed prefix: root, local secret/public, remote public, - send_ck/send_n, recv_ck/recv_n, PN, established, flags, - skipped-count -then remote ratchet KEM public key (1184 bytes) if flag 0x01 -then pending KEM ciphertext (1088 bytes) if flag 0x02 - (flag 0x04 marks a receiving chain established hybrid) -then skipped keys, dh_pub[32] || n u32 BE || message key[32] -``` - -The state is device-local: it is **never** transmitted, and its layout is not -part of this wire protocol. The store is encrypted as a whole, so the blob is -ciphertext on disk. - -**Hard cut.** Version `0x01` is the pre-hybrid layout, which had no KEM ratchet -key and no pending ciphertext. It is **dropped, not migrated**: on load, a v1 -blob is deleted and the session re-bootstraps from the two prekeys, exactly the -way an `F8` prekey rotation drops state. Nothing is half-read, and epoch 0 comes -back identical because its derivation did not change. A *corrupt* v2 blob or one -written by a **newer** version is reported as an error instead — those are not an -old format, and silently resetting them would be a downgrade. The same cut -applies to any peer whose prekey or KEM key changes. +`state BLOB NOT NULL`, `updated_at`). The blob is version byte `0x01` followed by +the implementation's serialized ratchet state. The state is device-local: it is +**never** transmitted, and its layout is not part of this wire protocol. The +store is encrypted as a whole, so the blob is ciphertext on disk. ### Not ratcheted @@ -886,40 +566,28 @@ the new invite is the signal. Not a QR graphic. A single ASCII string, max 4096 characters: ``` -onionwire:v2:k=<64 hex>:o=:spk=<64 hex>:kem=:sig=<128 hex> +onionwire:v1:k=<64 hex>:o=:spk=<64 hex>:sig=<128 hex> ``` Field order in the string is not significant; duplicate or unknown fields are rejected. `k` is the identity pubkey, `spk` the x25519 prekey, `o` the current -locator, and `kem` the ML-KEM-768 encapsulation key (1184 bytes) encoded as -unpadded base64url (1579 characters). A v2 invite is about 1.9 KB, still well -under the 4096-character cap. +locator. **Current signature (encode this):** ``` ed25519_sign(identity_sk, - "onionwire-invite-v2" || 0x00 || k_ascii || 0x00 || o_ascii || 0x00 || - spk_ascii || 0x00 || kem_ascii) + "onionwire-invite-v1" || 0x00 || k_ascii || 0x00 || o_ascii || 0x00 || spk_ascii) ``` `k_ascii` / `spk_ascii` are the hex strings as they appear in the invite -(lowercase); `kem_ascii` is the base64url field value after `kem=`. Because the -signature covers `kem_ascii`, removing the field or substituting a different -key fails verification — that is the anti-strip/anti-substitution property. +(lowercase). -**Legacy accept (`onionwire:v1`):** a v1 invite has no `kem` field. Decode -accepts it while `LEGACY_SIGS` is on and yields a friend with no `kem_pk`, i.e. -a classical peer; with the switch off a v1 invite fails closed. A v1 -signature is accepted in either historical form: the tagged -`"onionwire-invite-v1" || 0x00 || k || 0x00 || o || 0x00 || spk` or the raw -concatenation `k || o || spk` (no tag, no separators), so old invites keep -verifying. `onionwire:v2` MUST have `kem=` and MUST verify over the v2 domain; -a v2 body relabelled v1 does not verify. +**Legacy accept:** a signature over the raw concatenation `k || o || spk` +(no domain tag, no separators) is still accepted on decode so old invites +verify. New invites MUST use the domain-separated form. Do not emit legacy. -Encode MUST emit `onionwire:v2` only. Unknown `k`: prompt. Same `k`: update -locator, prekey and KEM key on that row (never a second friend), and drop the -stored ratchet state if either key changed. +Unknown `k`: prompt. Same `k`: update onion and prekey only. ## What v1 will not grow into @@ -936,15 +604,9 @@ path”). They are out of scope, not postponed. ## Versioning -- Frame `version` 1 (normal), frame `version` 2 (PQ prelude), invite - `onionwire:v2` (emit) and invite `onionwire:v1` (decode only) are this - document. -- A new handshake prologue or a new invite scheme is a breaking change. The - hybrid prologue and the prelude are exactly that: v1 peers cannot talk to a - friend that has a `kem_pk`. +- Frame `version` 1 and invite `onionwire:v1` are this document. +- A new handshake prologue or a new invite scheme is a breaking change. - New typed prefixes (`xyz `) are backward compatible if old peers drop them. -- The `rat ` frame has its own version byte (`0x01` classical, `0x02` hybrid). - A different ratchet frame layout or a different KDF is a breaking change for - chat only: peers that disagree cannot read each other's chat, and every other - frame keeps working. A `0x02` frame from a peer whose roster row says - `classical`, or a `0x01` step from a hybrid peer, is rejected. +- The `rat ` frame has its own version byte (`0x01`). A different ratchet frame + layout or a different KDF is a breaking change for chat only: peers that + disagree cannot read each other's chat, and every other frame keeps working. diff --git a/docs/RELEASING.md b/docs/RELEASING.md index de6fe43..f2bd8d6 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -110,19 +110,11 @@ The `SOURCE_DATE_EPOCH` step reads the committer time of `needs.version.outputs.sha`. It is deliberately not "now": a rebuild of this tag in six months has to hand the compiler the same epoch CI handed it. -`publish` job (Pi runner) downloads both artifacts, stages them into `dist/`, -signs every asset with `scripts/sign-release.sh` inside the same digest-pinned -builder image, and only then calls `scripts/publish-release.sh` to create-or-update -the release with all four Linux assets plus the committed public key. Signing runs -in a container fed by a **named volume + `docker cp`**, not a bind mount of the -workspace: on this runner `$GITHUB_WORKSPACE` is a path inside the job container, -while docker resolves a `-v` source on the host — a bind mount therefore arrives -empty and the sign script is missing (run 768). Signing is also staged *after* -`dist/` is populated, so the files it signs exist; a run with no -`MINISIGN_SECRET_KEY` still stops before anything is uploaded. If this job fails -and the tag was created by *this* run, the final step deletes the incomplete -release and the tag. A failed `aarch64` or `x86_64` job always fails `publish`, so -nothing is published half-built. +`publish` job (Pi runner) downloads both artifacts, refuses any empty file, +and calls `scripts/publish-release.sh` to create-or-update the release with all +four Linux assets. If this job fails and the tag was created by *this* run, the +final step deletes the incomplete release and the tag. A failed `aarch64` or +`x86_64` job always fails `publish`, so nothing is published half-built. ## Android (APK + AAR) on the same tag diff --git a/docs/THREAT_MODEL.md b/docs/THREAT_MODEL.md index 14ac1e1..dadf0cf 100644 --- a/docs/THREAT_MODEL.md +++ b/docs/THREAT_MODEL.md @@ -20,57 +20,14 @@ A signed `loc` frame (`onion`, `ts`, `sig`) rewrites a friend’s locator **only ## Rotating the prekey is a hard cut, and it is wider than F4 -`F8` rotates the long-lived signed prekey **and the ML-KEM-768 install key**. The identity key and the onion are unchanged, but the prekey is our Noise static **and** the seed of the bootstrap ratchet epoch, and the KEM key is what peers encapsulate to, so once either moves nothing is reachable any more: a friend's dial uses the prekey and `kem=` they pinned from your invite, and their stored epoch is derived from the old prekey. There is no push path for either key — they only travel inside a signed invite — so every friend, online or offline, has to F3-paste the new invite before chat works in either direction again. F8 therefore also drops the local ratchet state for every friend, exactly as a peer's own prekey change does. Rotating the prekey shrinks the forward-secrecy window of the long-lived static; it is not a revocation (the old invite holder still learns nothing new, but they also cannot talk to you). - -## Post-quantum transport does not make messaging post-quantum - -Every Noise session to a v2 friend carries an ML-KEM-768 secret. The -initiator sends a `version = 2` prelude with `ct = Encapsulate(friend.kem_pk)` -before Noise msg 1, and both sides mix `(ct, ss_kem)` into the Noise prologue -(`"onionwire-v2" || 0x00 || ct || 0x00 || ss_kem`). A recorded handshake -therefore exposes an X25519 DH and an ML-KEM-768 encapsulation; a future -cryptographically relevant quantum adversary has to break ML-KEM-768 as well as -X25519 to recover the Noise transport keys. That removes the -harvest-now-decrypt-later exposure of the **one-shot transport**. - -What this does **not** buy: - -- **The chat ratchet stays classical.** Chat messages are `rat ` frames - (Double Ratchet, `docs/PROTOCOL.md`). The **bootstrap epoch is derived only - from the two long-lived X25519 prekeys** (HKDF over their DH, with the - identity pubkeys mixed in), so an adversary who records a `rat ` chain and - later obtains both prekeys can reconstruct epoch 0 even though the Noise - session that carried it was hybrid. Later epoch chains use fresh X25519 DH - steps, which are equally quantum-vulnerable. PQ ratchet steps are a separate - follow-up, not part of this transport work. -- **Identity and invite signatures are ed25519**, still classical. The KEM key - is authenticated by a v1-style ed25519 invite signature; an adversary who can - forge it can also swap `kem=`. Hybrid transport protects confidentiality, not - the long-term authentication root. -- **Legacy friends get nothing.** A friend added from an `onionwire:v1` invite - has no `kem_pk`; sessions to them are the old classical `onionwire-v1` - prologue, and the UI labels that friend as lacking PQ protection. The choice - is derived from the roster row, never from the wire: a `kem_pk` friend - rejects a prelude-less session with `prelude required` before any application - frame, so an active attacker cannot downgrade it. -- **Mixed-version fleets break.** A v1-only build cannot open a session with a - v2 friend; that is accepted rather than adding a fallback path. +`F8` rotates the long-lived signed prekey. The identity key and the onion are unchanged, but the prekey is our Noise static **and** the seed of the bootstrap ratchet epoch, so once it moves nothing is reachable any more: a friend's dial uses the prekey they pinned from your invite, and their stored epoch is derived from the old one. There is no push path for a prekey — it only travels inside a signed invite — so every friend, online or offline, has to F3-paste the new invite before chat works in either direction again. F8 therefore also drops the local ratchet state for every friend, exactly as a peer's own prekey change does. Rotating the prekey shrinks the forward-secrecy window of the long-lived static; it is not a revocation (the old invite holder still learns nothing new, but they also cannot talk to you). ## Your store is encrypted The sqlite store is SQLCipher (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`). -A 32-byte key is derived from the store passphrase with Argon2id — m = -65_536 KiB (64 MiB), t = 3, p = 1, out = 32 — over a per-install 16-byte salt -in `store_salt`, and handed to SQLCipher as a **raw** key (`PRAGMA key = -"x'…'"`) — no second KDF pass over it. The identity backup and the -message-key wrap in `store_meta` use the same profile. Parameters are -versioned with the data: a backup blob names its profile in the header and -`store_meta.kdf_profile` names the store's, and an unknown profile id is a -clear error, never a silent fallback. Data written with the earlier -19_456 KiB / t=2 / p=1 profile still opens: a legacy store is rekeyed and its -message key re-wrapped with the current profile on the first successful -unlock, and a legacy backup file opens as-is (re-exporting it writes the -current profile). +A 32-byte key is derived from the store passphrase with Argon2id (same params as +identity backup) over a per-install 16-byte salt in `store_salt`, and handed to +SQLCipher as a **raw** key (`PRAGMA key = "x'…'"`) — no second KDF pass over it. The key is the first statement after open, so the file header, schema, identity secret key, friend public keys, locators, profiles, payment rows and the per-friend ratchet session blobs (`ratchet_sessions`) are all ciphertext on @@ -144,22 +101,13 @@ device. below. - *Post-compromise security after a DH ratchet step.* An attacker holding a snapshot of one side's state cannot read the conversation past the next DH - ratchet step: that step feeds a fresh X25519 output — and, from the first - rotation, a fresh ML-KEM-768 secret — into the root, and the snapshot stops - producing chain keys. The window is not zero — it lasts until the next step — - but no attacker can prevent it closing. -- *Quantum-resistant chains from the first rotation.* Every ratchet step mixes a - fresh ML-KEM-768 secret into `KDF_RK` alongside the X25519 output - (`dh_out || ss_kem`, info `onionwire-ratchet-v2-kdfrk`). A harvest-now - adversary who records a hybrid chain and later breaks X25519 still needs the - ML-KEM-768 secret to walk that chain, which breaking X25519 does not give. - Ratchet keypairs are generated as `{x25519, ml-kem}` with the KEM seed derived - from the X25519 secret, so the KEM half adds no state to protect. -- *The ratchet header is not on the wire.* `dh_pub`, `N`, `PN` and, on hybrid - chains, `kem_pub`/`kem_ct` ride inside the Noise ciphertext (authenticated as - AEAD associated data), so message counts and ratchet-key changes are not - observable, and a tampered header fails closed. A missing KEM section on a - step is a hard `hybrid step required` rejection, never a classical fallback. + ratchet step: that step feeds a fresh X25519 output into the root, and the + snapshot stops producing chain keys. The window is not zero — it lasts until + the next step — but no attacker can prevent it closing. +- *The ratchet header is not on the wire.* `dh_pub`, `N` and `PN` ride inside + the Noise ciphertext (authenticated as AEAD associated data), so message + counts and ratchet-key changes are not observable, and a tampered header fails + closed. **Honest limits.** @@ -169,38 +117,16 @@ device. oldest-first. A snapshot also carries the current sending and receiving chain keys, which read the current chain until it advances. This is the price of out-of-order delivery, and it is per friend. -- *Epoch 0 is classical — this is the remaining harvest-now window.* The - bootstrap root and both initial ratchet secrets are HKDF outputs of the - X25519 DH between the two long-lived signed prekeys, and the identity pubkeys - that separate them are public. A per-session KEM secret cannot be folded into - epoch 0: each chat message is its own one-shot Noise session, so `ss_kem` - differs per dial and per peer, and a root bound to it would make the two peers - (or even message 1 and message 2) derive different chains. Epoch 0 is - therefore derived with the classical `KDF_RK`, and the ML-KEM secret enters at - the **first rotation** — two round trips in, at the latest. - What that leaves exposed, precisely: - - The epoch-0 *chain keys* are not post-quantum. A future X25519 break - reconstructs the prekey DH, hence the epoch-0 root and every message key on - that chain. This covers everything sent before the first hybrid step, - including any frame that was encoded on epoch 0 and left in the outbox. - - It does **not** by itself open a recorded v2 transcript, because a v2 friend - wraps every `rat ` frame in the hybrid Noise session (ML-KEM-768 prelude). - The epoch-0 chain keys are a second layer; breaking X25519 alone still leaves - that outer layer closed. The exposure becomes real the moment the rat frame - itself is accessible — a state snapshot taken at epoch 0, an old client that - logged it, or a peer running the classical transport. - - For a **classical (v1) friend** there is no PQ layer anywhere: transport and - every ratchet step are X25519-only, so the whole conversation is - harvest-now-decrypt-later exposed. Hybrid ratchet steps require `kem_pk` on - the roster row, which a legacy invite does not carry. - - From the first hybrid step on, a state snapshot plus a future X25519 break is - not enough: the chain also needs the ML-KEM-768 secret, and the next rotation - replaces it. We do **not** claim full post-quantum forward secrecy, because - epoch 0 is outside that guarantee. - The bootstrap epoch is still the reason state is dropped when a peer's prekey - changes, and an attacker holding both prekey statics can reconstruct epoch 0 - directly (no break needed). A recorded message is not opened by the prekeys - alone while the one-shot Noise session an ML-KEM friend used remains intact. +- *The bootstrap epoch is prekey-bound.* The initial root and both initial + ratchet secrets are HKDF outputs of the X25519 DH between the two long-lived + signed prekeys, and the identity pubkeys that separate them are public. An + attacker who has both peers' prekey statics can therefore reconstruct the + **first** epoch. What that does not buy is a recorded message: every `rat ` + frame travels inside a one-shot Noise session whose ephemerals are not derived + from the prekeys, so the prekeys alone do not open stored traffic. From the + first DH ratchet step on, fresh X25519 secrets enter and the prekeys derive + nothing — the bootstrap epoch is the exception, not the rule, and it is the + reason the state is dropped when a peer's prekey changes. - *No deniability and no non-repudiation claim.* Chat frames are not signed and both parties derive the same chain keys, so nothing here would let a third party decide which of the two authored a chat line. Identity is proven per @@ -217,17 +143,8 @@ device. history. `/wipe` clears chat, payments and outbox rows but **keeps** the ratchet state (roster and identity stay), so chat resumes on the same epoch; `/wipe-all` removes the data dir with it. -- *Length is bucketed; timing is not.* One Noise session per message, and chat - plaintext is padded inside the ratchet ciphertext to a fixed ladder (256 B to - 32 KiB — `docs/PROTOCOL.md`, “Length buckets”), so an observer sees only the - bucket and not the body length. That is all it hides: message timing, retry - cadence, the one-shot-per-message circuits, and the timing of the handshake - are unchanged, and no cover traffic or jitter is generated. The frame header - is not padded: a classical `rat ` frame is 350 bytes at its smallest, while a - hybrid step's 2312-byte ML-KEM header makes its smallest frame 2622 bytes on - the wire. That is a size class, not a message count, and it does not leak the - body length inside the bucket. Non-chat frames (`loc `, `prf `, `inv `, - `rcp `, `tip `, `fil `) are not padded and still reveal their own sizes. +- *No metadata protection beyond Noise.* One Noise session per message, no + padding: sizes and timing are what they were before the ratchet. - *The ratchet does not re-open the "no server-side outbox" lock.* The state is device-local, one row per friend in the encrypted store, and nothing about it is transmitted. The local retry queue's two accepted consequences (device @@ -321,7 +238,7 @@ the app does not pick a public remote node for them. every in-process surface still says `testnet only — mainnet is unvalidated`. Cross-compiled is not device-proven. - Cuprate's own `arti` feature is off (its Tor stack is `arti-client` 0.44, - which cannot unify with this crate's 0.49), so the in-process daemon's P2P + which cannot unify with this crate's 0.46), so the in-process daemon's P2P traffic is **clearnet**: your ISP sees that this device talks to Monero peers. No Tor is on the chain path — Tor is the messenger's transport here, not the chain's. @@ -340,8 +257,8 @@ the app does not pick a public remote node for them. `connect()`, and not a C-tor fallback for chat). That listener is the bundled `arti` **binary** run as a child (`arti proxy -p `) — a second, separate Tor client with its own state and cache dirs, because - `arti-client` 0.49 exposes no SOCKS listener API. It is TCP loopback only - (`arti proxy -p` binds `127.0.0.1`/`::1`; arti 2.6.0 / `tor-config` 0.49 + `arti-client` 0.46 exposes no SOCKS listener API. It is TCP loopback only + (`arti proxy -p` binds `127.0.0.1`/`::1`; arti 2.6.0 / `tor-config` 0.46 have no Unix-socket listen target — arti#1965), and the port is usable by any local process at the user's privilege level: it is an app-private port, not an access-controlled one. The app gates the spawn on the unlocked store diff --git a/docs/VERIFY.md b/docs/VERIFY.md index d2f2c4e..b89cb7e 100644 --- a/docs/VERIFY.md +++ b/docs/VERIFY.md @@ -60,21 +60,6 @@ is the code described above, and not something else. --- -## Check 0 — first, get the file, and know why a download can fail - -Two things break a download from this host, and neither means the release is -missing: - -- **`/releases/latest/download/…` is not served by this Forgejo — it is a 404.** - The GitHub habit fails here. Always pin the tag: - `…/releases/download/v0.7.0/onionwire-x86_64-unknown-linux-gnu`. -- **Cloudflare in front of the Forgejo rejects non-browser User-Agents.** A - script that sends a default library UA gets `HTTP 403` with the body - `error code: 1010` — even with a correct tag and URL. Measured against a real - asset on this host: browser UA → `206`, `curl/8.7.1` → `206`, - `Python-urllib/3.14` → `403`. Set a real `User-Agent` on any scripted fetch, - or use `curl`. - ## Check 1 — 30 seconds: what code is even in the binary From a clone, on whatever commit you are interested in: @@ -157,10 +142,10 @@ is public": *the binary I downloaded might not be that source.* git clone https://forgejo.siriusdevops.com/sirius/onionwire cd onionwire git fetch --tags -scripts/verify-reproducible.sh v0.7.0 +scripts/verify-reproducible.sh v0.14.0 ``` -Replace `v0.7.0` with the tag you are checking. You need docker; you do not +Replace `v0.14.0` with the tag you are checking. You need docker; you do not need Rust, or the right glibc, or the right distro. The rebuild happens inside the same builder image, pinned **by digest**, that CI uses, with the source paths, the target path, and `SOURCE_DATE_EPOCH` all fixed by diff --git a/docs/WALLET.md b/docs/WALLET.md index 3f6fdb4..09cda7d 100644 --- a/docs/WALLET.md +++ b/docs/WALLET.md @@ -181,7 +181,7 @@ for the TUI. A build with `--no-default-features` does not include the daemon. Cross-compiled is not device-proven. Pointing a mainnet wallet at it is not something this build claims to do. - **No Tor on the chain path.** Cuprate's `arti` feature is off (arti-client - 0.44 vs this crate's 0.49). P2P is **clearnet**. OnionWire's Arti is the + 0.44 vs this crate's 0.46). P2P is **clearnet**. OnionWire's Arti is the messenger only. - **Inbound P2P off**, restricted RPC listener disabled. Unrestricted RPC is loopback 18081. `--trusted-daemon` still never passed. @@ -208,42 +208,18 @@ C++ binary, so it reaches Tor through a SOCKS proxy the app provides: **Tor hides the transport, not the host.** The daemon operator still sees the wallet's addresses during sync. -### Readiness — receipt verification needs a synced wallet +### Readiness — receipt verification needs a synced daemon -`chain_ready()` compares the wallet's **own scanned height** with the **chain -tip**. Both halves must answer: - -1. the wallet RPC's `get_height` reports `height > 0`. That is - `monero-wallet-rpc`'s own method; `get_info` does **not** exist there — it - answers `-32601 Method not found`, so readiness never asks for it. -2. the chain daemon reports a tip, and the wallet is at it or within **2 - blocks**. The tip moves every ~2 minutes and the two numbers are two reads, - not one snapshot, so a strict equality flaps; two blocks of slack does not - hide a real lag. - -The tip comes from `daemon_get_height` (`GET /get_height` — one spelling that -works on monerod and Cuprate) against `ChildConfig::daemon_probe_addr()`: - -- local `monerod` / in-process Cuprate → `127.0.0.1:18081`; -- a **clearnet** remote daemon the user typed → that host. The wallet child - already dials it, so one `get_height` is the same exposure, not a new path; -- a **`.onion`** daemon → **not dialled** without the SOCKS child: a direct dial - would resolve the name on clearnet DNS and leak. Readiness stays false - (height-only); the status row reads syncing. A documented limit, not a bug; -- receive-only, or an externally run wallet RPC with no chain source → nothing - to ask, so not ready. - -Unknown is **not caught up**. A daemon that does not answer, a wallet with no -file open (`-13 No wallet file`), and a missing height all read *not ready*, -never a silent pass. "No wallet open" is a state, not an error banner. +`chain_ready()` asks the wallet RPC `get_info` and requires +**`synchronized == true`** with `height > 0` and `height >= target_height`. A +missing field is *not ready* — fail closed. Until then, **receipt verification stays `verified=0`**. An unsynced wallet cannot see the chain. That is an honest limit, not a UI bug. Loopback management calls (`get_address`, `query_key`, create/import) get 5s. -Calls that wait on the chain (`get_transfers`, `transfer`) get 60s -(`CHAIN_RPC_TIMEOUT`). Readiness is not a chain wait: it is one local -`get_height` plus one bounded daemon probe. +Calls that wait on the chain (`get_info`, `get_transfers`, `transfer`) get 60s +(`CHAIN_RPC_TIMEOUT`). ## Env vars (migration path) @@ -280,9 +256,8 @@ re-points the wallet without a restart; a rejected form writes nothing. UniFFI: `set_chain_source(ChainConfig)` / `chain_source()`, `start_wallet_child()`, `stop_wallet_child()`, `wallet_status()` (cached read: no dial, for first paint) and `wallet_child_refresh()` (a live probe of the -same record — it dials the loopback wallet RPC and asks the configured daemon -for its tip (the wallet's `get_height` is the other half), so poll it on the -order of seconds). +same record — it dials the loopback wallet RPC, and the local daemon's +`get_info` when that RPC does not answer, so poll it on the order of seconds). Pass absolute paths for `wallet_rpc_bin` / `arti_bin` (`nativeLibraryDir`); the core never resolves a binary the caller named explicitly. diff --git a/docs/design/pq-bootstrap-epoch.md b/docs/design/pq-bootstrap-epoch.md deleted file mode 100644 index 602dc93..0000000 --- a/docs/design/pq-bootstrap-epoch.md +++ /dev/null @@ -1,301 +0,0 @@ -# ADR: a post-quantum bootstrap epoch (epoch 0) - -**Status:** proposed. This is a decision record: it recommends a direction and -changes no code. The protocol and threat-model wording it depends on is already -on `main`; this file does not restate it. - -**Decision:** accept the window (Option C). Revisit when the one-shot session -model changes, or when a one-time prekey can reach the peer without a new wire -field. - -Related: [PROTOCOL.md](../PROTOCOL.md) ("Hybrid ratchet steps, and why epoch 0 -stays classical") and [THREAT_MODEL.md](../THREAT_MODEL.md) ("Epoch 0 is -classical — this is the remaining harvest-now window"). - -## 1. Context: the invariant, stated exactly - -Epoch 0 is the ratchet state a friend pair starts from. It is derived, not -negotiated: - -1. **Each chat message is its own one-shot Noise session.** `Node::send` encodes - exactly one `rat ` frame and hands those bytes to the outbox - (`src/node.rs:1905`, `src/outbox.rs:168`). Sending again opens a new Noise - session to the same onion. There is no connection, stream, or session object - that outlives one application frame. -2. **The Noise handshake carries no application payload.** It is frozen at - `Noise_IK_25519_ChaChaPoly_BLAKE2s`, so no field can hand the peer an initial - ratchet key (`src/node.rs:2316`). -3. **Either peer may send first.** Two peers can each build a sending chain - before either has received anything. The resolution is per-direction chains - over the *unordered pair* of ratchet public keys, so authorship of a direction - is decided by key order rather than by who spoke first - (`src/ratchet.rs:94-116`). -4. **Therefore epoch 0 must be a pure function of material both sides already - have**: the X25519 DH of the two long-lived signed prekeys, with each side's - initial ratchet keypair seeded by - `HKDF(info = "ratchet-key" || pubkey)` - (`src/node.rs:2325-2370`). No wire field, no round trip, no per-session - secret. This is the invariant the three options are measured against. - -The consequence, already documented and not re-argued here: epoch 0 is derived -with the classical `KDF_RK` and the ML-KEM secret enters at the **first -rotation** (`src/ratchet.rs:66-73`, `docs/PROTOCOL.md:683`). Every frame sent -before that point is X25519-only at the ratchet layer. - -Two facts bound how much that costs, and they matter for the ranking: - -- **For a v2 friend the `rat ` frame rides inside a hybrid Noise session.** A - recorded transcript is not opened by an X25519 break alone; the ML-KEM-768 - prelude has to be broken too, and it is per-dial. Epoch 0 becomes the exposed - layer when the rat frame is separated from the session that carried it — a - state snapshot, an outbox row at rest, a logging client, or a classical peer - (`docs/THREAT_MODEL.md:163-192`). -- **The ML-KEM half of a ratchet keypair is derived from the X25519 secret** - (`src/ratchet.rs:56-63`, `src/ratchet.rs:326`). It adds no independent secret - to epoch 0, so "every keypair is hybrid" does not mean the bootstrap epoch is. - -## 2. Options - -Each subsection has the same shape: mechanism, wire cost, convergence, effect on -the outbox and stored/replayed frames, test surface, and cost in slice-days. One -slice-day is one focused working day for one agent in this repo, including tests -and the doc updates the change would force. - -### Option A — one-time prekey batch in the invite - -**Mechanism.** The invite carries N ML-KEM-768 one-time prekeys (OPKs) in -addition to the long-lived `kem=`. The peer consumes one per dial or per epoch, -depending on which layer the OPK is meant to protect — that ambiguity is the -first finding below. The threat model already lists "No one-time prekeys" as an -honest limit (`docs/THREAT_MODEL.md:199-203`), so this is the option that would -close a named gap; the size and convergence findings are what kill it. - -**What the invite gains.** A new version, necessarily. The v2 signature domain is -`onionwire-invite-v2 || 0x00 || k || 0x00 || o || 0x00 || spk || 0x00 || kem` -(`src/qr.rs:38`), and `parse_fields` rejects any unrecognised field with -`unknown field` (`src/qr.rs`, `parse_fields`). So an `opk=` field on a v2 string -is a decode error, not an ignored extra: the batch is `onionwire:v3`, a new -signature domain, and a new field in the signed message. - -**Size, numerically.** A v2 invite is 1930 characters for a 56-character v3 -onion. Each ML-KEM-768 OPK is 1184 bytes, which is 1579 base64url characters -plus a 5-character `:opk=` prefix — **1584 characters each**. The decoder caps -input at `MAX_INVITE = 4096` (`src/qr.rs:30`), and the TUI renders the invite -through `qrcode` 0.14.1 at its default `EcLevel::M` (`src/tui.rs:2818`), whose -byte capacity is **2331 characters** (measured against the pinned crate, not -recalled). Therefore: - -| Invite | chars | fits `MAX_INVITE` | fits one QR at M | -|---|---|---|---| -| v2 today | 1930 | yes | yes | -| v3, 1 OPK | 3514 | yes | **no** | -| v3, 2 OPKs | 5098 | **no** | no | -| v3, 4 OPKs | 8266 | no | no | - -A batch that could survive more than one use cannot be carried by this invite at -all: two OPKs already exceed the decoder's own cap, and one already exceeds what -the QR path can render. The invite would have to move to a file/NFC transfer, or -the QR would have to be dropped, before the batch is even representable. - -**What is consumed, and when.** This is where the option loses its premise. If -the OPK is consumed at the **transport** layer (one per Noise dial), it is one -per message: a retry after a queued send is a new dial and burns another, and a -batch of N is exhausted after N dials with no replenishment path — the peer has -the invite, not a directory, so the next invite paste is the only refill. If it -is consumed at the **ratchet** layer, it is one per epoch, and the secret has to -reach the peer: ML-KEM encapsulation is randomised, so the sender must transmit -a 1088-byte ciphertext. That is exactly Option B's wire field. **A does not fix -epoch 0 without B**; on its own it only improves the transport handshake, which -already carries a per-dial ML-KEM secret in the v2 prelude. - -**Unused prekeys.** They are decapsulation keys stored for the life of the -install, with no expiry and no ratchet benefit. A state snapshot hands them over, -so they become an additional long-lived secret rather than a forward-secrecy -win. The roster already drops state when a peer's prekey changes -(`src/node.rs:2385-2395`); a batch would need its own consumption cursor, its own -versioned blob, and a rule for when a partly-consumed batch is abandoned. - -**Wire cost.** Invite only, if the OPK is used at the transport layer (+1584 -characters per prekey, and the QR stops working at one). Invite *and* frame -(+1088 header bytes per epoch-0 frame, repeated until the first rotation) if used -at the ratchet layer — at which point it is B. - -**Convergence.** At the transport layer, unchanged: each Noise session's two -endpoints both know that session's `ss_kem`, so per-dial secrets are fine there. -At the ratchet layer, A *breaks* convergence on its own: both peers encapsulate -to the same OPK, get different secrets (fresh randomness on each side), and -derive different epoch-0 roots. Only one direction's ciphertext can be the -authoritative one, and carrying it is a wire field. - -**Outbox and replayed frames.** A stored `rat ` frame is replayed byte-for-byte -over a fresh Noise session (`src/outbox.rs:161-175`; the retry loop must not -advance the sending chain twice, so the frame is encoded once). Transport-layer -OPK consumption therefore drains the batch on retries, not on delivered -messages. Ratchet-layer consumption requires the receiver to retain the OPK -private key until every queued row encrypted under it is delivered or -terminally failed — unbounded retention, which contradicts "one-time". - -**Test surface.** Invite v3 round-trip and signature domain; rejection of `opk=` -on v2; batch exhaustion and the fallback to `kem=`; QR capacity (the invite -render path currently has no graceful path for "too long for one symbol"); -retry-burns-a-prekey; a both-send-first test showing the two roots diverge if the -ratchet layer is attempted without a field. - -**Cost (estimate).** 5–7 slice-days for the invite/transport version of A (invite v3, -signed field, store pool, consumption cursor, tests, docs). It buys a -transport-layer improvement that is already covered by the per-dial prelude, and -leaves epoch 0 exactly as it is. The ratchet-layer variant is B plus this cost. - -### Option B — per-session epoch derivation with an extra wire field - -**Mechanism.** Add material to the ratchet header and derive the epoch from it. -The natural shape is a new version byte (`0x03` classical + field, `0x04` hybrid -+ field) because `0x01` and `0x02` are already taken and the header is the AEAD -associated data, so its exact shape is load-bearing -(`src/ratchet.rs:1-40`, `src/ratchet.rs:585-601`). The field would be a 32-byte -salt, or a 1088-byte ML-KEM ciphertext if it carries a prekey secret. - -**Wire cost.** 32 bytes per frame (salt) or 1088 bytes per frame (ciphertext), -repeated on every frame of the epoch-0 chain because the first frame can be lost. -The classical header goes 40 → 72 bytes, the hybrid header 2312 → 3400, and the -documented minimum frame sizes (350 classical, 2622 hybrid, -`docs/THREAT_MODEL.md:217-220`) all move. The minimum-size tests and the padding -ladder's interaction with the floor would have to be re-derived, not just -re-numbered. - -**Convergence.** This is the option's fatal case. The field arrives *in* the -frame, so neither side has the other's field before its first send. Two designs -are available and neither restores the invariant: - -- *Sender-chosen salt, per direction.* Each side derives its own sending chain - from its own salt. That works for the first message in each direction, but the - epoch's shared root advance now depends on two salts, and the side that rotates - first — the tie-break side rotates on its first *decrypt* - (`src/ratchet.rs:624-630`) — may have seen only one of them. The root is no - longer a pure function of the pair, so the lockstep argument in - `src/ratchet.rs:100-116` no longer holds and the peers can diverge at the - first rotation. -- *Salt derived from the Noise session secret.* Then the two peers' first sends - ride different sessions with different secrets, and message 2 rides a third - session, so a stored and retried frame cannot be re-derived at all — see the - outbox row. - -A public salt in the header adds no secrecy, because it is transmitted in clear -inside the Noise transport. It would only bind the chain to a random value, -which is not the threat. So B is either a no-op against harvest-now, or it is a -salt that breaks convergence, or it is a KEM ciphertext that reintroduces A's -consumption and retention problems. - -**Outbox and replayed frames.** A salt lives in the stored frame, so a verbatim -replay is consistent. A ciphertext likewise survives the replay, but the -receiver must still hold the matching private key when the retry lands — so the -"one-time" key is retained until the outbox row is delivered or fails, and -`DEFAULT_MAX_ATTEMPTS` (8) with a 30-minute backoff cap means that retention is -measured in hours at minimum. This is the same retention conflict as A, now on -the frame path. - -**Test surface.** New version bytes and header layout; AAD coverage of the new -field; the both-send-first matrix re-derived (the existing convergence tests in -`src/ratchet.rs` and `tests/ratchet_wire.rs` assert the current argument, not just -the happy path); `STATE_VERSION` 2 → 3 with a v2 blob dropped exactly like v1 -(`src/ratchet.rs:163`, `src/node.rs:2385-2395`); cross-version interop, since a -friend with a v2 invite has no field to send — downgrade is decided by the -roster, never by what arrives on the wire, so these are two different epoch -shapes that must never be negotiated dynamically; padding floor and minimum-frame -constants. - -**Cost (estimate).** 8–12 slice-days, and it leaves the ambiguous root-advance rule open -(that is the item in "Not solved by this doc"). - -### Option C — accept the window, keep the honesty bounds - -**Mechanism.** No change. Epoch 0 stays prekey-derived and classical; the KEM -secret enters at the first rotation; the docs keep saying so in the three places -they already do (`src/ratchet.rs:66-73`, `docs/PROTOCOL.md:683-720`, -`docs/THREAT_MODEL.md:163-192`). - -**What has to be true for this to stay acceptable.** These are the conditions the -decision rests on; if one stops holding, the trigger in §3 fires. - -- *The first rotation is prompt.* It happens on the first inbound frame after - `established`, and the lower-key side also rotates immediately on that decrypt - (`src/ratchet.rs:624-630`). A peer that sends and never receives stays on - epoch 0 by definition; the window closes with the first reply, not with time. -- *Nothing claims otherwise.* "Post-quantum transport, classical bootstrap - epoch" is the ceiling. `docs/THREAT_MODEL.md:25` and - `docs/THREAT_MODEL.md:163` are the sentences that must not drift, and - README/marketing copy inherits them. -- *A state snapshot is already the whole game.* The ratchet state lives in the - same SQLCipher file as the plaintext history, and `docs/THREAT_MODEL.md:205-209` - says a snapshot carries both chain keys, the skipped keys, and the history. - Epoch 0 is therefore not the weakest link at rest: an attacker with the store - reads the messages, not the chain. The epoch-0 exposure is about frames outside - the store — captured traffic and delivered outbox rows — not about the device. -- *Outbox exposure stays bounded by delivery.* A row encoded on epoch 0 carries - epoch-0 keys until it is delivered or terminally fails - (`docs/THREAT_MODEL.md:176`). The queue is local, bounded by - `DEFAULT_MAX_ATTEMPTS`, and never handed to a third party, so this is the same - window as a live epoch-0 message, not a new one. -- *The roster still decides downgrade.* A v1 friend has no PQ layer anywhere; - that is a roster fact, not a wire negotiation - (`docs/THREAT_MODEL.md:183-187`). - -**Wire cost.** Zero. **Convergence.** Unchanged, and covered by the existing -both-send-first and cross-peer tests. **Outbox and stored frames.** Unchanged; -the verbatim-replay property stays exact. **Test surface.** No new tests; the -existing ones already pin the invariant. **Cost.** 0 slice-days. The standing -cost is one honest sentence in the docs, which is already paid. - -## 3. Comparison and decision - -| | A — OPK batch | B — epoch field | C — accept | -|---|---|---|---| -| Wire cost | +1584 chars/invite (QR dies at 1) | +32 or +1088 B/frame, new versions | 0 | -| Fixes epoch 0? | no (transport only; needs B for ratchet) | only as a public salt, which is not the threat | n/a | -| Convergence | breaks it at the ratchet layer | ambiguous root advance; breaks lockstep | unchanged | -| Outbox / replay | drains batch on retries; unbounded OPK retention | verbatim replay OK, retention unbounded | unchanged, bounded by delivery | -| Test surface | invite v3, pool, QR capacity, divergence | header, state v3, both-send-first matrix, floors | none | -| Slice-days (est.) | 5–7 (and buys no epoch-0 fix) | 8–12 | 0 | - -**Decision: C.** A does not make epoch 0 post-quantum — it adds invite mass and a -consumption problem, and the part that would touch the ratchet is B's wire field, -which cannot converge under both-send-first without an ambiguous root rule. C -costs nothing, keeps the one property the design actually relies on (a root that -is a pure function of the prekey pair), and the exposure it accepts is already -shadowed for v2 friends by the per-dial hybrid Noise session. - -**Revisit triggers**, in priority order. Any one of these reopens this ADR; none -is a reason to start work now: - -1. **The one-shot session model changes.** If chat ever gets a session that - outlives one frame, the blocker in §1 disappears and epoch 0 can take a - per-session secret. This is the real trigger. -2. **A delivery path for a prekey ciphertext exists without a new field.** E.g. - the handshake gains an application payload. Then A becomes viable at the - ratchet layer. -3. **The invite stops being QR-first.** If invites move to file/NFC and the - `MAX_INVITE` cap can move with them, a batch is at least representable — still - subject to the replenishment problem, so this alone is not enough. -4. **Any doc or release note claims post-quantum messaging.** That is a - documentation failure to fix immediately, not a reason to ship A or B. - -**Consequences.** No code changes. The next card on this topic is not A or B; if -one is proposed anyway, it must answer B's root-advance question and the QR -capacity finding in A before it can be scoped. The docs on `main` continue to be -the authority on what is and is not post-quantum. - -## 4. Not solved by this doc - -- **In-band revocation / unfriend.** There is no revoke frame; the roster drops - a friend locally, and the peer keeps the current onion until F4 - (`docs/THREAT_MODEL.md:19`). -- **Prekey or KEM rotation without a new invite.** F8 rotates the signed prekey - and the ML-KEM install key, and every friend must paste the new invite; there - is no push path (`docs/THREAT_MODEL.md:21-24`). Option A makes this worse, not - better: a batch has no refill channel, so it inherits the same hard cut. -- **Option B's open question.** Which input advances the epoch root when two - per-direction salts exist and the first rotator has seen only one of them. A - future B proposal has to answer that before it can be implemented; this doc - does not. -- **Guard discovery.** The long-lived v3 onion and Arti's vanguards-lite are a - separate opsec gap and are not addressed by any of the three options. diff --git a/fuzz/fuzz_targets/ratchet_frame.rs b/fuzz/fuzz_targets/ratchet_frame.rs index 9d7f50f..9361768 100644 --- a/fuzz/fuzz_targets/ratchet_frame.rs +++ b/fuzz/fuzz_targets/ratchet_frame.rs @@ -10,45 +10,26 @@ //! Neither call may panic, and neither may leave the state mutated on a frame //! it rejects (asserted in `tests/ratchet.rs`, re-checked cheaply here by //! re-serializing after every decrypt). -//! -//! Both bootstrap shapes are exercised: a classical friend (`remote_kem_pub = -//! None`) and a hybrid friend, whose peer ML-KEM ratchet key is a real -//! encapsulation key of `kem::PK_LEN` bytes derived from a fixed seed. A -//! garbage key would only ever hit the "invalid encapsulation key" error path. #![no_main] use libfuzzer_sys::fuzz_target; -use onionwire::kem::{self, PK_LEN, SEED_LEN}; use onionwire::ratchet::{RatchetKeyPair, RatchetState}; -use std::sync::OnceLock; -/// A canonical ML-KEM-768 encapsulation key, built once: key generation is -/// deterministic for a fixed seed, so this only pays for itself on iteration 1. -fn peer_kem_pub() -> &'static [u8] { - static PK: OnceLock> = OnceLock::new(); - PK.get_or_init(|| { - let pk = kem::pk_from_seed(&[0x44u8; SEED_LEN]).expect("64 bytes is a valid ML-KEM seed"); - assert_eq!(pk.len(), PK_LEN, "crate ML-KEM public key length changed"); - pk - }) -} +fuzz_target!(|data: &[u8]| { + // Restore path: arbitrary bytes as a persisted ratchet state. + if let Ok(state) = RatchetState::from_bytes(data) { + // A state that parsed must re-serialize without panicking. + let _ = state.to_bytes(); + } -fn bootstrap(remote_kem_pub: Option<&[u8]>) -> RatchetState { - // The keys are fixed (not fuzzed) on purpose: the interesting surface is - // `data` as the frame. - RatchetState::bootstrap( + // Wire path: a fresh bootstrap epoch for every input, so one iteration can + // never influence the next. The keys are fixed (not fuzzed) on purpose: + // the interesting surface is `data` as the frame. + let mut state = RatchetState::bootstrap( [0x42u8; 32], RatchetKeyPair::from_secret([0x11u8; 32]), [0x33u8; 32], - remote_kem_pub, - ) -} - -/// Feed `data` to a fresh state and hold the existing invariants: a reject must -/// roll back, an accept must have advanced the receiving chain, and re-sending -/// from the resulting state must not panic. -fn exercise(remote_kem_pub: Option<&[u8]>, data: &[u8]) { - let mut state = bootstrap(remote_kem_pub); + ); let before = state.to_bytes(); match state.decrypt(data) { @@ -64,17 +45,4 @@ fn exercise(remote_kem_pub: Option<&[u8]>, data: &[u8]) { // Re-encrypting a byte-identical state must stay a pure function. let _ = state.encrypt(b"fuzz"); -} - -fuzz_target!(|data: &[u8]| { - // Restore path: arbitrary bytes as a persisted ratchet state. - if let Ok(state) = RatchetState::from_bytes(data) { - // A state that parsed must re-serialize without panicking. - let _ = state.to_bytes(); - } - - // Wire path: a fresh bootstrap epoch for every input, so one iteration can - // never influence the next. Classical and hybrid, both. - exercise(None, data); - exercise(Some(peer_kem_pub()), data); }); diff --git a/scripts/build-release-local.sh b/scripts/build-release-local.sh index 93a62ba..8ae0bad 100755 --- a/scripts/build-release-local.sh +++ b/scripts/build-release-local.sh @@ -2,7 +2,7 @@ # Offline fallback: build and publish the x86_64 release asset from this host # when CI (.forgejo/workflows/release.yml) cannot be used. # -# Usage: MINISIGN_SECRET_KEY=... FORGEJO_TOKEN=... scripts/build-release-local.sh v0.5.0 +# Usage: MINISIGN_SECRET_KEY=... FORGEJO_TOKEN=... scripts/build-release-local.sh v0.14.0 # # It runs the SAME recipe CI runs, inside the same digest-pinned builder image, # so the asset it publishes is one a verifier can reproduce. A plain host diff --git a/scripts/onionwire-signing.pub b/scripts/onionwire-signing.pub deleted file mode 100644 index ab51cce..0000000 --- a/scripts/onionwire-signing.pub +++ /dev/null @@ -1,2 +0,0 @@ -untrusted comment: minisign public key 806195CBAD1B1E56 -RWRWHhuty5VhgHpdAsbzMVNLmu1mztJblfxv06HjtVcrKHKS75792Jb+ diff --git a/scripts/verify-reproducible.sh b/scripts/verify-reproducible.sh index 852ebac..f664481 100755 --- a/scripts/verify-reproducible.sh +++ b/scripts/verify-reproducible.sh @@ -5,8 +5,8 @@ # Usage: # scripts/verify-reproducible.sh [published .sha256 file or URL] # -# ./scripts/verify-reproducible.sh v0.5.0 -# ./scripts/verify-reproducible.sh v0.5.0 /path/to/onionwire-x86_64-unknown-linux-gnu.sha256 +# ./scripts/verify-reproducible.sh v0.14.0 +# ./scripts/verify-reproducible.sh v0.14.0 /path/to/onionwire-x86_64-unknown-linux-gnu.sha256 # # Why this exists: "the source is public" is not a check anyone can run. This # is. It rebuilds the tag's exact tree inside the same pinned builder image CI diff --git a/src/backup.rs b/src/backup.rs index 7a4d000..5e6a775 100644 --- a/src/backup.rs +++ b/src/backup.rs @@ -1,9 +1,4 @@ //! Encrypted identity backup. Onion (locator) is not included. -//! -//! `seal()` writes `owbak1 || profile(1) || salt(16) || nonce(12) || ct`. -//! The pre-profile `owbak1 || salt(16) || nonce(12) || ct` layout is still -//! accepted as [`KdfProfile::Legacy`]; the two are unambiguous because the -//! plaintext is a fixed [`PLAIN_LEN`], so only two total lengths are legal. use argon2::{Algorithm, Argon2, Params, Version}; use chacha20poly1305::aead::{Aead, AeadCore, KeyInit, OsRng, Payload}; @@ -16,52 +11,6 @@ const SALT_LEN: usize = 16; const NONCE_LEN: usize = 12; const KEY_LEN: usize = 32; const PLAIN_LEN: usize = KEY_LEN * 4; -/// Salt + nonce + ciphertext + Poly1305 tag, i.e. everything after `MAGIC`. -const SEALED_BODY_LEN: usize = SALT_LEN + NONCE_LEN + PLAIN_LEN + 16; - -/// Which Argon2id parameters a stored blob was written with. -/// -/// The id is recorded with the data (a byte in the backup header, a -/// `store_meta.kdf_profile` column in the store). `Legacy` is id `0` and also -/// covers every blob written before profiles existed — those have no recorded -/// id at all. Never change an existing profile's parameters: a new cost means -/// a new id. -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum KdfProfile { - /// m = 19_456 KiB, t = 2, p = 1. - Legacy, - /// m = 65_536 KiB (64 MiB), t = 3, p = 1. - Current, -} - -impl KdfProfile { - pub(crate) const LEGACY_ID: u8 = 0; - pub(crate) const CURRENT_ID: u8 = 1; - - pub(crate) fn id(self) -> u8 { - match self { - Self::Legacy => Self::LEGACY_ID, - Self::Current => Self::CURRENT_ID, - } - } - - /// Strict: an id this build does not know is an error, never a fallback. - pub(crate) fn from_id(id: u8) -> Result { - match id { - Self::LEGACY_ID => Ok(Self::Legacy), - Self::CURRENT_ID => Ok(Self::Current), - other => Err(format!("unknown kdf profile {other}")), - } - } - - fn params(self) -> Result { - let (m_cost, t_cost, p_cost) = match self { - Self::Legacy => (19_456, 2, 1), - Self::Current => (65_536, 3, 1), - }; - Params::new(m_cost, t_cost, p_cost, Some(KEY_LEN)).map_err(|e| e.to_string()) - } -} /// The identity bundle. Secret halves wipe on drop; `Debug` never prints them. #[derive(Clone, PartialEq, Eq, Zeroize, ZeroizeOnDrop)] @@ -109,21 +58,14 @@ impl BackupKeys { } pub(crate) fn kdf(passphrase: &str, salt: &[u8]) -> Result, String> { - kdf_with(KdfProfile::Current, passphrase, salt) -} - -pub(crate) fn kdf_with( - profile: KdfProfile, - passphrase: &str, - salt: &[u8], -) -> Result, String> { if passphrase.is_empty() { return Err("empty passphrase".into()); } if salt.len() != SALT_LEN { return Err("salt length".into()); } - let argon = Argon2::new(Algorithm::Argon2id, Version::V0x13, profile.params()?); + let params = Params::new(19_456, 2, 1, Some(32)).map_err(|e| e.to_string())?; + let argon = Argon2::new(Algorithm::Argon2id, Version::V0x13, params); let mut key = Zeroizing::new([0u8; 32]); argon .hash_password_into(passphrase.as_bytes(), salt, &mut key[..]) @@ -143,9 +85,8 @@ pub fn seal(passphrase: &str, keys: &BackupKeys) -> Result, String> { let ct = cipher .encrypt(&nonce, &keys.to_bytes()[..]) .map_err(|_| "encrypt failed".to_string())?; - let mut out = Vec::with_capacity(MAGIC.len() + 1 + SEALED_BODY_LEN); + let mut out = Vec::with_capacity(MAGIC.len() + SALT_LEN + NONCE_LEN + ct.len()); out.extend_from_slice(MAGIC); - out.push(KdfProfile::Current.id()); out.extend_from_slice(&salt); out.extend_from_slice(&nonce); out.extend_from_slice(&ct); @@ -153,25 +94,15 @@ pub fn seal(passphrase: &str, keys: &BackupKeys) -> Result, String> { } pub fn open(passphrase: &str, blob: &[u8]) -> Result { - if !blob.starts_with(MAGIC) { + let min = MAGIC.len() + SALT_LEN + NONCE_LEN + 16; + if blob.len() < min || !blob.starts_with(MAGIC) { return Err("not an onionwire backup".into()); } - let rest = &blob[MAGIC.len()..]; - // The sealed plaintext is a fixed size, so a legacy blob is exactly - // SEALED_BODY_LEN bytes after MAGIC and a versioned one is one byte longer. - let (profile, body) = match rest.len() { - SEALED_BODY_LEN => (KdfProfile::Legacy, rest), - n if n == SEALED_BODY_LEN + 1 => { - let profile = KdfProfile::from_id(rest[0])?; - (profile, &rest[1..]) - } - _ => return Err("not an onionwire backup".into()), - }; - let salt = &body[..SALT_LEN]; - let nonce_off = SALT_LEN; - let nonce = Nonce::from_slice(&body[nonce_off..nonce_off + NONCE_LEN]); - let ct = &body[nonce_off + NONCE_LEN..]; - let key = kdf_with(profile, passphrase, salt)?; + let salt = &blob[MAGIC.len()..MAGIC.len() + SALT_LEN]; + let nonce_off = MAGIC.len() + SALT_LEN; + let nonce = Nonce::from_slice(&blob[nonce_off..nonce_off + NONCE_LEN]); + let ct = &blob[nonce_off + NONCE_LEN..]; + let key = kdf(passphrase, salt)?; let cipher = ChaCha20Poly1305::new(Key::from_slice(&key[..])); let pt = Zeroizing::new( cipher @@ -260,80 +191,4 @@ mod tests { assert!(dbg.contains(""), "{dbg}"); assert!(dbg.contains("174"), "public half should stay: {dbg}"); } - - /// The pre-profile layout: `MAGIC || salt || nonce || ct`, no id byte. - fn legacy_blob(passphrase: &str, keys: &BackupKeys) -> Vec { - let salt = [0x5Au8; SALT_LEN]; - let key = kdf_with(KdfProfile::Legacy, passphrase, &salt).expect("legacy kdf"); - let cipher = ChaCha20Poly1305::new(Key::from_slice(&key[..])); - let nonce = ChaCha20Poly1305::generate_nonce(&mut OsRng); - let ct = cipher.encrypt(&nonce, &keys.to_bytes()[..]).expect("seal"); - let mut out = Vec::new(); - out.extend_from_slice(MAGIC); - out.extend_from_slice(&salt); - out.extend_from_slice(&nonce); - out.extend_from_slice(&ct); - out - } - - #[test] - fn sealed_blob_records_the_current_profile_and_roundtrips() { - let k = keys(9); - let blob = seal("correct horse", &k).expect("seal"); - assert_eq!(blob.len(), MAGIC.len() + 1 + SEALED_BODY_LEN); - assert_eq!( - blob[MAGIC.len()], - KdfProfile::Current.id(), - "new blobs must name their KDF profile" - ); - assert_eq!(open("correct horse", &blob).expect("open"), k); - } - - #[test] - fn legacy_profile_blob_still_opens() { - let k = keys(4); - let blob = legacy_blob("correct horse", &k); - assert_eq!(blob.len(), MAGIC.len() + SEALED_BODY_LEN); - assert_eq!(open("correct horse", &blob).expect("legacy open"), k); - } - - #[test] - fn wrong_passphrase_on_a_current_profile_blob_is_the_existing_error() { - let blob = seal("right", &keys(1)).expect("seal"); - let err = open("wrong", &blob).expect_err("wrong passphrase must fail"); - assert_eq!(err, "wrong passphrase or corrupt backup"); - } - - #[test] - fn unknown_profile_id_is_a_clear_error_not_a_fallback() { - let mut blob = seal("pw", &keys(2)).expect("seal"); - blob[MAGIC.len()] = 9; - let err = open("pw", &blob).expect_err("unknown profile must fail"); - assert_eq!(err, "unknown kdf profile 9"); - } - - #[test] - fn trailing_garbage_is_not_an_onionwire_backup() { - let mut blob = seal("pw", &keys(3)).expect("seal"); - blob.push(0xff); - assert_eq!( - open("pw", &blob).expect_err("must reject"), - "not an onionwire backup" - ); - } - - #[test] - #[ignore = "manual KDF timing measurement; run with --release --ignored"] - fn kdf_profile_timings() { - use std::time::Instant; - let salt = [0x11u8; SALT_LEN]; - for (label, profile) in [ - ("legacy m=19456 t=2 p=1", KdfProfile::Legacy), - ("current m=65536 t=3 p=1", KdfProfile::Current), - ] { - let started = Instant::now(); - let _ = kdf_with(profile, "correct horse battery staple", &salt).expect("kdf"); - eprintln!("{label}: {:.3}s", started.elapsed().as_secs_f64()); - } - } } diff --git a/src/cuprate.rs b/src/cuprate.rs index f272e66..a13ea92 100644 --- a/src/cuprate.rs +++ b/src/cuprate.rs @@ -17,7 +17,7 @@ //! name reservation), so a pinned revision is the only honest way to depend on //! it. //! * Cuprate's own `arti` feature stays **off**. Its Tor stack is arti 0.44, -//! which cannot unify with this crate's arti 0.49, and this daemon is +//! which cannot unify with this crate's arti 0.46, and this daemon is //! clearnet-only: OnionWire's Arti is the only Tor in the process. //! * The **unrestricted** RPC listener binds `127.0.0.1:` — the address //! `WalletChild::daemon_address` returns for a local source. The restricted diff --git a/src/frame.rs b/src/frame.rs index f4aec8e..8dbb67c 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -1,9 +1,6 @@ use futures::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; pub const VERSION: u8 = 1; -/// PQ handshake prelude. Body is `uint16 ct_len` (big-endian) followed by -/// exactly `ct_len` bytes. Only the opening frame of a session may use it. -pub const VERSION_PRELUDE: u8 = 2; pub const MAX_FRAME: usize = 65535; pub type Result = std::result::Result; @@ -56,65 +53,11 @@ pub async fn write_frame(w: &mut W, body: &[u8]) -> Resul } pub async fn read_frame(r: &mut R) -> Result> { - let (version, body) = read_versioned(r).await?; - if version != VERSION { - return Err(Error("bad version".into())); - } - Ok(body) -} - -/// First frame of a handshake. Version 1 is Noise msg 1 (classical). Version 2 -/// is the PQ prelude; the ciphertext is exactly `ct_len` bytes and must be the -/// ML-KEM-768 ciphertext length. -pub enum Opening { - Classical(Vec), - Prelude(Vec), -} - -pub async fn read_opening(r: &mut R) -> Result { - let (version, body) = read_versioned(r).await?; - match version { - VERSION => Ok(Opening::Classical(body)), - VERSION_PRELUDE => Ok(Opening::Prelude(parse_prelude(&body)?)), - _ => Err(Error("bad version".into())), - } -} - -pub async fn write_prelude(w: &mut W, ct: &[u8]) -> Result<()> { - if ct.len() > u16::MAX as usize { - return Err(Error("frame too large".into())); - } - let mut body = Vec::with_capacity(2 + ct.len()); - body.extend_from_slice(&(ct.len() as u16).to_be_bytes()); - body.extend_from_slice(ct); - let framed = encode_version(VERSION_PRELUDE, &body)?; - w.write_all(&framed) - .await - .map_err(|e| Error(e.to_string()))?; - w.flush().await.map_err(|e| Error(e.to_string())) -} - -pub fn parse_prelude(body: &[u8]) -> Result> { - if body.len() < 2 { - return Err(Error("short frame".into())); - } - let ct_len = u16::from_be_bytes(body[..2].try_into().expect("2 bytes")) as usize; - if body.len() != 2 + ct_len { - return Err(Error("length mismatch".into())); - } - if ct_len != crate::kem::CT_LEN { - return Err(Error("bad prelude".into())); - } - Ok(body[2..].to_vec()) -} - -async fn read_versioned(r: &mut R) -> Result<(u8, Vec)> { let mut hdr = [0u8; 5]; r.read_exact(&mut hdr) .await .map_err(|e| Error(e.to_string()))?; - let version = hdr[0]; - if version != VERSION && version != VERSION_PRELUDE { + if hdr[0] != VERSION { return Err(Error("bad version".into())); } let len = u32::from_be_bytes(hdr[1..5].try_into().expect("4 bytes")) as usize; @@ -125,16 +68,5 @@ async fn read_versioned(r: &mut R) -> Result<(u8, Vec) r.read_exact(&mut body) .await .map_err(|e| Error(e.to_string()))?; - Ok((version, body)) -} - -fn encode_version(version: u8, body: &[u8]) -> Result> { - if body.len() > MAX_FRAME { - return Err(Error("frame too large".into())); - } - let mut out = Vec::with_capacity(5 + body.len()); - out.push(version); - out.extend_from_slice(&(body.len() as u32).to_be_bytes()); - out.extend_from_slice(body); - Ok(out) + Ok(body) } diff --git a/src/kem.rs b/src/kem.rs deleted file mode 100644 index 24c62eb..0000000 --- a/src/kem.rs +++ /dev/null @@ -1,106 +0,0 @@ -//! ML-KEM-768 (FIPS 203) install key. -//! -//! The decapsulation key is stored as the 64-byte seed (`DecapsulationKey::to_seed`), -//! the form the crate prefers. The 1184-byte encapsulation key is what an invite -//! carries. Ciphertext is 1088 bytes; the shared secret is 32. - -use ml_kem::kem::{Decapsulate, Encapsulate, Kem}; -use ml_kem::{DecapsulationKey768, EncapsulationKey768, KeyExport, MlKem768, Seed}; -use zeroize::Zeroizing; - -pub const PK_LEN: usize = 1184; -pub const CT_LEN: usize = 1088; -pub const SS_LEN: usize = 32; -pub const SEED_LEN: usize = 64; - -pub type Result = std::result::Result; - -#[derive(Debug)] -pub struct Error(String); - -impl std::fmt::Display for Error { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - self.0.fmt(f) - } -} - -impl std::error::Error for Error {} - -/// A freshly generated install key. `seed` wipes on drop. -pub struct Keypair { - pub seed: Zeroizing<[u8; SEED_LEN]>, - pub pk: [u8; PK_LEN], -} - -pub fn generate() -> Keypair { - let (dk, ek) = MlKem768::generate_keypair(); - let seed_arr = dk.to_seed().expect("generate_keypair yields a seed"); - let pk_arr = ek.to_bytes(); - let mut seed = Zeroizing::new([0u8; SEED_LEN]); - let mut pk = [0u8; PK_LEN]; - seed.copy_from_slice(seed_arr.as_slice()); - pk.copy_from_slice(pk_arr.as_slice()); - Keypair { seed, pk } -} - -/// Canonical encapsulation-key bytes. Rejects a length or a key the crate -/// will not load, so a garbage `kem=` never becomes a friend row. -pub fn encode_pk(pk: &[u8]) -> Result> { - let ek = encapsulation_key(pk)?; - Ok(ek.to_bytes().as_slice().to_vec()) -} - -pub fn decode_pk(bytes: &[u8]) -> Result> { - encode_pk(bytes) -} - -pub fn encapsulate(pk: &[u8]) -> Result<(Vec, Vec)> { - let ek = encapsulation_key(pk)?; - let (ct, ss) = ek.encapsulate(); - Ok((ct.as_slice().to_vec(), ss.as_slice().to_vec())) -} - -/// Ciphertext bytes. Length is the only check: ML-KEM decapsulation of a -/// wrong ciphertext does not error (implicit rejection), so a bad ct is -/// caught by the handshake prologue, not here. -pub fn encode_ct(ct: &[u8]) -> Result> { - if ct.len() != CT_LEN { - return Err(Error("ct length".into())); - } - Ok(ct.to_vec()) -} - -pub fn decode_ct(bytes: &[u8]) -> Result> { - encode_ct(bytes) -} - -pub fn decapsulate(seed: &[u8], ct: &[u8]) -> Result> { - if ct.len() != CT_LEN { - return Err(Error("ct length".into())); - } - let seed_arr = Seed::try_from(seed).map_err(|_| Error("seed length".into()))?; - let dk = DecapsulationKey768::from_seed(seed_arr); - let ss = dk - .decapsulate_slice(ct) - .map_err(|_| Error("ct length".into()))?; - Ok(ss.as_slice().to_vec()) -} - -/// Canonical encapsulation key for a stored 64-byte decapsulation seed. -/// -/// The ratchet derives its KEM half from the X25519 ratchet secret, so it never -/// stores the ML-KEM seed separately; this recomputes the public half. -pub fn pk_from_seed(seed: &[u8]) -> Result> { - let seed_arr = Seed::try_from(seed).map_err(|_| Error("seed length".into()))?; - let dk = DecapsulationKey768::from_seed(seed_arr); - Ok(dk.encapsulation_key().to_bytes().as_slice().to_vec()) -} - -fn encapsulation_key(pk: &[u8]) -> Result { - if pk.len() != PK_LEN { - return Err(Error("pk length".into())); - } - let key = ml_kem::kem::Key::::try_from(pk) - .map_err(|_| Error("pk length".into()))?; - EncapsulationKey768::new(&key).map_err(|_| Error("invalid encapsulation key".into())) -} diff --git a/src/lib.rs b/src/lib.rs index c80956c..9e4c7c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,11 +4,9 @@ pub mod dispatch; pub mod file; pub mod frame; pub mod hs; -pub mod kem; pub mod loc; pub mod node; pub mod outbox; -pub mod padding; pub mod pay; pub mod profile; pub mod qr; diff --git a/src/loc.rs b/src/loc.rs index 16d4f25..9803f77 100644 --- a/src/loc.rs +++ b/src/loc.rs @@ -54,10 +54,9 @@ pub fn verify(identity_pk: &[u8], loc: &Loc) -> bool { let signature = Signature::from_bytes(&sig); vk.verify(&sign_msg_v2(&loc.onion, loc.ts), &signature) .is_ok() - || (crate::pay::legacy_sigs() - && vk - .verify(&sign_msg_v1(&loc.onion, loc.ts), &signature) - .is_ok()) + || vk + .verify(&sign_msg_v1(&loc.onion, loc.ts), &signature) + .is_ok() } pub fn encode(loc: &Loc) -> Vec { diff --git a/src/node.rs b/src/node.rs index 340ab7a..b39a4e8 100644 --- a/src/node.rs +++ b/src/node.rs @@ -427,7 +427,7 @@ impl Node { pub fn qr_payload(&self) -> Result { let k = self.keys()?; - qr::encode(&k.identity_sk, &self.onion(), &k.prekey_pk, &k.kem_pk).map_err(|e| e.to_string()) + qr::encode(&k.identity_sk, &self.onion(), &k.prekey_pk).map_err(|e| e.to_string()) } pub fn write_backup(&self, path: &str, passphrase: &str) -> Result<(), String> { @@ -456,10 +456,6 @@ impl Node { pub fn restore_backup(&self, path: &str, passphrase: &str) -> Result<(), String> { let blob = std::fs::read(path).map_err(|e| e.to_string())?; let k = crate::backup::open(passphrase, &blob)?; - let (kem_seed, kem_pk) = { - let cur = self.keys()?; - (cur.kem_seed, cur.kem_pk) - }; self.store .lock() .map_err(|e| e.to_string())? @@ -470,11 +466,6 @@ impl Node { identity_pk: k.identity_pk, prekey_sk: k.prekey_sk, prekey_pk: k.prekey_pk, - // Backup blob is still the classical identity+prekey bundle. The - // KEM seed stays the one already in this store; friends who pinned - // a different encapsulation key have to re-paste. - kem_seed, - kem_pk, }; Ok(()) } @@ -486,30 +477,21 @@ impl Node { pub fn add_friend_payload(&self, p: &qr::QrPayload) -> Result<(), String> { let store = self.store.lock().map_err(|e| e.to_string())?; - let existing = store + let prekey_changed = store .get_friend(&p.pubkey) - .map_err(|e| e.to_string())?; - let prekey_changed = existing - .as_ref() + .map_err(|e| e.to_string())? .map(|f| f.prekey != p.signed_prekey) .unwrap_or(false); - let kem_changed = existing - .as_ref() - .map(|f| f.kem_pk.as_deref() != p.kem_pk.as_deref()) - .unwrap_or(false); store .upsert_friend(&p.pubkey, &p.onion, None) .map_err(|e| e.to_string())?; store .set_friend_prekey(&p.pubkey, &p.signed_prekey) .map_err(|e| e.to_string())?; - store - .set_friend_kem(&p.pubkey, p.kem_pk.as_deref()) - .map_err(|e| e.to_string())?; - if prekey_changed || kem_changed { + if prekey_changed { // The bootstrap epoch is derived from the peers' static prekey DH, - // and a new KEM key is the same hard cut as F8: the stored ratchet - // state is unusable. Drop it; the next frame rebuilds a fresh state. + // so a refreshed invite makes the stored ratchet state unusable on + // both sides. Drop it: the next frame rebuilds a fresh state. store.clear_ratchet(&p.pubkey).map_err(|e| e.to_string())?; } Ok(()) @@ -1065,12 +1047,7 @@ impl Node { return self.wallet_child_status(); } let cfg = self.wallet_child_config(); - // Readiness needs both halves: the wallet's own `get_height` and the - // chain tip. The tip comes from the configured daemon (loopback for a - // local source, the clearnet host the user typed, never a `.onion`). - let w = self - .wallet_snapshot() - .with_daemon_probe(cfg.daemon_probe_addr()); + let w = self.wallet_snapshot(); if !w.configured() { return self.wallet_child_status(); } @@ -1095,7 +1072,7 @@ impl Node { } let synced = progress.as_ref().is_some_and(wallet::ChainInfo::ready); let (height, target_height) = match progress { - Some(info) => (info.height, info.tip.unwrap_or(0)), + Some(info) => (info.height, info.target_height), // The wallet RPC is the honest source when it answers. When it does // not (a refused connection is the common one), the daemon this box // owns can still say — and a daemon that does not answer leaves @@ -1239,15 +1216,14 @@ impl Node { ) .map_err(|e| e.to_string())?; let pt = profile::encode(&prf); - let (onion, prekey, kem) = { + let (onion, prekey) = { let f = self.friend(friend_pk)?; if f.prekey.len() != 32 { return Err("friend missing prekey".into()); } - (f.onion, f.prekey, f.kem_pk) + (f.onion, f.prekey) }; - self.try_send(&onion, friend_pk, &prekey, &pt, kem.as_deref()) - .await + self.try_send(&onion, friend_pk, &prekey, &pt).await } /// Sign an invoice with this node's identity key. @@ -1339,9 +1315,7 @@ impl Node { /// Pay selected friend via wallet RPC, then signed receipt. pub async fn tip(&self, friend_pk: &[u8], atomic: &str, memo: &str) -> Result<(), String> { - let w = self - .wallet_snapshot() - .with_daemon_probe(self.wallet_child_config().daemon_probe_addr()); + let w = self.wallet_snapshot(); if !w.configured() { return Err(wallet::NOT_CONFIGURED_MSG.into()); } @@ -1745,15 +1719,14 @@ impl Node { async fn send_once(&self, friend_pk: &[u8], plaintext: &[u8]) -> Result<(), String> { self.ensure_running()?; - let (onion, prekey, kem) = { + let (onion, prekey) = { let f = self.friend(friend_pk)?; if f.prekey.len() != 32 { return Err("friend missing prekey".into()); } - (f.onion, f.prekey, f.kem_pk) + (f.onion, f.prekey) }; - self.try_send(&onion, friend_pk, &prekey, plaintext, kem.as_deref()) - .await + self.try_send(&onion, friend_pk, &prekey, plaintext).await } /// Dial a peer's onion. Success is evidence the peer is up, which is one of @@ -1828,7 +1801,7 @@ impl Node { let mut notified = 0; for f in &friends { if self - .push_loc(&f.pubkey, &f.onion, &f.prekey, f.kem_pk.as_deref(), &loc_pt) + .push_loc(&f.pubkey, &f.onion, &f.prekey, &loc_pt) .await .is_ok() { @@ -1842,18 +1815,17 @@ impl Node { }) } - /// Rotate the long-lived signed prekey and the ML-KEM-768 key together (F8). - /// Hard cut, like the locator rotate: the prekey is our Noise static, the - /// KEM key is what peers encapsulate to, and the bootstrap ratchet epoch is + /// Rotate the long-lived signed prekey (F8). Hard cut, like the locator + /// rotate: the prekey is our Noise static and the bootstrap ratchet epoch is /// derived from the prekey DH, so every stored session is dead the moment /// this returns and every friend has to F3-paste the new invite. Nothing is - /// pushed to peers — a new prekey or KEM key only travels inside a signed - /// invite. The identity key (and therefore the fingerprint) does not move. + /// pushed to peers — a new prekey only travels inside a signed invite. The + /// identity key (and therefore the fingerprint) does not move; the caller + /// re-encodes the F2 invite around the returned pubkey. pub fn rotate_prekey(&self) -> Result<[u8; 32], String> { let mut k = self.keys()?; let sk = StaticSecret::random_from_rng(OsRng); let pk = X25519Public::from(&sk).to_bytes(); - let kem_kp = crate::kem::generate(); { let store = self.store.lock().map_err(|e| e.to_string())?; // `replace_identity_keys` rewrites the prekey columns too; the @@ -1861,17 +1833,12 @@ impl Node { store .replace_identity_keys(&k.identity_sk, &k.identity_pk, &sk.to_bytes(), &pk) .map_err(|e| e.to_string())?; - store - .set_kem_keys(&kem_kp.seed[..], &kem_kp.pk) - .map_err(|e| e.to_string())?; for f in store.list_friends().map_err(|e| e.to_string())? { store.clear_ratchet(&f.pubkey).map_err(|e| e.to_string())?; } } k.prekey_sk = sk.to_bytes(); k.prekey_pk = pk; - k.kem_seed = *kem_kp.seed; - k.kem_pk = kem_kp.pk; *self.keys.lock().map_err(|e| e.to_string())? = k; Ok(pk) } @@ -1940,7 +1907,6 @@ impl Node { friend_pk: &[u8], onion: &str, prekey: &[u8], - remote_kem: Option<&[u8]>, loc_pt: &[u8], ) -> Result<(), String> { if prekey.len() != 32 { @@ -1949,10 +1915,7 @@ impl Node { let deadline = Instant::now() + Duration::from_secs(180); let mut last = None::; while Instant::now() < deadline { - match self - .try_send(onion, friend_pk, prekey, loc_pt, remote_kem) - .await - { + match self.try_send(onion, friend_pk, prekey, loc_pt).await { Ok(()) => return Ok(()), Err(e) if e.contains("fingerprint mismatch") => return Err(e), Err(e) => last = Some(e), @@ -1968,11 +1931,10 @@ impl Node { pinned_id: &[u8], remote_prekey: &[u8], plaintext: &[u8], - remote_kem: Option<&[u8]>, ) -> Result<(), String> { self.outbox .deliverer() - .deliver(onion, pinned_id, remote_prekey, plaintext, remote_kem) + .deliver(onion, pinned_id, remote_prekey, plaintext) .await } @@ -1986,10 +1948,7 @@ impl Node { let Ok(g) = store.lock() else { return None; }; - g.get_friend_by_prekey(spk).ok().flatten().map(|f| session::PeerAuth { - identity: f.pubkey, - kem_pk: f.kem_pk, - }) + g.get_friend_by_prekey(spk).ok().flatten().map(|f| f.pubkey) }) .await .map_err(session_err)?; @@ -2160,9 +2119,7 @@ impl Node { // Honest prerequisite: an unsynced wallet cannot see the tx, so a // get_transfers "miss" would be a lie. Until the chain is ready the // receipt stays verified=0 — that is the correct state, not an error. - let w = self - .wallet_snapshot() - .with_daemon_probe(self.wallet_child_config().daemon_probe_addr()); + let w = self.wallet_snapshot(); let ready = w.configured() && w.can_verify_receipts().await; if ready { match w.get_transfers().await { @@ -2335,7 +2292,6 @@ fn bootstrap_ratchet( keys: &Keys, peer_pk: &[u8], peer_prekey: &[u8], - hybrid: bool, ) -> Result { let peer_pk: [u8; 32] = peer_pk .try_into() @@ -2353,20 +2309,7 @@ fn bootstrap_ratchet( let local = RatchetKeyPair::from_secret(ratchet_seed(&hk, &keys.identity_pk)?); let remote = ratchet_seed(&hk, &peer_pk)?; let remote_pub = X25519Public::from(&StaticSecret::from(remote)).to_bytes(); - // The peer's initial ratchet keypair is derived, so its ML-KEM half is too: - // a hybrid friend needs no extra wire field at bootstrap. Epoch 0 itself - // stays classical; the first rotation is the first hybrid step. - let remote_kem = if hybrid { - Some(RatchetKeyPair::from_secret(remote).kem_public().to_vec()) - } else { - None - }; - Ok(RatchetState::bootstrap( - root_key, - local, - remote_pub, - remote_kem.as_deref(), - )) + Ok(RatchetState::bootstrap(root_key, local, remote_pub)) } /// `HKDF(info = "ratchet-key" || pubkey)` — the initial ratchet secret both @@ -2389,20 +2332,7 @@ fn ratchet_seed(hk: &Hkdf, pubkey: &[u8; 32]) -> Result<[u8; 32], String /// session behind. fn ratchet_for(store: &Store, keys: &Keys, friend_pk: &[u8]) -> Result { if let Some(blob) = store.load_ratchet(friend_pk).map_err(|e| e.to_string())? { - match RatchetState::from_bytes(&blob) { - Ok(state) => return Ok(state), - // Hard cut, exactly like F8: the *pre-hybrid* v1 blob has no KEM - // ratchet key and is dropped, never half-migrated. The bootstrap - // epoch is a pure function of the (unchanged) prekeys, so it is - // rebuilt. A newer version is not an old format and must not be - // reset silently. - Err(crate::ratchet::Error::UnsupportedStateVersion(1)) => { - store.clear_ratchet(friend_pk).map_err(|e| e.to_string())?; - } - // A corrupt *current* state, or one written by a newer client, is - // surfaced rather than silently reset. - Err(e) => return Err(format!("ratchet state: {e}")), - } + return RatchetState::from_bytes(&blob).map_err(|e| format!("ratchet state: {e}")); } let f = store .get_friend(friend_pk) @@ -2411,15 +2341,11 @@ fn ratchet_for(store: &Store, keys: &Keys, friend_pk: &[u8]) -> Result Result, String> { - // Pad to the normative ladder *inside* the AEAD, so an observer sees only - // the bucket and the padding itself is authenticated. - let padded = crate::padding::encode(plaintext)?; let mut state = ratchet_for(store, keys, friend_pk)?; - let frame = state.encrypt(&padded).map_err(|e| e.to_string())?; + let frame = state.encrypt(plaintext).map_err(|e| e.to_string())?; let blob = Zeroizing::new(state.to_bytes()); store .save_ratchet(friend_pk, &blob) @@ -2453,10 +2376,6 @@ pub fn encode_chat_frame( /// untouched, because `RatchetState` validates fully before it mutates. The /// ciphertext is never stored and there is no plaintext fallback. /// -/// The decrypted plaintext is then unpadded by `crate::padding`, whose -/// `uint16 pad_len` is the only authority for the body boundary. A `pad_len` -/// that overruns the buffer fails closed here, before any row is written. -/// /// Public for the same reason as [`encode_chat_frame`]. Callers hold the store /// lock across load → decrypt → append → save, which is what makes the /// read-modify-write atomic against a second inbound session on the same peer. @@ -2467,11 +2386,8 @@ pub fn ingest_chat_frame( frame: &[u8], ) -> Result, String> { let mut state = ratchet_for(store, keys, peer_pk)?; - let padded = state.decrypt(frame).map_err(|e| e.to_string())?; - // `pad_len` is authoritative and never inferred from trailing bytes. An - // overrun fails closed here, before anything is appended or persisted. - let plaintext = crate::padding::decode(&padded)?; - let line = Zeroizing::new(sanitize::display_text(plaintext).as_bytes().to_vec()); + let plaintext = state.decrypt(frame).map_err(|e| e.to_string())?; + let line = Zeroizing::new(sanitize::display_text(&plaintext).as_bytes().to_vec()); store .append_message(peer_pk, "in", &line[..]) .map_err(|e| e.to_string())?; @@ -2661,7 +2577,6 @@ pub(crate) mod tests { _pinned_id: &'a [u8], _prekey: &'a [u8], _payload: &'a [u8], - _remote_kem: Option<&'a [u8]>, ) -> crate::outbox::BoxFut<'a, Result<(), String>> { Box::pin(async { Err("connect peer.onion:80: timed out".to_string()) }) } @@ -2772,33 +2687,18 @@ pub(crate) mod tests { node.keys.lock().unwrap().prekey_pk } - fn node_kem_pk(node: &Node) -> [u8; crate::kem::PK_LEN] { - node.keys.lock().unwrap().kem_pk - } - /// One peer→node dial, end to end: a real Noise IK handshake and one /// already-encoded frame over an in-memory stream, into `handle_incoming`. - async fn deliver_frame( - node: &Node, - peer: &Keys, - frame: &[u8], - remote_kem: Option<&[u8]>, - ) -> Result<(), String> { + async fn deliver_frame(node: &Node, peer: &Keys, frame: &[u8]) -> Result<(), String> { let node_pk = node.identity_pk(); let node_prekey = node_prekey(node); let (client_side, server_side) = tokio::io::duplex(64 * 1024); let send = async { let mut stream = Duplex(client_side); - let mut sess = session::handshake_initiator( - &mut stream, - peer, - &node_pk, - &node_prekey, - remote_kem, - ) - .await - .map_err(|e| e.into_message())?; + let mut sess = session::handshake_initiator(&mut stream, peer, &node_pk, &node_prekey) + .await + .map_err(|e| e.into_message())?; let ct = sess.encrypt(frame).map_err(|e| e.into_message())?; frame::write_frame(&mut stream, &ct) .await @@ -2809,13 +2709,8 @@ pub(crate) mod tests { node.handle_incoming(&mut stream).await }; let (sent, received) = futures::join!(send, receive); - // The responder's error is the diagnostic one (e.g. a downgrade - // rejection); the initiator only sees the stream drop. - match (sent, received) { - (_, Err(e)) => Err(e), - (Err(e), Ok(())) => Err(e), - (Ok(()), Ok(())) => Ok(()), - } + sent?; + received } fn chat_lines(node: &Node, peer: &Keys) -> Vec<(String, String)> { @@ -2897,9 +2792,7 @@ pub(crate) mod tests { let frame = encode_chat_frame(&peer_store, &peer, &node.identity_pk(), b"hi bob").expect("encode"); - deliver_frame(&node, &peer, &frame, None) - .await - .expect("receive"); + deliver_frame(&node, &peer, &frame).await.expect("receive"); assert_eq!( chat_lines(&node, &peer), @@ -2908,395 +2801,6 @@ pub(crate) mod tests { ); } - #[tokio::test] - async fn pq_prelude_session_round_trips_a_real_rat_frame() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - { - let store = node.store.lock().unwrap(); - befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion"); - store - .set_friend_kem(&peer.identity_pk, Some(&peer.kem_pk)) - .expect("friend kem"); - } - let peer_store = - Store::open_at_with_passphrase(&dir.path().join("alice"), PASS).expect("peer store"); - { - let nk = node_kem_pk(&node); - befriend(&peer_store, &node.identity_pk(), &node_prekey(&node), "node.onion"); - peer_store - .set_friend_kem(&node.identity_pk(), Some(&nk)) - .expect("node kem"); - } - - let frame = - encode_chat_frame(&peer_store, &peer, &node.identity_pk(), b"pq hello").expect("encode"); - let nk = node_kem_pk(&node); - deliver_frame(&node, &peer, &frame, Some(&nk)) - .await - .expect("PQ handshake + rat frame"); - - assert_eq!( - chat_lines(&node, &peer), - vec![("in".to_string(), "pq hello".to_string())], - "a real ratchet frame survived the hybrid prelude" - ); - } - - #[tokio::test] - async fn a_v1_ratchet_blob_is_dropped_and_rebuilt_not_misread() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - { - let store = node.store.lock().unwrap(); - befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion"); - store - .set_friend_kem(&peer.identity_pk, Some(&peer.kem_pk)) - .expect("friend kem"); - // Exactly the pre-hybrid on-disk shape: version 0x01, 210 bytes. - let mut legacy = vec![0x01u8]; - legacy.resize(210, 0x5a); - store - .save_ratchet(&peer.identity_pk, &legacy) - .expect("legacy row"); - } - - let (frame, blob) = { - let store = node.store.lock().unwrap(); - let keys = node.keys.lock().unwrap(); - let frame = encode_chat_frame(&store, &keys, &peer.identity_pk, b"after the cut") - .expect("a pre-hybrid state is dropped and rebuilt, not fatal"); - let blob = store - .load_ratchet(&peer.identity_pk) - .expect("load ratchet") - .expect("the rebuilt state was persisted"); - (frame, blob) - }; - - assert_eq!( - frame[4], - crate::ratchet::FRAME_VERSION, - "the rebuilt epoch 0 is classical, one message before the first step" - ); - assert_eq!( - blob[0], - crate::ratchet::STATE_VERSION, - "the store now holds a v2 state" - ); - assert!( - blob.len() > 210, - "the rebuilt state carries the peer's KEM ratchet key" - ); - } - - #[tokio::test] - async fn a_corrupt_current_ratchet_blob_is_an_error_not_a_silent_drop() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - let store = node.store.lock().unwrap(); - befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion"); - store - .set_friend_kem(&peer.identity_pk, Some(&peer.kem_pk)) - .expect("friend kem"); - // A v2 blob missing its last byte: a hard cut must not paper over this - // one, because a corrupt current state is not an old format. - let mut corrupt = vec![crate::ratchet::STATE_VERSION]; - corrupt.resize(300, 0x5a); - store - .save_ratchet(&peer.identity_pk, &corrupt) - .expect("row"); - let keys = node.keys.lock().unwrap(); - let err = encode_chat_frame(&store, &keys, &peer.identity_pk, b"no") - .expect_err("a corrupt current state must fail, not re-bootstrap"); - assert!( - err.contains("ratchet state"), - "expected a state error, got: {err}" - ); - } - - #[tokio::test] - async fn a_future_ratchet_blob_is_an_error_not_a_silent_downgrade() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - let store = node.store.lock().unwrap(); - befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion"); - store - .set_friend_kem(&peer.identity_pk, Some(&peer.kem_pk)) - .expect("friend kem"); - // Only the *old* layout is a hard cut. A newer state must not be - // silently reset to epoch 0 by an older client. - let mut future = vec![crate::ratchet::STATE_VERSION + 1]; - future.resize(300, 0x5a); - store.save_ratchet(&peer.identity_pk, &future).expect("row"); - let keys = node.keys.lock().unwrap(); - let err = encode_chat_frame(&store, &keys, &peer.identity_pk, b"no") - .expect_err("a future state version must not be downgraded silently"); - assert!( - err.contains("unsupported ratchet state version"), - "expected a version error, got: {err}" - ); - } - - #[tokio::test] - async fn a_prelude_less_session_against_a_kem_friend_is_rejected() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - { - let store = node.store.lock().unwrap(); - befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion"); - store - .set_friend_kem(&peer.identity_pk, Some(&peer.kem_pk)) - .expect("friend kem"); - } - let peer_store = - Store::open_at_with_passphrase(&dir.path().join("alice"), PASS).expect("peer store"); - befriend(&peer_store, &node.identity_pk(), &node_prekey(&node), "node.onion"); - - let frame = - encode_chat_frame(&peer_store, &peer, &node.identity_pk(), b"downgrade").expect("encode"); - let err = deliver_frame(&node, &peer, &frame, None) - .await - .expect_err("a classical session to a KEM friend must fail"); - - assert!( - err.contains(session::PRELUDE_REQUIRED), - "expected a hard downgrade rejection, got: {err}" - ); - assert!( - chat_lines(&node, &peer).is_empty(), - "no application frame may be accepted after a downgrade" - ); - } - - /// A `rat ` frame's fixed overhead: prefix, version, header, nonce, tag. - const RAT_OVERHEAD: usize = 4 + 1 + crate::ratchet::HEADER_LEN + 12 + 16; - - /// One peer→node chat frame plus the stores both sides need. - fn chat_frame(dir: &tempfile::TempDir, node: &Node, peer: &Keys, body: &[u8]) -> Vec { - let peer_store = - Store::open_at_with_passphrase(&dir.path().join("alice"), PASS).expect("peer store"); - befriend( - &peer_store, - &node.identity_pk(), - &node_prekey(node), - "node.onion", - ); - encode_chat_frame(&peer_store, peer, &node.identity_pk(), body).expect("encode") - } - - #[tokio::test] - async fn chat_frames_are_padded_to_the_normative_length_ladder() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - befriend( - &node.store.lock().unwrap(), - &peer.identity_pk, - &peer.prekey_pk, - "peer.onion", - ); - - // 1-byte, empty and exactly-bucket-sized bodies all collapse into the - // smallest bucket; 255 bytes is the first body that needs the second. - for body in [&b"x"[..], &b""[..], &vec![b'a'; 254][..]] { - let frame = chat_frame(&dir, &node, &peer, body); - assert_eq!( - frame.len(), - RAT_OVERHEAD + 256, - "a {}-byte body rides in the 256-byte bucket", - body.len() - ); - } - let frame = chat_frame(&dir, &node, &peer, &vec![b'a'; 255]); - assert_eq!( - frame.len(), - RAT_OVERHEAD + 512, - "255 bytes no longer fit the 256-byte bucket" - ); - } - - #[tokio::test] - async fn an_oversize_chat_send_fails_closed_before_the_outbox() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - befriend( - &node.store.lock().unwrap(), - &peer.identity_pk, - &peer.prekey_pk, - "peer.onion", - ); - - let body = vec![b'a'; crate::padding::MAX_BODY + 1]; - let err = node - .send(&peer.identity_pk, &body) - .await - .expect_err("a body past the largest bucket is a protocol error"); - assert!(err.contains("too large"), "unexpected error: {err}"); - assert!( - node.outbox_pending(&peer.identity_pk).unwrap().is_empty(), - "a protocol error is never queued" - ); - } - - #[tokio::test] - async fn a_one_byte_chat_round_trips_in_the_smallest_bucket() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - befriend( - &node.store.lock().unwrap(), - &peer.identity_pk, - &peer.prekey_pk, - "peer.onion", - ); - - let frame = chat_frame(&dir, &node, &peer, b"x"); - deliver_frame(&node, &peer, &frame, None) - .await - .expect("receive"); - - assert_eq!( - chat_lines(&node, &peer), - vec![("in".to_string(), "x".to_string())], - "one byte in, the same byte out — no padding in history" - ); - } - - #[tokio::test] - async fn a_chat_body_ending_in_the_pad_fill_byte_round_trips() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - befriend( - &node.store.lock().unwrap(), - &peer.identity_pk, - &peer.prekey_pk, - "peer.onion", - ); - let peer_store = - Store::open_at_with_passphrase(&dir.path().join("alice"), PASS).expect("peer store"); - befriend( - &peer_store, - &node.identity_pk(), - &node_prekey(&node), - "node.onion", - ); - - // `pad_len` is authoritative, so a body that ends in the same byte as - // the fill is never trimmed: header says two bytes of 'A' fill, the - // body itself ends in an 'A'. - let mut padded = vec![0x00, 0x02]; - padded.extend_from_slice(b"tailA"); - padded.extend_from_slice(b"AA"); - let mut state = ratchet_for(&peer_store, &peer, &node.identity_pk()).expect("state"); - let frame = state.encrypt(&padded).expect("encrypt"); - - deliver_frame(&node, &peer, &frame, None) - .await - .expect("receive"); - - let lines = chat_lines(&node, &peer); - assert_eq!(lines.len(), 1); - assert_eq!(lines[0].1, "tailA"); - } - - #[tokio::test] - async fn a_pad_len_that_overruns_the_plaintext_writes_no_chat_row() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - befriend( - &node.store.lock().unwrap(), - &peer.identity_pk, - &peer.prekey_pk, - "peer.onion", - ); - let peer_store = - Store::open_at_with_passphrase(&dir.path().join("alice"), PASS).expect("peer store"); - befriend( - &peer_store, - &node.identity_pk(), - &node_prekey(&node), - "node.onion", - ); - - // A *validly authenticated* frame whose pad_len claims more fill than - // the plaintext holds: the AEAD cannot catch this, the padding layer - // must, and it must fail before a row is appended. - let mut state = ratchet_for(&peer_store, &peer, &node.identity_pk()).expect("state"); - let bad = state.encrypt(&[0xff, 0xff, b'h', b'i']).expect("encrypt"); - - let store = node.store.lock().unwrap(); - let keys = node.keys.lock().unwrap(); - let err = ingest_chat_frame(&store, &keys, &peer.identity_pk, &bad) - .expect_err("an overrunning pad_len must fail closed"); - assert!(err.contains("overrun"), "unexpected error: {err}"); - drop(keys); - drop(store); - - assert!( - chat_lines(&node, &peer).is_empty(), - "no partial plaintext may be rendered or stored" - ); - } - - #[tokio::test] - async fn a_hybrid_rat_frame_round_trips_inside_the_smallest_bucket() { - let dir = tempfile::tempdir().unwrap(); - let node = offline_node(&dir.path().join("bob"), Arc::new(NoDial)); - let peer = Keys::generate(); - { - let store = node.store.lock().unwrap(); - befriend(&store, &peer.identity_pk, &peer.prekey_pk, "peer.onion"); - store - .set_friend_kem(&peer.identity_pk, Some(&peer.kem_pk)) - .expect("friend kem"); - } - let peer_store = - Store::open_at_with_passphrase(&dir.path().join("alice"), PASS).expect("peer store"); - { - let nk = node_kem_pk(&node); - befriend( - &peer_store, - &node.identity_pk(), - &node_prekey(&node), - "node.onion", - ); - peer_store - .set_friend_kem(&node.identity_pk(), Some(&nk)) - .expect("node kem"); - } - - // Epoch 0 is always classical, even for a KEM friend: the first `rat ` - // frame carries the 40-byte header and the PQ prelude lives in the - // one-shot handshake. The 2312-byte hybrid header only appears on the - // first rotation (`tests/padding.rs` pins that 2601-byte floor). - let frame = - encode_chat_frame(&peer_store, &peer, &node.identity_pk(), b"pq").expect("encode"); - assert_eq!(frame[4], crate::ratchet::FRAME_VERSION); - assert_eq!( - frame.len(), - RAT_OVERHEAD + 256, - "epoch 0 is classical, so the hybrid prelude does not widen it" - ); - let nk = node_kem_pk(&node); - deliver_frame(&node, &peer, &frame, Some(&nk)) - .await - .expect("PQ handshake + rat frame"); - - assert_eq!( - chat_lines(&node, &peer), - vec![("in".to_string(), "pq".to_string())], - "a padded rat frame survives the PQ prelude" - ); - } - #[tokio::test] async fn the_receive_path_keeps_arrival_order_and_drops_replays_and_garbage() { let dir = tempfile::tempdir().unwrap(); @@ -3326,17 +2830,17 @@ pub(crate) mod tests { .collect(); // Arrival order 2, 0, 1 — the ratchet holds the two it has not seen. - deliver_frame(&node, &peer, &frames[2], None).await.unwrap(); - deliver_frame(&node, &peer, &frames[0], None).await.unwrap(); - deliver_frame(&node, &peer, &frames[1], None).await.unwrap(); + deliver_frame(&node, &peer, &frames[2]).await.unwrap(); + deliver_frame(&node, &peer, &frames[0]).await.unwrap(); + deliver_frame(&node, &peer, &frames[1]).await.unwrap(); // A replay of an already-consumed frame, and a corrupted one: both are // dropped inside `handle_incoming` without a chat row and without // wedging the session. - deliver_frame(&node, &peer, &frames[0], None).await.unwrap(); + deliver_frame(&node, &peer, &frames[0]).await.unwrap(); let mut corrupt = frames[1].clone(); let last = corrupt.len() - 1; corrupt[last] ^= 0x01; - deliver_frame(&node, &peer, &corrupt, None).await.unwrap(); + deliver_frame(&node, &peer, &corrupt).await.unwrap(); assert_eq!( chat_lines(&node, &peer), @@ -3360,7 +2864,6 @@ pub(crate) mod tests { _pinned_id: &'a [u8], _prekey: &'a [u8], _payload: &'a [u8], - _remote_kem: Option<&'a [u8]>, ) -> crate::outbox::BoxFut<'a, Result<(), String>> { Box::pin(async { Ok(()) }) } @@ -3426,43 +2929,25 @@ pub(crate) mod tests { } /// A loopback wallet RPC that answers what the tip path actually asks for: - /// a digest challenge, then the wallet's own scanned `get_height` for the - /// readiness gate and `tx_hash` for the transfer. `get_info` is a daemon - /// method, not a wallet one, so it is never asked. Returns the wallet and - /// the daemon stub's address (the tip the gate compares against). - async fn mock_wallet() -> (Wallet, String) { + /// a digest challenge, then a synced `get_info` for the readiness gate and + /// `tx_hash` for the transfer. The old single-answer mock stopped covering + /// the path when `Wallet::transfer` started probing the chain tip first — + /// it answered `tx_hash` to `get_info` and every tip was refused as unsynced. + async fn mock_wallet() -> Wallet { let listener = tokio::net::TcpListener::bind("127.0.0.1:0") .await .expect("bind mock wallet"); let port = listener.local_addr().expect("mock wallet addr").port(); let reply: Arc String + Send + Sync> = Arc::new(|req: &str| { - if req.contains("get_height") { - r#"{"jsonrpc":"2.0","id":"0","result":{"height":100}}"#.to_string() + if req.contains("get_info") { + r#"{"jsonrpc":"2.0","id":"0","result":{"height":100,"target_height":100,"synchronized":true}}"# + .to_string() } else { r#"{"jsonrpc":"2.0","id":"0","result":{"tx_hash":"abc123"}}"#.to_string() } }); tokio::spawn(serve_mock_rpc(listener, reply)); - let wallet = Wallet::from_url(&format!("http://ow:secret@127.0.0.1:{port}")) - .expect("wallet url"); - let daemon = mock_daemon(100, 100).await; - (wallet, daemon) - } - - /// Point a test node's chain source at a daemon stub, so readiness has a - /// tip to compare the wallet's scanned height against. - fn chain_source_at(node: &Node, addr: &str) { - let (host, port) = addr.rsplit_once(':').expect("host:port"); - node.set_wallet_child_config(&ChildConfig { - source: ChainSource::Remote { - host: host.to_string(), - port: port.parse().expect("port"), - }, - wallet_rpc_bin: PathBuf::from("monero-wallet-rpc"), - arti_bin: PathBuf::from("arti"), - wallet_filename: wallet::DEFAULT_WALLET_FILENAME.to_string(), - }) - .expect("set chain source"); + Wallet::from_url(&format!("http://ow:secret@127.0.0.1:{port}")).expect("wallet url") } /// The payer of a tip must see it in their own chat: `receipt_chat_line` is /// the recipient's view of the frame that arrived, `tip_chat_line` is what @@ -3470,9 +2955,11 @@ pub(crate) mod tests { #[tokio::test] async fn outbound_tip_appends_the_senders_own_tip_chat_line() { let dir = tempfile::tempdir().unwrap(); - let (wallet, daemon) = mock_wallet().await; - let node = offline_node_with_wallet(&dir.path().join("bob"), Arc::new(DialOk), wallet); - chain_source_at(&node, &daemon); + let node = offline_node_with_wallet( + &dir.path().join("bob"), + Arc::new(DialOk), + mock_wallet().await, + ); let peer = Keys::generate(); let addr = xmr_addr(); { @@ -3510,7 +2997,6 @@ pub(crate) mod tests { let peer = Keys::generate(); let old_identity = node.identity_pk(); let old_prekey = node_prekey(&node); - let old_kem = node_kem_pk(&node); *node.onion.lock().unwrap() = format!("{}.onion", "a".repeat(56)); { let store = node.store.lock().unwrap(); @@ -3524,11 +3010,6 @@ pub(crate) mod tests { assert_ne!(new_prekey, old_prekey, "the prekey must actually change"); assert_eq!(node_prekey(&node), new_prekey, "the live keys follow"); - assert_ne!( - node_kem_pk(&node), - old_kem, - "F8 rotates the ML-KEM key with the prekey" - ); assert_eq!( node.identity_pk(), old_identity, @@ -3541,11 +3022,6 @@ pub(crate) mod tests { new_prekey.to_vec(), "the self row carries the new prekey" ); - assert_eq!( - store.self_identity().unwrap().kem_pk, - node_kem_pk(&node).to_vec(), - "the self row carries the rotated KEM key" - ); assert!( store.load_ratchet(&peer.identity_pk).unwrap().is_none(), "the bootstrap epoch is prekey-bound, so the stored state is stale" @@ -3554,11 +3030,6 @@ pub(crate) mod tests { let payload = qr::decode(&node.qr_payload().expect("re-encode the invite")) .expect("the re-encoded invite decodes"); assert_eq!(payload.signed_prekey, new_prekey.to_vec()); - assert_eq!( - payload.kem_pk.as_deref(), - Some(&node_kem_pk(&node)[..]), - "the new invite carries the rotated KEM key" - ); assert_eq!( payload.pubkey, old_identity.to_vec(), @@ -3573,9 +3044,11 @@ pub(crate) mod tests { #[tokio::test] async fn outbound_tip_records_a_tip_payment_row() { let dir = tempfile::tempdir().unwrap(); - let (wallet, daemon) = mock_wallet().await; - let node = offline_node_with_wallet(&dir.path().join("bob"), Arc::new(DialOk), wallet); - chain_source_at(&node, &daemon); + let node = offline_node_with_wallet( + &dir.path().join("bob"), + Arc::new(DialOk), + mock_wallet().await, + ); let peer = Keys::generate(); let addr = xmr_addr(); { @@ -3790,62 +3263,23 @@ pub(crate) mod tests { } } - /// A chain-daemon stub on an ephemeral loopback port: `GET /get_height` - /// answers the tip, `/json_rpc get_info` answers height/target. Returns - /// `host:port`. - async fn mock_daemon(height: u64, target: u64) -> String { - use tokio::io::{AsyncReadExt, AsyncWriteExt}; - - let listener = tokio::net::TcpListener::bind("127.0.0.1:0") - .await - .expect("bind mock daemon"); - let addr = listener.local_addr().expect("mock daemon addr").to_string(); - tokio::spawn(async move { - while let Ok((mut sock, _)) = listener.accept().await { - let mut buf = vec![0u8; 4096]; - let Ok(n) = sock.read(&mut buf).await else { - return; - }; - if n == 0 { - continue; - } - let req = String::from_utf8_lossy(&buf[..n]).to_string(); - let body = if req.starts_with("GET /get_height") { - format!(r#"{{"height":{height}}}"#) - } else { - format!( - r#"{{"jsonrpc":"2.0","id":"0","result":{{"height":{height},"target_height":{target}}}}}"# - ) - }; - let _ = sock - .write_all( - format!( - "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}", - body.len() - ) - .as_bytes(), - ) - .await; - } - }); - addr - } - /// A loopback wallet RPC that answers the *status* probe: a digest - /// challenge, then `get_address` / `get_balance` / `get_height`, with the - /// wallet's own scanned height. Returns the wallet and the daemon stub's - /// address — the tip comes from the daemon, never from the wallet RPC. - /// [`mock_wallet`] above answers the *transfer* path; this one answers a - /// refresh, which never transfers. - async fn mock_syncing_wallet(height: u64, target: u64) -> (Wallet, String) { + /// challenge, then `get_address` / `get_balance` / `get_info`, with the + /// chain numbers a syncing daemon reports. [`mock_wallet`] above answers the + /// *transfer* path; this one answers a refresh, which never transfers. + /// A loopback wallet RPC that answers the *status* probe: a digest + /// challenge, then `get_address` / `get_balance` / `get_info`, with the + /// chain numbers a syncing daemon reports. [`mock_wallet`] above answers the + /// *transfer* path; this one answers a refresh, which never transfers. + async fn mock_syncing_wallet(height: u64, target: u64) -> Wallet { let listener = tokio::net::TcpListener::bind("127.0.0.1:0") .await .expect("bind mock wallet"); let port = listener.local_addr().expect("mock wallet addr").port(); let reply: Arc String + Send + Sync> = Arc::new(move |req: &str| { - if req.contains("get_height") { + if req.contains("get_info") { format!( - r#"{{"jsonrpc":"2.0","id":"0","result":{{"height":{height}}}}}"# + r#"{{"jsonrpc":"2.0","id":"0","result":{{"height":{height},"target_height":{target},"synchronized":true}}}}"# ) } else if req.contains("get_address") { format!( @@ -3857,10 +3291,7 @@ pub(crate) mod tests { } }); tokio::spawn(serve_mock_rpc(listener, reply)); - let wallet = - Wallet::from_url(&format!("http://ow:secret@127.0.0.1:{port}")).expect("wallet url"); - let daemon = mock_daemon(height, target).await; - (wallet, daemon) + Wallet::from_url(&format!("http://ow:secret@127.0.0.1:{port}")).expect("wallet url") } /// Point `node`'s wallet client at a mock. The child process stays whatever @@ -3869,14 +3300,13 @@ pub(crate) mod tests { *node.wallet.lock().expect("wallet") = wallet; } - /// Like [`mock_syncing_wallet`], but the wallet's scanned `height` is read on - /// every `get_height`, so a later store is a later answer. The daemon stub - /// reports `target` as its tip. Returns the wallet and the daemon address so - /// a caller can point a chain source at it. + /// Like [`mock_syncing_wallet`], but `height` is read on every `get_info`, + /// so a later store is a later answer. `synchronized` stays false: the + /// status line is a syncing chain, not a caught-up one. pub(crate) async fn mock_wallet_at( height: std::sync::Arc, target: u64, - ) -> (Wallet, String) { + ) -> Wallet { use std::sync::atomic::Ordering; let listener = tokio::net::TcpListener::bind("127.0.0.1:0") @@ -3884,9 +3314,11 @@ pub(crate) mod tests { .expect("bind mock wallet"); let port = listener.local_addr().expect("mock wallet addr").port(); let reply: Arc String + Send + Sync> = Arc::new(move |req: &str| { - if req.contains("get_height") { + if req.contains("get_info") { let h = height.load(Ordering::Relaxed); - format!(r#"{{"jsonrpc":"2.0","id":"0","result":{{"height":{h}}}}}"#) + format!( + r#"{{"jsonrpc":"2.0","id":"0","result":{{"height":{h},"target_height":{target},"synchronized":false}}}}"# + ) } else if req.contains("get_address") { r#"{"jsonrpc":"2.0","id":"0","result":{"address":"4test"}}"#.to_string() } else { @@ -3894,10 +3326,7 @@ pub(crate) mod tests { } }); tokio::spawn(serve_mock_rpc(listener, reply)); - let wallet = - Wallet::from_url(&format!("http://ow:secret@127.0.0.1:{port}")).expect("wallet url"); - let daemon = mock_daemon(target, target).await; - (wallet, daemon) + Wallet::from_url(&format!("http://ow:secret@127.0.0.1:{port}")).expect("wallet url") } /// A loopback daemon that answers `get_info` on the port the child probes @@ -3935,12 +3364,12 @@ pub(crate) mod tests { Some(()) } - /// The status row carries the real chain numbers: the wallet RPC's own - /// `get_height` is the wallet's scanned height, and the daemon's tip is the - /// target. A daemon that reports no separate target still gives a tip, so - /// `h/h` is the honest line — never an invented percentage. + /// The status row carries the real chain numbers: a wallet RPC that answers + /// `get_info` fills height and target, and the one-liner shows them. A + /// daemon that reports no target is not a caught-up chain — `h/0` with no + /// invented percentage. #[tokio::test] - async fn the_wallet_height_and_the_daemon_tip_fill_the_chain_progress() { + async fn a_wallet_that_answers_get_info_fills_the_chain_progress() { let dir = tempfile::tempdir().unwrap(); let node = offline_node(&dir.path().join("child"), Arc::new(NoDial)); let log = dir.path().join("argv.log"); @@ -3957,16 +3386,14 @@ pub(crate) mod tests { let _hold = PublishedPortHold::watching(std::slice::from_ref(&log)); node.start_wallet_child().expect("start"); // The child is a fake process; the wallet the node actually talks to is - // the mock RPC, and the tip comes from the daemon stub. - let (wallet, daemon) = mock_syncing_wallet(4549, 0).await; - *node.wallet.lock().unwrap() = wallet; - chain_source_at(&node, &daemon); + // the mock RPC, which is where the numbers come from. + *node.wallet.lock().unwrap() = mock_syncing_wallet(4549, 0).await; let status = node.wallet_child_refresh().await; assert_eq!(status.state, WalletChildState::Ready, "{status:?}"); assert_eq!(status.height, 4549, "{status:?}"); - assert_eq!(status.target_height, 4549, "{status:?}"); - assert!(status.line().contains("sync 4549/4549"), "{}", status.line()); + assert_eq!(status.target_height, 0, "{status:?}"); + assert!(status.line().contains("sync 4549/0"), "{}", status.line()); assert!(!status.line().contains('%'), "{}", status.line()); node.stop_wallet_child().expect("stop"); @@ -4416,10 +3843,7 @@ pub(crate) mod tests { let err = node .start_wallet_child() .expect_err("a missing binary fails"); - // The refusal names the configured path: the old `spawn