chainark

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 8 Imported by: 5

README

chainark

a ZKP library to prove a chain of any given relationship, block chain, signature chain, etc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertFpWitness

func AssertFpWitness[FR emulated.FieldParams](
	api frontend.API, fp FingerPrint, witnessValues []emulated.Element[FR], nbMaxBitsPerVar ...uint,
)

func AssertIDWitness

func AssertIDWitness[FR emulated.FieldParams](
	api frontend.API, id LinkageID, witnessValues []emulated.Element[FR], nbMaxBitsPerVar ...uint,
)

func AssertValsVSWtnsElements added in v0.2.0

func AssertValsVSWtnsElements[FR emulated.FieldParams](
	api frontend.API, vars []frontend.Variable, witnessValues []emulated.Element[FR], nbMaxBitsPerVar ...uint,
)

func IsIDEqualToWitness added in v0.2.0

func IsIDEqualToWitness[FR emulated.FieldParams](
	api frontend.API, id LinkageID, witnessValues []emulated.Element[FR], nbMaxBitsPerVar ...uint,
) frontend.Variable

func NewGenesisAssignment added in v0.2.0

func NewGenesisAssignment[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT](
	unitVkey plonk.VerifyingKey[FR, G1El, G2El],
	firstProof, secondProof plonk.Proof[FR, G1El, G2El],
	firstWitness, secondWitness plonk.Witness[FR],
	recursiveFp FingerPrint,
	genesisId, firstId, secondId LinkageID,
) frontend.Circuit

func NewGenesisCircuit added in v0.2.0

func NewGenesisCircuit[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT](
	nbIdVals, bitsPerIdVal, nbFpVals, bitsPerFpVal int,
	ccsUnit constraint.ConstraintSystem,
	unitFpBytes FingerPrintBytes) frontend.Circuit

func NewRecursiveAssignment added in v0.2.0

func NewRecursiveAssignment[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT](
	firstVkey, unitVkey plonk.VerifyingKey[FR, G1El, G2El],
	firstProof, secondProof plonk.Proof[FR, G1El, G2El],
	firstWitness, secondWitness plonk.Witness[FR],
	recursiveFp FingerPrint,
	genesisId, firstId, secondId LinkageID,
) frontend.Circuit

func NewRecursiveCircuit added in v0.2.0

func NewRecursiveCircuit[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT](
	idLength, bitsPerIdVal, fpLength, bitsPerFpVal int,
	ccsUnit, ccsGenesis constraint.ConstraintSystem,
	unitFpBytes, genesisFpBytes FingerPrintBytes) frontend.Circuit

func TestValsVSWtnsElements added in v0.2.0

func TestValsVSWtnsElements[FR emulated.FieldParams](
	api frontend.API, vars []frontend.Variable, witnessValues []emulated.Element[FR], nbMaxBitsPerVar ...uint,
) frontend.Variable

func TestVkeyFp

func TestVkeyFp[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT](
	api frontend.API, vkey plonk.VerifyingKey[FR, G1El, G2El], otherFp FingerPrint) (frontend.Variable, error)

func ValsFromBytes added in v0.2.0

func ValsFromBytes(data []byte, bitsPerVar int) []frontend.Variable

func ValsToU8s added in v0.2.0

func ValsToU8s(api frontend.API, vals []frontend.Variable, bitsPerVar int) ([]uints.U8, error)

Types

type FingerPrint

type FingerPrint struct {
	Vals       []frontend.Variable
	BitsPerVar int
}

func FingerPrintFromBytes

func FingerPrintFromBytes(data FingerPrintBytes, bitsPerVar int) FingerPrint

func FpValueOf

func FpValueOf(api frontend.API, v frontend.Variable, bitsPerVar int) (FingerPrint, error)

func NewFingerPrint

func NewFingerPrint(v []frontend.Variable, b int) FingerPrint

func PlaceholderFingerPrint

func PlaceholderFingerPrint(nbVars, bitsPerVar int) FingerPrint

func (FingerPrint) AssertIsEqual

func (fp FingerPrint) AssertIsEqual(api frontend.API, other FingerPrint)

func (FingerPrint) IsEqual

func (fp FingerPrint) IsEqual(api frontend.API, other FingerPrint) frontend.Variable

type FingerPrintBytes

type FingerPrintBytes []byte

type FpExtractor

type FpExtractor[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT] struct {
	Vkey recursive_plonk.VerifyingKey[FR, G1El, G2El]
}

func (*FpExtractor[FR, G1El, G2El]) Define

func (fe *FpExtractor[FR, G1El, G2El]) Define(api frontend.API) error

type GenesisCircuit

type GenesisCircuit[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT] struct {
	UnitVKey    plonk.VerifyingKey[FR, G1El, G2El]
	FirstProof  plonk.Proof[FR, G1El, G2El]
	SecondProof plonk.Proof[FR, G1El, G2El]

	AcceptableFirstFp FingerPrint `gnark:",public"` // only there to keep the shape of genesis public witness in alignment with that of recursive

	GenesisID     LinkageID `gnark:",public"`
	FirstID       LinkageID
	SecondID      LinkageID         `gnark:",public"`
	FirstWitness  plonk.Witness[FR] // GenesisID -> FirstID
	SecondWitness plonk.Witness[FR] // FirstID -> SecondID

	// some constant values passed from outside
	UnitVkeyFpBytes FingerPrintBytes
}

func (*GenesisCircuit[FR, G1El, G2El, GtEl]) Define

func (c *GenesisCircuit[FR, G1El, G2El, GtEl]) Define(api frontend.API) error

Note that AcceptableFirstFp is only there for shaping purpose, therefore no verification needed here

type GenesisOrRecursiveProof

type GenesisOrRecursiveProof[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT] struct {
	BeginID LinkageID
	EndID   LinkageID
}

func (*GenesisOrRecursiveProof[FR, G1El, G2El, GtEl]) Assert

func (rp *GenesisOrRecursiveProof[FR, G1El, G2El, GtEl]) Assert(
	api frontend.API,
	verifier *plonk.Verifier[FR, G1El, G2El, GtEl],
	vkey plonk.VerifyingKey[FR, G1El, G2El],
	witness plonk.Witness[FR],
	acceptableFp FingerPrint,
	genesisFpBytes FingerPrintBytes,
	proof plonk.Proof[FR, G1El, G2El]) error

type LinkageID

type LinkageID struct {
	Vals       []frontend.Variable
	BitsPerVar int
}

func LinkageIDFromBytes

func LinkageIDFromBytes(data LinkageIDBytes, bitsPerVar int) LinkageID

func LinkageIDFromU8s

func LinkageIDFromU8s(api frontend.API, data []uints.U8, bitsPerVar int) LinkageID

little-endian here

func NewLinkageID

func NewLinkageID(v []frontend.Variable, b int) LinkageID

func PlaceholderLinkageID

func PlaceholderLinkageID(nbEles, bitsPerVar int) LinkageID

func (LinkageID) AssertIsEqual

func (id LinkageID) AssertIsEqual(api frontend.API, other LinkageID)

func (LinkageID) IsEqual

func (id LinkageID) IsEqual(api frontend.API, other LinkageID) frontend.Variable

func (LinkageID) ToBytes

func (id LinkageID) ToBytes(api frontend.API) ([]uints.U8, error)

type LinkageIDBytes

type LinkageIDBytes []byte

type RecursiveCircuit

type RecursiveCircuit[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT] struct {
	FirstVKey         plonk.VerifyingKey[FR, G1El, G2El]
	FirstProof        plonk.Proof[FR, G1El, G2El]
	AcceptableFirstFp FingerPrint `gnark:",public"`

	SecondVKey  plonk.VerifyingKey[FR, G1El, G2El]
	SecondProof plonk.Proof[FR, G1El, G2El]

	BeginID LinkageID `gnark:",public"`
	RelayID LinkageID
	EndID   LinkageID `gnark:",public"`

	FirstWitness  plonk.Witness[FR]
	SecondWitness plonk.Witness[FR]

	// some constant values passed from outside
	GenesisFpBytes  FingerPrintBytes
	UnitVKeyFpBytes FingerPrintBytes
}

func (*RecursiveCircuit[FR, G1El, G2El, GtEl]) Define

func (c *RecursiveCircuit[FR, G1El, G2El, GtEl]) Define(api frontend.API) error

type UnitProof

type UnitProof[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT] struct {
	BeginID LinkageID
	EndID   LinkageID
}

func (*UnitProof[FR, G1El, G2El, GtEl]) AssertRelations added in v0.2.0

func (up *UnitProof[FR, G1El, G2El, GtEl]) AssertRelations(
	api frontend.API,
	vkey plonk.VerifyingKey[FR, G1El, G2El],
	witness plonk.Witness[FR],
	fpFixed FingerPrint) error

Directories

Path Synopsis
fp

Jump to

Keyboard shortcuts

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