statetransitiontest

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: AGPL-3.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CensusIMTForTest

func CensusIMTForTest(votes []*state.Vote) (*imtcensus.CensusIMT, error)

CensusIMTForTest creates a CensusIMT instance for testing purposes including the provided votes as census participants. It returns the initialized CensusIMT or an error if the process fails.

func CensusProofsForCircuitTest

func CensusProofsForCircuitTest(
	votes []*state.Vote,
	origin types.CensusOrigin,
	pid types.ProcessID,
) (*big.Int, statetransition.CensusProofs, error)

CensusProofsForCircuitTest generates the census proofs required for the state transition circuit tests based on the provided votes and census origin. It returns the census root, the generated census proofs ready to be used in the statetransition circuit, and an error if the process fails. It supports both Merkle tree and CSP-based by initializing a CSP instance or generating a Merkle tree census as needed.

func DummyAggProof

DummyAggProof returns a dummy aggregator proof

func DummyAggProofPlaceholder

DummyAggProofPlaceholder returns a placeholder for a dummy aggregator proof

func NewTransitionWithOverwrittenVotes

func NewTransitionWithOverwrittenVotes(t *testing.T, origin types.CensusOrigin) *statetransition.StateTransitionCircuit

NewTransitionWithOverwrittenVotes returns a witness that includes an overwritten vote

func NewTransitionWithVotes

func NewTransitionWithVotes(t *testing.T, s *state.State, votes ...*state.Vote) *statetransition.StateTransitionCircuit

func Prove

func Prove(placeholder, assignment frontend.Circuit, outer *big.Int, field *big.Int) (constraint.ConstraintSystem, witness.Witness, groth16.Proof, groth16.VerifyingKey, error)

Types

type DummyAggCircuit

type DummyAggCircuit struct {
	ValidProofs frontend.Variable                      `gnark:",public"`
	InputsHash  emulated.Element[sw_bn254.ScalarField] `gnark:",public"`
	SecretInput frontend.Variable                      `gnark:",secret"`
	// contains filtered or unexported fields
}

DummyAggCircuit is dummy aggregator circuit

func DummyAggAssignment

func DummyAggAssignment(validProofs, hash frontend.Variable) *DummyAggCircuit

DummyAggAssignment returns the assignment of a dummy aggregator circuit.

func DummyAggPlaceholder

func DummyAggPlaceholder(mainDummyAggCircuit constraint.ConstraintSystem) *DummyAggCircuit

DummyAggPlaceholder function returns the placeholder of a dummy aggregator circuit for the constraint.ConstraintSystem provided.

func DummyAggPlaceholderWithConstraints

func DummyAggPlaceholderWithConstraints(nbConstraints int) *DummyAggCircuit

DummyAggPlaceholderWithConstraints returns the placeholder of a dummy aggregator circuit with the desired number of constraints.

func (*DummyAggCircuit) Define

func (c *DummyAggCircuit) Define(api frontend.API) error

Define defines a dummy aggregator circuit

type StateTransitionTestResults

type StateTransitionTestResults struct {
	Process      circuits.Process[*big.Int]
	Votes        []*state.Vote
	PublicInputs *statetransition.PublicInputs
}

StateTransitionTestResults struct includes relevant data after StateTransitionCircuit inputs generation

func StateTransitionInputsForTest

func StateTransitionInputsForTest(
	t *testing.T,
	processID types.ProcessID,
	censusOrigin types.CensusOrigin,
	nValidVoters int,
) (
	*StateTransitionTestResults, *statetransition.StateTransitionCircuit, *statetransition.StateTransitionCircuit,
)

StateTransitionInputsForTest returns the StateTransitionTestResults, the placeholder and the assignments of a StateTransitionCircuit for the processID provided generating nValidVoters. Uses quicktest assertions instead of returning errors.

Jump to

Keyboard shortcuts

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