Bool
Class: Bool
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.
Table of contents
Constructors
Properties
Methods
- and
- assertEquals
- assertFalse
- assertTrue
- equals
- isConstant
- not
- or
- sizeInFields
- toBoolean
- toField
- toFields
- toJSON
- toString
- and
- assertEqual
- check
- empty
- equal
- fromBytes
- fromFields
- fromJSON
- not
- or
- readBytes
- sizeInFields
- toAuxiliary
- toBytes
- toField
- toFields
- toInput
- toJSON
Constructors
constructor
• new Bool(x)
Parameters
| Name | Type |
|---|---|
x | boolean | Bool | FieldVar |
Defined in
Properties
value
• value: FieldVar
Defined in
Unsafe
▪ Static Unsafe: Object
Type declaration
| Name | Type |
|---|---|
ofField | (x: Field) => Bool |
Defined in
sizeInBytes
▪ Static sizeInBytes: number = 1
Defined in
Methods
and
▸ and(y): Bool
Parameters
| Name | Type | Description |
|---|---|---|
y | boolean | Bool | A Bool to AND with this Bool. |
Returns
a new Bool that is set to true only if
this Bool and y are also true.
Defined in
assertEquals
▸ assertEquals(y, message?): void
Proves that this Bool is equal to y.
Parameters
| Name | Type | Description |
|---|---|---|
y | boolean | Bool | a Bool. |
message? | string | - |
Returns
void
Defined in
assertFalse
▸ assertFalse(message?): void
Proves that this Bool is false.
Parameters
| Name | Type |
|---|---|
message? | string |
Returns
void
Defined in
assertTrue
▸ assertTrue(message?): void
Proves that this Bool is true.
Parameters
| Name | Type |
|---|---|
message? | string |
Returns
void
Defined in
equals
▸ equals(y): Bool
Returns true if this Bool is equal to y.
Parameters
| Name | Type | Description |
|---|---|---|
y | boolean | Bool | a Bool. |
Returns
Defined in
isConstant
▸ isConstant(): this is Object
Returns
this is Object
Defined in
not
▸ not(): Bool
Returns
a new Bool that is the negation of this Bool.
Defined in
or
▸ or(y): Bool
Parameters
| Name | Type | Description |
|---|---|---|
y | boolean | Bool | a Bool to OR with this Bool. |
Returns
a new Bool that is set to true if either
this Bool or y is true.
Defined in
sizeInFields
▸ sizeInFields(): number
Returns the size of this type.
Returns
number
Defined in
toBoolean
▸ toBoolean(): boolean
This converts the Bool to a javascript [[boolean]]. This can only be called on non-witness values.
Returns
boolean
Defined in
toField
▸ toField(): Field
Converts a Bool to a Field. false becomes 0 and true becomes 1.
Returns
Defined in
toFields
▸ toFields(): Field[]
Serializes this Bool into Field elements.
Returns
Field[]
Defined in
toJSON
▸ 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.
Returns
boolean
Defined in
toString
▸ 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.
Returns
string
Defined in
and
▸ Static and(x, y): Bool
Boolean AND operation.
Parameters
| Name | Type |
|---|---|
x | boolean | Bool |
y | boolean | Bool |
Returns
Defined in
assertEqual
▸ Static assertEqual(x, y): void
Asserts if both Bool are equal.
Parameters
| Name | Type |
|---|---|
x | Bool |
y | boolean | Bool |
Returns
void
Defined in
check
▸ Static check(x): void
Parameters
| Name | Type |
|---|---|
x | Bool |
Returns
void
Defined in
empty
▸ Static empty(): Bool
Returns
Defined in
equal
▸ Static equal(x, y): Bool
Checks two Bool for equality.
Parameters
| Name | Type |
|---|---|
x | boolean | Bool |
y | boolean | Bool |
Returns
Defined in
fromBytes
▸ Static fromBytes(bytes): Bool
Parameters
| Name | Type |
|---|---|
bytes | number[] |
Returns
Defined in
fromFields
▸ Static fromFields(fields): Bool
Creates a data structure from an array of serialized Field elements.
Parameters
| Name | Type |
|---|---|
fields | Field[] |
Returns
Defined in
fromJSON
▸ Static fromJSON(b): 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.
Parameters
| Name | Type |
|---|---|
b | boolean |
Returns
Defined in
not
▸ Static not(x): Bool
Boolean negation.
Parameters
| Name | Type |
|---|---|
x | boolean | Bool |
Returns
Defined in
or
▸ Static or(x, y): Bool
Boolean OR operation.
Parameters
| Name | Type |
|---|---|
x | boolean | Bool |
y | boolean | Bool |
Returns
Defined in
readBytes
▸ Static readBytes\<N>(bytes, offset): [value: Bool, offset: number]
Type parameters
| Name | Type |
|---|---|
N | extends number |
Parameters
| Name | Type |
|---|---|
bytes | number[] |
offset | NonNegativeInteger\<N> |
Returns
[value: Bool, offset: number]
Defined in
sizeInFields
▸ Static sizeInFields(): number
Returns the size of this type.
Returns
number
Defined in
toAuxiliary
▸ Static toAuxiliary(_?): []
Static method to serialize a Bool into its auxiliary data.
Parameters
| Name | Type |
|---|---|
_? | Bool |
Returns
[]
Defined in
toBytes
▸ Static toBytes(b): number[]
Parameters
| Name | Type |
|---|---|
b | Bool |
Returns
number[]
Defined in
toField
▸ Static toField(x): Field
Parameters
| Name | Type |
|---|---|
x | boolean | Bool |
Returns
Defined in
toFields
▸ Static toFields(x): Field[]
Static method to serialize a Bool into an array of Field elements.
Parameters
| Name | Type |
|---|---|
x | Bool |
Returns
Field[]
Defined in
toInput
▸ Static toInput(x): Object
Parameters
| Name | Type |
|---|---|
x | Bool |
Returns
Object
| Name | Type |
|---|---|
packed | [Field, number][] |
Defined in
toJSON
▸ Static toJSON(x): 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.
Parameters
| Name | Type |
|---|---|
x | Bool |
Returns
boolean