MCPcopy Create free account
hub / github.com/PolyhedraZK/ExpanderCompilerCollection / ToBinary

Method ToBinary

ecgo/builder/api.go:196–207  ·  view source on GitHub ↗

--------------------------------------------------------------------------------------------- Bit operations ToBinary unpacks a frontend.Variable in binary, n is the number of bits to select (starting from lsb) n default value is fr.Bits the number of bits needed to represent a field element The re

(i1 frontend.Variable, n ...int)

Source from the content-addressed store, hash-verified

194//
195// The result in in little endian (first bit= lsb)
196func (builder *builder) ToBinary(i1 frontend.Variable, n ...int) []frontend.Variable {
197 // TODO: Currently this doesn't support MarkBoolean
198 nbBits := builder.field.FieldBitLen()
199 if len(n) == 1 {
200 nbBits = n[0]
201 if nbBits < 0 {
202 panic("invalid n")
203 }
204 }
205
206 return bits.ToBinary(builder, i1, bits.WithNbDigits(nbBits))
207}
208
209// FromBinary packs the given variables, seen as a fr.Element in little endian, into a single variable.
210func (builder *builder) FromBinary(_b ...frontend.Variable) frontend.Variable {

Callers 2

CmpMethod · 0.80
mustBeLessOrEqVarMethod · 0.80

Calls 1

FieldBitLenMethod · 0.65

Tested by

no test coverage detected