Skip to content

feat(r9cam): accept EdDSA device tokens - #521

Merged
simonvanlierde merged 3 commits into
mainfrom
r9cam-eddsa-device-tokens
Nov 15, 2026
Merged

simonvanlierde merged 3 commits into
mainfrom
r9cam-eddsa-device-tokens

Conversation

@simonvanlierde

@simonvanlierde simonvanlierde commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

This lets r9cam cameras sign their device tokens with EdDSA as well as ES256. Fixes #501.

  • Each camera may use only the algorithm of the key it paired with: an EC P-256 key means ES256, an OKP Ed25519 key means EdDSA. The stored JWK already holds the key type, so no migration is needed.
  • r9cam-models goes to 0.7.0, whose DevicePublicKeyJWK accepts Ed25519 keys. r9cam 0.8.0 pairs with Ed25519 by default, so this needs to be deployed before that release.

Tested: just backend/check passes, and the backend unit and integration tests pass, 2242 tests. The three new assertion tests failed against the old code, and the Ed25519 pairing test failed on the 0.6 pin.

Not checked: nothing beyond CI.

Device assertions were ES256 only (ASSERTION_ALGORITHMS = ("ES256",)), so a camera could not move to an Ed25519 key. The backend now accepts ES256 and EdDSA, and each camera may sign only with the algorithm its registered key implies: EC P-256 for ES256, OKP Ed25519 for EdDSA. The stored JWK already records the key type, so no migration is needed.

Pairing an Ed25519 camera also needs r9cam-models 0.7.0, whose DevicePublicKeyJWK accepts OKP keys; the relock follows once it is on PyPI.

Not tested: the database integration tests (pairing and relay flows) did not run locally.

Fixes #501

Signed-off-by: Simon van Lierde <90462640+simonvanlierde@users.noreply.github.com>
r9cam-models 0.7.0 lets DevicePublicKeyJWK carry an Ed25519 (OKP) key, which r9cam 0.8 pairs with by default. Under 0.6 pairing such a Pi failed with a ValidationError on PairingRegisterRequest.

- The OpenAPI exports and the generated frontend API types pick up the wider JWK schema; `y` is optional now, and no frontend code reads the JWK.
- A pairing test registers an Ed25519 key.

Signed-off-by: Simon van Lierde <90462640+simonvanlierde@users.noreply.github.com>
@codspeed

codspeed Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ Upgrade your CodSpeed plugin for Python 3.15

pytest-codspeed 5.0.3 is only tested on Python 3.9, 3.10, 3.11, 3.12, 3.13, and 3.14, so your Python 3.15 measurements may be inaccurate. Upgrade pytest-codspeed to 5.0.4 or later.

See affected benchmarks

✅ 7 untouched benchmarks


Comparing r9cam-eddsa-device-tokens (ca23578) with main (393bf21)

Open in CodSpeed

r9cam-models 0.7.0 types RelayPublicKeyJWK.alg as Literal["ES256", "EdDSA"], so unpacking a dict[str, str] into it fails ty with invalid-argument-type in backend/check.

Signed-off-by: Simon van Lierde <90462640+simonvanlierde@users.noreply.github.com>
@simonvanlierde
simonvanlierde merged commit 8cedfaa into main Nov 15, 2026
25 checks passed
@simonvanlierde
simonvanlierde deleted the r9cam-eddsa-device-tokens branch November 15, 2026 18:33
@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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.

Accept ES256 and EdDSA device tokens (algorithm agility)

1 participant