Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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
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 ¶
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