Skip to main content

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.

Constructors

new Bool()

new Bool(x: boolean | FieldVar | Bool): Bool

Parameters

x: boolean | FieldVar | Bool

Returns

Bool

Source

lib/provable/bool.ts:33

Properties

value

value: FieldVar;

Source

lib/provable/bool.ts:31


Unsafe

static Unsafe: {
"fromField": Bool;
};

fromField()

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.

Parameters

x: Field

a Field

Returns

Bool

Source

lib/provable/bool.ts:357


sizeInBytes

static sizeInBytes: number = 1;

Source

lib/provable/bool.ts:351

Methods

and()

and(y: boolean | Bool): Bool

Parameters

y: boolean | Bool

A Bool to AND with this Bool.

Returns

Bool

a new Bool that is set to true only if this Bool and y are also true.

Source

lib/provable/bool.ts:73


assertEquals()

assertEquals(y: boolean | Bool, message?: string): void

Proves that this Bool is equal to y.

Parameters

y: boolean | Bool

a Bool.

message?: string

Returns

void

Source

lib/provable/bool.ts:98


assertFalse()

assertFalse(message?: string): void

Proves that this Bool is false.

Parameters

message?: string

Returns

void

Source

lib/provable/bool.ts:129


assertTrue()

assertTrue(message?: string): void

Proves that this Bool is true.

Parameters

message?: string

Returns

void

Source

lib/provable/bool.ts:115


equals()

equals(y: boolean | Bool): Bool

Returns true if this Bool is equal to y.

Parameters

y: boolean | Bool

a Bool.

Returns

Bool

Source

lib/provable/bool.ts:144


isConstant()

isConstant(): this is Object

Returns

this is Object

Source

lib/provable/bool.ts:45


not()

not(): Bool

Returns

Bool

a new Bool that is the negation of this Bool.

Source

lib/provable/bool.ts:59


or()

or(y: boolean | Bool): Bool

Parameters

y: boolean | Bool

a Bool to OR with this Bool.

Returns

Bool

a new Bool that is set to true if either this Bool or y is true.

Source

lib/provable/bool.ts:86


sizeInFields()

sizeInFields(): number

Returns the size of this type.

Returns

number

Source

lib/provable/bool.ts:169


toBoolean()

toBoolean(): boolean

This converts the Bool to a JS boolean. This can only be called on non-witness values.

Returns

boolean

Source

lib/provable/bool.ts:200


toField()

toField(): Field

Converts a Bool to a Field. false becomes 0 and true becomes 1.

Returns

Field

Source

lib/provable/bool.ts:52


toFields()

toFields(): Field[]

Serializes this Bool into Field elements.

Returns

Field[]

Source

lib/provable/bool.ts:176


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

Source

lib/provable/bool.ts:192


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

Source

lib/provable/bool.ts:184


and()

static and(x: boolean | Bool, y: boolean | Bool): Bool

Boolean AND operation.

Parameters

x: boolean | Bool

y: boolean | Bool

Returns

Bool

Source

lib/provable/bool.ts:228


assertEqual()

static assertEqual(x: Bool, y: boolean | Bool): void

Asserts if both Bool are equal.

Parameters

x: Bool

y: boolean | Bool

Returns

void

Source

lib/provable/bool.ts:248


check()

static check(x: Bool): void

Parameters

x: Bool

Returns

void

Source

lib/provable/bool.ts:353


empty()

static empty(): Bool

Returns

Bool

Source

lib/provable/bool.ts:328


equal()

static equal(x: boolean | Bool, y: boolean | Bool): Bool

Checks two Bool for equality.

Parameters

x: boolean | Bool

y: boolean | Bool

Returns

Bool

Source

lib/provable/bool.ts:259


fromBytes()

static fromBytes(bytes: number[]): Bool

Parameters

bytes: number[]

Returns

Bool

Source

lib/provable/bool.ts:340


fromFields()

static fromFields(fields: Field[]): Bool

Creates a data structure from an array of serialized Field elements.

Parameters

fields: Field[]

Returns

Bool

Source

lib/provable/bool.ts:283


fromJSON()

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.

Parameters

b: boolean

Returns

Bool

Source

lib/provable/bool.ts:317


fromValue()

static fromValue(b: boolean | Bool): Bool

Provable<Bool>.fromValue()

Parameters

b: boolean | Bool

Returns

Bool

Source

lib/provable/bool.ts:300


not()

static not(x: boolean | Bool): Bool

Boolean negation.

Parameters

x: boolean | Bool

Returns

Bool

Source

lib/provable/bool.ts:218


or()

static or(x: boolean | Bool, y: boolean | Bool): Bool

Boolean OR operation.

Parameters

x: boolean | Bool

y: boolean | Bool

Returns

Bool

Source

lib/provable/bool.ts:238


readBytes()

static readBytes<N>(bytes: number[], offset: NonNegativeInteger<N>): [Bool, number]

Type parameters

N extends number

Parameters

bytes: number[]

offset: NonNegativeInteger\<N>

Returns

[Bool, number]

Source

lib/provable/bool.ts:344


sizeInFields()

static sizeInFields(): number

Returns the size of this type.

Returns

number

Source

lib/provable/bool.ts:324


toAuxiliary()

static toAuxiliary(_?: Bool): []

Static method to serialize a Bool into its auxiliary data.

Parameters

_?: Bool

Returns

[]

Source

lib/provable/bool.ts:276


toBytes()

static toBytes(b: Bool): number[]

Parameters

b: Bool

Returns

number[]

Source

lib/provable/bool.ts:336


toField()

static toField(x: boolean | Bool): Field

Parameters

x: boolean | Bool

Returns

Field

Source

lib/provable/bool.ts:211


toFields()

static toFields(x: Bool): Field[]

Static method to serialize a Bool into an array of Field elements.

Parameters

x: Bool

Returns

Field[]

Source

lib/provable/bool.ts:269


toInput()

static toInput(x: Bool): {
"packed": [Field, number][];
}

Parameters

x: Bool

Returns

{
"packed": [Field, number][];
}
packed
packed: [Field, number][];

Source

lib/provable/bool.ts:332


toJSON()

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.

Parameters

x: Bool

Returns

boolean

Source

lib/provable/bool.ts:309


toValue()

static toValue(x: Bool): boolean

Provable<Bool>.toValue()

Parameters

x: Bool

Returns

boolean

Source

lib/provable/bool.ts:293