-
Notifications
You must be signed in to change notification settings - Fork 843
Refactor Tx circuit and use challenge api #803
Refactor Tx circuit and use challenge api #803
Conversation
e716130
to
fe61a14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Amazing work! Not only you updated the circuit to use the challenge API, but also optimized it removing many rows, and also cleaned up some stuff :D
I've left some questions (so that I make sure i understood everything) and a suggestion, please take a look :)
885034b
to
ab7a796
Compare
ab7a796
to
bf7e44d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I did only a light review so that this pr can be merged to unblock other prs. Added a comment.
bf7e44d
to
bbb5921
Compare
bbb5921
to
7f123a9
Compare
Although the spec has not been merged, but since privacy-scaling-explorations/zkevm-specs#292 only adds some more description to Tx circuit, so I think we can merge this first to unblock #816. |
* feat: refactor tx circuit and use challenge api for it * feat: remove `#[ignore]` for tests of tx circuit * fix: apply suggestion and clean up * fix: apply suggestion from @ChihChengLiang
* support max snark upto 16 * more tests * fix bug in data input len * merge required features from max_snark=29 * clean up
This PR aims to refactor Tx circuit with challenge API.
It reuses
MainGate
's advice columns to create an extra random linear combination gate to get rid of 130 columns inSignVerifyChip
, with the cost of few more rows to doSignVerifyChip::assign_signature_verify
than previous approach. So now tests and benchmark of Tx circuit can be ran locally.In respect to more rows (76 rows precisely) to verify a single signature, I think it should be negligible cause ecdsa verification already costs ~70k, and is still the bottleneck. Also even we have reached our bottleneck on ecdsa verification, we can actually just allocate another
MainGate
to double our capacity (eachMainGate
withRangeChip
costs ~60 msm) without too much change to current code.There is also a caveat about multi-phase: The
AssignedCell
will havevalue: Value::unknown
in any phase that is not equal to current one, because we need to follow the principle that the functionto
ofassign_{fixed,advice}
will only be called once (it's aFnMut
so we need to guarantee that). So it's a little bit awkward to calculate later phase witness with previous phase'sAssignedCell
, we need to pass theCell
andValue
separately to make sure we can do the calculation and at the same time enforce the copy constraint.And currently this behavior is not shown in
MockProver
, so it takes me some time to find this issue, I have also created an issue privacy-scaling-explorations/halo2#102 to propose to makeMockProver
to do multi-phsae synthesis just like real prover.Todo