zk

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package zk provides utilities around the zkSNARK (Groth16) tooling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BigToFF added in v1.9.0

func BigToFF(iv *big.Int) *big.Int

BigToFF function returns the finite field representation of the big.Int provided. It uses Euclidean Modulus and the BN254 curve scalar field to represent the provided number.

func BytesToArbo added in v1.9.0

func BytesToArbo(input []byte) []*big.Int

BytesToArbo calculates the sha256 hash (32 bytes) of the slice of bytes provided. Then, splits the hash into a two parts of 16 bytes, swap the endianess of that parts and encodes they into a two big.Int's.

func BytesToArboStr added in v1.4.0

func BytesToArboStr(input []byte) []string

BytesToArboStr function wraps BytesToArbo to return the input as []string.

func LittleEndianToNBytes added in v1.4.0

func LittleEndianToNBytes(num *big.Int, n int) *big.Int

LittleEndianToNBytes truncate the most significant n bytes of the provided little endian number provided and returns into a new big.Int.

func ProofToCircomSiblings added in v1.9.0

func ProofToCircomSiblings(proof []byte) ([]string, error)

ProofToCircomSiblings function decodes the provided proof (or packaged siblings) and and encodes any contained siblings for use in a Circom circuit.

func ProtobufZKProofToProverProof added in v1.4.0

func ProtobufZKProofToProverProof(p *models.ProofZkSNARK) (*prover.Proof, error)

ProtobufZKProofToProverProof parses the provided protobuf ready proof struct into a prover ready proof struct.

func ProverProofToProtobufZKProof added in v1.4.0

func ProverProofToProtobufZKProof(p *prover.Proof, electionId, sikRoot,
	censusRoot, nullifier types.HexBytes, voteWeight *big.Int) (*models.ProofZkSNARK, error)

ProverProofToProtobufZKProof encodes the proof provided into a protobuf ready struct using including the index of the circuit used. If the provided proof does not contains a defined public signals, the rest of the arguments are required to calculate that parameter. If the provided proof does not contains a defined public signals and any of the rest of the parameters is nil, the resulting struct will not contains any defined PublicInputs value.

Types

This section is empty.

Directories

Path Synopsis
prover package abstracts the logic and types of go-rapidsnark (https://github.com/iden3/go-rapidsnark) to support basic operations for the rest of vocdoni-node project.
prover package abstracts the logic and types of go-rapidsnark (https://github.com/iden3/go-rapidsnark) to support basic operations for the rest of vocdoni-node project.

Jump to

Keyboard shortcuts

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