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