Skip to content

Optimize constants array initialization in C++ generator #9

@aesilevich

Description

@aesilevich

In the current implementation, the C++ generator does not include special handling for initializing constant arrays. Instead, the Circom compiler transforms constant declarations into a sequence of assignments to individual array elements. As a result, the C++ generator produces extremely large code for the POSEIDON_C function from the standard library—approximately 20,000 lines. This causes the C++ compiler to take an excessively long time to compile (it did not finish even after 6 hours).

We need to do the following:

  1. Disable the transformation of constants into assignments in the Circom compiler.
  2. Generate static variables for all constants, including arrays.
  3. Try to avoid array copies in the POSEIDON_C function. This can be done by returning a reference to the constant array instead of a copy.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions