Skip to content

feat: workflow for groth16 framework trusted setup #471

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

nicholas-mainardi
Copy link
Contributor

This PR adds some APIs to Groth16 framework to allow generation of Groth16 assets with a trusted setup ceremony.

More specifically:

  • It adds a build_verifier_circuit API that generates only the R1CS circuit rather than the full proving and verification keys; the R1CS circuit is needed as input for the trusted setup ceremony
  • It adds a generate_solidity_verifier API that generates the Solidity verifier contract code from the proving key and verification key found in the asset directory; the proving and verification key are the outputs of the trusted setup ceremony, and are expected to be placed in the asset directory
  • It changes the gen_params tool to add input flags and sub-commands to use these 2 APIs to generate the Groth16 assets altogether with the trusted setup tool

Furthermore, this PR also updates Gnark to a recent version, which needs to be used to successfully generate the parameters with the trusted setup Gnark APIs.

@@ -40,6 +46,15 @@ pub fn read_file<P: AsRef<Path>>(file_path: P) -> Result<Vec<u8>> {
Ok(data)
}

/// Read the data from a file as a String
pub fn read_file_to_string<P: AsRef<Path>>(file_path: P) -> Result<String> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just curious, how big can these keys be?

pub(crate) fn load_circuit_data(asset_dir: &str) -> Result<CircuitData<F, C, D>> {
// Read from file.
let file_path = Path::new(asset_dir).join(CIRCUIT_DATA_FILENAME);
let bytes = read_file(file_path)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same thing here, how big can these grow?

@@ -45,8 +41,32 @@ struct Args {
params_root_dir: String,

/// Generate Groth16 parameters from existing query parameters
#[arg(long)]
#[arg(long, default_value_t = false)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

bool already default to false.

/// If this flag is true, then only the R1CS file is generated for Groth16
/// instead of all the Groth16 assets; useful when the proving and verification
/// keys must be generated with a trusted setup ceremony
#[arg(long, default_value_t = false)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same

only_r1cs: bool,

#[command(subcommand)]
command: Option<Commands>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please put both operation behind a Command? It's weird that PPs generation is nothing, but Solidity generation is gated behind a command.

async fn main() {
env_logger::init();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we use a logger, then everything output should be a trace/info/debug/warn/error, otherwise everything should be a println – but please let us avoid mixing both.

@delehef delehef changed the title Feat/groth16 framework trusted setup.workflow feat: workflow for groth16 framework trusted setup Apr 1, 2025
@delehef
Copy link
Collaborator

delehef commented Apr 1, 2025

Please note that we need:

[ ] a major PR2 release after this is merged;
[ ] to make sure that the PPs worflow file is compatible with the updated tool;
[ ] ancillary QE & workers release to update to the new numeric settings location.

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