utils

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: May 10, 2025 License: MIT Imports: 21 Imported by: 2

Documentation

Index

Constants

View Source
const HashSize = 32

Variables

This section is empty.

Functions

func AreVarsEquals

func AreVarsEquals(api frontend.API, a, b []frontend.Variable) frontend.Variable

func AssertFpInFpSet added in v0.2.0

func AssertFpInFpSet[FR emulated.FieldParams](api frontend.API, fp frontend.Variable, fpSet []FingerPrint[FR])

func AssertFpInSet

func AssertFpInSet[FR emulated.FieldParams](api frontend.API, fp frontend.Variable, fpSet []FingerPrintBytes)

func AssertFpWitness

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

func AssertValsVSWtnsElements

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

func ElementsLessEq added in v0.2.3

func ElementsLessEq[T emulated.FieldParams](api frontend.API, a, b emulated.Element[T], nbSkipLimbs ...int) frontend.Variable

*

  • a, b should be already strictly reduced, so that we can employ nbSkipLimbs *

func InCircuitFingerPrint added in v0.2.4

func InCircuitFingerPrint[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT](
	api frontend.API, vk *plonk.VerifyingKey[FR, G1El, G2El]) (frontend.Variable, error)

FingerPrint() returns the MiMc hash of the VerifyingKey. It could be used to identify a VerifyingKey during recursive verification.

func IsEqual added in v0.1.4

func IsEqual(api frontend.API, a, b frontend.Variable) frontend.Variable

IsEqual returns 1 if a == b, 0 otherwise

func RetrieveU254ValueFromElement added in v0.1.5

func RetrieveU254ValueFromElement[FR emulated.FieldParams](api frontend.API, e emulated.Element[FR]) frontend.Variable

func RetrieveU32ValueFromElement

func RetrieveU32ValueFromElement[FR emulated.FieldParams](api frontend.API, e emulated.Element[FR]) frontend.Variable

assuming e has been reduced

func RetrieveU8ValueFromElement added in v0.1.5

func RetrieveU8ValueFromElement[FR emulated.FieldParams](api frontend.API, e emulated.Element[FR]) frontend.Variable

assuming e has been reduced

func RetrieveVarsFromElements added in v0.2.6

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

func TestFpInFpSet added in v0.2.0

func TestFpInFpSet[FR emulated.FieldParams](api frontend.API, fp frontend.Variable, fpSet []FingerPrint[FR]) frontend.Variable

func TestFpInSet added in v0.1.1

func TestFpWitness added in v0.1.1

func TestFpWitness[FR emulated.FieldParams](
	api frontend.API, fp FingerPrint[FR], els []emulated.Element[FR], nbMaxBitsPerVar ...uint,
) frontend.Variable

func TestValsVSWtnsElements

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

func UnsafeFingerPrintFromVkFile

func UnsafeFingerPrintFromVkFile[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT, GtEl algebra.GtElementT](vkFile string) ([]byte, error)

func ValsFromBytes

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

func VerifyingKeyMiMCHash

func VerifyingKeyMiMCHash[FR emulated.FieldParams, G1El algebra.G1ElementT, G2El algebra.G2ElementT](h hash.Hash, vk plonk.VerifyingKey[FR, G1El, G2El]) ([]byte, error)

Types

type FingerPrint

type FingerPrint[FR emulated.FieldParams] struct {
	Val frontend.Variable
}

*

  • FingerPrint[FR] is computed as MiMc(VerifyingKey[FR, ...]), and should be only one field long.
  • When it is used in another field other than where it is computed, it appear as a witness and we should deal with witness in other ways.

func FingerPrintFromBytes

func FingerPrintFromBytes[FR emulated.FieldParams](data FingerPrintBytes) FingerPrint[FR]

func FpValueOf

func FpValueOf[FR emulated.FieldParams](api frontend.API, v frontend.Variable) FingerPrint[FR]

func NewFingerPrint

func NewFingerPrint[FR emulated.FieldParams](v frontend.Variable) FingerPrint[FR]

func (FingerPrint[FR]) AssertIsEqual

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

func (FingerPrint[FR]) IsEqual

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

type FingerPrintBytes

type FingerPrintBytes []byte

type Hash added in v0.1.4

type Hash [HashSize]uints.U8

func FromBytesHash added in v0.1.4

func FromBytesHash(hash [HashSize]byte) Hash

func (Hash) AssertIsEqual added in v0.1.4

func (h Hash) AssertIsEqual(api frontend.API, other Hash)

func (Hash) IsEqual added in v0.1.4

func (h Hash) IsEqual(api frontend.API, other Hash) frontend.Variable

Jump to

Keyboard shortcuts

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