groupStore

package
v4.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const MaxGroupChats = 64

MaxGroupChats is the maximum number of group chats that a user can be a part of at once.

Variables

This section is empty.

Functions

This section is empty.

Types

type DhKeyList

type DhKeyList map[id.ID]*cyclic.Int

DhKeyList is a map of users to their DH key.

func DeserializeDhKeyList

func DeserializeDhKeyList(data []byte) (DhKeyList, error)

DeserializeDhKeyList deserializes the bytes into a DhKeyList.

func GenerateDhKeyList

func GenerateDhKeyList(userID *id.ID, privKey *cyclic.Int,
	members group.Membership, grp *cyclic.Group) DhKeyList

GenerateDhKeyList generates the DH key between the user and all group members.

func (DhKeyList) Add

func (dkl DhKeyList) Add(privKey *cyclic.Int, m group.Member, grp *cyclic.Group)

Add generates DH key between the user and the group member. The

func (DhKeyList) DeepCopy

func (dkl DhKeyList) DeepCopy() DhKeyList

DeepCopy returns a copy of the DhKeyList.

func (DhKeyList) GoString

func (dkl DhKeyList) GoString() string

GoString returns all the elements in the DhKeyList as text in sorted order. This functions satisfies the fmt.GoStringer interface.

func (DhKeyList) Serialize

func (dkl DhKeyList) Serialize() []byte

Serialize serializes the DhKeyList and returns the byte slice.

type Group

type Group struct {
	Name        []byte            // Name of the group set by the user
	ID          *id.ID            // Group ID
	Key         group.Key         // Group key
	IdPreimage  group.IdPreimage  // 256-bit randomly generated value
	KeyPreimage group.KeyPreimage // 256-bit randomly generated value
	InitMessage []byte            // The original invite message
	Created     time.Time         // Timestamp of when the group was created
	Members     group.Membership  // Sorted list of members in group
	DhKeys      DhKeyList         // List of shared DH keys
}

Group contains the membership list, the cryptographic information, and the identifying information of a group chat.

func DeserializeGroup

func DeserializeGroup(data []byte) (Group, error)

DeserializeGroup deserializes the bytes into a Group.

func NewGroup

func NewGroup(name []byte, groupID *id.ID, groupKey group.Key,
	idPreimage group.IdPreimage, keyPreimage group.KeyPreimage,
	initMessage []byte, created time.Time, members group.Membership,
	dhKeys DhKeyList) Group

NewGroup creates a new Group from copies of the given data.

func (Group) DeepCopy

func (g Group) DeepCopy() Group

DeepCopy returns a copy of the Group.

func (Group) GoString

func (g Group) GoString() string

GoString returns all the Group's fields as text. This functions satisfies the fmt.GoStringer interface.

func (Group) Serialize

func (g Group) Serialize() []byte

Serialize serializes the Group and returns the byte slice. The serialized data follows the following format. +----------+----------+----------+----------+------------+-------------+-----------------+-------------+---------+-------------+----------+----------+ | Name len | Name | ID | Key | IdPreimage | KeyPreimage | InitMessage len | InitMessage | Created | Members len | Members | DhKeys | | 8 bytes | variable | 33 bytes | 32 bytes | 32 bytes | 32 bytes | 8 bytes | variable | 8 bytes | 8 bytes | variable | variable | +----------+----------+----------+----------+------------+-------------+-----------------+-------------+---------+-------------+----------+----------+

type Store

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

Store stores the list of Groups that a user is a part of.

func LoadStore

func LoadStore(kv versioned.KV, user group.Member) (*Store, error)

LoadStore loads all the Groups from storage into memory and return them in a Store object.

func NewOrLoadStore

func NewOrLoadStore(kv versioned.KV, user group.Member) (*Store, error)

NewOrLoadStore loads the group store from storage or makes a new one if it does not exist.

func NewStore

func NewStore(kv versioned.KV, user group.Member) (*Store, error)

NewStore constructs a new Store object for the user and saves it to storage.

func (*Store) Add

func (s *Store) Add(g Group) error

Add adds a new group to the group list and saves it to storage. An error is returned if the user has the max number of groups (MaxGroupChats).

func (*Store) Get

func (s *Store) Get(groupID *id.ID) (Group, bool)

Get returns the Group for the given group ID. Returns false if no Group is found.

func (*Store) GetByKeyFp

func (s *Store) GetByKeyFp(keyFp format.Fingerprint, salt [group.SaltLen]byte) (
	Group, bool)

GetByKeyFp returns the group with the matching key fingerprint and salt. Returns false if no group is found.

func (*Store) GetUser

func (s *Store) GetUser() group.Member

GetUser returns the group member for the current user.

func (*Store) GroupIDs

func (s *Store) GroupIDs() []*id.ID

GroupIDs returns a list of all group IDs.

func (*Store) Groups

func (s *Store) Groups() []Group

Groups returns a list of all groups.

func (*Store) Len

func (s *Store) Len() int

Len returns the number of groups stored.

func (*Store) Remove

func (s *Store) Remove(groupID *id.ID) error

Remove removes the group with the corresponding ID from memory and storage. An error is returned if the group cannot be found in memory or storage.

func (*Store) SetUser

func (s *Store) SetUser(user group.Member, x interface{})

SetUser allows a user to be set. This function is for testing purposes only. It panics if the interface is not of a testing type.

Jump to

Keyboard shortcuts

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