-
Notifications
You must be signed in to change notification settings - Fork 244
/
persistence.go
51 lines (44 loc) · 1.94 KB
/
persistence.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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 {
// GetKeysStorage returns the associated double ratchet KeysStorage object
GetKeysStorage() dr.KeysStorage
// GetSessionStorage returns the associated double ratchet SessionStorage object
GetSessionStorage() dr.SessionStorage
// GetPublicBundle retrieves an existing Bundle for the specified public key
GetPublicBundle(*ecdsa.PublicKey) (*Bundle, error)
// AddPublicBundle persists a specified Bundle
AddPublicBundle(*Bundle) error
// GetAnyPrivateBundle retrieves any bundle containing a private key
GetAnyPrivateBundle([]byte) (*BundleContainer, error)
// GetPrivateKeyBundle retrieves a BundleContainer with the specified signed prekey
GetPrivateKeyBundle([]byte) ([]byte, error)
// AddPrivateBundle persists a BundleContainer
AddPrivateBundle(*BundleContainer) error
// MarkBundleExpired marks a bundle as expired, not to be used for encryption anymore
MarkBundleExpired([]byte) error
// AddRatchetInfo persists the specified ratchet info
AddRatchetInfo([]byte, []byte, []byte, []byte, string) error
// GetRatchetInfo retrieves the existing RatchetInfo for a specified bundle ID and interlocutor public key
GetRatchetInfo([]byte, []byte) (*RatchetInfo, error)
// GetAnyRatchetInfo retrieves any existing RatchetInfo for a specified interlocutor public key
GetAnyRatchetInfo([]byte, string) (*RatchetInfo, error)
// RatchetInfoConfirmed clears the ephemeral key in the RatchetInfo
// associated with the specified bundle ID and interlocutor identity public key
RatchetInfoConfirmed([]byte, []byte) error
}