Groups
Groups
This file documents a contract which is not yet deployed to Mainnet.
This library is used as a registry of created groups.
This library should be used along with DKG library that ensures linear groups creation (only one group creation happens at a time). A candidate group has to be popped or activated before adding a new candidate group.
Group
Data
GroupRegistered
validatePublicKey
Performs preliminary validation of a new group public key. The group public key must be unique and have 128 bytes in length. If the validation fails, the function reverts. This function must be called first for a public key of a group added with addGroup
function.
Parameters
self
struct Groups.Data
groupPubKey
bytes
Candidate group public key
addGroup
Adds a new candidate group. The group is stored with group public key and group members, but is not yet activated.
The group members list is stored with all misbehaved members filtered out. The code calling this function should ensure that the number of candidate (not activated) groups is never more than one.
Parameters
self
struct Groups.Data
groupPubKey
bytes
Generated candidate group public key
membersHash
bytes32
Keccak256 hash of members that actively took part in DKG.
expireOldGroups
Goes through groups starting from the oldest one that is still active and checks if it hasn't expired. If so, updates the information about expired groups so that all expired groups are marked as such.
terminateGroup
Terminates group with the provided index. Reverts if the group is already terminated.
Parameters
self
struct Groups.Data
groupId
uint64
Index in the groupRegistry array.
selectGroup
Returns an index of a randomly selected active group. Terminated and expired groups are not considered as active. Before new group is selected, information about expired groups is updated. At least one active group needs to be present for this function to succeed.
Parameters
self
struct Groups.Data
seed
uint256
Random number used as a group selection seed.
setGroupLifetime
Setter for group lifetime.
Parameters
self
struct Groups.Data
lifetime
uint256
Lifetime of a group in blocks.
isGroupTerminated
Checks if group with the given index is terminated.
groupLifetimeOf
Gets the cutoff time until which the given group is considered to be active assuming it hasn't been terminated before.
isGroupActive
Checks if group with the given index is active and non-terminated.
getGroup
getGroup
numberOfActiveGroups
Gets the number of active groups. Expired and terminated groups are not counted as active.
shiftByExpiredGroups
Evaluates the shift of a selected group index based on the number of expired groups.
shiftByTerminatedGroups
Evaluates the shift of a selected group index based on the number of non-expired but terminated groups.
Last updated