chat

package
v0.16.4-7-gc36c6042 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSessionNotFound = errors.New("session not found")

Functions

func DirectMessageToWhisper

func DirectMessageToWhisper(rpcMsg SendDirectMessageRPC, payload []byte) whisper.NewMessage

func ExtractIdentity

func ExtractIdentity(bundle *Bundle) (string, error)

ExtractIdentity extracts the identity key from a given bundle

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 PublicMessageToWhisper

func PublicMessageToWhisper(rpcMsg SendPublicMessageRPC, payload []byte) whisper.NewMessage

func SignBundle

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

func VerifyBundle

func VerifyBundle(bundle *Bundle) error

VerifyBundle checks that a bundle is valid

Types

type Bundle

type Bundle struct {
	// Identity key
	Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"`
	// Installation id
	SignedPreKeys map[string]*SignedPreKey `` /* 190-byte string literal not displayed */
	// Prekey signature
	Signature            []byte   `protobuf:"bytes,4,opt,name=signature,proto3" json:"signature,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

X3DH prekey bundle

func FromBase64

func FromBase64(str string) (*Bundle, error)

FromBase64 unmarshals a Bundle from a Base64 encoding representation of the protobuf Bundle message

func (*Bundle) Descriptor

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

func (*Bundle) GetIdentity

func (m *Bundle) GetIdentity() []byte

func (*Bundle) GetSignature

func (m *Bundle) GetSignature() []byte

func (*Bundle) GetSignedPreKeys

func (m *Bundle) GetSignedPreKeys() map[string]*SignedPreKey

func (*Bundle) ProtoMessage

func (*Bundle) ProtoMessage()

func (*Bundle) Reset

func (m *Bundle) Reset()

func (*Bundle) String

func (m *Bundle) String() string

func (*Bundle) ToBase64

func (bundle *Bundle) ToBase64() (string, error)

ToBase64 returns a Base64 encoding representation of the protobuf Bundle message

func (*Bundle) XXX_DiscardUnknown

func (m *Bundle) XXX_DiscardUnknown()

func (*Bundle) XXX_Marshal

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

func (*Bundle) XXX_Merge

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

func (*Bundle) XXX_Size

func (m *Bundle) XXX_Size() int

func (*Bundle) XXX_Unmarshal

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

type BundleContainer

type BundleContainer struct {
	// X3DH prekey bundle
	Bundle *Bundle `protobuf:"bytes,1,opt,name=bundle,proto3" json:"bundle,omitempty"`
	// Private signed prekey
	PrivateSignedPreKey []byte `protobuf:"bytes,2,opt,name=private_signed_pre_key,json=privateSignedPreKey,proto3" json:"private_signed_pre_key,omitempty"`
	// Local time creation
	Timestamp            int64    `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func NewBundleContainer

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

NewBundleContainer creates a new BundleContainer from an identity private key

func (*BundleContainer) Descriptor

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

func (*BundleContainer) GetBundle

func (m *BundleContainer) GetBundle() *Bundle

func (*BundleContainer) GetPrivateSignedPreKey

func (m *BundleContainer) GetPrivateSignedPreKey() []byte

func (*BundleContainer) GetTimestamp

func (m *BundleContainer) GetTimestamp() int64

func (*BundleContainer) ProtoMessage

func (*BundleContainer) ProtoMessage()

func (*BundleContainer) Reset

func (m *BundleContainer) Reset()

func (*BundleContainer) String

func (m *BundleContainer) String() string

func (*BundleContainer) XXX_DiscardUnknown

func (m *BundleContainer) XXX_DiscardUnknown()

func (*BundleContainer) XXX_Marshal

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

func (*BundleContainer) XXX_Merge

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

func (*BundleContainer) XXX_Size

func (m *BundleContainer) XXX_Size() int

func (*BundleContainer) XXX_Unmarshal

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

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 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 DHHeader

type DHHeader struct {
	// Compressed ephemeral public key
	Key                  []byte   `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*DHHeader) Descriptor

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

func (*DHHeader) GetKey

func (m *DHHeader) GetKey() []byte

func (*DHHeader) ProtoMessage

func (*DHHeader) ProtoMessage()

func (*DHHeader) Reset

func (m *DHHeader) Reset()

func (*DHHeader) String

func (m *DHHeader) String() string

func (*DHHeader) XXX_DiscardUnknown

func (m *DHHeader) XXX_DiscardUnknown()

func (*DHHeader) XXX_Marshal

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

func (*DHHeader) XXX_Merge

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

func (*DHHeader) XXX_Size

func (m *DHHeader) XXX_Size() int

func (*DHHeader) XXX_Unmarshal

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

type DRHeader

type DRHeader struct {
	// Current ratchet public key
	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// Number of the message in the sending chain
	N uint32 `protobuf:"varint,2,opt,name=n,proto3" json:"n,omitempty"`
	// Length of the previous sending chain
	Pn uint32 `protobuf:"varint,3,opt,name=pn,proto3" json:"pn,omitempty"`
	// Bundle ID
	Id                   []byte   `protobuf:"bytes,4,opt,name=id,proto3" json:"id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*DRHeader) Descriptor

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

func (*DRHeader) GetId

func (m *DRHeader) GetId() []byte

func (*DRHeader) GetKey

func (m *DRHeader) GetKey() []byte

func (*DRHeader) GetN

func (m *DRHeader) GetN() uint32

func (*DRHeader) GetPn

func (m *DRHeader) GetPn() uint32

func (*DRHeader) ProtoMessage

func (*DRHeader) ProtoMessage()

func (*DRHeader) Reset

func (m *DRHeader) Reset()

func (*DRHeader) String

func (m *DRHeader) String() string

func (*DRHeader) XXX_DiscardUnknown

func (m *DRHeader) XXX_DiscardUnknown()

func (*DRHeader) XXX_Marshal

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

func (*DRHeader) XXX_Merge

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

func (*DRHeader) XXX_Size

func (m *DRHeader) XXX_Size() int

func (*DRHeader) XXX_Unmarshal

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

type DirectMessageProtocol

type DirectMessageProtocol struct {
	X3DHHeader *X3DHHeader `protobuf:"bytes,1,opt,name=X3DH_header,json=X3DHHeader,proto3" json:"X3DH_header,omitempty"`
	DRHeader   *DRHeader   `protobuf:"bytes,2,opt,name=DR_header,json=DRHeader,proto3" json:"DR_header,omitempty"`
	DHHeader   *DHHeader   `protobuf:"bytes,101,opt,name=DH_header,json=DHHeader,proto3" json:"DH_header,omitempty"`
	// Encrypted payload
	Payload              []byte   `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Direct message value

func (*DirectMessageProtocol) Descriptor

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

func (*DirectMessageProtocol) GetDHHeader

func (m *DirectMessageProtocol) GetDHHeader() *DHHeader

func (*DirectMessageProtocol) GetDRHeader

func (m *DirectMessageProtocol) GetDRHeader() *DRHeader

func (*DirectMessageProtocol) GetPayload

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

func (*DirectMessageProtocol) GetX3DHHeader

func (m *DirectMessageProtocol) GetX3DHHeader() *X3DHHeader

func (*DirectMessageProtocol) ProtoMessage

func (*DirectMessageProtocol) ProtoMessage()

func (*DirectMessageProtocol) Reset

func (m *DirectMessageProtocol) Reset()

func (*DirectMessageProtocol) String

func (m *DirectMessageProtocol) String() string

func (*DirectMessageProtocol) XXX_DiscardUnknown

func (m *DirectMessageProtocol) XXX_DiscardUnknown()

func (*DirectMessageProtocol) XXX_Marshal

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

func (*DirectMessageProtocol) XXX_Merge

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

func (*DirectMessageProtocol) XXX_Size

func (m *DirectMessageProtocol) XXX_Size() int

func (*DirectMessageProtocol) XXX_Unmarshal

func (m *DirectMessageProtocol) 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, installationID string) *EncryptionService

NewEncryptionService creates a new EncryptionService instance

func (*EncryptionService) CreateBundle

func (s *EncryptionService) CreateBundle(privateKey *ecdsa.PrivateKey) (*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]*DirectMessageProtocol) ([]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, payload []byte) (map[string]*DirectMessageProtocol, error)

EncryptPayload returns a new DirectMessageProtocol with a given payload encrypted, given a recipient's public key and the sender private identity key TODO: refactor this nolint: gocyclo

func (*EncryptionService) EncryptPayloadWithDH added in v0.16.4

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

func (*EncryptionService) ProcessPublicBundle

func (s *EncryptionService) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, b *Bundle) ([]IdentityAndIDPair, error)

ProcessPublicBundle persists a bundle and returns a list of tuples identity/installationID

type HandleMessageResponse added in v0.16.4

type HandleMessageResponse struct {
	AddedBundles []IdentityAndIDPair
	Message      []byte
}

type IdentityAndIDPair added in v0.16.4

type IdentityAndIDPair [2]string

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 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
	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, 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 ProtocolMessage

type ProtocolMessage struct {
	// An optional bundle is exchanged with each message
	Bundle *Bundle `protobuf:"bytes,1,opt,name=bundle,proto3" json:"bundle,omitempty"`
	// The device id of the sender
	InstallationId string `protobuf:"bytes,2,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"`
	// One to one message, encrypted, indexed by installation_id
	DirectMessage map[string]*DirectMessageProtocol `` /* 190-byte string literal not displayed */
	// Public chats, not encrypted
	PublicMessage        []byte   `protobuf:"bytes,102,opt,name=public_message,json=publicMessage,proto3" json:"public_message,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

Top-level protocol message

func (*ProtocolMessage) Descriptor

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

func (*ProtocolMessage) GetBundle

func (m *ProtocolMessage) GetBundle() *Bundle

func (*ProtocolMessage) GetDirectMessage

func (m *ProtocolMessage) GetDirectMessage() map[string]*DirectMessageProtocol

func (*ProtocolMessage) GetInstallationId added in v0.16.4

func (m *ProtocolMessage) GetInstallationId() string

func (*ProtocolMessage) GetPublicMessage

func (m *ProtocolMessage) GetPublicMessage() []byte

func (*ProtocolMessage) ProtoMessage

func (*ProtocolMessage) ProtoMessage()

func (*ProtocolMessage) Reset

func (m *ProtocolMessage) Reset()

func (*ProtocolMessage) String

func (m *ProtocolMessage) String() string

func (*ProtocolMessage) XXX_DiscardUnknown

func (m *ProtocolMessage) XXX_DiscardUnknown()

func (*ProtocolMessage) XXX_Marshal

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

func (*ProtocolMessage) XXX_Merge

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

func (*ProtocolMessage) XXX_Size

func (m *ProtocolMessage) XXX_Size() int

func (*ProtocolMessage) XXX_Unmarshal

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

type ProtocolService

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

func NewProtocolService

func NewProtocolService(encryption *EncryptionService) *ProtocolService

NewProtocolService creates a new ProtocolService instance

func (*ProtocolService) BuildDirectMessage

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

BuildDirectMessage marshals a 1:1 chat message given the user identity private key, the recipient's public key, and a payload

func (*ProtocolService) BuildPairingMessage added in v0.16.4

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

BuildPairingMessage sends a message to our own devices using DH so that it can be decrypted by any other device

func (*ProtocolService) BuildPublicMessage

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

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

func (*ProtocolService) GetBundle

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

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

func (*ProtocolService) HandleMessage

func (p *ProtocolService) HandleMessage(myIdentityKey *ecdsa.PrivateKey, theirPublicKey *ecdsa.PublicKey, payload []byte) (*HandleMessageResponse, 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 *Bundle) ([]IdentityAndIDPair, error)

ProcessPublicBundle processes a received X3DH bundle

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) 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) DeletePk

func (s *SQLLiteKeysStorage) DeletePk(pubKey dr.Key) error

DeletePk deletes the keys with the specified public key

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(pubKey dr.Key, msgNum uint, mk dr.Key) error

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

type SQLLitePersistence

type SQLLitePersistence struct {
	// 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(b *BundleContainer) error

AddPrivateBundle adds the specified BundleContainer to the database

func (*SQLLitePersistence) AddPublicBundle

func (s *SQLLitePersistence) AddPublicBundle(b *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) (*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) 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) (*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) MarkBundleExpired

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

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

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
	Payload hexutil.Bytes
	PubKey  hexutil.Bytes
}

SendDirectMessageRPC represents the RPC payload for the SendDirectMessage RPC method

type SendGroupMessageRPC

type SendGroupMessageRPC struct {
	Sig     string
	Payload hexutil.Bytes
	PubKeys []hexutil.Bytes
}

SendGroupMessageRPC represents the RPC payload for the SendGroupMessage RPC method

type SendPublicMessageRPC

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

SendPublicMessageRPC represents the RPC payload for the SendPublicMessage RPC method

type SignedPreKey

type SignedPreKey struct {
	SignedPreKey         []byte   `protobuf:"bytes,1,opt,name=signed_pre_key,json=signedPreKey,proto3" json:"signed_pre_key,omitempty"`
	Version              uint32   `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*SignedPreKey) Descriptor

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

func (*SignedPreKey) GetSignedPreKey

func (m *SignedPreKey) GetSignedPreKey() []byte

func (*SignedPreKey) GetVersion

func (m *SignedPreKey) GetVersion() uint32

func (*SignedPreKey) ProtoMessage

func (*SignedPreKey) ProtoMessage()

func (*SignedPreKey) Reset

func (m *SignedPreKey) Reset()

func (*SignedPreKey) String

func (m *SignedPreKey) String() string

func (*SignedPreKey) XXX_DiscardUnknown

func (m *SignedPreKey) XXX_DiscardUnknown()

func (*SignedPreKey) XXX_Marshal

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

func (*SignedPreKey) XXX_Merge

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

func (*SignedPreKey) XXX_Size

func (m *SignedPreKey) XXX_Size() int

func (*SignedPreKey) XXX_Unmarshal

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

type X3DHHeader

type X3DHHeader struct {
	// Ephemeral key used
	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// Used bundle's signed prekey
	Id []byte `protobuf:"bytes,4,opt,name=id,proto3" json:"id,omitempty"`
	// DEPRECATED: The device id
	InstallationId       string   `protobuf:"bytes,3,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*X3DHHeader) Descriptor

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

func (*X3DHHeader) GetId

func (m *X3DHHeader) GetId() []byte

func (*X3DHHeader) GetInstallationId

func (m *X3DHHeader) GetInstallationId() string

func (*X3DHHeader) GetKey

func (m *X3DHHeader) GetKey() []byte

func (*X3DHHeader) ProtoMessage

func (*X3DHHeader) ProtoMessage()

func (*X3DHHeader) Reset

func (m *X3DHHeader) Reset()

func (*X3DHHeader) String

func (m *X3DHHeader) String() string

func (*X3DHHeader) XXX_DiscardUnknown

func (m *X3DHHeader) XXX_DiscardUnknown()

func (*X3DHHeader) XXX_Marshal

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

func (*X3DHHeader) XXX_Merge

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

func (*X3DHHeader) XXX_Size

func (m *X3DHHeader) XXX_Size() int

func (*X3DHHeader) XXX_Unmarshal

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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