Skip to content

Replace trust_level with boolean paired - #138

Closed
maximmaxim345 wants to merge 3 commits into
mainfrom
refactor/trust-level-paired
Closed

maximmaxim345 wants to merge 3 commits into
mainfrom
refactor/trust-level-paired

Conversation

@maximmaxim345

@maximmaxim345 maximmaxim345 commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

In a previous draft we had 3 trust levels: none, user, and owner. With only 2 left, a boolean paired says the same thing, and it keeps "trust level" jargon out of server and client UIs.

Keeping the field means the client can still correct a server whose own view of the pairing state has gone stale, which the matched PSK alone does not always reveal.

Warning

This is a breaking change for servers and clients.

Alternative to #158, which deletes the field entirely on top of per-category psk_id derivation labels.

Closes #140

@maximmaxim345

maximmaxim345 commented Aug 18, 2026 •

Copy link
Copy Markdown
Member Author

Marked this PR as draft for now since #140 looks like an even better solution.

@maximmaxim345

Copy link
Copy Markdown
Member Author

Superseded by #158

@maximmaxim345 maximmaxim345 reopened this Aug 27, 2026
@maximmaxim345
maximmaxim345 force-pushed the refactor/trust-level-paired branch from 39f98ec to dcdd044 Compare August 27, 2026 13:05
@maximmaxim345
maximmaxim345 marked this pull request as ready for review August 27, 2026 13:05
arturpragacz added a commit that referenced this pull request Aug 28, 2026
The server already knows which PSK matched during the Noise handshake,
so it can derive whether the session is paired instead of taking the
client's word for it. Nothing consumed the field: every enforcement rule
already keys on the matched PSK.

One gap made the field load-bearing until now: a management server could
remove a record and then set its PSK as the client's pairing PSK, and
the original server's next handshake would complete with the two sides
disagreeing about the matched category - `trust_level` was the only
signal exposing that. This PR therefore adds `psk_category: 'lt' | 'pr'
| 'sn'` to the Noise message 1 payload: the server declares which
category it is using the referenced PSK as, and the client matches
`psk_id` only among candidates of that category. A recategorized
credential is now an ordinary lookup miss that lands in the Sentinel
fallback, which already tells the server to re-pair, so paired state is
fully derivable on both sides and the field can go. A miss during a
re-handshake instead fails the handshake as before; the server's
reconnect then takes the initial-handshake fallback path.

Design notes: a category mismatch is deliberately a miss rather than a
hard failure - the fallback turns it into an authenticated
credential-mismatch signal with the re-pair path attached, where a hard
failure would just produce a mute reconnect loop. The three codes share
one length, keeping the encrypted payload's length independent of the
category. The `psk_id` derivation, the published Sentinel constant, and
the `already_exists` guards are all unchanged; the cross-category
uniqueness rule stays, its rationale restated as what it actually
protects (the pairing token distributes the pairing PSK in cleartext, so
the same bytes must not also back a record).

This PR also rewords the "trust level" term in the spec. This was a left
over from when we had 3 (the additional owner level, whose management
rights were merged into the user level - now called just paired).

`unpaired_access.enabled` remains because it is genuine client policy
the server cannot derive.

## Breaking change

Existing pairing records and `psk_id`s are untouched, so deployed
pairings keep working. Breaking only when a client is updated before its
server: an updated client requires `psk_category` in Noise message 1 and
no longer sends `trust_level`, both of which an old server trips on. The
reverse order is safe: receivers ignore unrecognized payload fields, so
an updated server interoperates with old clients, which then simply
don't enforce the category check.

---

Closes #140

Alternative to #138, which keeps the field as a boolean `paired`
instead.

---------

Co-authored-by: Artur Pragacz <49985303+arturpragacz@users.noreply.github.com>
@maximmaxim345

Copy link
Copy Markdown
Member Author

Closing since #158 was merged.

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.

Delete trust_level from client/hello instead of renaming it — the server already derives it from the matched PSK

1 participant