Skip to content

feat: per-operation signature verification and transitive vouching#163

Merged
careck merged 7 commits intomasterfrom
feat/per-op-verification
Apr 25, 2026
Merged

feat: per-operation signature verification and transitive vouching#163
careck merged 7 commits intomasterfrom
feat/per-op-verification

Conversation

@careck
Copy link
Copy Markdown
Member

@careck careck commented Apr 25, 2026

Summary

Implements #150 — per-operation Ed25519 signature verification and transitive vouching for delta sync.

  • Schema: Added verified_by TEXT NOT NULL DEFAULT '' column to operations table (with migration for existing DBs)
  • Self-authored ops: verified_by is populated with the workspace identity pubkey on INSERT
  • Delta payload: New DeltaOperation wrapper struct around Operation carrying optional verified_by metadata
  • Receiver verification: apply_incoming_operation now verifies Ed25519 signatures for sender-authored ops and validates vouches for relayed ops. Unvouched relayed ops are rejected.
  • Sender vouching: generate_delta queries verified_by from the DB and wraps ops with appropriate vouching metadata: self-authored ops get None (receiver verifies directly), previously-verified ops get re-vouched with sender's key
  • Full chain test: A→B→C integration test verifying the complete trust chain

Closes #150

Test plan

  • 626 tests pass (cargo test -p krillnotes-core)
  • TypeScript compiles (npx tsc --noEmit)
  • Code formatted (cargo fmt --check)
  • Manual test: two-peer delta sync still works
  • Manual test: three-peer relay chain propagates ops

careck added 7 commits April 25, 2026 10:04
Add schema column and migration for per-operation verification tracking.
The column stores the base64 public key of the identity that verified
(authored or validated) each operation. Defaults to empty string for
backward compatibility with existing operations.
OperationLog now carries the identity pubkey and stamps it into
verified_by on every INSERT. Both workspace constructors (create/open)
pass the identity's base64 public key to OperationLog::new, so all
locally-authored operations are immediately marked as verified.
Introduce DeltaOperation struct wrapping Operation with an optional
verified_by field for per-op verification. Rename operations ->
delta_operations throughout DeltaParams, ParsedDelta, and all callers
in swarm/sync.rs, sync/mod.rs, and receive_poll.rs. Ops are wrapped
with verified_by: None for now (Task 6 adds real vouching logic).
Add per-operation verification to apply_incoming_operation:
- Sender-authored ops: verify Ed25519 signature against sender identity
- Relayed ops with vouch: accept if verified_by matches sender identity
- Relayed ops without vouch: reject
- RetractOperation (empty author_key): accept only if vouched by sender

Update all callers (swarm/sync, folder sync, relay poll) to pass
delta_op.verified_by and sender_public_key through to verification.
Update INSERT to persist resolved verified_by. Add 7 new tests covering
valid signatures, tampered ops, vouched relays, unvouched relays,
vouch mismatches, and retract op vouching.
Simulates multi-hop delta propagation: A creates and signs an op,
sends to B without vouch; B verifies A's signature and re-sends to C
with verified_by set, proving the vouch chain round-trips correctly
through the delta bundle codec.

Also applies cargo fmt to sync.rs.
Add verified_by column to OperationSummary, resolve pubkeys to display
names in the Tauri command layer, and show the value in both the
operations list/detail views and the note metadata panel. Includes
new get_note_verified_by Tauri command and i18n keys for all 7 locales.
@careck careck merged commit 531552b into master Apr 25, 2026
1 of 2 checks passed
@careck careck deleted the feat/per-op-verification branch April 28, 2026 04:31
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.

Per-operation signature verification and transitive vouching

1 participant