v1

package
v0.0.0-...-db31170 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxNbBatches = 100 // TODO ensure this is a reasonable maximum

)

Variables

This section is empty.

Functions

func Assign

func Assign(blobBytes, dict []byte, eip4844Enabled bool, x [32]byte, y fr381.Element) (assignment frontend.Circuit, publicInput fr377.Element, snarkHash []byte, err error)

func BatchesChecksumAssign

func BatchesChecksumAssign(ends []int, payload []byte) [][]byte

the result for each batch is <data (31 bytes)> ... <data (31 bytes)> for soundness some kind of length indicator must later be incorporated.

func CheckBatchesSums

func CheckBatchesSums(api frontend.API, hasher snarkHash.FieldHasher, nbBatches frontend.Variable, blobPayload []frontend.Variable, batchLengths []frontend.Variable, expectedChecksums []frontend.Variable) error

CheckBatchesSums checks batch checksums consisting of H(batchLen, contentSum) where contentSum = Blocks[0] if len(Blocks) == 1 and H(Blocks...) otherwise. Blocks are consecutive 31-byte chunks of the data in the batch, with the last one right-padded with zeros if necessary. All batches must be at least 31 bytes long. The function performs this range check. It is also checked that the batches are all within the MAXIMUM range of the blob. CheckBatchesSums does not have access to the actual blob size, so it remains the caller's responsibility to check that the batches are within the confines of the ACTUAL blob size. The expected checksums are not checked beyond nbBatches

func CheckDictChecksum

func CheckDictChecksum(api frontend.API, checksum frontend.Variable, dict []frontend.Variable) error

func Compile

func Compile(dictionaryLength int) constraint.ConstraintSystem

func NewBuilder

func NewBuilder(dictionaryLength int) *builder

func ProcessBlob

func ProcessBlob(api frontend.API, hsh snarkHash.FieldHasher, maxUncompressedBlobSize int, blobBytes []frontend.Variable, evaluationChallenge [32]frontend.Variable, eip4844Enabled frontend.Variable, expectedBatchSums internal.VarSlice, dict []frontend.Variable) (blobSum frontend.Variable, evaluation [2]frontend.Variable, err error)

ProcessBlob takes in a blob, an evaluation challenge, and a decompression dictionary. It returns a hash of the blob data along with its "evaluation" at the challenge point and a hash of all the batches in the blob payload TODO too many arguments; confusing. Replace with a request struct?

Types

type Circuit

type Circuit struct {
	// The dictionary used in the compression algorithm
	Dict []frontend.Variable

	// The uncompressed and compressed data corresponds to the data that is
	// made available on L1 when we submit a blob of transactions. The circuit
	// proves that these two correspond to the same data. The uncompressed
	// data is then passed to the EVM execution circuit.
	BlobBytes []frontend.Variable

	// The final public input. It is the hash of
	// 	- the hash of the uncompressed message.
	// 	- the hash of the compressed message. aka the SnarKHash on the contract
	// 	- the X and Y evaluation points claimed on the contract
	//  TODO - whether we are using Eip4844
	PublicInput frontend.Variable `gnark:",public"`

	// The X and Y evaluation point that are "claimed" by the contract. The
	// circuit will verify that the polynomial describing the compressed data
	// does evaluate to Y when evaluated at point X. This needed to ensure that
	// both the keccak hash of the compressed data (claimed on the contract) and
	// later the blob-hash (when we support EIP4844). TODO update this comment
	FuncPI FunctionalPublicInputSnark

	MaxBlobPayloadNbBytes int
	UseGkrMiMC            bool
}

Circuit used to prove data compression and blob submission related operations It performs the following operations:

  • Proves the compression
  • Prove the equivalence of the compressed data with the one claimed on L1. Through an evaluation check
  • Prove the equivalence of the decompressed datastream with the stream used to prove EVM execution through hashing using a SNARK friendly hash function.

The circuit has a single public input derived by mimc hashing the compressed data (or rather its mimc hash), the hash of the uncompressed data stream and the X and Y values that are computed on L1 and that serves proving the equivalence of the compressed data stream in the witness and the one claimed on L1.

func (Circuit) Define

func (c Circuit) Define(api frontend.API) error

type FPISumOption

type FPISumOption func(settings *fpiSumSettings)

func WithBatchesSum

func WithBatchesSum(b []byte) FPISumOption

func WithHash

func WithHash(h hash.Hash) FPISumOption

type FunctionalPublicInput

type FunctionalPublicInput struct {
	X              [32]byte  // X[1] holds 252 bits
	Y              [2][]byte // Y[1] holds 252 bits
	SnarkHash      []byte
	Eip4844Enabled bool
	BatchSums      [][]byte
}

func AssignFPI

func AssignFPI(blobBytes, dict []byte, eip4844Enabled bool, x [32]byte, y fr381.Element) (fpi FunctionalPublicInput, err error)

func (*FunctionalPublicInput) Sum

func (i *FunctionalPublicInput) Sum(opts ...FPISumOption) ([]byte, error)

func (*FunctionalPublicInput) ToSnarkType

type FunctionalPublicInputQSnark

type FunctionalPublicInputQSnark struct {
	Y              [2]frontend.Variable // Y[1] holds 252 bits
	SnarkHash      frontend.Variable
	Eip4844Enabled frontend.Variable
	NbBatches      frontend.Variable
	X              [32]frontend.Variable // unreduced value
}

FunctionalPublicInputQSnark the "unique" portion of the functional public input that cannot be inferred from other circuits in the same aggregation batch

func (*FunctionalPublicInputQSnark) RangeCheck

func (i *FunctionalPublicInputQSnark) RangeCheck(api frontend.API)

RangeCheck checks that values are within range

func (*FunctionalPublicInputQSnark) Sum

Sum ignores NbBatches, as its value is expected to be incorporated into batchesSum

type FunctionalPublicInputSnark

type FunctionalPublicInputSnark struct {
	FunctionalPublicInputQSnark
	BatchSums [MaxNbBatches]frontend.Variable
}

func (*FunctionalPublicInputSnark) Sum

Sum hashes the inputs together into a single "de facto" public input WARNING: i.X[-] are not range-checked here

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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