spec

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: AGPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BallotIndex

func BallotIndex(voterIndex uint64) (uint64, error)

BallotIndex returns a BallotIndex on the lower half of the 64 bit space, between BallotMin and BallotMax.

BallotIndex = BallotMin + voterIndex

func BallotInputsHashRTE

func BallotInputsHashRTE(
	processID *big.Int,
	ballotMode BallotMode,
	encryptionKeyX *big.Int,
	encryptionKeyY *big.Int,
	address *big.Int,
	voteID uint64,
	ballot []*big.Int,
	weight *big.Int,
) (*big.Int, error)

BallotInputsHashRTE computes the ballot inputs hash using RTE-encoded points.

func StateRoot

func StateRoot(processID, censusOrigin, pubKeyX, pubKeyY, ballotMode *big.Int) (*big.Int, error)

StateRoot computes the state root hash for the process parameters.

func VoteID

func VoteID(processID, address, k *big.Int) (uint64, error)

VoteID calculates the poseidon hash of: the process ID, voter's address and a secret value k. This is truncated to the least significant 63 bits, and then shifted to the upper half of the 64 bit space by setting the first bit to 1.

Types

type BallotMode

type BallotMode struct {
	NumFields      uint8  `json:"numFields" cbor:"0,keyasint,omitempty"`
	GroupSize      uint8  `json:"groupSize" cbor:"1,keyasint,omitempty"`
	UniqueValues   bool   `json:"uniqueValues" cbor:"2,keyasint,omitempty"`
	CostFromWeight bool   `json:"costFromWeight" cbor:"3,keyasint,omitempty"`
	CostExponent   uint8  `json:"costExponent" cbor:"4,keyasint,omitempty"`
	MaxValue       uint64 `json:"maxValue" cbor:"5,keyasint,omitempty"`
	MinValue       uint64 `json:"minValue" cbor:"6,keyasint,omitempty"`
	MaxValueSum    uint64 `json:"maxValueSum" cbor:"7,keyasint,omitempty"`
	MinValueSum    uint64 `json:"minValueSum" cbor:"8,keyasint,omitempty"`
}

BallotMode defines the ballot configuration fields used by the spec.

func (BallotMode) Pack

func (bm BallotMode) Pack() (*big.Int, error)

Pack packs the ballot mode fields into a single field element.

func (BallotMode) String

func (bm BallotMode) String() string

String returns a string representation of the ballot mode.

func (BallotMode) Validate

func (bm BallotMode) Validate() error

Validate validates the ballot mode fields for basic consistency.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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