feat: workflow for groth16 framework trusted setup#471
feat: workflow for groth16 framework trusted setup#471nicholas-mainardi wants to merge 12 commits into
Conversation
| } | ||
|
|
||
| /// Read the data from a file as a String | ||
| pub fn read_file_to_string<P: AsRef<Path>>(file_path: P) -> Result<String> { |
There was a problem hiding this comment.
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)?; |
There was a problem hiding this comment.
Same thing here, how big can these grow?
|
|
||
| /// Generate Groth16 parameters from existing query parameters | ||
| #[arg(long)] | ||
| #[arg(long, default_value_t = false)] |
There was a problem hiding this comment.
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)] |
| only_r1cs: bool, | ||
|
|
||
| #[command(subcommand)] | ||
| command: Option<Commands>, |
There was a problem hiding this comment.
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.
| #[tokio::main] | ||
| /// Main entry point for the parameter generation tool | ||
| async fn main() { | ||
| env_logger::init(); |
There was a problem hiding this comment.
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.
|
Please note that we need: [ ] a major PR2 release after this is merged; |
This PR adds some APIs to Groth16 framework to allow generation of Groth16 assets with a trusted setup ceremony.
More specifically:
build_verifier_circuitAPI 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 ceremonygenerate_solidity_verifierAPI 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 directorygen_paramstool to add input flags and sub-commands to use these 2 APIs to generate the Groth16 assets altogether with the trusted setup toolFurthermore, 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.