Skip to content

Commit

Permalink
Merge pull request #248 from HashMapsData2Value/master
Browse files Browse the repository at this point in the history
Update signals.md
  • Loading branch information
clararod9 authored Mar 29, 2024
2 parents 1fd338e + a0bca7c commit 3528694
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mkdocs/docs/circom-language/signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ signal inter;
This small example declares an input signal with identifier `in`, an N-dimension array of output signals with identifier `out` and an intermediate signal with identifier `inter`.

## Types of Signal Assignments
Signals can only be assigned using the operations `<--` or `<==` (with the signal to be assigned occurring on the left hand side operation) and `-->` or `==>` (with the signal to be assigned occurring on the right hand side). All these operations are translated into an assigment in the witness generation code produced by the compiler. However, the key difference between the 'double arrow' assigments `<==` and `==>` and the 'single arrow' assigments `<--` and `-->` is that only the former adds a constraint to the R1CS system stating that the signal is equal to the assigned expression. Hence, using `<--` and `-->` is considered dangerous and hardly discouraged for non expert circom programmers, as it is the most common source of programming buggy ZK-protocols using circom.
Signals can only be assigned using the operations `<--` or `<==` (with the signal to be assigned occurring on the left hand side operation) and `-->` or `==>` (with the signal to be assigned occurring on the right hand side). All these operations are translated into an assigment in the witness generation code produced by the compiler. However, the key difference between the 'double arrow' assigments `<==` and `==>` and the 'single arrow' assigments `<--` and `-->` is that only the former adds a constraint to the R1CS system stating that the signal is equal to the assigned expression. Hence, using `<--` and `-->` is considered dangerous and strongly discouraged for non expert circom programmers, as it is the most common source of programming buggy ZK-protocols using circom.

The safe options for assignments are `<==` and `==>`, since the assigned value is the only solution to the constraint system. Using `<--` and `-->` should be avoided, and only used when the assigned expression cannot be included in an arithmetic constraint in R1CS, like in the following example.

Expand Down

0 comments on commit 3528694

Please sign in to comment.