Package-level declarations

Types

Link copied to clipboard
sealed interface FakeKeyOperation

The operation a FakeKeyScheme is about to run, as its before hook sees it. The arrays are the caller's own, not copies: read them, do not change them.

Link copied to clipboard
class FakeKeyScheme(random: Random, before: suspend (FakeKeyOperation) -> Unit = {}) : KeyScheme

A KeyScheme for tests: it makes keys, reads keys, signs and checks without ever waiting on the platform's cryptographic provider, so a room test on wasmJs stays on virtual time. Anyone can forge its signatures: a signature is SHA-512 of a fixed tag, the key's compressed point and the message.

Link copied to clipboard
@RequiresOptIn(message = "A fake key scheme whose signatures anyone can compute. For tests only; never use it in production.", level = RequiresOptIn.Level.ERROR)
annotation class TestOnlyKeyScheme

Marks the fake key scheme, which is for tests only. A room built on it accepts signatures anyone can compute.

Functions

Link copied to clipboard

The fixed fake key numbered index, made without suspending: the same key in every run and on every target, so a hand-built frame, a seeded roster or a golden vector can name it. It signs at once, with no hook; FakeKeyScheme.key makes the same key with its scheme's hook. Distinct indices are distinct keys.

Link copied to clipboard
fun fakeDidKey(index: Int): DidKey

The name of fakeDeviceKey(index), made without suspending: a syntactically valid P-256 did:key whose point is 0x02 followed by the first 32 bytes of SHA-512 of a fixed tag and index. Its point need not be on the curve, so the real KeyScheme.P256 may refuse to parse it; a room on the fake scheme reads it as any other key.

Link copied to clipboard
fun fakeKeyStore(index: Int, scheme: FakeKeyScheme = FakeKeyScheme(Random(index))): DeviceKeyStore

The fake device numbered index: a DeviceKeyStore whose key is fakeDeviceKey(index), and on which a room signs and checks with scheme. It keeps grants by the same rules as every other store, since an InMemoryDeviceKeyStore keeps them underneath.