internal

package
v0.2.20 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BreakUpBytesIntoBitsHint

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

func BreakUpBytesIntoCrumbsHint

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

func BreakUpBytesIntoHalfHint

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

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

func (nr *NumReader) AssertNextEquals(v frontend.Variable)

AssertNextEquals is functionally equivalent to

z := nr.Next()
api.AssertIsEqual(v, z)

while saving exactly one constraint

func (*NumReader) Next

func (nr *NumReader) Next() frontend.Variable

Next returns the next number in the sequence and advances the reader head by one word. assumes bits past the end of the Slice are 0

type RangeChecker

type RangeChecker struct {
	// contains filtered or unexported fields
}

TODO Use std/rangecheck instead

func NewRangeChecker

func NewRangeChecker(api frontend.API) *RangeChecker

func (*RangeChecker) AssertLessThan

func (r *RangeChecker) AssertLessThan(bound uint, c ...frontend.Variable)

func (*RangeChecker) BreakUpBytesIntoWords

func (r *RangeChecker) BreakUpBytesIntoWords(wordNbBits int, bytes ...frontend.Variable) (words, recombined []frontend.Variable)

BreakUpBytesIntoWords breaks up bytes into words of size wordNbBits It also returns a Slice of bytes which are a reading of the input byte Slice starting from each of the words, thus a super-Slice of the input It has the side effect of checking that the input does in fact consist of bytes As an example, let the words be bits and the input be the bytes [b₀ b₁ b₂ b₃ b₄ b₅ b₆ b₇], [b₈ b₉ b₁₀ b₁₁ b₁₂ b₁₃ b₁₄ b₁₅] Then the output words are b₀, b₁, b₂, b₃, b₄, b₅, b₆, b₇, b₈, b₉, b₁₀, b₁₁, b₁₂, b₁₃, b₁₄, b₁₅ The "recombined" output is the slice {[b₀ b₁ b₂ b₃ b₄ b₅ b₆ b₇], [b₁ b₂ b₃ b₄ b₅ b₆ b₇ b₈], ...} Note that for any i in range we get recombined[8*i] = bytes[i]

func (*RangeChecker) IsLessThan

func (r *RangeChecker) IsLessThan(bound uint, c frontend.Variable) frontend.Variable

IsLessThan returns a variable that is 1 if 0 ≤ c < bound, 0 otherwise TODO perf @Tabaie see if we can get away with a weaker contract, where the return value is 0 iff 0 ≤ c < bound

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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