record

package
v0.0.0-...-d09bcab Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2017 License: GPL-3.0 Imports: 4 Imported by: 17

Documentation

Overview

Package record provides the state and record of a group session.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SenderKey

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

SenderKey record is a structure for storing pre keys inside a SenderKeyStore.

func NewSenderKey

func NewSenderKey(serializer SenderKeySerializer,
	stateSerializer SenderKeyStateSerializer) *SenderKey

NewSenderKey record returns a new sender key record that can be stored in a SenderKeyStore.

func NewSenderKeyFromBytes

func NewSenderKeyFromBytes(serialized []byte, serializer SenderKeySerializer,
	stateSerializer SenderKeyStateSerializer) (*SenderKey, error)

NewSenderKeyFromBytes will return a prekey record from the given bytes using the given serializer.

func NewSenderKeyFromStruct

func NewSenderKeyFromStruct(structure *SenderKeyStructure, serializer SenderKeySerializer,
	stateSerializer SenderKeyStateSerializer) (*SenderKey, error)

NewSenderKeyFromStruct returns a SenderKey record using the given serializable structure.

func (*SenderKey) AddSenderKeyState

func (k *SenderKey) AddSenderKeyState(id uint32, iteration uint32,
	chainKey []byte, signatureKey ecc.ECPublicKeyable)

AddSenderKeyState will add a new state to this senderkey record with the given id, iteration, chainkey, and signature key.

func (*SenderKey) GetSenderKeyStateByID

func (k *SenderKey) GetSenderKeyStateByID(keyID uint32) (*SenderKeyState, error)

GetSenderKeyStateByID will return the sender key state with the given key id.

func (*SenderKey) IsEmpty

func (k *SenderKey) IsEmpty() bool

IsEmpty will return false if there is more than one state in this senderkey record.

func (*SenderKey) SenderKeyState

func (k *SenderKey) SenderKeyState() (*SenderKeyState, error)

SenderKeyState will return the first sender key state in the record's list of sender key states.

func (*SenderKey) Serialize

func (k *SenderKey) Serialize() []byte

Serialize will return the record as serialized bytes so it can be persistently stored.

func (*SenderKey) SetSenderKeyState

func (k *SenderKey) SetSenderKeyState(id uint32, iteration uint32,
	chainKey []byte, signatureKey *ecc.ECKeyPair)

SetSenderKeyState will replace the current senderkey states with the given senderkey state.

type SenderKeySerializer

type SenderKeySerializer interface {
	Serialize(preKey *SenderKeyStructure) []byte
	Deserialize(serialized []byte) (*SenderKeyStructure, error)
}

SenderKeySerializer is an interface for serializing and deserializing SenderKey objects into bytes. An implementation of this interface should be used to encode/decode the object into JSON, Protobuffers, etc.

type SenderKeyState

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

SenderKeyState is a structure for maintaining a senderkey session state.

func NewSenderKeyState

func NewSenderKeyState(keyID uint32, iteration uint32, chainKey []byte,
	signatureKey *ecc.ECKeyPair, serializer SenderKeyStateSerializer) *SenderKeyState

NewSenderKeyState returns a new SenderKeyState.

func NewSenderKeyStateFromBytes

func NewSenderKeyStateFromBytes(serialized []byte, serializer SenderKeyStateSerializer) (*SenderKeyState, error)

NewSenderKeyStateFromBytes will return a Signal State from the given bytes using the given serializer.

func NewSenderKeyStateFromPublicKey

func NewSenderKeyStateFromPublicKey(keyID uint32, iteration uint32, chainKey []byte,
	signatureKey ecc.ECPublicKeyable, serializer SenderKeyStateSerializer) *SenderKeyState

NewSenderKeyStateFromPublicKey returns a new SenderKeyState with the given publicKey.

func NewSenderKeyStateFromStructure

func NewSenderKeyStateFromStructure(structure *SenderKeyStateStructure,
	serializer SenderKeyStateSerializer) (*SenderKeyState, error)

NewSenderKeyStateFromStructure will return a new session state with the given state structure. This structure is given back from an implementation of the sender key state serializer.

func (*SenderKeyState) AddSenderMessageKey

func (k *SenderKeyState) AddSenderMessageKey(senderMsgKey *ratchet.SenderMessageKey)

AddSenderMessageKey will add the given sender message key to the state.

func (*SenderKeyState) HasSenderMessageKey

func (k *SenderKeyState) HasSenderMessageKey(iteration uint32) bool

HasSenderMessageKey will return true if the state has a key with the given iteration.

func (*SenderKeyState) KeyID

func (k *SenderKeyState) KeyID() uint32

KeyID returns the state's key id.

func (*SenderKeyState) RemoveSenderMessageKey

func (k *SenderKeyState) RemoveSenderMessageKey(iteration uint32) *ratchet.SenderMessageKey

RemoveSenderMessageKey will remove the key in this state with the given iteration number.

func (*SenderKeyState) SenderChainKey

func (k *SenderKeyState) SenderChainKey() *ratchet.SenderChainKey

SenderChainKey returns the sender chain key of the state.

func (*SenderKeyState) Serialize

func (k *SenderKeyState) Serialize() []byte

Serialize will return the state as bytes using the given serializer.

func (*SenderKeyState) SetSenderChainKey

func (k *SenderKeyState) SetSenderChainKey(senderChainKey *ratchet.SenderChainKey)

SetSenderChainKey will set the state's sender chain key with the given key.

func (*SenderKeyState) SigningKey

func (k *SenderKeyState) SigningKey() *ecc.ECKeyPair

SigningKey returns the signing key pair of the sender key state.

type SenderKeyStateSerializer

type SenderKeyStateSerializer interface {
	Serialize(state *SenderKeyStateStructure) []byte
	Deserialize(serialized []byte) (*SenderKeyStateStructure, error)
}

SenderKeyStateSerializer is an interface for serializing and deserializing a Signal State into bytes. An implementation of this interface should be used to encode/decode the object into JSON, Protobuffers, etc.

type SenderKeyStateStructure

type SenderKeyStateStructure struct {
	Keys              []*ratchet.SenderMessageKeyStructure
	KeyID             uint32
	SenderChainKey    *ratchet.SenderChainKeyStructure
	SigningKeyPrivate []byte
	SigningKeyPublic  []byte
}

SenderKeyStateStructure is a serializeable structure of SenderKeyState.

type SenderKeyStructure

type SenderKeyStructure struct {
	SenderKeyStates []*SenderKeyStateStructure
}

SenderKeyStructure is a structure for serializing SenderKey records.

Jump to

Keyboard shortcuts

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