-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: main
Are you sure you want to change the base?
feat: workflow for groth16 framework trusted setup #471
Conversation
@@ -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> { |
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.
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.
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)] |
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.
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)] |
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.
Same
only_r1cs: bool, | ||
|
||
#[command(subcommand)] | ||
command: Option<Commands>, |
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.
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(); |
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.
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_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 ceremonygenerate_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 directorygen_params
tool 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.