â€‹Field elementsâ€‹

â€‹Booleansâ€‹

â€‹Arraysâ€‹

A **field element** is a value in the domain of `Z/pZ`

, where `p`

is the prime number set by default to

p = 21888242871839275222246405745257275088548364400416034343698204186575808495617

As such, field elements are operated in arithmetic modulo `p`

. The `circom`

language is parametric to this number, and it can be changed without affecting the rest of the language (using `GLOBAL_FIELD_P`

). To understand why we need to operate over `Z/pZ`

and when it makes sense to change `p`

, take a look at the Background section.

Field element is the **default type** for all signals and basic variables.

There is no explicit **boolean** type. In `circom`

we consider:

`TRUE`

: Any field element different from`0`

.`FALSE`

: Only the element`0`

.

**Arrays** can hold a finite number of elements (known at compilation time) of the same type (`signal`

, `var`

or the same type of components or arrays again).

The elements are numbered

**from zero on**, and can be accessed using the corresponding index of their position.Array access is made using square brackets.

Declaration of an array of a given type is made by adding

`[]`

aside of the variable identifier and including the size between the brackets (which should be defined using constant values and/or numeric parameters of templates).The notation

`m[i,j]`

for arrays of arrays (matrices) is not allowed. The access and the declaration should be consistent with their type and hence we access and declare with`m[i][j]`

, since`m[i]`

is an array.

Below there are few examples of declarations with and without initialization:

var x[3] = [2,8,4];var z[n+1]; // where n is a parameter of a templatevar dbl[16][2] = base;var y[5] = someFunction(n);

The following case would result in a compilation `error`

, since the size of the array is not explicitly given:

var z = [2, 8, 4];

The **type** of signals need to be declared as they cannot be assigned globally as an array. They are **assigned** by positions.