mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-24 02:31:44 +03:00
Create FAQ.md
This commit is contained in:
parent
af84f66902
commit
1c8699696c
26
FAQ.md
Normal file
26
FAQ.md
Normal file
@ -0,0 +1,26 @@
|
||||
# FAQs
|
||||
|
||||
#### For some given code, changing the value in a constant variable changes the number of constraints in the generated circuit. Is this behavior correct?
|
||||
|
||||
**Yes**, take the integers as an example. In Leo, integers are represented as its binary decomposition,
|
||||
with each bit occupying one field element (that takes on 0 or 1). Then, for an expression such as `a == 4u32`, the operation to evaluate equality
|
||||
would comprise a linear pass of bitwise `AND` operations, comparing every bit in the **variable** value with each bit in the **constant** value.
|
||||
|
||||
As the constant value is already known to the compiler during circuit synthesis, the compiler is already able to complete part of the equality evaluation,
|
||||
by assuming that any bit in the constant value that is `0` will clearly evaluate to `0`. As such, depending on the value of the constant integer in your code,
|
||||
the total number of constraints in the generate circuit can vary.
|
||||
|
||||
To illustrate this, here are two examples to show the difference:
|
||||
```
|
||||
const = 00000001
|
||||
variable = abcdefgh
|
||||
---------------------------------
|
||||
output = 0000000h (1 constraint)
|
||||
```
|
||||
|
||||
```
|
||||
const = 01110001
|
||||
variable = abcdefgh
|
||||
---------------------------------
|
||||
output = 0bcd000h (4 constraints)
|
||||
```
|
Loading…
Reference in New Issue
Block a user