-
Notifications
You must be signed in to change notification settings - Fork 598
chore: move check_circuit functionality from TranslatorCircuitBuilder into a TranslatorCircuitChecker
#13761
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b4ec388
create translator circuit checker
3fbf526
fix build-fuzz compilation and cleanup
3b15a1b
docs
941c2c7
docs
b515488
Merge remote-tracking branch 'origin/master' into mm/translator-metho…
7bdd9f5
actually fix fuzzing build and add more docs
8ffd722
fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
457 changes: 457 additions & 0 deletions
457
barretenberg/cpp/src/barretenberg/circuit_checker/translator_circuit_checker.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
barretenberg/cpp/src/barretenberg/circuit_checker/translator_circuit_checker.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #pragma once | ||
| #include "barretenberg/translator_vm/translator_circuit_builder.hpp" | ||
| namespace bb { | ||
| class TranslatorCircuitChecker { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the code present in the header and source of this class has just simply been relocated from TranslatorCircuitBuilder with no modifications to actual functionality except what was required to make it compile |
||
| using Fr = bb::fr; | ||
| using Fq = bb::fq; | ||
| using Builder = TranslatorCircuitBuilder; | ||
| using WireIds = Builder::WireIds; | ||
|
|
||
| // Number of limbs used to decompose a 254-bit value for modular arithmetic | ||
| static constexpr size_t NUM_BINARY_LIMBS = Builder::NUM_BINARY_LIMBS; | ||
|
|
||
| public: | ||
| struct RelationInputs { | ||
| std::array<Fr, NUM_BINARY_LIMBS> x_limbs; | ||
| std::array<Fr, NUM_BINARY_LIMBS> v_limbs; | ||
| std::array<Fr, NUM_BINARY_LIMBS> v_squared_limbs = { 0 }; | ||
| std::array<Fr, NUM_BINARY_LIMBS> v_cubed_limbs = { 0 }; | ||
| std::array<Fr, NUM_BINARY_LIMBS> v_quarted_limbs = { 0 }; | ||
| }; | ||
| TranslatorCircuitChecker() = default; | ||
|
|
||
| /** | ||
| * @brief Get the result of accumulation, stored as 4 binary limbs in the first row of the circuit. | ||
| * | ||
| */ | ||
| static Fq get_computation_result(const Builder& circuit) | ||
| { | ||
| const size_t RESULT_ROW = 1; | ||
| ASSERT(circuit.num_gates > RESULT_ROW); | ||
| return Fq( | ||
| circuit.get_variable(circuit.wires[WireIds::ACCUMULATORS_BINARY_LIMBS_0][RESULT_ROW]) + | ||
| circuit.get_variable(circuit.wires[WireIds::ACCUMULATORS_BINARY_LIMBS_1][RESULT_ROW]) * Builder::SHIFT_1 + | ||
| circuit.get_variable(circuit.wires[WireIds::ACCUMULATORS_BINARY_LIMBS_2][RESULT_ROW]) * Builder::SHIFT_2 + | ||
| circuit.get_variable(circuit.wires[WireIds::ACCUMULATORS_BINARY_LIMBS_3][RESULT_ROW]) * Builder::SHIFT_3); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Create limb representations of x and powers of v that are needed to compute the witness or check | ||
| * circuit correctness | ||
| * | ||
| * @param evaluation_input_x The point at which the polynomials are being evaluated | ||
| * @param batching_challenge_v The batching challenge | ||
| * @return RelationInputs | ||
| */ | ||
| static RelationInputs compute_relation_inputs_limbs(const Fq& batching_challenge_v, const Fq& evaluation_input_x); | ||
|
|
||
| /** | ||
| * @brief Check the witness satisifies the circuit | ||
| * | ||
| * @details Goes through each gate and checks the correctness of accumulation | ||
| * | ||
| * @return true | ||
| * @return false | ||
| */ | ||
|
|
||
| static bool check(const Builder& circuit); | ||
| }; | ||
| } // namespace bb | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 found some remains of the term circuit constructor here and in the ultra circuit builder tests and addressed them as well