@@ -25,18 +25,19 @@ pub fn groth16_setup(
2525 circuit_file : & str ,
2626 pk_file : & str ,
2727 vk_file : & str ,
28+ to_hex : bool ,
2829) -> Result < ( ) > {
2930 let mut rng = rand:: thread_rng ( ) ;
3031 match curve_type {
3132 "BN128" => {
3233 let circuit = create_circuit_from_file :: < Bn256 > ( circuit_file, None ) ;
3334 let ( pk, vk) = Groth16 :: circuit_specific_setup ( circuit, & mut rng) ?;
34- write_pk_vk_to_files ( curve_type, pk, vk, pk_file, vk_file) ?
35+ write_pk_vk_to_files ( curve_type, pk, vk, pk_file, vk_file, to_hex ) ?
3536 }
3637 "BLS12381" => {
3738 let circuit = create_circuit_from_file :: < Bls12 > ( circuit_file, None ) ;
3839 let ( pk, vk) = Groth16 :: circuit_specific_setup ( circuit, & mut rng) ?;
39- write_pk_vk_to_files ( curve_type, pk, vk, pk_file, vk_file) ?
40+ write_pk_vk_to_files ( curve_type, pk, vk, pk_file, vk_file, to_hex ) ?
4041 }
4142 _ => {
4243 return Err ( EigenError :: Unknown ( format ! (
@@ -48,6 +49,7 @@ pub fn groth16_setup(
4849 Ok ( ( ) )
4950}
5051
52+ #[ allow( clippy:: too_many_arguments) ]
5153pub fn groth16_prove (
5254 curve_type : & str ,
5355 circuit_file : & str ,
@@ -56,6 +58,7 @@ pub fn groth16_prove(
5658 input_file : & str ,
5759 public_input_file : & str ,
5860 proof_file : & str ,
61+ to_hex : bool ,
5962) -> Result < ( ) > {
6063 let mut rng = rand:: thread_rng ( ) ;
6164
@@ -77,7 +80,7 @@ pub fn groth16_prove(
7780 . collect :: < Vec < _ > > ( ) ;
7881 let circuit = create_circuit_from_file :: < Bn256 > ( circuit_file, Some ( w) ) ;
7982 let proof = Groth16 :: prove ( & pk, circuit. clone ( ) , & mut rng) ?;
80- let proof_json = serialize_proof ( & proof, curve_type, false ) ?;
83+ let proof_json = serialize_proof ( & proof, curve_type, to_hex ) ?;
8184 std:: fs:: write ( proof_file, proof_json) ?;
8285 let input_json = circuit. get_public_inputs_json ( ) ;
8386 std:: fs:: write ( public_input_file, input_json) ?;
@@ -96,7 +99,7 @@ pub fn groth16_prove(
9699 . collect :: < Vec < _ > > ( ) ;
97100 let circuit = create_circuit_from_file :: < Bls12 > ( circuit_file, Some ( w) ) ;
98101 let proof = Groth16 :: prove ( & pk, circuit. clone ( ) , & mut rng) ?;
99- let proof_json = serialize_proof ( & proof, curve_type, false ) ?;
102+ let proof_json = serialize_proof ( & proof, curve_type, to_hex ) ?;
100103 std:: fs:: write ( proof_file, proof_json) ?;
101104 let input_json = circuit. get_public_inputs_json ( ) ;
102105 std:: fs:: write ( public_input_file, input_json) ?;
@@ -195,10 +198,11 @@ fn write_pk_vk_to_files<P: Parser>(
195198 vk : VerifyingKey < P > ,
196199 pk_file : & str ,
197200 vk_file : & str ,
201+ to_hex : bool ,
198202) -> Result < ( ) > {
199203 let writer = std:: fs:: File :: create ( pk_file) ?;
200204 pk. write ( writer) ?;
201- let vk_json = serialize_vk ( & vk, curve_type, false ) ?;
205+ let vk_json = serialize_vk ( & vk, curve_type, to_hex ) ?;
202206 std:: fs:: write ( vk_file, vk_json) ?;
203207 Ok ( ( ) )
204208}
0 commit comments