Skip to content
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

feat(barretenberg): Graph methods for circuit analysis (part 2) #12130

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

DanielKotov
Copy link
Contributor

This PR continues Graph Description for Ultra Circuit Builder.

There were added functions for processing:

  1. auxiliary block (bigfield limb accumulation, bigfield product, RAM/ROM tables read gates)
  2. poseidon2s external and internal blocks.

There were tested primitives like Poseidon2s hash function, Dynamic Array and Bigfield. Poseidon and Dynamic Array have been fully tested. Bigfield has been tested halfway.

There has been completed function for arithmetic block. (q_arith == 3 case), and it processes fix_witness another way.

There was added new filtering mechanism for finalize_circuit() function using tau and range tags, filtering mechanism for RAM/ROM gate and filtering mechanism for variables that were fixed.

Also there was added new data structure for containing information about gates for every variable. It can be helpful in further filtering mechanisms or debugging process.

No vulnerabilities were found by static analyzer.

@DanielKotov DanielKotov force-pushed the dk/boomerang_value_detection_final2 branch from 6a67e67 to 86f9a35 Compare February 26, 2025 13:34

/**
all these tests check graph description for sha256 circuits. All circuits have to consist from 1 connected component
all these tests check graph description for sha256 circuits. All circuits have to consist of 1 connected component
*/

TEST(boomerang_stdlib_sha256, test_graph_for_sha256_55_bytes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to add separate descriptions to each test. If I go to the last one, I don't know that there is a description here.

EXPECT_EQ(variables_in_one_gate.size(), 0);
if (variables_in_one_gate.size() > 0) {
for (const auto& elem : variables_in_one_gate) {
info("elem == ", elem);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to remove info from tests in the general case, but here it's not an issue since the branch is not being taken

auto variables_in_one_gate = graph.show_variables_in_one_gate(circuit_constructor);
bool result = num_connected_components == 256;
EXPECT_EQ(result, true);
[[maybe_unused]] auto variables_in_one_gate = graph.show_variables_in_one_gate(circuit_constructor);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this unused?

auto connected_components = graph.find_connected_components();
EXPECT_EQ(connected_components.size(), 1);
auto variables_in_one_gate = graph.show_variables_in_one_gate(builder);
EXPECT_EQ(variables_in_one_gate.size(), 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there 2?

fq_ct b(witness_ct(&builder, fr(uint256_t(inputs[1]).slice(0, fq_ct::NUM_LIMB_BITS * 2))),
witness_ct(&builder, fr(uint256_t(inputs[1]).slice(fq_ct::NUM_LIMB_BITS * 2, fq_ct::NUM_LIMB_BITS * 4))));
fq_ct c = a * b;
for (size_t i = 0; i < num_repetitions; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to repeat these operations

{
auto builder = Builder();
size_t num_repetitions = 4;
for (size_t i = 0; i < num_repetitions; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to repeat these operations

{
auto builder = Builder();
size_t num_repetitions = 10;
for (size_t i = 0; i < num_repetitions; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and basically everywhere further there is no need to repeat operations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants