Documentation ¶
Index ¶
- Variables
- func ExtractIdentity(bundle *Bundle) (*ecdsa.PublicKey, error)
- func GenerateSharedKey(privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey) ([]byte, error)
- func GetCurrentTime() uint64
- 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)deprecated
- func (x *Bundle) GetIdentity() []byte
- func (x *Bundle) GetSignature() []byte
- func (x *Bundle) GetSignedPreKeys() map[string]*SignedPreKey
- func (x *Bundle) GetTimestamp() int64
- func (*Bundle) ProtoMessage()
- func (x *Bundle) ProtoReflect() protoreflect.Message
- func (x *Bundle) Reset()
- func (x *Bundle) String() string
- type BundleContainer
- func (*BundleContainer) Descriptor() ([]byte, []int)deprecated
- func (x *BundleContainer) GetBundle() *Bundle
- func (x *BundleContainer) GetPrivateSignedPreKey() []byte
- func (*BundleContainer) ProtoMessage()
- func (x *BundleContainer) ProtoReflect() protoreflect.Message
- func (x *BundleContainer) Reset()
- func (x *BundleContainer) String() string
- type DHHeader
- type DRHeader
- func (*DRHeader) Descriptor() ([]byte, []int)deprecated
- func (x *DRHeader) GetId() []byte
- func (x *DRHeader) GetKey() []byte
- func (x *DRHeader) GetN() uint32
- func (x *DRHeader) GetPn() uint32
- func (*DRHeader) ProtoMessage()
- func (x *DRHeader) ProtoReflect() protoreflect.Message
- func (x *DRHeader) Reset()
- func (x *DRHeader) String() string
- type DecryptMessageResponse
- type EncryptedMessageProtocol
- func (*EncryptedMessageProtocol) Descriptor() ([]byte, []int)deprecated
- func (x *EncryptedMessageProtocol) GetDHHeader() *DHHeader
- func (x *EncryptedMessageProtocol) GetDRHeader() *DRHeader
- func (x *EncryptedMessageProtocol) GetHRHeader() *HRHeader
- func (x *EncryptedMessageProtocol) GetPayload() []byte
- func (x *EncryptedMessageProtocol) GetX3DHHeader() *X3DHHeader
- func (*EncryptedMessageProtocol) ProtoMessage()
- func (x *EncryptedMessageProtocol) ProtoReflect() protoreflect.Message
- func (x *EncryptedMessageProtocol) Reset()
- func (x *EncryptedMessageProtocol) String() string
- type HRCache
- type HRHeader
- func (*HRHeader) Descriptor() ([]byte, []int)deprecated
- func (x *HRHeader) GetDeprecatedKeyId() uint32
- func (x *HRHeader) GetGroupId() []byte
- func (x *HRHeader) GetKeyId() []byte
- func (x *HRHeader) GetKeys() *HRKeys
- func (x *HRHeader) GetSeqNo() uint32
- func (*HRHeader) ProtoMessage()
- func (x *HRHeader) ProtoReflect() protoreflect.Message
- func (x *HRHeader) Reset()
- func (x *HRHeader) String() string
- type HRKey
- func (*HRKey) Descriptor() ([]byte, []int)deprecated
- func (x *HRKey) GetDeprecatedKeyId() uint32
- func (x *HRKey) GetKey() []byte
- func (x *HRKey) GetTimestamp() uint64
- func (*HRKey) ProtoMessage()
- func (x *HRKey) ProtoReflect() protoreflect.Message
- func (x *HRKey) Reset()
- func (x *HRKey) String() string
- type HRKeys
- type HashRatchetInfo
- type HashRatchetKeyCompatibility
- type PartitionTopicMode
- type Protocol
- func (p *Protocol) AddInstallation(identity []byte, timestamp int64, installation *multidevice.Installation, ...) ([]*multidevice.Installation, error)
- 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) BuildHashRatchetKeyExchangeMessageWithPayload(myIdentityKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, groupID []byte, ...) (*ProtocolMessageSpec, error)
- func (p *Protocol) BuildHashRatchetMessage(groupID []byte, payload []byte) (*ProtocolMessageSpec, error)
- func (p *Protocol) BuildHashRatchetReKeyGroupMessage(myIdentityKey *ecdsa.PrivateKey, recipients []*ecdsa.PublicKey, groupID []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) DecryptCommunityGrant(myIdentityKey *ecdsa.PrivateKey, senderKey *ecdsa.PublicKey, ...) ([]byte, error)
- func (p *Protocol) DecryptWithHashRatchet(keyID []byte, seqNo uint32, payload []byte) ([]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) EncryptCommunityGrants(privateKey *ecdsa.PrivateKey, recipientGrants map[*ecdsa.PublicKey][]byte) (map[uint32][]byte, error)
- func (p *Protocol) EncryptWithHashRatchet(groupID []byte, payload []byte) ([]byte, *HashRatchetKeyCompatibility, uint32, error)
- func (p *Protocol) GenerateHashRatchetKey(groupID []byte) (*HashRatchetKeyCompatibility, error)
- func (p *Protocol) GetAllHRKeys(groupID []byte) (*HRKeys, error)
- func (p *Protocol) GetAllHRKeysMarshaledV1(groupID []byte) ([]byte, error)deprecated
- func (p *Protocol) GetAllHRKeysMarshaledV2(groupID []byte) ([]byte, error)
- func (p *Protocol) GetBundle(myIdentityKey *ecdsa.PrivateKey) (*Bundle, error)
- func (p *Protocol) GetCurrentKeyForGroup(groupID []byte) (*HashRatchetKeyCompatibility, error)
- func (p *Protocol) GetHRKeys(ratchets []*HashRatchetKeyCompatibility) *HRKeys
- func (p *Protocol) GetKeyExMessageSpecs(groupID []byte, identity *ecdsa.PrivateKey, recipients []*ecdsa.PublicKey, ...) ([]*ProtocolMessageSpec, error)
- func (p *Protocol) GetKeysForGroup(groupID []byte) ([]*HashRatchetKeyCompatibility, 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) HandleHashRatchetHeadersPayload(encodedHeaders [][]byte) error
- func (p *Protocol) HandleHashRatchetKeys(groupID []byte, keys *HRKeys, myIdentityKey *ecdsa.PrivateKey, ...) ([]*HashRatchetInfo, error)
- func (p *Protocol) HandleHashRatchetKeysPayload(groupID, encodedKeys []byte, myIdentityKey *ecdsa.PrivateKey, ...) ([]*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)deprecated
- func (x *ProtocolMessage) GetBundles() []*Bundle
- func (x *ProtocolMessage) GetEncryptedMessage() map[string]*EncryptedMessageProtocol
- func (x *ProtocolMessage) GetInstallationId() string
- func (x *ProtocolMessage) GetPublicMessage() []byte
- func (*ProtocolMessage) ProtoMessage()
- func (x *ProtocolMessage) ProtoReflect() protoreflect.Message
- func (x *ProtocolMessage) Reset()
- func (x *ProtocolMessage) String() string
- type ProtocolMessageSpec
- type RatchetInfo
- type RekeyGroup
- func (*RekeyGroup) Descriptor() ([]byte, []int)deprecated
- func (x *RekeyGroup) GetKeys() map[uint32][]byte
- func (x *RekeyGroup) GetTimestamp() uint64
- func (*RekeyGroup) ProtoMessage()
- func (x *RekeyGroup) ProtoReflect() protoreflect.Message
- func (x *RekeyGroup) Reset()
- func (x *RekeyGroup) String() string
- type SignedPreKey
- func (*SignedPreKey) Descriptor() ([]byte, []int)deprecated
- func (x *SignedPreKey) GetProtocolVersion() uint32
- func (x *SignedPreKey) GetSignedPreKey() []byte
- func (x *SignedPreKey) GetVersion() uint32
- func (*SignedPreKey) ProtoMessage()
- func (x *SignedPreKey) ProtoReflect() protoreflect.Message
- func (x *SignedPreKey) Reset()
- func (x *SignedPreKey) String() string
- type Subscriptions
- type X3DHHeader
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") ErrNoEncryptionKey = errors.New("no encryption key found for the community") )
var ( // ErrNoPayload means that there was no payload found in the received protocol message. ErrNoPayload = errors.New("no payload") ErrNoRatchetKey = errors.New("no ratchet key for given keyID") )
var File_protocol_message_proto protoreflect.FileDescriptor
Functions ¶
func ExtractIdentity ¶
ExtractIdentity extracts the identity key from a given bundle
func GenerateSharedKey ¶ added in v0.181.33
func GetCurrentTime ¶ added in v0.162.9
func GetCurrentTime() uint64
GetCurrentTime64 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"` // contains filtered or unexported fields }
X3DH prekey bundle
func (*Bundle) Descriptor
deprecated
func (*Bundle) GetIdentity ¶
func (*Bundle) GetSignature ¶
func (*Bundle) GetSignedPreKeys ¶
func (x *Bundle) GetSignedPreKeys() map[string]*SignedPreKey
func (*Bundle) GetTimestamp ¶
func (*Bundle) ProtoMessage ¶
func (*Bundle) ProtoMessage()
func (*Bundle) ProtoReflect ¶ added in v0.163.14
func (x *Bundle) ProtoReflect() protoreflect.Message
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"` // contains filtered or unexported fields }
func NewBundleContainer ¶
func NewBundleContainer(identity *ecdsa.PrivateKey, installationID string) (*BundleContainer, error)
NewBundleContainer creates a new BundleContainer from an identity private key
func (*BundleContainer) Descriptor
deprecated
func (*BundleContainer) Descriptor() ([]byte, []int)
Deprecated: Use BundleContainer.ProtoReflect.Descriptor instead.
func (*BundleContainer) GetBundle ¶
func (x *BundleContainer) GetBundle() *Bundle
func (*BundleContainer) GetPrivateSignedPreKey ¶
func (x *BundleContainer) GetPrivateSignedPreKey() []byte
func (*BundleContainer) ProtoMessage ¶
func (*BundleContainer) ProtoMessage()
func (*BundleContainer) ProtoReflect ¶ added in v0.163.14
func (x *BundleContainer) ProtoReflect() protoreflect.Message
func (*BundleContainer) Reset ¶
func (x *BundleContainer) Reset()
func (*BundleContainer) String ¶
func (x *BundleContainer) String() string
type DHHeader ¶
type DHHeader struct { // Compressed ephemeral public key Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // contains filtered or unexported fields }
func (*DHHeader) Descriptor
deprecated
func (*DHHeader) ProtoMessage ¶
func (*DHHeader) ProtoMessage()
func (*DHHeader) ProtoReflect ¶ added in v0.163.14
func (x *DHHeader) ProtoReflect() protoreflect.Message
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"` // contains filtered or unexported fields }
func (*DRHeader) Descriptor
deprecated
func (*DRHeader) ProtoMessage ¶
func (*DRHeader) ProtoMessage()
func (*DRHeader) ProtoReflect ¶ added in v0.163.14
func (x *DRHeader) ProtoReflect() protoreflect.Message
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"` // contains filtered or unexported fields }
Direct message value
func (*EncryptedMessageProtocol) Descriptor
deprecated
added in
v0.91.12
func (*EncryptedMessageProtocol) Descriptor() ([]byte, []int)
Deprecated: Use EncryptedMessageProtocol.ProtoReflect.Descriptor instead.
func (*EncryptedMessageProtocol) GetDHHeader ¶ added in v0.91.12
func (x *EncryptedMessageProtocol) GetDHHeader() *DHHeader
func (*EncryptedMessageProtocol) GetDRHeader ¶ added in v0.91.12
func (x *EncryptedMessageProtocol) GetDRHeader() *DRHeader
func (*EncryptedMessageProtocol) GetHRHeader ¶ added in v0.91.12
func (x *EncryptedMessageProtocol) GetHRHeader() *HRHeader
func (*EncryptedMessageProtocol) GetPayload ¶ added in v0.91.12
func (x *EncryptedMessageProtocol) GetPayload() []byte
func (*EncryptedMessageProtocol) GetX3DHHeader ¶ added in v0.91.12
func (x *EncryptedMessageProtocol) GetX3DHHeader() *X3DHHeader
func (*EncryptedMessageProtocol) ProtoMessage ¶ added in v0.91.12
func (*EncryptedMessageProtocol) ProtoMessage()
func (*EncryptedMessageProtocol) ProtoReflect ¶ added in v0.163.14
func (x *EncryptedMessageProtocol) ProtoReflect() protoreflect.Message
func (*EncryptedMessageProtocol) Reset ¶ added in v0.91.12
func (x *EncryptedMessageProtocol) Reset()
func (*EncryptedMessageProtocol) String ¶ added in v0.91.12
func (x *EncryptedMessageProtocol) String() string
type HRHeader ¶ added in v0.91.12
type HRHeader struct { // deprecated group key ID DeprecatedKeyId uint32 `protobuf:"varint,1,opt,name=deprecated_key_id,json=deprecatedKeyId,proto3" json:"deprecated_key_id,omitempty"` // group message number for this key_id SeqNo uint32 `protobuf:"varint,2,opt,name=seq_no,json=seqNo,proto3" json:"seq_no,omitempty"` // group ID GroupId []byte `protobuf:"bytes,3,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` // group key ID KeyId []byte `protobuf:"bytes,4,opt,name=key_id,json=keyId,proto3" json:"key_id,omitempty"` Keys *HRKeys `protobuf:"bytes,5,opt,name=keys,proto3" json:"keys,omitempty"` // contains filtered or unexported fields }
Hash Ratchet Header
func (*HRHeader) Descriptor
deprecated
added in
v0.91.12
func (*HRHeader) GetDeprecatedKeyId ¶ added in v0.171.5
func (*HRHeader) GetGroupId ¶ added in v0.91.12
func (*HRHeader) ProtoMessage ¶ added in v0.91.12
func (*HRHeader) ProtoMessage()
func (*HRHeader) ProtoReflect ¶ added in v0.163.14
func (x *HRHeader) ProtoReflect() protoreflect.Message
type HRKey ¶ added in v0.111.7
type HRKey struct { DeprecatedKeyId uint32 `protobuf:"varint,1,opt,name=deprecated_key_id,json=deprecatedKeyId,proto3" json:"deprecated_key_id,omitempty"` Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` Timestamp uint64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // contains filtered or unexported fields }
func (*HRKey) Descriptor
deprecated
added in
v0.111.7
func (*HRKey) GetDeprecatedKeyId ¶ added in v0.171.5
func (*HRKey) GetTimestamp ¶ added in v0.171.5
func (*HRKey) ProtoMessage ¶ added in v0.111.7
func (*HRKey) ProtoMessage()
func (*HRKey) ProtoReflect ¶ added in v0.163.14
func (x *HRKey) ProtoReflect() protoreflect.Message
type HRKeys ¶ added in v0.111.7
type HRKeys struct { Keys []*HRKey `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` RekeyGroup *RekeyGroup `protobuf:"bytes,2,opt,name=rekey_group,json=rekeyGroup,proto3" json:"rekey_group,omitempty"` // contains filtered or unexported fields }
func (*HRKeys) Descriptor
deprecated
added in
v0.111.7
func (*HRKeys) GetRekeyGroup ¶ added in v0.171.5
func (x *HRKeys) GetRekeyGroup() *RekeyGroup
func (*HRKeys) ProtoMessage ¶ added in v0.111.7
func (*HRKeys) ProtoMessage()
func (*HRKeys) ProtoReflect ¶ added in v0.163.14
func (x *HRKeys) ProtoReflect() protoreflect.Message
type HashRatchetInfo ¶ added in v0.111.7
type HashRatchetKeyCompatibility ¶ added in v0.171.5
type HashRatchetKeyCompatibility struct { GroupID []byte Timestamp uint64 Key []byte // contains filtered or unexported fields }
func (*HashRatchetKeyCompatibility) DeprecatedKeyID ¶ added in v0.171.5
func (h *HashRatchetKeyCompatibility) DeprecatedKeyID() uint32
func (*HashRatchetKeyCompatibility) GenerateNext ¶ added in v0.171.5
func (h *HashRatchetKeyCompatibility) GenerateNext() (*HashRatchetKeyCompatibility, error)
func (*HashRatchetKeyCompatibility) GetKeyID ¶ added in v0.171.5
func (h *HashRatchetKeyCompatibility) GetKeyID() ([]byte, error)
func (*HashRatchetKeyCompatibility) IsOldFormat ¶ added in v0.171.5
func (h *HashRatchetKeyCompatibility) IsOldFormat() bool
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) AddInstallation ¶ added in v0.182.40
func (p *Protocol) AddInstallation(identity []byte, timestamp int64, installation *multidevice.Installation, enabled bool) ([]*multidevice.Installation, error)
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, ratchets []*HashRatchetKeyCompatibility) (*ProtocolMessageSpec, error)
BuildHashRatchetKeyExchangeMessage builds a 1:1 message containing newly generated hash ratchet key
func (*Protocol) BuildHashRatchetKeyExchangeMessageWithPayload ¶ added in v0.174.0
func (p *Protocol) BuildHashRatchetKeyExchangeMessageWithPayload(myIdentityKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey, groupID []byte, ratchets []*HashRatchetKeyCompatibility, payload []byte) (*ProtocolMessageSpec, error)
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) BuildHashRatchetReKeyGroupMessage ¶ added in v0.171.5
func (p *Protocol) BuildHashRatchetReKeyGroupMessage(myIdentityKey *ecdsa.PrivateKey, recipients []*ecdsa.PublicKey, groupID []byte, payload []byte, ratchet *HashRatchetKeyCompatibility) (*ProtocolMessageSpec, error)
BuildHashRatchetRekeyGroup builds a public message with the new key
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) DecryptCommunityGrant ¶ added in v0.179.5
func (*Protocol) DecryptWithHashRatchet ¶ added in v0.171.39
func (*Protocol) DisableInstallation ¶
DisableInstallation disables an installation for multi-device sync.
func (*Protocol) EnableInstallation ¶
EnableInstallation enables an installation for multi-device sync.
func (*Protocol) EncryptCommunityGrants ¶ added in v0.179.5
func (*Protocol) EncryptWithHashRatchet ¶ added in v0.171.39
func (*Protocol) GenerateHashRatchetKey ¶ added in v0.102.2
func (p *Protocol) GenerateHashRatchetKey(groupID []byte) (*HashRatchetKeyCompatibility, error)
func (*Protocol) GetAllHRKeys ¶ added in v0.176.1
func (*Protocol) GetAllHRKeysMarshaledV1
deprecated
added in
v0.176.1
func (*Protocol) GetAllHRKeysMarshaledV2 ¶ added in v0.176.1
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 (p *Protocol) GetCurrentKeyForGroup(groupID []byte) (*HashRatchetKeyCompatibility, error)
func (*Protocol) GetHRKeys ¶ added in v0.176.1
func (p *Protocol) GetHRKeys(ratchets []*HashRatchetKeyCompatibility) *HRKeys
func (*Protocol) GetKeyExMessageSpecs ¶ added in v0.102.2
func (p *Protocol) GetKeyExMessageSpecs(groupID []byte, identity *ecdsa.PrivateKey, recipients []*ecdsa.PublicKey, forceRekey bool) ([]*ProtocolMessageSpec, error)
func (*Protocol) GetKeysForGroup ¶ added in v0.171.5
func (p *Protocol) GetKeysForGroup(groupID []byte) ([]*HashRatchetKeyCompatibility, error)
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) HandleHashRatchetHeadersPayload ¶ added in v0.176.1
func (*Protocol) HandleHashRatchetKeys ¶ added in v0.114.4
func (p *Protocol) HandleHashRatchetKeys(groupID []byte, keys *HRKeys, myIdentityKey *ecdsa.PrivateKey, theirIdentityKey *ecdsa.PublicKey) ([]*HashRatchetInfo, error)
func (*Protocol) HandleHashRatchetKeysPayload ¶ added in v0.174.0
func (p *Protocol) HandleHashRatchetKeysPayload(groupID, encodedKeys []byte, myIdentityKey *ecdsa.PrivateKey, theirIdentityKey *ecdsa.PublicKey) ([]*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"` // contains filtered or unexported fields }
Top-level protocol message
func (*ProtocolMessage) Descriptor
deprecated
func (*ProtocolMessage) Descriptor() ([]byte, []int)
Deprecated: Use ProtocolMessage.ProtoReflect.Descriptor instead.
func (*ProtocolMessage) GetBundles ¶
func (x *ProtocolMessage) GetBundles() []*Bundle
func (*ProtocolMessage) GetEncryptedMessage ¶ added in v0.91.12
func (x *ProtocolMessage) GetEncryptedMessage() map[string]*EncryptedMessageProtocol
func (*ProtocolMessage) GetInstallationId ¶
func (x *ProtocolMessage) GetInstallationId() string
func (*ProtocolMessage) GetPublicMessage ¶
func (x *ProtocolMessage) GetPublicMessage() []byte
func (*ProtocolMessage) ProtoMessage ¶
func (*ProtocolMessage) ProtoMessage()
func (*ProtocolMessage) ProtoReflect ¶ added in v0.163.14
func (x *ProtocolMessage) ProtoReflect() protoreflect.Message
func (*ProtocolMessage) Reset ¶
func (x *ProtocolMessage) Reset()
func (*ProtocolMessage) String ¶
func (x *ProtocolMessage) String() string
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 RekeyGroup ¶ added in v0.171.5
type RekeyGroup struct { Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` Keys map[uint32][]byte `` /* 150-byte string literal not displayed */ // contains filtered or unexported fields }
func (*RekeyGroup) Descriptor
deprecated
added in
v0.171.5
func (*RekeyGroup) Descriptor() ([]byte, []int)
Deprecated: Use RekeyGroup.ProtoReflect.Descriptor instead.
func (*RekeyGroup) GetKeys ¶ added in v0.171.5
func (x *RekeyGroup) GetKeys() map[uint32][]byte
func (*RekeyGroup) GetTimestamp ¶ added in v0.171.5
func (x *RekeyGroup) GetTimestamp() uint64
func (*RekeyGroup) ProtoMessage ¶ added in v0.171.5
func (*RekeyGroup) ProtoMessage()
func (*RekeyGroup) ProtoReflect ¶ added in v0.171.5
func (x *RekeyGroup) ProtoReflect() protoreflect.Message
func (*RekeyGroup) Reset ¶ added in v0.171.5
func (x *RekeyGroup) Reset()
func (*RekeyGroup) String ¶ added in v0.171.5
func (x *RekeyGroup) String() string
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"` // contains filtered or unexported fields }
func (*SignedPreKey) Descriptor
deprecated
func (*SignedPreKey) Descriptor() ([]byte, []int)
Deprecated: Use SignedPreKey.ProtoReflect.Descriptor instead.
func (*SignedPreKey) GetProtocolVersion ¶
func (x *SignedPreKey) GetProtocolVersion() uint32
func (*SignedPreKey) GetSignedPreKey ¶
func (x *SignedPreKey) GetSignedPreKey() []byte
func (*SignedPreKey) GetVersion ¶
func (x *SignedPreKey) GetVersion() uint32
func (*SignedPreKey) ProtoMessage ¶
func (*SignedPreKey) ProtoMessage()
func (*SignedPreKey) ProtoReflect ¶ added in v0.163.14
func (x *SignedPreKey) ProtoReflect() protoreflect.Message
func (*SignedPreKey) Reset ¶
func (x *SignedPreKey) Reset()
func (*SignedPreKey) String ¶
func (x *SignedPreKey) String() string
type Subscriptions ¶ added in v0.59.0
type Subscriptions struct { SendContactCode <-chan struct{} NewHashRatchetKeys chan []*HashRatchetInfo 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"` // contains filtered or unexported fields }
func (*X3DHHeader) Descriptor
deprecated
func (*X3DHHeader) Descriptor() ([]byte, []int)
Deprecated: Use X3DHHeader.ProtoReflect.Descriptor instead.
func (*X3DHHeader) GetId ¶
func (x *X3DHHeader) GetId() []byte
func (*X3DHHeader) GetKey ¶
func (x *X3DHHeader) GetKey() []byte
func (*X3DHHeader) ProtoMessage ¶
func (*X3DHHeader) ProtoMessage()
func (*X3DHHeader) ProtoReflect ¶ added in v0.163.14
func (x *X3DHHeader) ProtoReflect() protoreflect.Message
func (*X3DHHeader) Reset ¶
func (x *X3DHHeader) Reset()
func (*X3DHHeader) String ¶
func (x *X3DHHeader) String() string