Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#### Improvements
- Adding a specific 64-bit arithmetization for Goldilocks in C++ (not using asm), which dramatically improves witness generation efficiency for this prime.
- Generation of full C++ code for the arithmatization (for the prime in use) as an alternative to asm code. This is activated with the new --no_asm flag and provides C++ witness generation code which is independent from the architecture being used.
- Improving the analysis of signal double assigment: branch case no longer causes an error in assignments in different branches.
- Improving the analysis of signal double assignment: branch case no longer causes an error in assignments in different branches.
- Improving the generated C++ code by removing unnecessary instructions.

###Fixed bugs
Expand Down Expand Up @@ -247,7 +247,7 @@
#### Extensions
- Improvement of unused signals removal in constraint optimization.
- macos (x86_64) support for cpp backend added: use template to generate makefile (Not available for M1).
- wabt dependency swapped to wast dependency instead.
- wabt dependency swapped to waste dependency instead.
- Improvement of the known/unknown analysis.
- Single signal declaration with initialization added for both <== and <--.
- Input signal size check added in wasm/JS and C++ generated code.
Expand Down
8 changes: 4 additions & 4 deletions mkdocs/docs/circom-language/circom-insight/simplification.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ Constraint simplification is a key part of the `circom` compiler. A fast simplif

Let us explain the kind of simplification we can perform in detail.

As pointed out in Section 2.3 (Quadratic arithmetic programs) of the [Groth16 paper](https://eprint.iacr.org/2016/260) (where ZK-SNARKs based on arithmetic circuits were introduced):
As pointed out in Section 2.3 (Quadratic arithmetic programs) of the [Growth16 paper](https://eprint.iacr.org/2016/260) (where ZK-SNARKs based on arithmetic circuits were introduced):

> Addition gates are handled for free in the sums defining the equations, i.e., if a<sub>i</sub> + a<sub>j</sub> = a<sub>k</sub> and a<sub>k</sub> is multiplied by a<sub>l</sub>, we may simply write (a<sub>i</sub> + a<sub>j</sub>) * a<sub>l</sub> and skip the calculation of a<sub>k</sub>.

Note that since we can skip its calculation, it will not be part of the witness (the values of the signals that satisfy the arithmetic circuit, i.e. the quadratic constraints).

This means that we can remove any constraint E = 0 if E is linear, by choosing one of the signals in E, say x, and expressing E = 0 as x = E' and replacing x by E' in all other constraints. This way, we may skip the calculation of x since it is not in the resulting problem.

In the context of [Groth16], the statement to be proved is that given the public inputs and outputs and the relation between them expressed by means of quadratic constrains of the form A*B-C = 0 (where A, B and C are linear expressions) we know a witness (an assignment to the signals that includes the given public inputs and outputs) that satisfies the relation (i.e. the constraints for the given public inputs and outputs). Therefore, we cannot remove the public inputs and outputs (even if they occur in a linear constraint) but we can remove any other private signal if it is equivalent to a linear combination of the other signals (i.e. just using additions), since `we can skip the computation of such signal` (because `addition gates are handled for free`) and we are not changing the relation between public inputs and outputs, i.e. the statement.
In the context of [Growth16], the statement to be proved is that given the public inputs and outputs and the relation between them expressed by means of quadratic constrains of the form A*B-C = 0 (where A, B and C are linear expressions) we know a witness (an assignment to the signals that includes the given public inputs and outputs) that satisfies the relation (i.e. the constraints for the given public inputs and outputs). Therefore, we cannot remove the public inputs and outputs (even if they occur in a linear constraint) but we can remove any other private signal if it is equivalent to a linear combination of the other signals (i.e. just using additions), since `we can skip the computation of such signal` (because `addition gates are handled for free`) and we are not changing the relation between public inputs and outputs, i.e. the statement.

In case we are using the PLONK proof system (instead of Groth16), since additions are not free we cannot remove linear constraints anymore. Still we can remove equalities between signals or equalities between signals and constants which is made with the flag --O1 (see below). Moreover, note that if we apply linear simplification to a constraint system in PLONK format, the resulting constraints will in general not be in PLONK format anymore, and transforming the result back to PLONK format may lead to a worse result than the original. For this reason, when using PLONK, it is always recommended to use the --O1 flag.
In case we are using the PLONK proof system (instead of Growth16), since additions are not free we cannot remove linear constraints anymore. Still we can remove equalities between signals or equalities between signals and constants which is made with the flag --O1 (see below). Moreover, note that if we apply linear simplification to a constraint system in PLONK format, the resulting constraints will in general not be in PLONK format anymore, and transforming the result back to PLONK format may lead to a worse result than the original. For this reason, when using PLONK, it is always recommended to use the --O1 flag.

Once we have explained why removing any private signal (including the private inputs) and applying linear simplification is correct, let us explain what kind of simplification is applied when we enable the flag `--O1` (which is activated by default) or the flag `--O2`. Notice that if we do not want to apply any simplification we must use the flag `--O0`.

Expand All @@ -34,4 +34,4 @@ Since circom 2.2.0, we have set `--O1` as the default simplification option. Thi

Note that, using the full simplification `--O2` can significantly reduce the number of constraints and signals, which has a positive impact in the time and space needed to compute the proof. However, this is the most time and space consuming phase of the compilation process. Hence, with large circuits, say with millions of constraints, compilation can take a long time (even minutes or hours) and can run in out-of-memory exceptions. In such cases, it is recommended to only use the `--O2` flag in the final steps of the project development.

[Groth16] Jens Groth. "On the Size of Pairing-Based Non-interactive Arguments". Advances in Cryptology -- EUROCRYPT 2016, pages 305--326. Springer Berlin Heidelberg, 2016.
[Growth16] Jens Growth. "On the Size of Pairing-Based Non-interactive Arguments". Advances in Cryptology -- EUROCRYPT 2016, pages 305--326. Springer Berlin Heidelberg, 2016.
2 changes: 1 addition & 1 deletion mkdocs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The compiler outputs the representation of the circuit as constraints and everyt

## circomlib

With `circom`, it is possible to create large circuits by combining smaller generic circuits called `templates`. The `circomlib` is a library of `circom` templates that contains hundreds of circuits such as comparators, hash functions, digital signatures, binary and decimal convertors and many more. You can also create your custom templates, but before start coding, we recommend you to take a look at our already created templates.
With `circom`, it is possible to create large circuits by combining smaller generic circuits called `templates`. The `circomlib` is a library of `circom` templates that contains hundreds of circuits such as comparators, hash functions, digital signatures, binary and decimal converters and many more. You can also create your custom templates, but before start coding, we recommend you to take a look at our already created templates.

The package already contains tests for circuits available in the `circomlib`.
The package also installs the npm packages `circomlibjs`, `circom_tester` and `ffjavascript` as dependencies.
Expand Down