problem

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2022 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const SEED = "Go Evanesco"

Variables

View Source
var (
	ErrorInvalidR1CSPath = errors.New("r1cs path invalid")
	ErrorInvalidPkPath   = errors.New("proving key path invalid")
	ErrorInvalidVkPath   = errors.New("verifying key path invalid")
)
View Source
var MimcHasher = Hasher{
	// contains filtered or unexported fields
}

Functions

func CompileCircuit

func CompileCircuit() frontend.CompiledConstraintSystem

func GetChallengeIndex

func GetChallengeIndex(index [32]byte, interval uint64) uint64

func NewProvingKey

func NewProvingKey(b []byte) groth16.ProvingKey

func NewVerifyingKey

func NewVerifyingKey(b []byte) groth16.VerifyingKey

func ZKPProve

func ZKPProve(r1cs frontend.CompiledConstraintSystem, pk groth16.ProvingKey, preimage []byte) ([]byte, []byte)

func ZKPVerify

func ZKPVerify(vk groth16.VerifyingKey, preimage []byte, hash []byte, proof []byte) bool

Types

type Circuit

type Circuit struct {
	PreImage frontend.Variable `gnark:",public"`
	Hash     frontend.Variable `gnark:",public"`
}

func (*Circuit) Define

func (circuit *Circuit) Define(curveID ecc.ID, cs *frontend.ConstraintSystem) error

Define declares the circuit's constraints Hash = mimc(PreImage)

type GetHeaderByNum

type GetHeaderByNum = func(uint642 uint64) (*types.Header, error)

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

func (*Hasher) Hash

func (h *Hasher) Hash(m []byte) []byte

type Prover

type Prover struct {
	// contains filtered or unexported fields
}

func NewProblemProver

func NewProblemProver(pkPath string) (*Prover, error)

func (*Prover) Prove

func (p *Prover) Prove(preimage []byte) ([]byte, []byte)

type Verifier

type Verifier struct {
	// contains filtered or unexported fields
}

func NewProblemVerifier

func NewProblemVerifier(vkPath string, interval, advance uint64, getHeaderByNum GetHeaderByNum) (*Verifier, error)

func (*Verifier) VerifyLottery

func (v *Verifier) VerifyLottery(lottery *types.Lottery, sigBytes []byte, lastCoinbaseHeader *types.Header) (res bool)

todo: add additional check if the lottery miner pledged

func (*Verifier) VerifyZKP

func (v *Verifier) VerifyZKP(preimage []byte, mimcHash []byte, proof []byte) bool

Jump to

Keyboard shortcuts

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