Documentation ¶
Index ¶
- func AssertChecksumEquals(api frontend.API, e []frontend.Variable, checksum frontend.Variable) error
- func ChecksumPaddedBytes(b []byte, validLength int, hsh hash.Hash, fieldNbBits int) []byte
- func Pack(api frontend.API, words []frontend.Variable, bitsPerWord int) []frontend.Variable
- func PackN(api frontend.API, words []frontend.Variable, bitsPerWord, wordsPerElem int) []frontend.Variable
- func ReadNum(api frontend.API, c []frontend.Variable, radix int) frontend.Variable
- func ShiftLeft(api frontend.API, slice []frontend.Variable, shiftAmount frontend.Variable) []frontend.Variable
- func UnpackIntoBytes(api frontend.API, bytesPerElem int, packed []frontend.Variable) (unpacked []frontend.Variable, nbBytes frontend.Variable, err error)
- func UnpackIntoBytesHint(_ *big.Int, ins, outs []*big.Int) error
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 ¶
ChecksumPaddedBytes packs b into field elements, then hashes the field elements along with validLength (encoded into a field element of its own)
func Pack ¶
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 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
Types ¶
This section is empty.