chat

package
v0.28.0-alpha.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2019 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolVersion = 1

Variables

View Source
var ErrDeviceNotFound = errors.New("device not found")
View Source
var ErrNotProtocolMessage = errors.New("Not a protocol message")
View Source
var ErrSessionNotFound = errors.New("session not found")

Functions

func ExtractIdentity

func ExtractIdentity(bundle *protobuf.Bundle) (*ecdsa.PublicKey, error)

ExtractIdentity extracts the identity key from a given bundle

func NewBundleContainer

func NewBundleContainer(identity *ecdsa.PrivateKey, installationID string) (*protobuf.BundleContainer, error)

NewBundleContainer creates a new BundleContainer from an identity private key

func PerformActiveDH

func PerformActiveDH(publicKey *ecdsa.PublicKey) ([]byte, *ecdsa.PublicKey, error)

PerformActiveDH performs a Diffie-Hellman exchange using a public key and a generated ephemeral key. Returns the key resulting from the DH exchange as well as the ephemeral public key.

func PerformActiveX3DH

func PerformActiveX3DH(identity []byte, signedPreKey []byte, prv *ecdsa.PrivateKey) ([]byte, *ecdsa.PublicKey, error)

PerformActiveX3DH takes someone else's bundle and calculates shared secret. Returns the shared secret and the ephemeral key used.

func PerformDH

func PerformDH(privateKey *ecies.PrivateKey, publicKey *ecies.PublicKey) ([]byte, error)

PerformDH generates a shared key given a private and a public key

func PerformPassiveX3DH

func PerformPassiveX3DH(theirIdentityKey *ecdsa.PublicKey, mySignedPreKey *ecdsa.PrivateKey, theirEphemeralKey *ecdsa.PublicKey, myPrivateKey *ecdsa.PrivateKey) ([]byte, error)

PerformPassiveX3DH handles the part of the protocol where our interlocutor used our bundle, with ID of the signedPreKey, we loaded our identity key and the correct signedPreKey and we perform X3DH

func SignBundle

func SignBundle(identity *ecdsa.PrivateKey, bundleContainer *protobuf.BundleContainer) error

func VerifyBundle

func VerifyBundle(bundle *protobuf.Bundle) error

VerifyBundle checks that a bundle is valid

Types

type ChatMessagePayload

type ChatMessagePayload struct {
	// Message content
	Content string `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
	// MIME type
	ContentType string `protobuf:"bytes,2,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
	// Message type
	MessageType string `protobuf:"bytes,3,opt,name=message_type,json=messageType,proto3" json:"message_type,omitempty"`
	// Sender's clock value for message ordering
	ClockValue           float64  `protobuf:"fixed64,4,opt,name=clock_value,json=clockValue,proto3" json:"clock_value,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

What is sent through the wire

func (*ChatMessagePayload) Descriptor

func (*ChatMessagePayload) Descriptor() ([]byte, []int)

func (*ChatMessagePayload) GetClockValue

func (m *ChatMessagePayload) GetClockValue() float64

func (*ChatMessagePayload) GetContent

func (m *ChatMessagePayload) GetContent() string

func (*ChatMessagePayload) GetContentType

func (m *ChatMessagePayload) GetContentType() string

func (*ChatMessagePayload) GetMessageType

func (m *ChatMessagePayload) GetMessageType() string

func (*ChatMessagePayload) ProtoMessage

func (*ChatMessagePayload) ProtoMessage()

func (*ChatMessagePayload) Reset

func (m *ChatMessagePayload) Reset()

func (*ChatMessagePayload) String

func (m *ChatMessagePayload) String() string

func (*ChatMessagePayload) XXX_DiscardUnknown

func (m *ChatMessagePayload) XXX_DiscardUnknown()

func (*ChatMessagePayload) XXX_Marshal

func (m *ChatMessagePayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ChatMessagePayload) XXX_Merge

func (m *ChatMessagePayload) XXX_Merge(src proto.Message)

func (*ChatMessagePayload) XXX_Size

func (m *ChatMessagePayload) XXX_Size() int

func (*ChatMessagePayload) XXX_Unmarshal

func (m *ChatMessagePayload) XXX_Unmarshal(b []byte) error

type ChatProtocolMessage

type ChatProtocolMessage struct {
	Payload              []byte   `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Incoming messages

func (*ChatProtocolMessage) Descriptor

func (*ChatProtocolMessage) Descriptor() ([]byte, []int)

func (*ChatProtocolMessage) GetPayload

func (m *ChatProtocolMessage) GetPayload() []byte

func (*ChatProtocolMessage) ProtoMessage

func (*ChatProtocolMessage) ProtoMessage()

func (*ChatProtocolMessage) Reset

func (m *ChatProtocolMessage) Reset()

func (*ChatProtocolMessage) String

func (m *ChatProtocolMessage) String() string

func (*ChatProtocolMessage) XXX_DiscardUnknown

func (m *ChatProtocolMessage) XXX_DiscardUnknown()

func (*ChatProtocolMessage) XXX_Marshal

func (m *ChatProtocolMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ChatProtocolMessage) XXX_Merge

func (m *ChatProtocolMessage) XXX_Merge(src proto.Message)

func (*ChatProtocolMessage) XXX_Size

func (m *ChatProtocolMessage) XXX_Size() int

func (*ChatProtocolMessage) XXX_Unmarshal

func (m *ChatProtocolMessage) XXX_Unmarshal(b []byte) error

type ConfirmationData

type ConfirmationData struct {
	// contains filtered or unexported fields
}

type ContactUpdatePayload

type ContactUpdatePayload struct {
	// Contact display name
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// Contact profile image, using the data URI scheme (e.g. "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAA...")
	ProfileImage string `protobuf:"bytes,2,opt,name=profile_image,json=profileImage,proto3" json:"profile_image,omitempty"`
	// Contact address
	Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
	// Contact Firebase Cloud Messaging token
	FcmToken             string   `protobuf:"bytes,4,opt,name=fcm_token,json=fcmToken,proto3" json:"fcm_token,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

ContactUpdatePayload is sent when a user updates its profile

func (*ContactUpdatePayload) Descriptor

func (*ContactUpdatePayload) Descriptor() ([]byte, []int)

func (*ContactUpdatePayload) GetAddress

func (m *ContactUpdatePayload) GetAddress() string

func (*ContactUpdatePayload) GetFcmToken

func (m *ContactUpdatePayload) GetFcmToken() string

func (*ContactUpdatePayload) GetName

func (m *ContactUpdatePayload) GetName() string

func (*ContactUpdatePayload) GetProfileImage

func (m *ContactUpdatePayload) GetProfileImage() string

func (*ContactUpdatePayload) ProtoMessage

func (*ContactUpdatePayload) ProtoMessage()

func (*ContactUpdatePayload) Reset

func (m *ContactUpdatePayload) Reset()

func (*ContactUpdatePayload) String

func (m *ContactUpdatePayload) String() string

func (*ContactUpdatePayload) XXX_DiscardUnknown

func (m *ContactUpdatePayload) XXX_DiscardUnknown()

func (*ContactUpdatePayload) XXX_Marshal

func (m *ContactUpdatePayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ContactUpdatePayload) XXX_Merge

func (m *ContactUpdatePayload) XXX_Merge(src proto.Message)

func (*ContactUpdatePayload) XXX_Size

func (m *ContactUpdatePayload) XXX_Size() int

func (*ContactUpdatePayload) XXX_Unmarshal

func (m *ContactUpdatePayload) XXX_Unmarshal(b []byte) error

type ContactUpdateRPC

type ContactUpdateRPC struct {
	Src                  string                `protobuf:"bytes,1,opt,name=src,proto3" json:"src,omitempty"`
	Dst                  string                `protobuf:"bytes,2,opt,name=dst,proto3" json:"dst,omitempty"`
	Payload              *ContactUpdatePayload `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{}              `json:"-"`
	XXX_unrecognized     []byte                `json:"-"`
	XXX_sizecache        int32                 `json:"-"`
}

func (*ContactUpdateRPC) Descriptor

func (*ContactUpdateRPC) Descriptor() ([]byte, []int)

func (*ContactUpdateRPC) GetDst

func (m *ContactUpdateRPC) GetDst() string

func (*ContactUpdateRPC) GetPayload

func (m *ContactUpdateRPC) GetPayload() *ContactUpdatePayload

func (*ContactUpdateRPC) GetSrc

func (m *ContactUpdateRPC) GetSrc() string

func (*ContactUpdateRPC) ProtoMessage

func (*ContactUpdateRPC) ProtoMessage()

func (*ContactUpdateRPC) Reset

func (m *ContactUpdateRPC) Reset()

func (*ContactUpdateRPC) String

func (m *ContactUpdateRPC) String() string

func (*ContactUpdateRPC) XXX_DiscardUnknown

func (m *ContactUpdateRPC) XXX_DiscardUnknown()

func (*ContactUpdateRPC) XXX_Marshal

func (m *ContactUpdateRPC) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ContactUpdateRPC) XXX_Merge

func (m *ContactUpdateRPC) XXX_Merge(src proto.Message)

func (*ContactUpdateRPC) XXX_Size

func (m *ContactUpdateRPC) XXX_Size() int

func (*ContactUpdateRPC) XXX_Unmarshal

func (m *ContactUpdateRPC) XXX_Unmarshal(b []byte) error

type EncryptionService

type EncryptionService struct {
	// contains filtered or unexported fields
}

EncryptionService defines a service that is responsible for the encryption aspect of the protocol.

func NewEncryptionService

func NewEncryptionService(p PersistenceService, config EncryptionServiceConfig) *EncryptionService

NewEncryptionService creates a new EncryptionService instance.

func (*EncryptionService) ConfirmMessagesProcessed

func (s *EncryptionService) ConfirmMessagesProcessed(messageIDs [][]byte) error

ConfirmMessagesProcessed confirms and deletes message keys for the given messages

func (*EncryptionService) CreateBundle

func (s *EncryptionService) CreateBundle(privateKey *ecdsa.PrivateKey, installations []*multidevice.Installation) (*protobuf.Bundle, error)

CreateBundle retrieves or creates an X3DH bundle given a private key

func (*EncryptionService) DecryptPayload

func (s *EncryptionService) DecryptPayload(myIdentityKey *ecdsa.PrivateKey, theirIdentityKey *ecdsa.PublicKey, theirInstallationID string, msgs map[string]*protobuf.DirectMessageProtocol, messageID []byte) ([]byte, error)

DecryptPayload decrypts the payload of a DirectMessageProtocol, given an identity private key and the sender's public key

func (*EncryptionService) DecryptWithDH

func (s *EncryptionService) DecryptWithDH(myIdentityKey *ecdsa.PrivateKey, theirEphemeralKey *ecdsa.PublicKey, payload []byte) ([]byte, error)

DecryptWithDH decrypts message sent with a DH key exchange, and throws away the key after decryption

func (*EncryptionService) EncryptPayload

func (s *EncryptionService) EncryptPayload(theirIdentityKey *ecdsa.PublicKey, myIdentityKey *ecdsa.PrivateKey, installations []*multidevice.Installation, payload []byte) (map[string]*protobuf.DirectMessageProtocol, []*multidevice.Installation, error)

EncryptPayload returns a new DirectMessageProtocol with a given payload encrypted, given a recipient's public key and the sender private identity key

func (*EncryptionService) EncryptPayloadWithDH added in v0.16.4

func (s *EncryptionService) EncryptPayloadWithDH(theirIdentityKey *ecdsa.PublicKey, payload []byte) (map[string]*protobuf.DirectMessageProtocol, error)

func (*EncryptionService) GetPublicBundle

func (s *EncryptionService) GetPublicBundle(theirIdentityKey *ecdsa.PublicKey, installations []*multidevice.Installation) (*protobuf.Bundle, error)

GetPublicBundle returns the active installations bundles for a given user

func (*EncryptionService) ProcessPublicBundle

func (s *EncryptionService) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, b *protobuf.Bundle) error

ProcessPublicBundle persists a bundle

type EncryptionServiceConfig

type EncryptionServiceConfig struct {
	InstallationID string
	// Max number of installations we keep synchronized.
	MaxInstallations int
	// How many consecutive messages can be skipped in the receiving chain.
	MaxSkip int
	// Any message with seqNo <= currentSeq - maxKeep will be deleted.
	MaxKeep int
	// How many keys do we store in total per session.
	MaxMessageKeysPerSession int
	// How long before we refresh the interval in milliseconds
	BundleRefreshInterval int64
}

func DefaultEncryptionServiceConfig

func DefaultEncryptionServiceConfig(installationID string) EncryptionServiceConfig

DefaultEncryptionServiceConfig returns the default values used by the encryption service

type OneToOneRPC

type OneToOneRPC struct {
	Src                  string   `protobuf:"bytes,1,opt,name=src,proto3" json:"src,omitempty"`
	Dst                  string   `protobuf:"bytes,2,opt,name=dst,proto3" json:"dst,omitempty"`
	Payload              []byte   `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Incoming RPC messages

func (*OneToOneRPC) Descriptor

func (*OneToOneRPC) Descriptor() ([]byte, []int)

func (*OneToOneRPC) GetDst

func (m *OneToOneRPC) GetDst() string

func (*OneToOneRPC) GetPayload

func (m *OneToOneRPC) GetPayload() []byte

func (*OneToOneRPC) GetSrc

func (m *OneToOneRPC) GetSrc() string

func (*OneToOneRPC) ProtoMessage

func (*OneToOneRPC) ProtoMessage()

func (*OneToOneRPC) Reset

func (m *OneToOneRPC) Reset()

func (*OneToOneRPC) String

func (m *OneToOneRPC) String() string

func (*OneToOneRPC) XXX_DiscardUnknown

func (m *OneToOneRPC) XXX_DiscardUnknown()

func (*OneToOneRPC) XXX_Marshal

func (m *OneToOneRPC) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OneToOneRPC) XXX_Merge

func (m *OneToOneRPC) XXX_Merge(src proto.Message)

func (*OneToOneRPC) XXX_Size

func (m *OneToOneRPC) XXX_Size() int

func (*OneToOneRPC) XXX_Unmarshal

func (m *OneToOneRPC) XXX_Unmarshal(b []byte) error

type PartitionTopic

type PartitionTopic int
const (
	PartitionTopicNoSupport PartitionTopic = iota
	PartitionTopicV1
)

type PersistenceService

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 & installations
	GetPublicBundle(*ecdsa.PublicKey, []*multidevice.Installation) (*protobuf.Bundle, error)
	// AddPublicBundle persists a specified Bundle
	AddPublicBundle(*protobuf.Bundle) error

	// GetAnyPrivateBundle retrieves any bundle for our identity & installations
	GetAnyPrivateBundle([]byte, []*multidevice.Installation) (*protobuf.BundleContainer, error)
	// GetPrivateKeyBundle retrieves a BundleContainer with the specified signed prekey.
	GetPrivateKeyBundle([]byte) ([]byte, error)
	// AddPrivateBundle persists a BundleContainer.
	AddPrivateBundle(*protobuf.BundleContainer) error
	// MarkBundleExpired marks a private 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, string) (*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, string) error
}

PersistenceService defines the interface for a storage service

type ProtocolMessageSpec

type ProtocolMessageSpec struct {
	Message *protobuf.ProtocolMessage
	// Installations is the targeted devices
	Installations []*multidevice.Installation
	// SharedSecret is a shared secret established among the installations
	SharedSecret []byte
}

func (*ProtocolMessageSpec) MinVersion

func (p *ProtocolMessageSpec) MinVersion() uint32

func (*ProtocolMessageSpec) PartitionedTopic

func (p *ProtocolMessageSpec) PartitionedTopic() PartitionTopic

type ProtocolService

type ProtocolService struct {
	Enabled bool
	// contains filtered or unexported fields
}

func NewProtocolService

func NewProtocolService(encryption *EncryptionService, secret *sharedsecret.Service, multidevice *multidevice.Service, addedBundlesHandler func([]*multidevice.Installation), onNewSharedSecretHandler func([]*sharedsecret.Secret)) *ProtocolService

NewProtocolService creates a new ProtocolService instance

func (*ProtocolService) BuildDHMessage

func (p *ProtocolService) BuildDHMessage(myIdentityKey *ecdsa.PrivateKey, destination *ecdsa.PublicKey, payload []byte) (*ProtocolMessageSpec, error)

BuildDHMessage builds a message with DH encryption so that it can be decrypted by any other device.

func (*ProtocolService) BuildDirectMessage

func (p *ProtocolService) BuildDirectMessage(myIdentityKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, payload []byte) (*ProtocolMessageSpec, error)

BuildDirectMessage returns a 1:1 chat message and optionally a negotiated topic given the user identity private key, the recipient's public key, and a payload

func (*ProtocolService) BuildPublicMessage

func (p *ProtocolService) BuildPublicMessage(myIdentityKey *ecdsa.PrivateKey, payload []byte) (*protobuf.ProtocolMessage, error)

BuildPublicMessage marshals a public chat message given the user identity private key and a payload

func (*ProtocolService) ConfirmMessagesProcessed

func (p *ProtocolService) ConfirmMessagesProcessed(messageIDs [][]byte) error

ConfirmMessagesProcessed confirms and deletes message keys for the given messages

func (*ProtocolService) DisableInstallation

func (p *ProtocolService) DisableInstallation(myIdentityKey *ecdsa.PublicKey, installationID string) error

DisableInstallation disables an installation for multi-device sync.

func (*ProtocolService) EnableInstallation

func (p *ProtocolService) EnableInstallation(myIdentityKey *ecdsa.PublicKey, installationID string) error

EnableInstallation enables an installation for multi-device sync.

func (*ProtocolService) GetBundle

func (p *ProtocolService) GetBundle(myIdentityKey *ecdsa.PrivateKey) (*protobuf.Bundle, error)

GetBundle retrieves or creates a X3DH bundle, given a private identity key.

func (*ProtocolService) GetOurInstallations

func (p *ProtocolService) GetOurInstallations(myIdentityKey *ecdsa.PublicKey) ([]*multidevice.Installation, error)

GetOurInstallations returns all the installations available given an identity

func (*ProtocolService) GetPublicBundle

func (p *ProtocolService) GetPublicBundle(theirIdentityKey *ecdsa.PublicKey) (*protobuf.Bundle, error)

GetPublicBundle retrieves a public bundle given an identity

func (*ProtocolService) HandleMessage

func (p *ProtocolService) HandleMessage(myIdentityKey *ecdsa.PrivateKey, theirPublicKey *ecdsa.PublicKey, protocolMessage *protobuf.ProtocolMessage, messageID []byte) ([]byte, error)

HandleMessage unmarshals a message and processes it, decrypting it if it is a 1:1 message.

func (*ProtocolService) ProcessPublicBundle

func (p *ProtocolService) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, bundle *protobuf.Bundle) ([]*multidevice.Installation, error)

ProcessPublicBundle processes a received X3DH bundle.

func (*ProtocolService) SetInstallationMetadata

func (p *ProtocolService) SetInstallationMetadata(myIdentityKey *ecdsa.PublicKey, installationID string, data *multidevice.InstallationMetadata) error

SetInstallationMetadata sets the metadata for our own installation

type RatchetInfo

type RatchetInfo struct {
	ID             []byte
	Sk             []byte
	PrivateKey     []byte
	PublicKey      []byte
	Identity       []byte
	BundleID       []byte
	EphemeralKey   []byte
	InstallationID string
}

RatchetInfo holds the current ratchet state

type SQLLiteKeysStorage

type SQLLiteKeysStorage struct {
	// contains filtered or unexported fields
}

SQLLiteKeysStorage represents a keys persistence service tied to an SQLite database

func NewSQLLiteKeysStorage

func NewSQLLiteKeysStorage(db *sql.DB) *SQLLiteKeysStorage

NewSQLLiteKeysStorage creates a new SQLLiteKeysStorage instance associated with the specified database

func (*SQLLiteKeysStorage) All

func (s *SQLLiteKeysStorage) All() (map[dr.Key]map[uint]dr.Key, error)

All returns nil

func (*SQLLiteKeysStorage) Count

func (s *SQLLiteKeysStorage) Count(pubKey dr.Key) (uint, error)

Count returns the count of keys with the specified public key

func (*SQLLiteKeysStorage) CountAll

func (s *SQLLiteKeysStorage) CountAll() (uint, error)

CountAll returns the count of keys with the specified public key

func (*SQLLiteKeysStorage) DeleteMk

func (s *SQLLiteKeysStorage) DeleteMk(pubKey dr.Key, msgNum uint) error

DeleteMk deletes the key with the specified public key and message key

func (*SQLLiteKeysStorage) DeleteOldMks

func (s *SQLLiteKeysStorage) DeleteOldMks(sessionID []byte, deleteUntil uint) error

DeleteOldMks caps remove any key < seq_num, included

func (*SQLLiteKeysStorage) Get

func (s *SQLLiteKeysStorage) Get(pubKey dr.Key, msgNum uint) (dr.Key, bool, error)

Get retrieves the message key for a specified public key and message number

func (*SQLLiteKeysStorage) Put

func (s *SQLLiteKeysStorage) Put(sessionID []byte, pubKey dr.Key, msgNum uint, mk dr.Key, seqNum uint) error

Put stores a key with the specified public key, message number and message key

func (*SQLLiteKeysStorage) TruncateMks

func (s *SQLLiteKeysStorage) TruncateMks(sessionID []byte, maxKeysPerSession int) error

TruncateMks caps the number of keys to maxKeysPerSession deleting them in FIFO fashion

type SQLLitePersistence

type SQLLitePersistence struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

SQLLitePersistence represents a persistence service tied to an SQLite database

func NewSQLLitePersistence

func NewSQLLitePersistence(path string, key string) (*SQLLitePersistence, error)

NewSQLLitePersistence creates a new SQLLitePersistence instance, given a path and a key

func (*SQLLitePersistence) AddPrivateBundle

func (s *SQLLitePersistence) AddPrivateBundle(bc *protobuf.BundleContainer) error

AddPrivateBundle adds the specified BundleContainer to the database

func (*SQLLitePersistence) AddPublicBundle

func (s *SQLLitePersistence) AddPublicBundle(b *protobuf.Bundle) error

AddPublicBundle adds the specified Bundle to the database

func (*SQLLitePersistence) AddRatchetInfo

func (s *SQLLitePersistence) AddRatchetInfo(key []byte, identity []byte, bundleID []byte, ephemeralKey []byte, installationID string) error

AddRatchetInfo persists the specified ratchet info into the database

func (*SQLLitePersistence) GetAnyPrivateBundle

func (s *SQLLitePersistence) GetAnyPrivateBundle(myIdentityKey []byte, installations []*multidevice.Installation) (*protobuf.BundleContainer, error)

GetAnyPrivateBundle retrieves any bundle from the database containing a private key

func (*SQLLitePersistence) GetAnyRatchetInfo

func (s *SQLLitePersistence) GetAnyRatchetInfo(identity []byte, installationID string) (*RatchetInfo, error)

GetAnyRatchetInfo retrieves any existing RatchetInfo for a specified interlocutor public key from the database

func (*SQLLitePersistence) GetKeysStorage

func (s *SQLLitePersistence) GetKeysStorage() dr.KeysStorage

GetKeysStorage returns the associated double ratchet KeysStorage object

func (*SQLLitePersistence) GetMultideviceStorage

func (s *SQLLitePersistence) GetMultideviceStorage() multidevice.Persistence

GetMultideviceStorage returns the associated multideviceStorage

func (*SQLLitePersistence) GetPrivateKeyBundle

func (s *SQLLitePersistence) GetPrivateKeyBundle(bundleID []byte) ([]byte, error)

GetPrivateKeyBundle retrieves a private key for a bundle from the database

func (*SQLLitePersistence) GetPublicBundle

func (s *SQLLitePersistence) GetPublicBundle(publicKey *ecdsa.PublicKey, installations []*multidevice.Installation) (*protobuf.Bundle, error)

GetPublicBundle retrieves an existing Bundle for the specified public key from the database

func (*SQLLitePersistence) GetRatchetInfo

func (s *SQLLitePersistence) GetRatchetInfo(bundleID []byte, theirIdentity []byte, installationID string) (*RatchetInfo, error)

GetRatchetInfo retrieves the existing RatchetInfo for a specified bundle ID and interlocutor public key from the database

func (*SQLLitePersistence) GetSessionStorage

func (s *SQLLitePersistence) GetSessionStorage() dr.SessionStorage

GetSessionStorage returns the associated double ratchet SessionStorage object

func (*SQLLitePersistence) GetSharedSecretStorage

func (s *SQLLitePersistence) GetSharedSecretStorage() sharedsecret.PersistenceService

GetSharedSecretStorage returns the associated secretStorageObject

func (*SQLLitePersistence) MarkBundleExpired

func (s *SQLLitePersistence) MarkBundleExpired(identity []byte) error

MarkBundleExpired expires any private bundle for a given identity

func (*SQLLitePersistence) Open

func (s *SQLLitePersistence) Open(path string, key string) error

Open opens a file at the specified path

func (*SQLLitePersistence) RatchetInfoConfirmed

func (s *SQLLitePersistence) RatchetInfoConfirmed(bundleID []byte, theirIdentity []byte, installationID string) error

RatchetInfoConfirmed clears the ephemeral key in the RatchetInfo associated with the specified bundle ID and interlocutor identity public key

type SQLLiteSessionStorage

type SQLLiteSessionStorage struct {
	// contains filtered or unexported fields
}

SQLLiteSessionStorage represents a session persistence service tied to an SQLite database

func NewSQLLiteSessionStorage

func NewSQLLiteSessionStorage(db *sql.DB) *SQLLiteSessionStorage

NewSQLLiteSessionStorage creates a new SQLLiteSessionStorage instance associated with the specified database

func (*SQLLiteSessionStorage) Load

func (s *SQLLiteSessionStorage) Load(id []byte) (*dr.State, error)

Load retrieves the double ratchet state for a given ID

func (*SQLLiteSessionStorage) Save

func (s *SQLLiteSessionStorage) Save(id []byte, state *dr.State) error

Save persists the specified double ratchet state

type SendDirectMessageRPC

type SendDirectMessageRPC struct {
	Sig     string
	Chat    string
	Payload hexutil.Bytes
	PubKey  hexutil.Bytes
	DH      bool
}

SendDirectMessageRPC represents the RPC payload for the SendDirectMessage RPC method

type SendPublicMessageRPC

type SendPublicMessageRPC struct {
	Sig     string
	Chat    string
	Payload hexutil.Bytes
}

SendPublicMessageRPC represents the RPC payload for the SendPublicMessage RPC method

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL