Documentation ¶
Index ¶
- Variables
- func ExtractIdentity(bundle *Bundle) (*ecdsa.PublicKey, error)
- func GetCurrentTime() uint32
- func PerformActiveDH(publicKey *ecdsa.PublicKey) ([]byte, *ecdsa.PublicKey, error)
- func PerformActiveX3DH(identity []byte, signedPreKey []byte, prv *ecdsa.PrivateKey) ([]byte, *ecdsa.PublicKey, error)
- func PerformDH(privateKey *ecies.PrivateKey, publicKey *ecies.PublicKey) ([]byte, error)
- func PerformPassiveX3DH(theirIdentityKey *ecdsa.PublicKey, mySignedPreKey *ecdsa.PrivateKey, ...) ([]byte, error)
- func SignBundle(identity *ecdsa.PrivateKey, bundleContainer *BundleContainer) error
- func VerifyBundle(bundle *Bundle) error
- type Bundle
- func (*Bundle) Descriptor() ([]byte, []int)
- func (m *Bundle) GetIdentity() []byte
- func (m *Bundle) GetSignature() []byte
- func (m *Bundle) GetSignedPreKeys() map[string]*SignedPreKey
- func (m *Bundle) GetTimestamp() int64
- func (*Bundle) ProtoMessage()
- func (m *Bundle) Reset()
- func (m *Bundle) String() string
- func (m *Bundle) XXX_DiscardUnknown()
- func (m *Bundle) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Bundle) XXX_Merge(src proto.Message)
- func (m *Bundle) XXX_Size() int
- func (m *Bundle) XXX_Unmarshal(b []byte) error
- type BundleContainer
- func (*BundleContainer) Descriptor() ([]byte, []int)
- func (m *BundleContainer) GetBundle() *Bundle
- func (m *BundleContainer) GetPrivateSignedPreKey() []byte
- func (*BundleContainer) ProtoMessage()
- func (m *BundleContainer) Reset()
- func (m *BundleContainer) String() string
- func (m *BundleContainer) XXX_DiscardUnknown()
- func (m *BundleContainer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *BundleContainer) XXX_Merge(src proto.Message)
- func (m *BundleContainer) XXX_Size() int
- func (m *BundleContainer) XXX_Unmarshal(b []byte) error
- type DHHeader
- func (*DHHeader) Descriptor() ([]byte, []int)
- func (m *DHHeader) GetKey() []byte
- func (*DHHeader) ProtoMessage()
- func (m *DHHeader) Reset()
- func (m *DHHeader) String() string
- func (m *DHHeader) XXX_DiscardUnknown()
- func (m *DHHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *DHHeader) XXX_Merge(src proto.Message)
- func (m *DHHeader) XXX_Size() int
- func (m *DHHeader) XXX_Unmarshal(b []byte) error
- type DRHeader
- func (*DRHeader) Descriptor() ([]byte, []int)
- func (m *DRHeader) GetId() []byte
- func (m *DRHeader) GetKey() []byte
- func (m *DRHeader) GetN() uint32
- func (m *DRHeader) GetPn() uint32
- func (*DRHeader) ProtoMessage()
- func (m *DRHeader) Reset()
- func (m *DRHeader) String() string
- func (m *DRHeader) XXX_DiscardUnknown()
- func (m *DRHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *DRHeader) XXX_Merge(src proto.Message)
- func (m *DRHeader) XXX_Size() int
- func (m *DRHeader) XXX_Unmarshal(b []byte) error
- type DecryptMessageResponse
- type EncryptedMessageProtocol
- func (*EncryptedMessageProtocol) Descriptor() ([]byte, []int)
- func (m *EncryptedMessageProtocol) GetDHHeader() *DHHeader
- func (m *EncryptedMessageProtocol) GetDRHeader() *DRHeader
- func (m *EncryptedMessageProtocol) GetHRHeader() *HRHeader
- func (m *EncryptedMessageProtocol) GetPayload() []byte
- func (m *EncryptedMessageProtocol) GetX3DHHeader() *X3DHHeader
- func (*EncryptedMessageProtocol) ProtoMessage()
- func (m *EncryptedMessageProtocol) Reset()
- func (m *EncryptedMessageProtocol) String() string
- func (m *EncryptedMessageProtocol) XXX_DiscardUnknown()
- func (m *EncryptedMessageProtocol) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *EncryptedMessageProtocol) XXX_Merge(src proto.Message)
- func (m *EncryptedMessageProtocol) XXX_Size() int
- func (m *EncryptedMessageProtocol) XXX_Unmarshal(b []byte) error
- type HRCache
- type HRHeader
- func (*HRHeader) Descriptor() ([]byte, []int)
- func (m *HRHeader) GetGroupId() []byte
- func (m *HRHeader) GetKeyId() uint32
- func (m *HRHeader) GetSeqNo() uint32
- func (*HRHeader) ProtoMessage()
- func (m *HRHeader) Reset()
- func (m *HRHeader) String() string
- func (m *HRHeader) XXX_DiscardUnknown()
- func (m *HRHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HRHeader) XXX_Merge(src proto.Message)
- func (m *HRHeader) XXX_Size() int
- func (m *HRHeader) XXX_Unmarshal(b []byte) error
- type HRKey
- func (*HRKey) Descriptor() ([]byte, []int)
- func (m *HRKey) GetKey() []byte
- func (m *HRKey) GetKeyId() uint32
- func (*HRKey) ProtoMessage()
- func (m *HRKey) Reset()
- func (m *HRKey) String() string
- func (m *HRKey) XXX_DiscardUnknown()
- func (m *HRKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HRKey) XXX_Merge(src proto.Message)
- func (m *HRKey) XXX_Size() int
- func (m *HRKey) XXX_Unmarshal(b []byte) error
- type HRKeys
- func (*HRKeys) Descriptor() ([]byte, []int)
- func (m *HRKeys) GetKeys() []*HRKey
- func (*HRKeys) ProtoMessage()
- func (m *HRKeys) Reset()
- func (m *HRKeys) String() string
- func (m *HRKeys) XXX_DiscardUnknown()
- func (m *HRKeys) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *HRKeys) XXX_Merge(src proto.Message)
- func (m *HRKeys) XXX_Size() int
- func (m *HRKeys) XXX_Unmarshal(b []byte) error
- type HashRatchetInfo
- type PartitionTopicMode
- type Protocol
- func (p *Protocol) BuildBundleAdvertiseMessage(myIdentityKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey) (*ProtocolMessageSpec, error)
- func (p *Protocol) BuildDHMessage(myIdentityKey *ecdsa.PrivateKey, destination *ecdsa.PublicKey, payload []byte) (*ProtocolMessageSpec, error)
- func (p *Protocol) BuildEncryptedMessage(myIdentityKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, payload []byte) (*ProtocolMessageSpec, error)
- func (p *Protocol) BuildHashRatchetKeyExchangeMessage(myIdentityKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, groupID []byte, ...) (*ProtocolMessageSpec, error)
- func (p *Protocol) BuildHashRatchetMessage(groupID []byte, payload []byte) (*ProtocolMessageSpec, error)
- func (p *Protocol) BuildPublicMessage(myIdentityKey *ecdsa.PrivateKey, payload []byte) (*ProtocolMessageSpec, error)
- func (p *Protocol) ConfirmBundleAdvertisement(publicKey *ecdsa.PublicKey, time int64)
- func (p *Protocol) ConfirmMessageProcessed(messageID []byte) error
- func (p *Protocol) DisableInstallation(myIdentityKey *ecdsa.PublicKey, installationID string) error
- func (p *Protocol) EnableInstallation(myIdentityKey *ecdsa.PublicKey, installationID string) error
- func (p *Protocol) GenerateHashRatchetKey(groupID []byte) (uint32, error)
- func (p *Protocol) GetAllHREncodedKeys(groupID []byte) ([]byte, error)
- func (p *Protocol) GetBundle(myIdentityKey *ecdsa.PrivateKey) (*Bundle, error)
- func (p *Protocol) GetCurrentKeyForGroup(groupID []byte) (uint32, error)
- func (p *Protocol) GetHREncodedKeys(groupID []byte, keyIDs []uint32) ([]byte, error)
- func (p *Protocol) GetKeyExMessageSpecs(communityID []byte, identity *ecdsa.PrivateKey, recipients []*ecdsa.PublicKey, ...) ([]*ProtocolMessageSpec, error)
- func (p *Protocol) GetKeyIDsForGroup(groupID []byte) ([]uint32, error)
- func (p *Protocol) GetMultiDevice() *multidevice.Multidevice
- func (p *Protocol) GetOurActiveInstallations(myIdentityKey *ecdsa.PublicKey) ([]*multidevice.Installation, error)
- func (p *Protocol) GetOurInstallations(myIdentityKey *ecdsa.PublicKey) ([]*multidevice.Installation, error)
- func (p *Protocol) GetPublicBundle(theirIdentityKey *ecdsa.PublicKey) (*Bundle, error)
- func (p *Protocol) HandleHashRatchetKeys(groupID, encodedKeys []byte) ([]*HashRatchetInfo, error)
- func (p *Protocol) HandleMessage(myIdentityKey *ecdsa.PrivateKey, theirPublicKey *ecdsa.PublicKey, ...) (*DecryptMessageResponse, error)
- func (p *Protocol) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, bundle *Bundle) ([]*multidevice.Installation, error)
- func (p *Protocol) SetInstallationMetadata(myIdentityKey *ecdsa.PublicKey, installationID string, ...) error
- func (p *Protocol) SetInstallationName(myIdentityKey *ecdsa.PublicKey, installationID string, name string) error
- func (p *Protocol) ShouldAdvertiseBundle(publicKey *ecdsa.PublicKey, time int64) (bool, error)
- func (p *Protocol) Start(myIdentity *ecdsa.PrivateKey) (*Subscriptions, error)
- func (p *Protocol) Stop() error
- type ProtocolMessage
- func (*ProtocolMessage) Descriptor() ([]byte, []int)
- func (m *ProtocolMessage) GetBundles() []*Bundle
- func (m *ProtocolMessage) GetEncryptedMessage() map[string]*EncryptedMessageProtocol
- func (m *ProtocolMessage) GetInstallationId() string
- func (m *ProtocolMessage) GetPublicMessage() []byte
- func (*ProtocolMessage) ProtoMessage()
- func (m *ProtocolMessage) Reset()
- func (m *ProtocolMessage) String() string
- func (m *ProtocolMessage) XXX_DiscardUnknown()
- func (m *ProtocolMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ProtocolMessage) XXX_Merge(src proto.Message)
- func (m *ProtocolMessage) XXX_Size() int
- func (m *ProtocolMessage) XXX_Unmarshal(b []byte) error
- type ProtocolMessageSpec
- type RatchetInfo
- type SignedPreKey
- func (*SignedPreKey) Descriptor() ([]byte, []int)
- func (m *SignedPreKey) GetProtocolVersion() uint32
- func (m *SignedPreKey) GetSignedPreKey() []byte
- func (m *SignedPreKey) GetVersion() uint32
- func (*SignedPreKey) ProtoMessage()
- func (m *SignedPreKey) Reset()
- func (m *SignedPreKey) String() string
- func (m *SignedPreKey) XXX_DiscardUnknown()
- func (m *SignedPreKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *SignedPreKey) XXX_Merge(src proto.Message)
- func (m *SignedPreKey) XXX_Size() int
- func (m *SignedPreKey) XXX_Unmarshal(b []byte) error
- type Subscriptions
- type X3DHHeader
- func (*X3DHHeader) Descriptor() ([]byte, []int)
- func (m *X3DHHeader) GetId() []byte
- func (m *X3DHHeader) GetKey() []byte
- func (*X3DHHeader) ProtoMessage()
- func (m *X3DHHeader) Reset()
- func (m *X3DHHeader) String() string
- func (m *X3DHHeader) XXX_DiscardUnknown()
- func (m *X3DHHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *X3DHHeader) XXX_Merge(src proto.Message)
- func (m *X3DHHeader) XXX_Size() int
- func (m *X3DHHeader) XXX_Unmarshal(b []byte) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrDeviceNotFound = errors.New("device not found") // ErrNotPairedDevice means that we received a message signed with our public key // but from a device that has not been paired. // This should not happen because the protocol forbids sending a message to // non-paired devices, however, in theory it is possible to receive such a message. ErrNotPairedDevice = errors.New("received a message from not paired device") ErrHashRatchetSeqNoTooHigh = errors.New("Hash ratchet seq no is too high") ErrHashRatchetGroupIDNotFound = errors.New("Hash ratchet group id not found") )
var ( // ErrNoPayload means that there was no payload found in the received protocol message. ErrNoPayload = errors.New("no payload") )
Functions ¶
func ExtractIdentity ¶
ExtractIdentity extracts the identity key from a given bundle
func GetCurrentTime ¶ added in v0.162.9
func GetCurrentTime() uint32
GetCurrentTime returns the current unix time in milliseconds
func PerformActiveDH ¶
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 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 *BundleContainer) error
SignBundle signs the bundle and refreshes the timestamps
func VerifyBundle ¶
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"` // When the bundle was created locally Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
X3DH prekey bundle
func (*Bundle) Descriptor ¶
func (*Bundle) GetIdentity ¶
func (*Bundle) GetSignature ¶
func (*Bundle) GetSignedPreKeys ¶
func (m *Bundle) GetSignedPreKeys() map[string]*SignedPreKey
func (*Bundle) GetTimestamp ¶
func (*Bundle) ProtoMessage ¶
func (*Bundle) ProtoMessage()
func (*Bundle) XXX_DiscardUnknown ¶
func (m *Bundle) XXX_DiscardUnknown()
func (*Bundle) XXX_Marshal ¶
func (*Bundle) XXX_Unmarshal ¶
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"` 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) 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 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) ProtoMessage ¶
func (*DHHeader) ProtoMessage()
func (*DHHeader) XXX_DiscardUnknown ¶
func (m *DHHeader) XXX_DiscardUnknown()
func (*DHHeader) XXX_Marshal ¶
func (*DHHeader) XXX_Unmarshal ¶
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) ProtoMessage ¶
func (*DRHeader) ProtoMessage()
func (*DRHeader) XXX_DiscardUnknown ¶
func (m *DRHeader) XXX_DiscardUnknown()
func (*DRHeader) XXX_Marshal ¶
func (*DRHeader) XXX_Unmarshal ¶
type DecryptMessageResponse ¶ added in v0.59.0
type DecryptMessageResponse struct { DecryptedMessage []byte Installations []*multidevice.Installation HashRatchetInfo []*HashRatchetInfo }
type EncryptedMessageProtocol ¶ added in v0.91.12
type EncryptedMessageProtocol 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"` HRHeader *HRHeader `protobuf:"bytes,102,opt,name=HR_header,json=HRHeader,proto3" json:"HR_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 (*EncryptedMessageProtocol) Descriptor ¶ added in v0.91.12
func (*EncryptedMessageProtocol) Descriptor() ([]byte, []int)
func (*EncryptedMessageProtocol) GetDHHeader ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) GetDHHeader() *DHHeader
func (*EncryptedMessageProtocol) GetDRHeader ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) GetDRHeader() *DRHeader
func (*EncryptedMessageProtocol) GetHRHeader ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) GetHRHeader() *HRHeader
func (*EncryptedMessageProtocol) GetPayload ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) GetPayload() []byte
func (*EncryptedMessageProtocol) GetX3DHHeader ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) GetX3DHHeader() *X3DHHeader
func (*EncryptedMessageProtocol) ProtoMessage ¶ added in v0.91.12
func (*EncryptedMessageProtocol) ProtoMessage()
func (*EncryptedMessageProtocol) Reset ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) Reset()
func (*EncryptedMessageProtocol) String ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) String() string
func (*EncryptedMessageProtocol) XXX_DiscardUnknown ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) XXX_DiscardUnknown()
func (*EncryptedMessageProtocol) XXX_Marshal ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*EncryptedMessageProtocol) XXX_Merge ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) XXX_Merge(src proto.Message)
func (*EncryptedMessageProtocol) XXX_Size ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) XXX_Size() int
func (*EncryptedMessageProtocol) XXX_Unmarshal ¶ added in v0.91.12
func (m *EncryptedMessageProtocol) XXX_Unmarshal(b []byte) error
type HRHeader ¶ added in v0.91.12
type HRHeader struct { // community key ID KeyId uint32 `protobuf:"varint,1,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` // Community message number for this key_id SeqNo uint32 `protobuf:"varint,2,opt,name=seq_no,json=seqNo,proto3" json:"seq_no,omitempty"` // Community ID GroupId []byte `protobuf:"bytes,3,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
Hash Ratchet Header
func (*HRHeader) Descriptor ¶ added in v0.91.12
func (*HRHeader) GetGroupId ¶ added in v0.91.12
func (*HRHeader) ProtoMessage ¶ added in v0.91.12
func (*HRHeader) ProtoMessage()
func (*HRHeader) XXX_DiscardUnknown ¶ added in v0.91.12
func (m *HRHeader) XXX_DiscardUnknown()
func (*HRHeader) XXX_Marshal ¶ added in v0.91.12
func (*HRHeader) XXX_Unmarshal ¶ added in v0.91.12
type HRKey ¶ added in v0.111.7
type HRKey struct { KeyId uint32 `protobuf:"varint,1,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*HRKey) Descriptor ¶ added in v0.111.7
func (*HRKey) ProtoMessage ¶ added in v0.111.7
func (*HRKey) ProtoMessage()
func (*HRKey) XXX_DiscardUnknown ¶ added in v0.111.7
func (m *HRKey) XXX_DiscardUnknown()
func (*HRKey) XXX_Marshal ¶ added in v0.111.7
func (*HRKey) XXX_Unmarshal ¶ added in v0.111.7
type HRKeys ¶ added in v0.111.7
type HRKeys struct { Keys []*HRKey `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*HRKeys) Descriptor ¶ added in v0.111.7
func (*HRKeys) ProtoMessage ¶ added in v0.111.7
func (*HRKeys) ProtoMessage()
func (*HRKeys) XXX_DiscardUnknown ¶ added in v0.111.7
func (m *HRKeys) XXX_DiscardUnknown()
func (*HRKeys) XXX_Marshal ¶ added in v0.111.7
func (*HRKeys) XXX_Unmarshal ¶ added in v0.111.7
type HashRatchetInfo ¶ added in v0.111.7
type PartitionTopicMode ¶
type PartitionTopicMode int
const ( PartitionTopicNoSupport PartitionTopicMode = iota PartitionTopicV1 )
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
func NewWithEncryptorConfig ¶
func NewWithEncryptorConfig( db *sql.DB, installationID string, encryptorConfig encryptorConfig, logger *zap.Logger, ) *Protocol
DB and migrations are shared between encryption package and its sub-packages.
func (*Protocol) BuildBundleAdvertiseMessage ¶
func (p *Protocol) BuildBundleAdvertiseMessage(myIdentityKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey) (*ProtocolMessageSpec, error)
func (*Protocol) BuildDHMessage ¶
func (p *Protocol) 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 (*Protocol) BuildEncryptedMessage ¶ added in v0.91.12
func (p *Protocol) BuildEncryptedMessage(myIdentityKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, payload []byte) (*ProtocolMessageSpec, error)
BuildEncryptedMessage 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 (*Protocol) BuildHashRatchetKeyExchangeMessage ¶ added in v0.91.12
func (p *Protocol) BuildHashRatchetKeyExchangeMessage(myIdentityKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, groupID []byte, keyIDs []uint32) (*ProtocolMessageSpec, error)
BuildHashRatchetKeyExchangeMessage builds a 1:1 message containing newly generated hash ratchet key
func (*Protocol) BuildHashRatchetMessage ¶ added in v0.91.12
func (p *Protocol) BuildHashRatchetMessage(groupID []byte, payload []byte) (*ProtocolMessageSpec, error)
BuildHashRatchetMessage returns a hash ratchet chat message
func (*Protocol) BuildPublicMessage ¶
func (p *Protocol) BuildPublicMessage(myIdentityKey *ecdsa.PrivateKey, payload []byte) (*ProtocolMessageSpec, error)
BuildPublicMessage marshals a public chat message given the user identity private key and a payload
func (*Protocol) ConfirmBundleAdvertisement ¶
func (*Protocol) ConfirmMessageProcessed ¶
ConfirmMessageProcessed confirms and deletes message keys for the given messages
func (*Protocol) DisableInstallation ¶
DisableInstallation disables an installation for multi-device sync.
func (*Protocol) EnableInstallation ¶
EnableInstallation enables an installation for multi-device sync.
func (*Protocol) GenerateHashRatchetKey ¶ added in v0.102.2
func (*Protocol) GetAllHREncodedKeys ¶ added in v0.114.4
func (*Protocol) GetBundle ¶
func (p *Protocol) GetBundle(myIdentityKey *ecdsa.PrivateKey) (*Bundle, error)
GetBundle retrieves or creates a X3DH bundle, given a private identity key.
func (*Protocol) GetCurrentKeyForGroup ¶ added in v0.102.2
func (*Protocol) GetHREncodedKeys ¶ added in v0.114.4
func (*Protocol) GetKeyExMessageSpecs ¶ added in v0.102.2
func (p *Protocol) GetKeyExMessageSpecs(communityID []byte, identity *ecdsa.PrivateKey, recipients []*ecdsa.PublicKey, forceRekey bool) ([]*ProtocolMessageSpec, error)
func (*Protocol) GetKeyIDsForGroup ¶ added in v0.162.9
GetKeyIDsForGroup returns a slice of key IDs belonging to a given group ID
func (*Protocol) GetMultiDevice ¶ added in v0.134.0
func (p *Protocol) GetMultiDevice() *multidevice.Multidevice
func (*Protocol) GetOurActiveInstallations ¶
func (p *Protocol) GetOurActiveInstallations(myIdentityKey *ecdsa.PublicKey) ([]*multidevice.Installation, error)
GetOurActiveInstallations returns all the active installations available given an identity
func (*Protocol) GetOurInstallations ¶
func (p *Protocol) GetOurInstallations(myIdentityKey *ecdsa.PublicKey) ([]*multidevice.Installation, error)
GetOurInstallations returns all the installations available given an identity
func (*Protocol) GetPublicBundle ¶
GetPublicBundle retrieves a public bundle given an identity
func (*Protocol) HandleHashRatchetKeys ¶ added in v0.114.4
func (p *Protocol) HandleHashRatchetKeys(groupID, encodedKeys []byte) ([]*HashRatchetInfo, error)
func (*Protocol) HandleMessage ¶
func (p *Protocol) HandleMessage( myIdentityKey *ecdsa.PrivateKey, theirPublicKey *ecdsa.PublicKey, protocolMessage *ProtocolMessage, messageID []byte, ) (*DecryptMessageResponse, error)
HandleMessage unmarshals a message and processes it, decrypting it if it is a 1:1 message.
func (*Protocol) ProcessPublicBundle ¶
func (p *Protocol) ProcessPublicBundle(myIdentityKey *ecdsa.PrivateKey, bundle *Bundle) ([]*multidevice.Installation, error)
ProcessPublicBundle processes a received X3DH bundle.
func (*Protocol) SetInstallationMetadata ¶
func (p *Protocol) SetInstallationMetadata(myIdentityKey *ecdsa.PublicKey, installationID string, data *multidevice.InstallationMetadata) error
SetInstallationMetadata sets the metadata for our own installation
func (*Protocol) SetInstallationName ¶ added in v0.138.8
func (p *Protocol) SetInstallationName(myIdentityKey *ecdsa.PublicKey, installationID string, name string) error
SetInstallationName sets the metadata for our own installation
func (*Protocol) ShouldAdvertiseBundle ¶
func (*Protocol) Start ¶
func (p *Protocol) Start(myIdentity *ecdsa.PrivateKey) (*Subscriptions, error)
type ProtocolMessage ¶
type ProtocolMessage struct { // The device id of the sender InstallationId string `protobuf:"bytes,2,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"` // List of bundles Bundles []*Bundle `protobuf:"bytes,3,rep,name=bundles,proto3" json:"bundles,omitempty"` // One to one message, encrypted, indexed by installation_id // TODO map here is redundant in case of community messages EncryptedMessage map[string]*EncryptedMessageProtocol `` /* 199-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) GetBundles ¶
func (m *ProtocolMessage) GetBundles() []*Bundle
func (*ProtocolMessage) GetEncryptedMessage ¶ added in v0.91.12
func (m *ProtocolMessage) GetEncryptedMessage() map[string]*EncryptedMessageProtocol
func (*ProtocolMessage) GetInstallationId ¶
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 ProtocolMessageSpec ¶
type ProtocolMessageSpec struct { Message *ProtocolMessage // Installations is the targeted devices Installations []*multidevice.Installation SharedSecret *sharedsecret.Secret // AgreedSecret indicates whether the shared secret has been agreed AgreedSecret bool // Public means that the spec contains a public wrapped message Public bool }
func (*ProtocolMessageSpec) MinVersion ¶
func (p *ProtocolMessageSpec) MinVersion() uint32
func (*ProtocolMessageSpec) PartitionedTopicMode ¶
func (p *ProtocolMessageSpec) PartitionedTopicMode() PartitionTopicMode
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 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"` ProtocolVersion uint32 `protobuf:"varint,3,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*SignedPreKey) Descriptor ¶
func (*SignedPreKey) Descriptor() ([]byte, []int)
func (*SignedPreKey) GetProtocolVersion ¶
func (m *SignedPreKey) GetProtocolVersion() uint32
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 Subscriptions ¶ added in v0.59.0
type Subscriptions struct { SendContactCode <-chan struct{} Quit chan struct{} }
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"` 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) 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