Alternate 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>,
secrets: Vec<String>,
)
| 224 | // Alternate Step 3 |
| 225 | // given public and runtime parameters (proof and scalars) generate Assertions |
| 226 | pub fn generate_signatures( |
| 227 | proof: ark_groth16::Proof<Bn<ark_bn254::Config>>, |
| 228 | scalars: Vec<ark_bn254::Fr>, |
| 229 | vk: &ark_groth16::VerifyingKey<Bn254>, |
| 230 | secrets: Vec<String>, |
| 231 | ) -> Result<Signatures, String> { |
| 232 | println!("generate_signatures; get_segments_from_groth16_proof"); |
| 233 | let (success, segments) = get_segments_from_groth16_proof(proof, scalars, vk); |
| 234 | if !success { |
| 235 | return Err(format!("generate_signatures; get_segments_from_groth16_proof; success false; num_aggregated segments {}", segments.len())); |
| 236 | } |
| 237 | println!("generate_signatures; get_assertion_from_segments"); |
| 238 | let assn = get_assertion_from_segments(&segments); |
| 239 | println!("generate_signatures; get_signature_from_assertion"); |
| 240 | let sigs = get_signature_from_assertion(assn, secrets.clone()); |
| 241 | println!("generate_signatures; get_pubkeys"); |
| 242 | let pubkeys = get_pubkeys(secrets); |
| 243 | |
| 244 | println!("generate_signatures; partial_scripts_from_segments"); |
| 245 | let partial_scripts: Vec<ScriptBuf> = partial_scripts_from_segments(&segments); |
| 246 | let partial_scripts: [ScriptBuf; NUM_TAPS] = partial_scripts.try_into().unwrap(); |
| 247 | println!("generate_signatures; append_bitcom_locking_script_to_partial_scripts"); |
| 248 | let disprove_scripts = |
| 249 | append_bitcom_locking_script_to_partial_scripts(pubkeys, partial_scripts.to_vec()); |
| 250 | let disprove_scripts: [ScriptBuf; NUM_TAPS] = disprove_scripts.try_into().unwrap(); |
| 251 | |
| 252 | println!("generate_signatures; execute_script_from_signature"); |
| 253 | let exec_res = execute_script_from_signature(&segments, sigs.clone(), &disprove_scripts); |
| 254 | if let Some(fault) = exec_res { |
| 255 | println!( |
| 256 | "generate_signatures; execute_script_from_assertion return fault at script index {}", |
| 257 | fault.0 |
| 258 | ); |
| 259 | return Err(format!( |
| 260 | "generate_signatures; execute_script_from_assertion return fault at script index {}", |
| 261 | fault.0 |
| 262 | )); |
| 263 | } else { |
| 264 | println!("generate_signatures; validated assertion by executing all scripts"); |
| 265 | } |
| 266 | Ok(sigs) |
| 267 | } |
| 268 | |
| 269 | // Step 4 |
| 270 | // validate signed assertions |