Conversation
There was a problem hiding this comment.
This reminds me of your comments in #8 (comment) when you refactored the merkle_sum_tree.
It appears that the constraint, without doubling, is also satisfied in this narrowed version of the chip.
therefore without checking that the values were carried from row(cur) to row(next) correctly without performing any swap.
I'm not entirely clear on the meaning of "performing" in this context. Does the code already perform a swap during the assignment phase here:
summa-solvency/zk_prover/src/chips/merkle_sum_tree.rs
Lines 203 to 209 in 7e39b84
It seems to me that both the previous and fixed constraints work well without any bugs.
|
Yes, thanks @sifnoc for finding the comment! I didn't remember that we performed such a fix in the past. The current constraint works fine (as expected) when
The problem of such constraint emerges when In this case, the constraint will be satisfied (as expected) when no swap is to be performed. The constraint will be satisfied But the same constraint will also be satisfied if the swap is performed (going against the rule of the The constraint will still be satisfied in this case, which shouldn't be the case! So, to conclude, the bug in the current version is that it is not constraining the swap to not be performed when |
Thanks for the kind explanation! Oh, I see now, it's a bug! |
alxkzmn
left a comment
There was a problem hiding this comment.
Let's fix the "elelment" in the next PR
| * ((elelment_l_next - elelment_l_cur) - (elelment_r_cur - elelment_r_next)); | ||
| * ((swap_bit | ||
| * Expression::Constant(Fp::from(2)) | ||
| * (elelment_r_cur.clone() - elelment_l_cur.clone()) |
There was a problem hiding this comment.
There's a typo in "element"
This PR fixes a bug in our current
swap_constraint.In particular the current swap_constraint
s * swap_bit * ((elelment_l_next - elelment_l_cur) - (elelment_r_cur - elelment_r_next))correctly check that the swapping is performed correctly only in the case in whichswap_bitis equal to 1 and therefore the swapping needs to be performed.In the case in which
swap_bitis equal to 0, meaning that the swapping between row(cur) and row(next) doesn't need to be performed, the polynomial constraint will always be equal to 0, therefore without checking that the values were carried from row(cur) to row(next) correctly without performing any swap.The new polynomial constraint solves this issue