group

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 3 Imported by: 13

Documentation

Overview

Package group contains an implementation of a generic protocol group and auxiliary tools that help during group-related operations.

Index

Constants

View Source
const MaxMemberIndex = 255

MaxMemberIndex denotes the maximum value of the MemberIndex type. That type is represented as uint8 so the maximum member index is 255.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

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

Group is protocol's members group.

func NewGroup

func NewGroup(dishonestThreshold int, size int) *Group

NewGroup creates a new Group with the provided dishonest threshold and empty IA and DQ members list.

func (*Group) DishonestThreshold

func (g *Group) DishonestThreshold() int

DishonestThreshold returns value of the dishonest members threshold as set for the group.

func (*Group) DisqualifiedMemberIndexes

func (g *Group) DisqualifiedMemberIndexes() []MemberIndex

DisqualifiedMemberIndexes returns indexes of all group members that have been disqualified during the protocol execution.

func (*Group) GroupSize

func (g *Group) GroupSize() int

GroupSize returns the full size of the group, including IA and DQ members.

func (*Group) HonestThreshold

func (g *Group) HonestThreshold() int

HonestThreshold returns value of the honest members threshold as set for the group.

func (*Group) InactiveMemberIndexes

func (g *Group) InactiveMemberIndexes() []MemberIndex

InactiveMemberIndexes returns indexes of all group members that have been marked as inactive during the protocol execution.

func (*Group) IsOperating

func (g *Group) IsOperating(memberIndex MemberIndex) bool

IsOperating returns true if member with the given index has not been marked as IA or DQ in the group.

func (*Group) MarkMemberAsDisqualified

func (g *Group) MarkMemberAsDisqualified(memberIndex MemberIndex)

MarkMemberAsDisqualified adds the member with the given index to the list of disqualified members. If the member is not a part of the group, is already disqualified or marked as inactive, method does nothing.

func (*Group) MarkMemberAsInactive

func (g *Group) MarkMemberAsInactive(memberIndex MemberIndex)

MarkMemberAsInactive adds the member with the given index to the list of inactive members. If the member is not a part of the group, is already disqualified or marked as inactive, method does nothing.

func (*Group) MemberIndexes

func (g *Group) MemberIndexes() []MemberIndex

MemberIndexes returns indexes of all group members, as initially selected to the group. Returned list contains indexes of all members, including those marked as inactive or disqualified.

func (*Group) OperatingMemberIndexes

func (g *Group) OperatingMemberIndexes() []MemberIndex

OperatingMemberIndexes returns indexes of all group members that are active and have not been disqualified. All those members are properly operating in the group at the moment of calling this method.

type InactiveMemberFilter

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

InactiveMemberFilter is a proxy facilitates filtering out inactive members in the given phase and registering their final list in the Group.

func NewInactiveMemberFilter

func NewInactiveMemberFilter(
	logger log.StandardLogger,
	selfMemberIndex MemberIndex,
	group *Group,
) *InactiveMemberFilter

NewInactiveMemberFilter creates a new instance of InactiveMemberFilter. It accepts member index of the current member (the one which will be filtering out other group members for inactivity) and the reference to Group to which all those members belong.

func (*InactiveMemberFilter) FlushInactiveMembers

func (mf *InactiveMemberFilter) FlushInactiveMembers()

FlushInactiveMembers takes all members who were not previously marked as active and flushes them to the group as inactive members.

func (*InactiveMemberFilter) MarkMemberAsActive

func (mf *InactiveMemberFilter) MarkMemberAsActive(memberID MemberIndex)

MarkMemberAsActive marks member with the given index as active in the given phase.

type MemberIndex

type MemberIndex = uint8

MemberIndex is an index of a member in a group. The maximum member index value is 255.

type MembershipValidator

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

MembershipValidator operates on a group selection result and lets to validate one's membership based on the provided public key.

Validator is used to filter out messages from parties not selected to the group. It is also used to confirm the position in the group of a party that was selected. This is used to validate messages sent by that party to all other group members.

func NewMembershipValidator

func NewMembershipValidator(
	logger log.StandardLogger,
	operatorsAddresses []chain.Address,
	signing chain.Signing,
) *MembershipValidator

NewMembershipValidator creates a validator for the provided group selection result.

func (*MembershipValidator) IsInGroup

func (mv *MembershipValidator) IsInGroup(
	publicKey *operator.PublicKey,
) bool

IsInGroup returns true if party with the given public key has been selected to the group. Otherwise, function returns false.

func (*MembershipValidator) IsValidMembership

func (mv *MembershipValidator) IsValidMembership(
	memberID MemberIndex,
	publicKey []byte,
) bool

IsValidMembership returns true if party with the given public key has been selected to the group at the given position. If the position does not match function returns false. The same happens when the party was not selected to the group.

Jump to

Keyboard shortcuts

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