Documentation
¶
Overview ¶
Package store is a local, at-rest-encrypted SQLite persistence layer for an Olvid client: the owned identity, contacts, oblivious-channel state, and the conversation history. Sensitive columns are encrypted with a passphrase- derived key (see crypto.go / STORAGE.md); lookup columns keep a blind index so equality queries still work. It is deliberately isolated so the crypto, server, and client packages stay pure-Go (this is the only package that pulls in a cgo SQLite driver).
Index ¶
- Variables
- type Contact
- type KDFProfile
- type Message
- type Store
- func (s *Store) ChangePassphrase(newPassphrase []byte, profile KDFProfile) error
- func (s *Store) Close() error
- func (s *Store) DeleteChannel(deviceUID []byte) error
- func (s *Store) DeleteContact(identity []byte) error
- func (s *Store) DeleteGroup(groupUID []byte) error
- func (s *Store) DeleteMeta(key string) error
- func (s *Store) GetMeta(key string) ([]byte, bool, error)
- func (s *Store) ListContacts() ([]Contact, error)
- func (s *Store) ListMessages(contactIdentity []byte) ([]Message, error)
- func (s *Store) ListRecentMessages(contactIdentity []byte, limit int) ([]Message, error)
- func (s *Store) LoadChannels() (map[string]*engine.ObliviousChannel, error)
- func (s *Store) LoadChannelsInto(add func(deviceUID, encoded []byte, ownDevice bool)) error
- func (s *Store) LoadContactBlobs() ([][]byte, error)
- func (s *Store) LoadGroupBlobs() ([][]byte, error)
- func (s *Store) LoadOwnedIdentity() (*engine.OwnedCryptoIdentity, []byte, error)
- func (s *Store) MarkOwnDeviceChannel(deviceUID []byte) error
- func (s *Store) SaveChannel(contactDeviceUID, encoded []byte) error
- func (s *Store) SaveChannelState(contactDeviceUID []byte, ch *engine.ObliviousChannel) error
- func (s *Store) SaveContact(identity []byte, displayName string, trusted bool) error
- func (s *Store) SaveContactBlob(identity, encoded []byte) error
- func (s *Store) SaveGroupBlob(groupUID, encoded []byte) error
- func (s *Store) SaveMessage(contactIdentity []byte, incoming bool, serverUID []byte, timestamp int64, ...) error
- func (s *Store) SaveOwnedIdentity(owned *engine.OwnedCryptoIdentity, deviceUID []byte) error
- func (s *Store) SetMeta(key string, value []byte) error
- func (s *Store) SetTrusted(identity []byte, trusted bool) error
Constants ¶
This section is empty.
Variables ¶
var ( ProfileInteractive = KDFProfile{Time: 2, Memory: 64 * 1024, Threads: 4} // 64 MiB ProfileParanoid = KDFProfile{Time: 3, Memory: 512 * 1024, Threads: 4} // 512 MiB )
Preset profiles. Interactive is the default (snappy for a CLI that unlocks per invocation); Paranoid is opt-in for maximal hardening.
var ErrWrongPassphrase = fmt.Errorf("store: wrong passphrase")
ErrWrongPassphrase is returned by Open when the DEK cannot be unwrapped — the passphrase is wrong (or the keyring is corrupt).
Functions ¶
This section is empty.
Types ¶
type KDFProfile ¶
KDFProfile holds the Argon2id cost parameters (memory in KiB).
type Message ¶
type Message struct {
ContactIdentity []byte
Incoming bool
ServerUID []byte
Timestamp int64
Payload []byte
Body string
}
Message is a stored conversation message.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a handle to the local encrypted SQLite database.
func Open ¶
func Open(path string, passphrase []byte, initProfile KDFProfile) (*Store, error)
Open opens (creating if needed) the encrypted database at path and unlocks it with passphrase. On a fresh database the keyring is initialized using initProfile (e.g. ProfileInteractive); on an existing one the stored profile is used and initProfile is ignored. Returns ErrWrongPassphrase if the passphrase does not unwrap the data key.
func (*Store) ChangePassphrase ¶
func (s *Store) ChangePassphrase(newPassphrase []byte, profile KDFProfile) error
ChangePassphrase re-wraps the data key under a new passphrase (and profile), without re-encrypting any data. The store must already be unlocked.
func (*Store) Close ¶
Close closes the database and best-effort zeroizes the in-memory key material.
func (*Store) DeleteChannel ¶
DeleteChannel removes a persisted channel by device UID (so removing a contact frees its channel rows). Implements client.ChannelDeleter.
func (*Store) DeleteContact ¶
DeleteContact removes a contact by identity. Implements client.ContactStore.
func (*Store) DeleteGroup ¶
DeleteGroup removes a group by UID. Implements client.GroupStore.
func (*Store) DeleteMeta ¶
DeleteMeta removes any value stored under key (no error if absent).
func (*Store) ListContacts ¶
ListContacts returns all contacts.
func (*Store) ListMessages ¶
ListMessages returns the whole conversation with a contact, oldest first (nil = all contacts). WARNING: this loads the entire matching history into memory; for a long-lived client prefer ListRecentMessages with a limit. Kept for full export.
func (*Store) ListRecentMessages ¶
ListRecentMessages returns the most recent `limit` messages with a contact (nil = all contacts), oldest-first, bounding memory over a long history. limit <= 0 means no limit.
func (*Store) LoadChannels ¶
func (s *Store) LoadChannels() (map[string]*engine.ObliviousChannel, error)
LoadChannels returns all persisted channels keyed by contact device UID (hex).
func (*Store) LoadChannelsInto ¶
LoadChannelsInto invokes add for every persisted channel with its decrypted device UID, encoded state, and own-device flag. Implements client's channel-restore contract without coupling the two packages to a shared record type.
func (*Store) LoadContactBlobs ¶
LoadContactBlobs returns all persisted contact records. Implements client.ContactStore.
func (*Store) LoadGroupBlobs ¶
LoadGroupBlobs returns all persisted group records. Implements client.GroupStore.
func (*Store) LoadOwnedIdentity ¶
func (s *Store) LoadOwnedIdentity() (*engine.OwnedCryptoIdentity, []byte, error)
LoadOwnedIdentity returns the stored owned identity + device UID, or (nil, nil, nil) if none has been saved yet.
func (*Store) MarkOwnDeviceChannel ¶
MarkOwnDeviceChannel flags a persisted channel as one of the owned identity's own devices, so multi-device sync survives a restart. Implements client.OwnDeviceMarker.
func (*Store) SaveChannel ¶
SaveChannel persists an oblivious channel's ratchet state (already encoded). Implements the client.ChannelStore interface. The state is encrypted at rest.
func (*Store) SaveChannelState ¶
func (s *Store) SaveChannelState(contactDeviceUID []byte, ch *engine.ObliviousChannel) error
SaveChannelState is a convenience wrapper that encodes and saves a channel.
func (*Store) SaveContact ¶
SaveContact inserts or updates a contact.
func (*Store) SaveContactBlob ¶
SaveContactBlob upserts a contact's encoded record (client.Contact.Encode()), keyed by identity. Implements client.ContactStore.
func (*Store) SaveGroupBlob ¶
SaveGroupBlob upserts a group's encoded record, keyed by group UID. Implements client.GroupStore.
func (*Store) SaveMessage ¶
func (s *Store) SaveMessage(contactIdentity []byte, incoming bool, serverUID []byte, timestamp int64, payload []byte, body string) error
SaveMessage appends a message to the conversation history (content encrypted at rest).
func (*Store) SaveOwnedIdentity ¶
func (s *Store) SaveOwnedIdentity(owned *engine.OwnedCryptoIdentity, deviceUID []byte) error
SaveOwnedIdentity stores the single owned identity + device (the private keys are encrypted at rest).