Replies: 2 comments 3 replies
-
It seems that you are rewriting the circuit variables: for i := 0; i < 1000000; i++ {
c.X1 = api.Add(c.X1, c.X2)
c.X2 = api.Add(c.X1, c.X2)
} Could you instead try something like: res1 = api.Add(c.X1, c.X2)
res2 = api.Add(c.X2, res1)
for i := 0; i < 100000; i++ {
res := api.Add(res1, res2)
res1, res2 = res2, tmp
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
See the written Fibonacci example: http://play.gnark.io/?id=_wmhuc14gg What happens in R1CS is that the gnark compiler essentially computes the Fibonacci sequence value at runtime as it can replace recursively the additions when computing the sequence. So there is no need to create any new variables as the result depends solely on F0 and F1. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I am a beginner trying to use gnark as a zero knowledge proof framework.
I have implemented two types of circuits here. The first circuit is used to prove the last two terms of a fixed length Fibonacci sequence, and the second circuit is used to recursively verify the proof.At the beginning, the latter could run normally, but the former encountered some problems.
Firstly, let me explain the problems encountered in the former. The circuit I have written is as follows:
After compilation, I found that the number of wires obtained was only 5, including the public input "1" that r1cs already has, as well as the 2 public inputs and 2 private inputs I declared in the circuit.But the effect I hope to present is to have 100000 internal variables, because in the
Define
function, I wrote 1000000 loops.After investigation, I found that if I comment out the judgment conditions in the following code in
frontend/cs/r1cs/builder.go
.Then the result I want will appear.Based on the commented out judgment criteria, I attempted to modify CompressThreshold to 2, in other words, almost all equations will be compressed.But in this way, my second circuit will report an error.
The secondcircuit is the recursive verification circuit.This is an official sample provided by gnark.
After modifying the above configuration, I encountered an error when attempting to prove the circuit:
I really hope to know a way to balance the above two issues, Looking forward to your answer very much, thank you!
Beta Was this translation helpful? Give feedback.
All reactions