Skip to content

feat(identity): add authentication keys bound to a contract - #1123

Draft
Claudius-Maginificent wants to merge 10 commits into
feat/identity-key-limitsfrom
feat/contract-bound-auth-keys
Draft

Claudius-Maginificent wants to merge 10 commits into
feat/identity-key-limitsfrom
feat/contract-bound-auth-keys

Conversation

@Claudius-Maginificent

@Claudius-Maginificent Claudius-Maginificent commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR: On networks that accept them, you can add an authentication key below MASTER that signs only for one contract or one document type. Combined with #1120's spending limit and expiry, this lets you hand an app a key that cannot act anywhere else.

Stacked atop #1120.

User story

As a user handing a key to an app or a helper, I want to limit that key to one contract or document type, so that a leaked key cannot act on anything else (IDN-022, contract-bounds criterion).

Scenario

  1. On testnet, Priya opens Add Key, picks AUTHENTICATION at HIGH, and chooses "limited to contract X" (or "limited to document type note of contract X").
  2. She can add a spending limit and an expiry too.
  3. The key is added with those contract bounds. fix(identity): choose signing keys Platform accepts on protocol 14 #1117's key selection then uses it only for actions in that scope, and leaves it out of the manual chooser elsewhere.

On a network that does not accept bound authentication keys, AUTHENTICATION is not offered for a contract-bound key, and the backend refuses one before anything is sent.

Detailed discussion

  • Gate: the ContractBoundAuthenticationKeys capability opens where upstream's validate_identity_public_key_contract_bounds validation version is at least 2. Upstream names no feature constant for this, so the validation version is the source of truth. As with every protocol capability, it stays closed until the network's protocol version is proven, and on a version this build does not define.
  • Rule: model::identity_key_limits::contract_bounds_allowed holds the rule:
    • encryption and decryption keys may always be bound, per the contract's own rules;
    • authentication keys may be bound only below MASTER, and only where the network admits it;
    • other purposes may never be bound.
  • Where the rule is enforced:
    • Add Key uses the rule to decide whether to offer AUTHENTICATION for a bound key.
    • add_key_to_identity enforces it again before prompting or broadcasting. A key that may never be bound (a MASTER or transfer key) gets TaskError::KeyCannotBeBound. A bound authentication key on a network that does not accept one yet gets TaskError::ContractBoundAuthenticationKeysNotSupported. Each message says what to do.
  • Key version: a bound key goes through feat(identity): add keys with spending limits and raise key limits #1120's key_with_limits, so it keeps its bounds either way. Without limits it is a version 0 key; with limits it is a version 1 key.

Testing

  • Library tests and UI tests (kittest) pass.
  • cargo clippy --all-features --all-targets -- -D warnings and cargo fmt --all -- --check pass.
  • New tests cover:
    • the bounds rule for each purpose, level and network;
    • the backend refusals: a bound authentication key on protocol 13, and a MASTER or transfer bound key on protocols 13 and 14;
    • a bound key keeping its bounds with and without limits;
    • the capability gate, closed at boot and on 13, open on 14.
  • No live network or GUI flows were run.

🤖 Co-authored by Claudius the Magnificent AI Agent

🤖 Generated with Claude Code

https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q

lklimek and others added 3 commits October 24, 2026 20:20
Where contract bounds validation is at version 2 or later
(ContractBoundAuthenticationKeys capability), an AUTHENTICATION key
below MASTER may be bound to one contract or document type. The rule
lives in contract_bounds_allowed; adding a key enforces it before
prompting or broadcasting and refuses a bound authentication key on a
network that does not admit one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
With contract bounds enabled, Add Key offers AUTHENTICATION where the
network admits bound authentication keys, and a bound key may carry a
spending limit and an expiry too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@coderabbitai

coderabbitai Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

🕓 Review not started yet because this PR is a draft.

  • Request normal review — click when the PR is ready for review.
  • Request priority review — click to move this review to the front of the queue.

Commit 048dba0. Normal review starts when eligible; priority review starts as soon as a slot is available.

lklimek and others added 7 commits October 25, 2026 11:23
… branch

Resolves the imports and the identity_key_limits doc conflict, and moves
the contract-bound refusal test to the shared test identity, since the
key limits test helper it used is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
The backend answered every refused contract-bound key with advice to
wait for a network upgrade, which is wrong for a MASTER or transfer key
that no network lets carry contract bounds. Such a key now gets its own
message, and the upgrade advice stays for a bound authentication key on
a network that does not accept one yet. The identity_key_limits module
doc names the contract bounds rule it holds, and a test pins that a
bound key keeps its bounds, with or without limits, in the version its
limits call for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…ys branch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…ntract-bound keys branch

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…version

The Platform bump removed DET's own protocol version copy; the capability
and its test now read the version the network has proven.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
…-keys

Brings in the v1.0-dev squash of #1114; the tree is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ujJpB9DBhvtbjhYB3aG9Q
@Claudius-Maginificent Claudius-Maginificent added priority: low Low priority — nice to have priority: medium Medium priority and removed priority: low Low priority — nice to have priority: medium Medium priority labels Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: low Low priority — nice to have

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants