circuitstest

package
v0.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const AggregatorCacheKeyVersion = "poseidon-v1"

AggregatorCacheKeyVersion forces cache refresh when aggregator hash semantics change.

Variables

This section is empty.

Functions

func GenerateDeterministicK

func GenerateDeterministicK(processID types.ProcessID, nValidVoters int) *big.Int

GenerateDeterministicK creates a deterministic big.Int value based on ProcessID and parameters This ensures consistent K generation for cryptographic operations

func GenerateDeterministicSeed

func GenerateDeterministicSeed(processID types.ProcessID, index int) int64

GenerateDeterministicSeed creates a deterministic seed based on ProcessID and index This ensures the same ProcessID + index always generates the same seed

Types

type AggregatorCacheData

type AggregatorCacheData struct {
	Proof            groth16.Proof
	VerifyingKey     groth16.VerifyingKey
	ProvingKey       groth16.ProvingKey
	ConstraintSystem constraint.ConstraintSystem
	Witness          witness.Witness
	Inputs           AggregatorTestResults
}

AggregatorCacheData holds cached aggregator circuit data

func (*AggregatorCacheData) ReadFromCache

func (d *AggregatorCacheData) ReadFromCache(cacheDir, cacheKey string, requireProvingKey bool) error

ReadFromCache implements CacheableData interface for AggregatorCacheData

func (*AggregatorCacheData) WriteToCache

func (d *AggregatorCacheData) WriteToCache(cacheDir, cacheKey string) error

WriteToCache implements CacheableData interface for AggregatorCacheData

type AggregatorTestResults

type AggregatorTestResults struct {
	InputsHash *big.Int
	Process    circuits.Process[*big.Int]
	Votes      []state.Vote
}

AggregatorTestResults struct includes relevant data after AggregatorCircuit inputs generation

type CacheFiles

type CacheFiles struct {
	BaseDir  string
	CacheKey string
}

CacheFiles manages file paths for cache entries

func (CacheFiles) Exists

func (cf CacheFiles) Exists(extensions ...string) bool

Exists checks if files with any of the given extensions exist

func (CacheFiles) Path

func (cf CacheFiles) Path(extension string) string

Path returns the full path for a file with the given extension

type CacheableData

type CacheableData interface {
	WriteToCache(cacheDir, cacheKey string) error
	ReadFromCache(cacheDir, cacheKey string, requireProvingKey bool) error
}

CacheableData defines the interface for data that can be cached

type CircuitCache

type CircuitCache struct {
	BaseDir string
}

CircuitCache manages caching for circuit test data

func NewCircuitCache

func NewCircuitCache() (*CircuitCache, error)

NewCircuitCache creates a new circuit cache instance

func (*CircuitCache) Exists

func (c *CircuitCache) Exists(cacheKey string) bool

Exists checks if cached data exists for the given key

func (*CircuitCache) GenerateCacheKey

func (c *CircuitCache) GenerateCacheKey(circuitType string, processID types.ProcessID, params ...any) string

GenerateCacheKey creates a deterministic cache key based on circuit type and parameters

func (*CircuitCache) LoadData

func (c *CircuitCache) LoadData(cacheKey string, data CacheableData, requireProvingKey bool) error

LoadData loads cacheable data from the cache

func (*CircuitCache) SaveData

func (c *CircuitCache) SaveData(cacheKey string, data CacheableData) error

SaveData saves cacheable data to the cache

type DeterministicGenerator

type DeterministicGenerator struct {
	ProcessID types.ProcessID
}

DeterministicGenerator provides deterministic value generation based on ProcessID

func NewDeterministicGenerator

func NewDeterministicGenerator(processID types.ProcessID) *DeterministicGenerator

NewDeterministicGenerator creates a new deterministic generator

func (*DeterministicGenerator) BigInt

func (dg *DeterministicGenerator) BigInt(nValidVoters int) *big.Int

BigInt creates a deterministic big.Int value based on ProcessID and parameters

func (*DeterministicGenerator) Seed

func (dg *DeterministicGenerator) Seed(index int) int64

Seed creates a deterministic seed based on ProcessID and index

type VoteVerifierCacheData

type VoteVerifierCacheData struct {
	ProvingKey       groth16.ProvingKey
	VerifyingKey     groth16.VerifyingKey
	ConstraintSystem constraint.ConstraintSystem
	Witness          []witness.Witness
	Inputs           VoteVerifierTestResults
}

VoteVerifierCacheData holds cached vote verifier circuit data

func (*VoteVerifierCacheData) ReadFromCache

func (d *VoteVerifierCacheData) ReadFromCache(cacheDir, cacheKey string, requireProvingKey bool) error

ReadFromCache implements CacheableData interface for VoteVerifierCacheData

func (*VoteVerifierCacheData) WriteToCache

func (d *VoteVerifierCacheData) WriteToCache(cacheDir, cacheKey string) error

WriteToCache implements CacheableData interface for VoteVerifierCacheData

type VoteVerifierTestResults

type VoteVerifierTestResults struct {
	InputsHashes     []*big.Int
	EncryptionPubKey circuits.EncryptionKey[*big.Int]
	Addresses        []*big.Int
	Weights          []*big.Int
	ProcessID        *big.Int
	CensusOrigin     types.CensusOrigin
	CensusRoot       *big.Int
	Ballots          []elgamal.Ballot
	VoteIDs          []types.HexBytes
}

VoteVerifierTestResults struct includes relevant data after VerifyVoteCircuit inputs generation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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