A boolean value. You can use it like this:
const x = new Bool(true);
You can also combine multiple booleans via [[not
]], [[and
]], [[or
]].
Use [[assertEquals]] to enforce the value of a Bool.
new Bool(x: boolean | FieldVar | Bool): Bool
• x: boolean
| FieldVar
| Bool
value: FieldVar;
static Unsafe: {
"fromField": Bool;
};
Converts a Field into a Bool. This is an unsafe operation as it assumes that the field element is either 0 or 1 (which might not be true).
Only use this if you have already constrained the Field element to be 0 or 1.
• x: Field
a Field
static sizeInBytes: number = 1;
and(y: boolean | Bool): Bool
• y: boolean
| Bool
a new Bool that is set to true only if
this Bool and y
are also true.
assertEquals(y: boolean | Bool, message?: string): void
Proves that this Bool is equal to y
.
• y: boolean
| Bool
a Bool.
• message?: string
void
assertFalse(message?: string): void
Proves that this Bool is false
.
• message?: string
void
assertTrue(message?: string): void
Proves that this Bool is true
.
• message?: string
void
equals(y: boolean | Bool): Bool
Returns true if this Bool is equal to y
.
• y: boolean
| Bool
a Bool.
implies(y: boolean | Bool): Bool
Whether this Bool implies another Bool y
.
This is the same as x.not().or(y)
: if x
is true, then y
must be true for the implication to be true.
• y: boolean
| Bool
let isZero = x.equals(0);
let lessThan10 = x.lessThan(10);
assert(isZero.implies(lessThan10), 'x = 0 implies x < 10');
isConstant(): this is Object
this is Object
not(): Bool
a new Bool that is the negation of this Bool.
or(y: boolean | Bool): Bool
• y: boolean
| Bool
a new Bool that is set to true if either
this Bool or y
is true.
sizeInFields(): number
Returns the size of this type.
number
toBoolean(): boolean
This converts the Bool to a JS boolean
.
This can only be called on non-witness values.
boolean
toField(): Field
Converts a Bool to a Field. false
becomes 0 and true
becomes 1.
toFields(): Field[]
Serializes this Bool into Field elements.
Field
[]
toJSON(): boolean
Serialize the Bool to a JSON string. This operation does not affect the circuit and can't be used to prove anything about the string representation of the Field.
boolean
toString(): string
Serialize the Bool to a string, e.g. for printing. This operation does not affect the circuit and can't be used to prove anything about the string representation of the Field.
string
static and(x: boolean | Bool, y: boolean | Bool): Bool
Boolean AND operation.
• x: boolean
| Bool
• y: boolean
| Bool
static assertEqual(x: Bool, y: boolean | Bool): void
Asserts if both Bool are equal.
• x: Bool
• y: boolean
| Bool
void
static check(x: Bool): void
• x: Bool
void
static empty(): Bool
static equal(x: boolean | Bool, y: boolean | Bool): Bool
Checks two Bool for equality.
• x: boolean
| Bool
• y: boolean
| Bool
static fromBytes(bytes: number[]): Bool
• bytes: number
[]
static fromFields(fields: Field[]): Bool
Creates a data structure from an array of serialized Field elements.
• fields: Field
[]
static fromJSON(b: boolean): Bool
Deserialize a JSON structure into a Bool. This operation does not affect the circuit and can't be used to prove anything about the string representation of the Field.
• b: boolean
static fromValue(b: boolean | Bool): Bool
Provable<Bool>.fromValue()
• b: boolean
| Bool
static not(x: boolean | Bool): Bool
Boolean negation.
• x: boolean
| Bool
static or(x: boolean | Bool, y: boolean | Bool): Bool
Boolean OR operation.
• x: boolean
| Bool
• y: boolean
| Bool
static readBytes<N>(bytes: number[], offset: NonNegativeInteger<N>): [Bool, number]
• N extends number
• bytes: number
[]
• offset: NonNegativeInteger
<N
>
[Bool
, number
]
static sizeInFields(): number
Returns the size of this type.
number
static toAuxiliary(_?: Bool): []
Static method to serialize a Bool into its auxiliary data.
• _?: Bool
[]
static toBytes(b: Bool): number[]
• b: Bool
number
[]
static toField(x: boolean | Bool): Field
• x: boolean
| Bool
static toFields(x: Bool): Field[]
Static method to serialize a Bool into an array of Field elements.
• x: Bool
Field
[]
static toInput(x: Bool): {
"packed": [Field, number][];
}
• x: Bool
{
"packed": [Field, number][];
}
packed: [Field, number][];
static toJSON(x: Bool): boolean
Serialize a Bool to a JSON string. This operation does not affect the circuit and can't be used to prove anything about the string representation of the Field.
• x: Bool
boolean
static toValue(x: Bool): boolean
Provable<Bool>.toValue()
• x: Bool
boolean