math

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright (C) 2019-2023 David Florness SPDX-License-Identifier: MPL-2.0

Copyright (C) 2019-2023 David Florness SPDX-License-Identifier: MPL-2.0

Copyright (C) 2019-2023 David Florness SPDX-License-Identifier: MPL-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvalsCircuitR1CS added in v0.4.0

func EvalsCircuitR1CS(numVoters int, numCandidates int) (constraint.ConstraintSystem, error)

func LagrangeEvalAtZero added in v0.4.0

func LagrangeEvalAtZero(points []Point) *fr.Element

uses https://en.wikipedia.org/wiki/Lagrange_polynomial#Definition but returns the evaluation at zero (the only one we care about)

func SumCircuitR1CS added in v0.4.0

func SumCircuitR1CS(numVoters int) (constraint.ConstraintSystem, error)

Types

type EvalsCircuit added in v0.4.0

type EvalsCircuit struct {
	Inputs       []frontend.Variable `gnark:",public"`
	OutputHashes []frontend.Variable `gnark:",public"`

	// must be created with length numCandidates^2
	BallotBits []frontend.Variable `gnark:",secret"`
	// must be created with length numVoters - 1
	Coeffs   []frontend.Variable `gnark:",secret"`
	Constant frontend.Variable   `gnark:",secret"`
}

func (*EvalsCircuit) Define added in v0.4.0

func (circuit *EvalsCircuit) Define(api frontend.API) error

type Point added in v0.4.0

type Point [2]*fr.Element

p[0] is x coordinate, p[1] is y coordinate

type Poly

type Poly struct {
	Ballot [][]byte      `json:"ballot"`
	Coeffs []*fr.Element `json:"coeffs"`
	Inputs []*fr.Element `json:"inputs"`
	// contains filtered or unexported fields
}

func NewRandomPoly

func NewRandomPoly(ballot [][]byte, inputs []*fr.Element) *Poly

NewRandomPoly generates a random polynomial of degree numVoters-1, using `ballot' as the constant term

func (*Poly) EvalAndProve added in v0.4.0

func (p *Poly) EvalAndProve(input *fr.Element, provingKey groth16.ProvingKey) (*fr.Element, []byte, groth16.Proof)

type SumCircuit added in v0.4.0

type SumCircuit struct {
	HashSelects  []frontend.Variable `gnark:",public"`
	OutputHashes []frontend.Variable `gnark:",public"`
	Sum          frontend.Variable   `gnark:",public"`

	Outputs []frontend.Variable `gnark:",secret"`
}

func (*SumCircuit) Define added in v0.4.0

func (circuit *SumCircuit) Define(api frontend.API) error

Jump to

Keyboard shortcuts

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