[vault] Licences: the domi-licence key, the strict payload parser, the licence grant (0.21.0) #29

Merged
mnovak merged 2 commits from feature/licence into main 2026-11-30 07:17:14 +01:00
Owner

Atrium Domi's Day 2 (Mark's decision): paid Domi licences are signed automatically after payment, under a scoped grant, with no card each time. The byte format is Fundamentum docs/LICENCE.md (licence v1, atrium-v0.4.0). This core does the signing.

What

  • licence.rs (new):
    • The key domi-licence: Ed25519, made by Mark's click, never exported. Only its 32-byte public key leaves.
    • It's stored as an ordinary Ed25519 entry (release, no scope, no minisign id), so cores before 0.21.0, the phone and the web vault, still open the vault and can never sign with it.
    • It signs plain Ed25519 over the exact payload: custos_sign::ed25519_plain, ed25519-dalek, no custom crypto.
    • parse_payload is the spec's strict parser on a payload: �2.4 steps 1�4 and 7 for a licence, �4.1 for a revocation list, with the spec's error codes. Caps are 4004 and 61 348 bytes, the file caps minus the sig: line, so every signed file passes the service's size check.
    • The licence grant (licence_grant_set / _revoke, Mark's click, standing-granted / standing-revoked) holds an allowlist of app ids.
    • licence_ask(payload, Caller { app, domi_signed }, now):
      • refused with no card: malformed, no key, a caller other than licence-issue, issued more than 24 h from this clock, a licence id signed before (replay), a revocation seq not above the highest signed (rollback), a full log;
      • a card: a revocation list always; a licence when there's no grant, the program isn't Domi-signed (or unknown), Sign only with a card is ticked, an app is off the allowlist, or 50 were signed in 24 h;
      • otherwise the grant signs it.
    • licence_sign checks again, signs, and logs time, how, the licence id and its apps, or the seq and count. It never logs the signature, the payload or the nickname.
  • signing.rs:
    • The store's licence member, which older cores ignore and drop on save. The grant is then gone (fail closed) and the key stays.
    • Load-time checks of the licence key's shape.
    • The reserved id is refused by check(), set_scope and the Android key form.
  • custos-sign: ed25519_plain.
  • docs/SIGNING.md: "Domi licences (core 0.21.0)" and the API lines.
  • Version: 0.21.0.

Tests

  • cargo test --workspace: 291 passed, 0 failed.
  • New in licence::tests (7):
    • the spec example and UTC parsing;
    • every malformed payload refused with its spec code;
    • revocation-list parsing;
    • the grant signs an allowed licence, the signature verifies with verify_strict over the exact payload, and the same id again is a replay;
    • off-allowlist, unsigned program and the cap each ask on a card, and the cap frees after a day;
    • refused without a card: another caller, a bad clock either way, rollback;
    • the licence key signs nothing else, its scope can't be set, and key, grant and log survive a save and reopen.

Self-review

  • Compatibility: no new KeyKind, SignKind or Outcome variant, so older cores parse the vault unchanged. The new state sits in an optional member.
  • Security: the key's secret is used only in signing.rs's licence_signature. Every refusal carries a code, never bytes. The service's own anti-rollback check (LICENCE.md �4.2) is the second line if an older vault is restored.
  • Atrium confirmed the stricter caps.
Atrium Domi's Day 2 (Mark's decision): paid Domi licences are signed automatically after payment, under a scoped grant, with no card each time. The byte format is Fundamentum `docs/LICENCE.md` (licence v1, atrium-v0.4.0). This core does the signing. ## What - **`licence.rs` (new):** - The key `domi-licence`: Ed25519, made by Mark's click, never exported. Only its 32-byte public key leaves. - It's stored as an ordinary Ed25519 entry (release, no scope, no minisign id), so cores before 0.21.0, the phone and the web vault, still open the vault and can never sign with it. - It signs plain Ed25519 over the exact payload: `custos_sign::ed25519_plain`, ed25519-dalek, no custom crypto. - `parse_payload` is the spec's strict parser on a payload: �2.4 steps 1�4 and 7 for a licence, �4.1 for a revocation list, with the spec's error codes. Caps are 4004 and 61 348 bytes, the file caps minus the `sig:` line, so every signed file passes the service's size check. - The licence grant (`licence_grant_set` / `_revoke`, Mark's click, `standing-granted` / `standing-revoked`) holds an allowlist of app ids. - `licence_ask(payload, Caller { app, domi_signed }, now)`: - refused with no card: malformed, no key, a caller other than `licence-issue`, `issued` more than 24 h from this clock, a licence id signed before (`replay`), a revocation `seq` not above the highest signed (`rollback`), a full log; - a card: a revocation list always; a licence when there's no grant, the program isn't Domi-signed (or unknown), *Sign only with a card* is ticked, an app is off the allowlist, or 50 were signed in 24 h; - otherwise the grant signs it. - `licence_sign` checks again, signs, and logs time, how, the licence id and its apps, or the seq and count. It never logs the signature, the payload or the nickname. - **`signing.rs`:** - The store's `licence` member, which older cores ignore and drop on save. The grant is then gone (fail closed) and the key stays. - Load-time checks of the licence key's shape. - The reserved id is refused by `check()`, `set_scope` and the Android key form. - **`custos-sign`:** `ed25519_plain`. - **docs/SIGNING.md:** "Domi licences (core 0.21.0)" and the API lines. - **Version:** 0.21.0. ## Tests - `cargo test --workspace`: 291 passed, 0 failed. - New in `licence::tests` (7): - the spec example and UTC parsing; - every malformed payload refused with its spec code; - revocation-list parsing; - the grant signs an allowed licence, the signature verifies with `verify_strict` over the exact payload, and the same id again is a replay; - off-allowlist, unsigned program and the cap each ask on a card, and the cap frees after a day; - refused without a card: another caller, a bad clock either way, rollback; - the licence key signs nothing else, its scope can't be set, and key, grant and log survive a save and reopen. ## Self-review - Compatibility: no new `KeyKind`, `SignKind` or `Outcome` variant, so older cores parse the vault unchanged. The new state sits in an optional member. - Security: the key's secret is used only in `signing.rs`'s `licence_signature`. Every refusal carries a code, never bytes. The service's own anti-rollback check (LICENCE.md �4.2) is the second line if an older vault is restored. - Atrium confirmed the stricter caps.
mnovak added 2 commits 2026-11-30 07:17:01 +01:00
The key that signs Domi licences and revocation lists (Fundamentum docs/LICENCE.md, licence v1): Ed25519 under
the reserved id domi-licence, no scope, refused by every other signing path, signing plain Ed25519 over the exact
payload. The payload is parsed first, as the spec's strict parser does (section 2.4 steps 1-4 and 7, section 4.1),
and a malformed one is refused with the spec's code and no card. The licence grant (Mark's click) signs a licence
from licence-issue whose apps are on the allowlist, within 50 a day, without a card; anything else that is well
formed asks on a card, a revocation list always. Refused outright: a licence dated more than a day from this clock,
a licence id signed before (replay), a seq not above the highest signed (rollback), any other caller. The grant and
the log live in signing.licence, which older cores ignore; the key is an ordinary Ed25519 entry every core reads.

Not compiled or tested yet: the PC is over Mark's 90 % rule.
mnovak merged commit f622bd283c into main 2026-11-30 07:17:14 +01:00
mnovak deleted branch feature/licence 2026-11-30 07:17:14 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/CustosPublic#29