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 *big.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
- type NumReader
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/linea-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 ¶
type NumReader ¶
type NumReader struct {
// contains filtered or unexported fields
}
NumReader takes a sequence of words [ b₀ b₁ ... ], along with a base r and length n and returns the numbers (b₀ b₁ ... bₙ₋₁)ᵣ, (b₁ b₂ ... bₙ)ᵣ, ... upon successive calls to Next()
func NewNumReader ¶
func NewNumReader(api frontend.API, toRead []frontend.Variable, numNbBits, wordNbBits int) *NumReader
NewNumReader returns a new NumReader toRead is the slice of words to read from numNbBits defines the radix as r = 2ⁿᵘᵐᴺᵇᴮⁱᵗˢ (or rather numNbBits = log₂(r) ) wordNbBits defines the number of bits in each word such that n = numNbBits/wordNbBits it is the caller's responsibility to check 0 ≤ bᵢ < r ∀ i
func (*NumReader) AssertNextEquals ¶
AssertNextEquals is functionally equivalent to
z := nr.Next() api.AssertIsEqual(v, z)
while saving exactly one constraint