Skip to content

Pair from a pasted in-person link once its host's device id is confirmed - #59

Merged
TheAnimatrix merged 2 commits into
mainfrom
confirmed-link-arrival
Nov 30, 2026
Merged

TheAnimatrix merged 2 commits into
mainfrom
confirmed-link-arrival

Conversation

@TheAnimatrix

@TheAnimatrix TheAnimatrix commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

An in-person (kind 1) ticket pairs only from an in-app scan. A pasted link of one is refused (pairing_failed), because a link can be swapped on its way. The app needs a way to pair from a pasted code-free link without passing it off as a scan.

Change

A pasted in-person link pairs once the person has confirmed its host's short device id against the host's screen.

  • join, join.check, join.probe: these take arrival: "link" with confirmed, the host's short device id the person confirmed. That id is the first 8 bytes of the host key's fingerprint, as 16 hex digits; spaces, dashes and case are ignored.
    • The helper admits the kind-1 ticket only when that id is the ticket's host's, and then joins it as a scan.
    • A plain link stays refused, and so does one confirmed with any other id. Both get pairing_failed before anything is dialled.
    • confirmed with arrival: "scan", or one that is not a string, is bad_request.
  • join.check: the reply adds host_device (the ticket host's short id) and needs_confirm. needs_confirm is true for an in-person link with no confirmed yet. Such a link is inspected as the scan it becomes, so the app can show the id before the person confirms; join and join.probe still refuse it until then.
  • Feature confirmed-link: listed in the 1.2 hello, so an app knows it may send confirmed.
  • Spec: spec/wire.md §10.1 gives the exact join.check and join requests. Both screens show all 16 digits; the app shows the link's unsigned n apart from the id, labelled as the name the link gives. It also says why a swapped link cannot pass: matching a chosen 64-bit id is a second-preimage search of the fingerprint. A join with no arrival still counts as a scan, so the app must send "arrival": "link" for every link that did not come from its own scanner. spec/privacy.md and the feature table in docs/pairing-flow-design.md name confirmed-link; §4 documents the new fields and the check.

The ticket carries no name, so the host's name stays the app's: the unsigned n in the link. Only the id is checked.

Checks

  • New check pairing-flow.confirmed-link runs crates/mousse-helper/tests/app_confirmed_link.rs:
    • The host's own hello.device is exactly 16 lowercase hex digits and equals the joiner's host_device. Confirmed with it, grouped and in capitals as read off a screen, join.probe reaches the host and join pairs.
    • A plain link, another real device's id, and a made-up id are each refused by join and join.probe, with no connection.
    • Malformed confirmed is bad_request.
  • New must-fail control confirmed-link-any-id takes any confirmed id as the host's. Its test fails under it, and so does the existing link-accepts-kind1. That control leaves pairing-flow.join-check, where a plain link now previews.
  • app_join_check.rs: an unconfirmed pasted link now reports needs_confirm and host_device instead of pairing_failed. A wrong id is still pairing_failed, and the right one clears needs_confirm.

How to review

crates/mousse-helper/src/app/pairing.rs: came_from and admit. Then check.rs and probe.rs, which use them.

Verification

On Windows x64 (MSVC toolchain), all passed:

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace
  • cargo check -p mousse-net-core --target wasm32-unknown-unknown

These all passed again at the head, after the review fixes.

The success test also fails when hello.device comes from another function, and when short_id is cut to 6 bytes (both tried locally).

Controls, run locally:

  • confirmed-link-any-id fails app_confirmed_link (1 of 3).
  • link-accepts-kind1 fails app_confirmed_link (1 of 3).

The core library and the wire are unchanged (Arrival stays scan or link, and the vectors are untouched), so the second implementation in interop/second-impl-ts needs no change.

Refs mousse-agent/mousse#1510

… 16-digit id, and the name is the link's own; the test compares the host's own hello.device

wire.md 10.1 gives the join.check and join requests, says the app labels the unsigned n as the link's name and shows all 16 digits of host_device apart from it, and that every link not from the app's own scanner must say arrival link. privacy.md and the feature table name confirmed-link. app_confirmed_link reads the host's hello.device, checks it is 16 lowercase hex digits, compares it with host_device, and pairs and probes with it as read off a screen. link-accepts-kind1 leaves the join-check entry, where a plain link now previews.
@TheAnimatrix
TheAnimatrix merged commit d5b17f0 into main Nov 30, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant