roundedcensus

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByBalance

type ByBalance []*Participant

ByBalance implements sort.Interface for []Participant based on the Balance field.

func (ByBalance) Len

func (a ByBalance) Len() int

func (ByBalance) Less

func (a ByBalance) Less(i, j int) bool

func (ByBalance) Swap

func (a ByBalance) Swap(i, j int)

type GroupsConfig

type GroupsConfig struct {
	// GroupBalanceDiff is the maximum difference between consecutive balances
	GroupBalanceDiff *big.Int
	// MinPrivacyThreshold is the minimum number of participants in a group.
	MinPrivacyThreshold int64
	// MinAccuracy is the minimum accuracy required for the rounding process.
	MinAccuracy float64
	// OutliersThreshold is the z-score threshold for identifying outliers.
	OutliersThreshold float64
}

GroupsConfig represents the configuration for the grouping and rounding process.

var DefaultGroupsConfig GroupsConfig = GroupsConfig{
	GroupBalanceDiff:    big.NewInt(0),
	MinPrivacyThreshold: 3,
	MinAccuracy:         50.0,
	OutliersThreshold:   2.0,
}

type Participant

type Participant struct {
	Address string
	Balance *big.Int
}

Participant represents a participant with an Ethereum address and balance.

func GroupAndRoundCensus

func GroupAndRoundCensus(participants []*Participant, config GroupsConfig) ([]*Participant, float64, error)

GroupAndRoundCensus groups the participants and rounds their balances. It rounds the balances of the participants with the highest accuracy possible while maintaining a minimum privacy threshold. It discards outliers from the rounding process but returns them in the final list of participants.

Jump to

Keyboard shortcuts

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