PreKeyRepository

Public prekey material of each device, as published by the devices. Holds public keys only; the server never sees private keys. State is kept per DeviceAddress: one identity key, one current signed prekey, an inventory of available one-time prekeys and the IDs of consumed one-time prekeys.

Both functions that change state are atomic: they either apply completely or, if they throw, change nothing. Concurrent calls behave as if they ran one after the other. Byte arrays are copied at the boundary.

See docs/prekey-publication.md.

Functions

Link copied to clipboard
abstract suspend fun consumePreKeyBundle(address: DeviceAddress): PreKeyBundle?

Returns the bundle for address, or null for an unknown device. The bundle holds the identity key, the current signed prekey and the available one-time prekey with the lowest ID, or none if the inventory is empty. That one-time prekey is removed and its ID recorded as consumed, in the same atomic step: no two callers get the same one.

Link copied to clipboard
abstract suspend fun oneTimePreKeyCount(address: DeviceAddress): Int

Number of available (published, not yet handed out) one-time prekeys of address.

Link copied to clipboard
abstract suspend fun publish(publication: PreKeyPublication)

Applies publication: