Step 3 given public and runtime parameters (proof and scalars) generate Assertions
(
proof: ark_groth16::Proof<Bn<ark_bn254::Config>>,
scalars: Vec<ark_bn254::Fr>,
vk: &ark_groth16::VerifyingKey<Bn254>,
)
| 194 | // Step 3 |
| 195 | // given public and runtime parameters (proof and scalars) generate Assertions |
| 196 | pub fn generate_assertions( |
| 197 | proof: ark_groth16::Proof<Bn<ark_bn254::Config>>, |
| 198 | scalars: Vec<ark_bn254::Fr>, |
| 199 | vk: &ark_groth16::VerifyingKey<Bn254>, |
| 200 | ) -> Result<Assertions, String> { |
| 201 | let (success, segments) = get_segments_from_groth16_proof(proof, scalars, vk); |
| 202 | if !success { |
| 203 | return Err(format!("generate_assertions; get_segments_from_groth16_proof; success false; num_aggregated segments {}", segments.len())); |
| 204 | } |
| 205 | assert!(success); |
| 206 | let assts = get_assertion_from_segments(&segments); |
| 207 | let exec_res = execute_script_from_assertion(&segments, assts); |
| 208 | |
| 209 | if let Some(fault) = exec_res { |
| 210 | println!( |
| 211 | "generate_assertions; execute_script_from_assertion return fault at script index {}", |
| 212 | fault.0 |
| 213 | ); |
| 214 | return Err(format!( |
| 215 | "generate_assertions; execute_script_from_assertion return fault at script index {}", |
| 216 | fault.0 |
| 217 | )); |
| 218 | } else { |
| 219 | println!("generate_assertions; validated assertion by executing all scripts"); |
| 220 | } |
| 221 | Ok(assts) |
| 222 | } |
| 223 | |
| 224 | // Alternate Step 3 |
| 225 | // given public and runtime parameters (proof and scalars) generate Assertions |