-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: eccvm transcript builder #9026
Conversation
VMState state{ | ||
.pc = total_number_of_muls, | ||
.count = 0, | ||
.accumulator = CycleGroup::affine_point_at_infinity, | ||
.msm_accumulator = offset_generator(), | ||
.is_accumulator_empty = true, | ||
}; | ||
|
||
VMState updated_state; |
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.
tried to remove it, but seems tricky
accumulator_trace[i] = state.accumulator; | ||
msm_accumulator_trace[i] = msm_transition ? updated_state.msm_accumulator : Element::infinity(); | ||
intermediate_accumulator_trace[i] = | ||
msm_transition ? (updated_state.msm_accumulator - offset_generator()) : Element::infinity(); | ||
if (entry.mul && next_not_msm && !row.accumulator_empty) { |
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.
state is re-written by the updates state, so this check is unnecessary
auto rhsy = accumulator_trace[i].is_point_at_infinity() ? (0) : accumulator_trace[i].y; | ||
inverse_trace_x[i] = lhsx - rhsx; | ||
inverse_trace_y[i] = lhsy - rhsy; | ||
} else if (add) { |
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.
here add = row.q_add, but it coincides with entry.add, so the logic could be simplified a little
for (size_t i = 0; i < accumulator_trace.size(); ++i) { | ||
TranscriptRow& row = transcript_state[i + 1]; |
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.
this is not necessary, but makes the operations with the current transcipt row way clearer
@@ -10,8 +10,13 @@ class ECCVMTranscriptBuilder { | |||
using FF = grumpkin::fr; | |||
using Element = typename CycleGroup::element; | |||
using AffineElement = typename CycleGroup::affine_element; | |||
using VMOperation = typename bb::eccvm::VMOperation<CycleGroup>; | |||
using Accumulator = typename std::vector<Element>; | |||
|
|||
struct TranscriptRow { |
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.
seemed logical to group the fields in the order of being populated
@@ -212,7 +212,7 @@ void ECCVMTranscriptRelationImpl<FF>::accumulate(ContainerOverSubrelations& accu | |||
* If q_mul = 1 OR q_add = 1 OR q_eq = 1, require (transcript_Px, transcript_Py) is valid ecc point | |||
* q_mul/q_add/q_eq mutually exclusive, can represent as sum of 3 | |||
*/ | |||
const auto validate_on_curve = q_mul + q_add + q_mul + q_eq; | |||
const auto validate_on_curve = q_add + q_mul + q_eq; |
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.
must have been a typo
Changes to circuit sizes
🧾 Summary (100% most significant diffs)
Full diff report 👇
|
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.
Everthing looks good, could you just please document (add descriptions) to all the functions you've split out.
} | ||
|
||
private: | ||
static void populate_transcript_row(TranscriptRow& row, |
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.
All of these functions need descriptions
} | ||
} | ||
static void batch_invert(std::vector<FF>& inverse_trace_x, |
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.
I think these calls can stay in the original function
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.
done
TranscriptRow& final_row = transcript_state.back(); | ||
final_row.pc = updated_state.pc; | ||
final_row.accumulator_x = | ||
(updated_state.accumulator.is_point_at_infinity()) ? 0 : AffineElement(updated_state.accumulator).x; | ||
updated_state.accumulator.is_point_at_infinity() ? 0 : AffineElement(updated_state.accumulator).x; |
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.
Should probably add an explanation for (0,0)
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.
Currently, I don't have a good explanation, because that's exactly where the point at infinity breaks Goblin
add_lambda_numerator[i], | ||
add_lambda_denominator[i]); | ||
} else { | ||
row.transcript_add_x_equal = 0; |
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.
what does this do?
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.
the slopes are only used when there's an msm transition or an addition
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.
Expanded the docs to some extent. Agree that they could be done even more detailed
improved the structure of the main method compute_rows
cleaned up logic without modifying it
improved code sharing
added docs (not very detailed but should be helpful)
added the point at infinity test to ECCVMCircuitBuilderTests. this test passing means that we are not handling point at infinity correctly