2018-09-24 18:07:34 +00:00
|
|
|
package chat
|
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
|
|
|
dr "github.com/status-im/doubleratchet"
|
|
|
|
)
|
|
|
|
|
|
|
|
// RatchetInfo holds the current ratchet state
|
|
|
|
type RatchetInfo struct {
|
|
|
|
ID []byte
|
|
|
|
Sk []byte
|
|
|
|
PrivateKey []byte
|
|
|
|
PublicKey []byte
|
|
|
|
Identity []byte
|
|
|
|
BundleID []byte
|
|
|
|
EphemeralKey []byte
|
|
|
|
InstallationID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// PersistenceService defines the interface for a storage service
|
|
|
|
type PersistenceService interface {
|
2018-11-06 08:05:32 +00:00
|
|
|
// GetKeysStorage returns the associated double ratchet KeysStorage object.
|
2018-09-24 18:07:34 +00:00
|
|
|
GetKeysStorage() dr.KeysStorage
|
2018-11-06 08:05:32 +00:00
|
|
|
// GetSessionStorage returns the associated double ratchet SessionStorage object.
|
2018-09-24 18:07:34 +00:00
|
|
|
GetSessionStorage() dr.SessionStorage
|
|
|
|
|
2018-11-06 08:05:32 +00:00
|
|
|
// GetPublicBundle retrieves an existing Bundle for the specified public key & installationIDs.
|
|
|
|
GetPublicBundle(*ecdsa.PublicKey, []string) (*Bundle, error)
|
2018-09-24 18:07:34 +00:00
|
|
|
// AddPublicBundle persists a specified Bundle
|
|
|
|
AddPublicBundle(*Bundle) error
|
|
|
|
|
2018-11-06 08:05:32 +00:00
|
|
|
// GetAnyPrivateBundle retrieves any bundle for our identity & installationIDs
|
|
|
|
GetAnyPrivateBundle([]byte, []string) (*BundleContainer, error)
|
|
|
|
// GetPrivateKeyBundle retrieves a BundleContainer with the specified signed prekey.
|
2018-09-24 18:07:34 +00:00
|
|
|
GetPrivateKeyBundle([]byte) ([]byte, error)
|
2018-11-06 08:05:32 +00:00
|
|
|
// AddPrivateBundle persists a BundleContainer.
|
2018-09-24 18:07:34 +00:00
|
|
|
AddPrivateBundle(*BundleContainer) error
|
2018-11-06 08:05:32 +00:00
|
|
|
// MarkBundleExpired marks a private bundle as expired, not to be used for encryption anymore.
|
2018-09-24 18:07:34 +00:00
|
|
|
MarkBundleExpired([]byte) error
|
|
|
|
|
|
|
|
// AddRatchetInfo persists the specified ratchet info
|
|
|
|
AddRatchetInfo([]byte, []byte, []byte, []byte, string) error
|
2018-11-06 08:05:32 +00:00
|
|
|
// GetRatchetInfo retrieves the existing RatchetInfo for a specified bundle ID and interlocutor public key.
|
2018-10-16 10:31:05 +00:00
|
|
|
GetRatchetInfo([]byte, []byte, string) (*RatchetInfo, error)
|
2018-11-06 08:05:32 +00:00
|
|
|
// GetAnyRatchetInfo retrieves any existing RatchetInfo for a specified interlocutor public key.
|
2018-09-24 18:07:34 +00:00
|
|
|
GetAnyRatchetInfo([]byte, string) (*RatchetInfo, error)
|
|
|
|
// RatchetInfoConfirmed clears the ephemeral key in the RatchetInfo
|
2018-11-06 08:05:32 +00:00
|
|
|
// associated with the specified bundle ID and interlocutor identity public key.
|
2018-10-16 10:31:05 +00:00
|
|
|
RatchetInfoConfirmed([]byte, []byte, string) error
|
2018-11-06 08:05:32 +00:00
|
|
|
|
|
|
|
// GetActiveInstallations returns the active installations for a given identity.
|
2018-11-27 08:54:20 +00:00
|
|
|
GetActiveInstallations(maxInstallations int, identity []byte) ([]string, error)
|
2018-11-06 08:05:32 +00:00
|
|
|
// AddInstallations adds the installations for a given identity.
|
|
|
|
AddInstallations(identity []byte, timestamp int64, installationIDs []string, enabled bool) error
|
|
|
|
// EnableInstallation enables the installation.
|
|
|
|
EnableInstallation(identity []byte, installationID string) error
|
|
|
|
// DisableInstallation disable the installation.
|
|
|
|
DisableInstallation(identity []byte, installationID string) error
|
2018-09-24 18:07:34 +00:00
|
|
|
}
|