feat(train): the person's key on Train's devices (ADR 0030, D15)

TrainKeys holds the one key everything of Train's is sealed with: made
on the first write where the account's keys are, kept in the synced
content_key rows sealed to the account, opened on the person's other
devices. Only keys sealed under Train's own IDs open, so the instance
can't relabel one, and a key the account sealed for another app never
counts; two devices that each made one offline write with the older. A
device without the account's keys opens and writes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-28 11:17:26 +01:00
commit 61fc5c5f7c
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -0,0 +1,19 @@
import 'dart:typed_data';
import 'package:halkyon_train_flutter/src/core/privacy/content_key_gateway.dart';
/// [ContentKeyGateway] in memory, which tests share between "devices" as the
/// sync engine would, and change as an instance could.
class MemoryContentKeyGateway() implements ContentKeyGateway {
/// The rows, as the instance holds them.
final rows = <ContentKeyRow>[];
@override
Future<List<ContentKeyRow>> all() async => List.of(rows);
@override
Future<void> insert({
required String dataKeyId,
required Uint8List sealedKey,
}) async => rows.add((dataKeyId: dataKeyId, sealedKey: sealedKey));
}