ZoKrates icon indicating copy to clipboard operation
ZoKrates copied to clipboard

Add cast from field to boolean

Open stefandeml opened this issue 5 years ago • 1 comments

currently we support going from a field element to boolean this way:

field a = 0
bool b = if a == 0 then true else false fi

this is based on the comparison a == 0, which at least takes 2 constraints.

However, the cast can also easily be done by adding the following single constraint: a * (a-1) = 0

stefandeml avatar Oct 01 '19 14:10 stefandeml

Isn't it the case that a cast to bool has 3 possible outcomes: true, false, and error? In general I feel like instead of casting field to bool, one should wonder if it's possible to have a boolean in the first place, no?

Schaeff avatar Oct 03 '19 11:10 Schaeff