--------------------------------------------------------------------------------------------- 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)
| 194 | // |
| 195 | // The result in in little endian (first bit= lsb) |
| 196 | func (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. |
| 210 | func (builder *builder) FromBinary(_b ...frontend.Variable) frontend.Variable { |
no test coverage detected