voteverifier

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

voteverifier package contains the Gnark circuit definition that verifies a vote package to be aggregated by the vote aggregator and included in a new state transition. A vote package includes a ballot proof (generated from a circom circuit with snarkjs), the public inputs of the ballot proof circuit, the signature of the public inputs, and a census proof. The vote package is valid if the ballot proof is valid if:

  • The public inputs of the ballot proof are valid (match with the hash provided).
  • The ballot proof is valid for the public inputs.
  • The public inputs of the verification circuit are valid (match with the hash provided).
  • The signature of the public inputs is valid for the public key of the voter.
  • The address derived from the user public key is part of the census, and verifies the census proof with the user weight provided.

Public inputs:

  • InputsHash: The hash of all the inputs that could be public.

Private inputs:

  • NumFields: The maximum number of votes that can be included in the package.
  • UniqueValues: A flag that indicates if the votes in the package values should be unique.
  • MaxValue: The maximum value that a vote can have.
  • MinValue: The minimum value that a vote can have.
  • MaxValueSum: The maximum total cost of the votes in the package.
  • MinValueSum: The minimum total cost of the votes in the package.
  • CostExponent: The exponent used to calculate the cost of a vote.
  • Address: The address of the voter.
  • UserWeight: The weight of the user that is voting.
  • EncryptionPubKey: The public key used to encrypt the votes in the package.
  • ProcessId: The process id of the votes in the package.
  • Ballot: The encrypted votes in the package.
  • CensusRoot: The root of the census tree.
  • CensusSiblings: The siblings of the address in the census tree.
  • Msg: The hash of the public inputs of the ballot proof but as scalar element of the Secp256k1 curve.
  • PublicKey: The public key of the voter.
  • Signature: The signature of the inputs hash.
  • CircomProof: The proof of the ballot proof.
  • CircomPublicInputsHash: The hash of the public inputs of the ballot proof.
  • CircomVerificationKey: The verification key of the ballot proof (fixed).

Note: The inputs of the circom circuit should be provided as elements of the bn254 scalar field, and the inputs of the gnark circuit should be provided as elements of the current compiler field (BLS12377 expected).

Index

Constants

This section is empty.

Variables

Artifacts contains the circuit artifacts for the vote verifier circuit, which includes the proving and verification keys.

Functions

func Compile added in v0.0.2

func Compile() (constraint.ConstraintSystem, error)

Compile compiles the VoteVerifier circuit definition using the canonical Circom placeholder setup.

Types

type VerifyVoteCircuit

type VerifyVoteCircuit struct {
	IsValid frontend.Variable `gnark:",public"`

	// Hash of the public inputs of the ballot proof circuit (circom)
	BallotHash emulated.Element[sw_bn254.ScalarField] `gnark:",public"`

	// The following variables are private inputs and they are used to verify
	// the user identity ownership
	Address   emulated.Element[sw_bn254.ScalarField]
	VoteID    frontend.Variable
	PublicKey ecdsa.PublicKey[emulated.Secp256k1Fp, emulated.Secp256k1Fr]
	Signature ecdsa.Signature[emulated.Secp256k1Fr]

	// The ballot proof is passed as private inputs
	CircomProof           groth16.Proof[sw_bn254.G1Affine, sw_bn254.G2Affine]
	CircomVerificationKey groth16.VerifyingKey[sw_bn254.G1Affine, sw_bn254.G2Affine, sw_bn254.GTEl] `gnark:"-"`
}

func DummyAssignment

func DummyAssignment() (*VerifyVoteCircuit, error)

DummyAssignment function returns a dummy assignment for the VerifyVoteCircuit with dummy values. This function can be used to generate dummy proofs to fill a chunk of votes that does not reach the required number of votes to be valid.

func DummyPlaceholder

func DummyPlaceholder() (*VerifyVoteCircuit, error)

DummyPlaceholder function returns a placeholder for the VerifyVoteCircuit with dummy values. This function can be used to generate dummy proofs to fill a chunk of votes that does not reach the required number of votes to be valid.

func (*VerifyVoteCircuit) Define

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

Jump to

Keyboard shortcuts

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