Skip to content

Commit

Permalink
Merge pull request iden3#2 from iden3/feature/update-docs+remove-esca…
Browse files Browse the repository at this point in the history
…ping

update-docs+remove-escaping
  • Loading branch information
mmilenkovic authored Oct 11, 2021
2 parents 8451253 + 326ea2f commit 5fc8354
Show file tree
Hide file tree
Showing 45 changed files with 1,893 additions and 1,677 deletions.
4 changes: 2 additions & 2 deletions mkdocs/docs/circom-language/basic-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Circom provides boolean, arithmetic, and bitwise operators. They have the standard semantics but the arithmetic operators applied to numeric values work modulo p.

The precedence and association of the operators are like in Rust \(defined [here](https://doc.rust-lang.org/1.22.1/reference/expressions/operator-expr.html#operator-precedence)\).
The precedence and association of the operators are like in Rust (defined [here](https://doc.rust-lang.org/1.22.1/reference/expressions/operator-expr.html#operator-precedence)).

Expressions can be built using the next operators, but the conditional operator `?_:_` can only occur at the top level.

Expand All @@ -14,7 +14,7 @@ A field element is a value in the domain of Z/pZ, where p is the prime number se

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`\).
The circom language is parametric to this number, and it can be changed without affecting the rest of the language (using `GLOBAL_FIELD_P`).

## Conditional expressions

Expand Down
2 changes: 1 addition & 1 deletion mkdocs/docs/circom-language/code-quality/code-assertion.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Code Assertion

**assert\(bool\_expression\);**
**assert(bool_expression);**

This statement introduces conditions to be checked at execution time. If the condition fails, the witness generation is interrupted and the error is reported.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Debugging Operations

In circom there is an operation that can be used while developing circuits to help the programmer debug \(note that there are no input/output operations on the standard input/output channels\). To this end, the operation `log` has as parameter a non-conditional expression \(i.e., not including the _`?`_`;_` operator\). The execution of this instruction prints the result of the evaluation of the expression in the standard error stream. As examples consider:
In circom there is an operation that can be used while developing circuits to help the programmer debug (note that there are no input/output operations on the standard input/output channels). To this end, the operation `log` has as parameter a non-conditional expression (i.e., not including the _`?`_`;_` operator). The execution of this instruction prints the result of the evaluation of the expression in the standard error stream. As examples consider:

```text
log(135);
Expand Down
10 changes: 5 additions & 5 deletions mkdocs/docs/circom-language/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ We have standard constructions for defining the control flow of the program.

## Conditional statement: if-then-else

**if \( boolean\_condition \) block\_of\_code else block\_of\_code**
**if ( boolean_condition ) block_of_code else block_of_code**

The else part is optional. When omitted, it means “else do nothing”.

Expand All @@ -21,9 +21,9 @@ if (x >= 0) {

## Loop statement: for

**for \( initialization\_code ; boolean\_condition ; step\_code \) block\_of\_code**
**for ( initialization_code ; boolean_condition ; step_code ) block_of_code**

If the initialization\_code includes a var declaration then its scope is reduced to the for statement and hence, using it later on \(without defining it again\) will produce a compilation error.
If the initialization_code includes a var declaration then its scope is reduced to the for statement and hence, using it later on (without defining it again) will produce a compilation error.

```text
var y = 0;
Expand All @@ -34,7 +34,7 @@ for(var i = 0; i < 100; i++){

## Loop statement: while

**while \( boolean\_condition \) block\_of\_code**
**while ( boolean_condition ) block_of_code**

It executes the block of code while the condition holds. The condition is checked every time before executing the block of code.

Expand All @@ -47,7 +47,7 @@ while(i < 100){
}
```

**Important**: when constraints are generated in any block inside an if-then-else or loop statement, the condition cannot be unknown \(see [Unknowns](/circom-language/circom-insight/unknowns)\). This is because the constraint generation must be unique and cannot depend on unknown input signals.
**Important**: when constraints are generated in any block inside an if-then-else or loop statement, the condition cannot be unknown (see [Unknowns](/circom-language/circom-insight/unknowns)). This is because the constraint generation must be unique and cannot depend on unknown input signals.

In case the expression in the condition is unknown and some constraint is generated, the compiler will generate the next error message: "_There are constraints depending on the value of the condition and it can be unknown during the constraint generation phase_".

Expand Down
8 changes: 4 additions & 4 deletions mkdocs/docs/circom-language/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

The basic var types in circom are:

* **Field element values**: integer values modulo the prime number _p_ \(see [Signals](/circom-language/signals)\). This is the default type for all signals and basic variables.
* **Arrays**: they 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\).
* **Field element values**: integer values modulo the prime number _p_ (see [Signals](/circom-language/signals)). This is the default type for all signals and basic variables.
* **Arrays**: they 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 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. Examples of declarations with and without initialization:

Expand All @@ -14,7 +14,7 @@ var dbl[16][2] = base;
var y[5] = someFunction(n);
```

The notation m\[i,j\] for arrays of arrays \(matrices\) is not allowed.
The notation m\[i,j\] for arrays of arrays (matrices) is not allowed.

On the other hand, the following case will produce a compilation error, since the size of the array should be explicitly given;

Expand All @@ -30,7 +30,7 @@ Finally, the type of signals needs to be declared as they cannot be assigned glo
signal intermediate[4];
```

An array of components must be instantiated with the same template with \(optionally\) different parameters.
An array of components must be instantiated with the same template with (optionally) different parameters.

```text
pragma circom 2.0.0;
Expand Down
6 changes: 3 additions & 3 deletions mkdocs/docs/circom-language/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function funid ( param1, ... , paramn ) {
}
```

Functions compute numeric \(or arrays of\) values or expressions. Functions can be recursive. Consider the [next function](https://github.com/iden3/circomlib/blob/master/circuits/binsum.circom) from the circom library.
Functions compute numeric (or arrays of) values or expressions. Functions can be recursive. Consider the [next function](https://github.com/iden3/circomlib/blob/master/circuits/binsum.circom) from the circom library.

```text
/*
Expand All @@ -30,7 +30,7 @@ function nbits(a) {
}
```

Functions cannot declare signals or generate constraints \(use templates if you need so\). The next function produces the error message: "Template operator found".
Functions cannot declare signals or generate constraints (use templates if you need so). The next function produces the error message: "Template operator found".

```text
function nbits(a) {
Expand All @@ -46,7 +46,7 @@ function nbits(a) {
}
```

As usual, there can be many return statements, but every execution trace must end in a return statement \(otherwise, a compile error will be produced\). The execution of the return statement returns the control to the caller of the function.
As usual, there can be many return statements, but every execution trace must end in a return statement (otherwise, a compile error will be produced). The execution of the return statement returns the control to the caller of the function.

```text
function example(N){
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/docs/circom-language/include.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Include

Templates, like other code, can be found in other files like in libraries. In order to use code in other files, we have to include them in our program by using the keyword include, with the corresponding name of the file \(.circom extension is the default\).
Templates, like other code, can be found in other files like in libraries. In order to use code in other files, we have to include them in our program by using the keyword include, with the corresponding name of the file (.circom extension is the default).

```text
include "montgomery.circom";
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/docs/circom-language/templates-and-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ template Main() {
component main = Main();
```

**Components are immutable** \(like signals\). A component can be declared first and initialized in a second step. If there are several initialization instructions \(in different execution paths\) they all need to be instantiations of the same template \(maybe with different values for the parameters\).
**Components are immutable** (like signals). A component can be declared first and initialized in a second step. If there are several initialization instructions (in different execution paths) they all need to be instantiations of the same template (maybe with different values for the parameters).

```text
template A(N){
Expand Down
2 changes: 1 addition & 1 deletion mkdocs/docs/circom-language/variables-and-mutability.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Variables are identifiers that hold non-signal data and are mutable. Variables a
var x;
```

They hold either numerical values of the field or arithmetic expressions when they are used to build constraints \(see [Constraint Generation](/circom-language/constraint-generation)\). They can be named using a variable identifier or can be stored in arrays.
They hold either numerical values of the field or arithmetic expressions when they are used to build constraints (see [Constraint Generation](/circom-language/constraint-generation)). They can be named using a variable identifier or can be stored in arrays.

Variable assignment is made using the equal symbol `=`. Declarations may also include an initialization, as in the following examples:

Expand Down
2 changes: 1 addition & 1 deletion mkdocs/docs/getting-started/computing-the-witness.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: >-

Before creating the proof, we need to calculate all the signals of the circuit that match all the constraints of the circuit. For that, we will use the `Wasm` module generated by`circom` that helps to do this job. It can also be done with the `C++` code in a similar way (see below).

Let us start with the `Wasm` code. Using the generated `Wasm` binary and three JavaScript files, we simply need to provide a file with the inputs and the module will execute the circuit and calculate all the intermediate signals and the output. The set of inputs, intermediate signals and output is called [witness](/getting-started/background#witness).
Let us start with the `Wasm` code. Using the generated `Wasm` binary and three JavaScript files, we simply need to provide a file with the inputs and the module will execute the circuit and calculate all the intermediate signals and the output. The set of inputs, intermediate signals and output is called [witness](/background/background#witness).

In our case, we want to prove that we are able to factor the number 33. So, we assign `a = 3` and `b = 11`.

Expand Down
2 changes: 1 addition & 1 deletion mkdocs/docs/getting-started/proving-circuits.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ contains all the computed signals and a file with extension .r1cs that contains

Now, we will use the `snarkjs` tool to generate and validate our zk-SNARK. In particular, using the multiplier2, **we will prove that we are able to provide the two factors of the number 33**. That is, we will show that we know two integers `a` and `b` such that when we multiply them, it results in the number 33.

Before generating the proof, you will need to generate a [trusted setup](/getting-started/background#trusted-setup). Generating a trusted setup consists of 2 parts: powers of tau and phase 2. Next, we provide a very basic ceremony for creating the trusted setup for the [Groth16](https://eprint.iacr.org/2016/260) zk-SNARK protocol. We also provide the basic commands to create and verify [Groth16](https://eprint.iacr.org/2016/260) proofs. Review the related [Background](/getting-started/background) section and check [the snarkjs tutorial](https://github.com/iden3/snarkjs) for further information.
Before generating the proof, you will need to generate a [trusted setup](/background/background#trusted-setup). Generating a trusted setup consists of 2 parts: powers of tau and phase 2. Next, we provide a very basic ceremony for creating the trusted setup for the [Groth16](https://eprint.iacr.org/2016/260) zk-SNARK protocol. We also provide the basic commands to create and verify [Groth16](https://eprint.iacr.org/2016/260) proofs. Review the related [Background](/background/background) section and check [the snarkjs tutorial](https://github.com/iden3/snarkjs) for further information.

## Trusted setup: Powers of Tau <a id="my-first-trusted-setup"></a>

Expand Down
4 changes: 2 additions & 2 deletions mkdocs/docs/getting-started/writing-compiling-circuits.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ circom multiplier2.circom --r1cs --wasm --sym --c

With these options we generate three types of files:

* `--r1cs`: it generates the file `multiplier2.r1cs` that contains the [R1CS constraint system](/getting-started/background#rank-1-constraint-system) of the circuit in binary format.
* `--wasm`: it generates the directory `multiplier2_js` that contains the `Wasm` code (multiplier2.wasm) and other files needed to generate the [witness](/getting-started/background#witness).
* `--r1cs`: it generates the file `multiplier2.r1cs` that contains the [R1CS constraint system](/background/background#rank-1-constraint-system) of the circuit in binary format.
* `--wasm`: it generates the directory `multiplier2_js` that contains the `Wasm` code (multiplier2.wasm) and other files needed to generate the [witness](/background/background#witness).
* `--sym` : it generates the file `multiplier2.sym` , a symbols file required for debugging or for printing the constraint system in an annotated mode.
* `--c` : it generates the directory `multiplier2_cpp` that contains several files (multiplier2.cpp, multiplier2.dat, and other common files for every compiled program like main.cpp, MakeFile, etc) needed to compile the C code to generate the witness.

Expand Down
4 changes: 2 additions & 2 deletions mkdocs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
site_name: Circom 2 Documentation
site_url: http://127.0.0.1:8000
site_url: http://docs.circom.io
theme:
name: material
palette:
Expand All @@ -8,7 +8,7 @@ theme:
# favicon: images/favicon.png
features:
- navigation.tabs
- navigation.top
- navigation.tabs.sticky
repo_url: https://github.com/iden3/circom
markdown_extensions:
- pymdownx.arithmatex:
Expand Down
Loading

0 comments on commit 5fc8354

Please sign in to comment.