compress

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertChecksumEquals

func AssertChecksumEquals(api frontend.API, e []frontend.Variable, checksum frontend.Variable) error

AssertChecksumEquals takes a MiMC hash of e and asserts it is equal to checksum

func ChecksumPaddedBytes

func ChecksumPaddedBytes(b []byte, validLength int, hsh hash.Hash, fieldNbBits int) []byte

ChecksumPaddedBytes packs b into field elements, then hashes the field elements along with validLength (encoded into a field element of its own)

func Pack

func Pack(api frontend.API, words []frontend.Variable, bitsPerWord int) []frontend.Variable

Pack packs the words as tightly as possible, and works Big Endian: i.e. the first word is the most significant in the packed elem it is on the caller to make sure the words are within range

func PackN

func PackN(api frontend.API, words []frontend.Variable, bitsPerWord, wordsPerElem int) []frontend.Variable

PackN packs the words wordsPerElem at a time into field elements, and works Big Endian: i.e. the first word is the most significant in the packed elem it is on the caller to make sure the words are within range

func ReadNum

func ReadNum(api frontend.API, c []frontend.Variable, radix int) frontend.Variable

ReadNum reads the slice c as a big endian number in base radix

func ShiftLeft

func ShiftLeft(api frontend.API, slice []frontend.Variable, shiftAmount frontend.Variable) []frontend.Variable

ShiftLeft erases shiftAmount many elements from the left of Slice and replaces them in the right with zeros it is the caller's responsibility to make sure that 0 \le shift < len(c)

func UnpackIntoBytes

func UnpackIntoBytes(api frontend.API, bytesPerElem int, packed []frontend.Variable) (unpacked []frontend.Variable, nbBytes frontend.Variable, err error)

UnpackIntoBytes construes every element in packed as consisting of bytesPerElem bytes, returning those bytes it DOES NOT prove that the elements in unpacked are actually bytes nbBytes is the number of "valid" bytes according to the padding scheme in https://github.com/Consensys/zkevm-monorepo/blob/main/prover/lib/compressor/blob/blob_maker.go#L299 TODO @tabaie @gbotrel move the padding/packing code to gnark or compress the very last non-zero byte in the unpacked stream is meant to encode the number of unused bytes in the last field element used. though UnpackIntoBytes includes that last byte in unpacked, it is not counted in nbBytes

func UnpackIntoBytesHint

func UnpackIntoBytesHint(_ *big.Int, ins, outs []*big.Int) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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