Skip to content

Commit

Permalink
add simple tobinary implement
Browse files Browse the repository at this point in the history
  • Loading branch information
siq1 committed Sep 10, 2024
1 parent beb91a4 commit b9dfbd4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ecgo/builder/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,16 @@ func (builder *builder) Inverse(i1 frontend.Variable) frontend.Variable {
//
// The result in in little endian (first bit= lsb)
func (builder *builder) ToBinary(i1 frontend.Variable, n ...int) []frontend.Variable {
panic("unimplemented")
// TODO: Currently this doesn't support MarkBoolean
nbBits := builder.field.FieldBitLen()
if len(n) == 1 {
nbBits = n[0]
if nbBits < 0 {
panic("invalid n")
}
}

return bits.ToBinary(builder, i1, bits.WithNbDigits(nbBits))
}

// FromBinary packs the given variables, seen as a fr.Element in little endian, into a single variable.
Expand Down

0 comments on commit b9dfbd4

Please sign in to comment.