PreKeyStore class abstract interface

Abstract interface for storing pre-keys.

Pre-keys are one-time use keys that enable asynchronous session establishment. When a pre-key is used to establish a session, it should typically be removed from the store.

A user should maintain a pool of pre-keys and replenish them as they are consumed.

Example implementation:

class MyPreKeyStore implements PreKeyStore {
  final _preKeys = <int, Uint8List>{};

  @override
  Future<PreKeyRecord?> loadPreKey(int preKeyId) async {
    final data = _preKeys[preKeyId];
    return data != null ? PreKeyRecord.deserialize(data) : null;
  }
  // ... other methods
}

Durability (critical)

Writes to this store must be durably persisted before the returned future completes, or be part of a transaction committed durably before the decrypted plaintext is acted upon. Consumption of a one-time pre-key is a write: see removePreKey. This is a different failure mode from SessionStore — nothing rewinds the ratchet, but a pre-key that survives its use can be used again.

Implementers

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

containsPreKey(int preKeyId) Future<bool>
Checks if a pre-key exists with the given ID.
getAllPreKeyIds() Future<List<int>>
Gets all stored pre-key IDs.
loadPreKey(int preKeyId) Future<PreKeyRecord?>
Loads a pre-key by its ID.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removePreKey(int preKeyId) Future<void>
Removes a pre-key by its ID.
storePreKey(int preKeyId, PreKeyRecord record) Future<void>
Stores a pre-key.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited