noname icon indicating copy to clipboard operation
noname copied to clipboard

Add Bool type in stdlib

Open katat opened this issue 1 year ago • 1 comments

When creating a variable to represent a bool value, we have to make sure it is constrained as a boolean.

For example:

assert_eq(bit * (bit - 1), 0); // where bit is a field variable

To make the code more expressive by itself, we can add a bool type in stdlib to constrain the field variable as a boolean value.

For example:

use std::bits;

let bool = bits::Bool::new(1); // the new method should also constrain the argument value.

This Bool type can be an addition to the existing std::bits stdlib module.

Related: https://github.com/zksecurity/noname/pull/201#discussion_r1813111834

katat avatar Oct 24 '24 04:10 katat

To make it distinguishable from TyKind::Bool (mentioned here as well: https://github.com/zksecurity/noname/pull/201#discussion_r1813111834 ). Would it make sense to have bits::Bit::new(1); instead of bits::Bool::new(1);?

bufferhe4d avatar Nov 18 '24 14:11 bufferhe4d