| 490 | } |
| 491 | |
| 492 | pub(crate) fn execute_script_from_assertion( |
| 493 | segments: &[Segment], |
| 494 | assts: Assertions, |
| 495 | ) -> Option<(usize, Script)> { |
| 496 | // if there is partial disprove script; with no locking script; i can directly push hashes |
| 497 | // segments and assertions |
| 498 | fn collect_wots_msg_as_witness_per_segment( |
| 499 | segments: &[Segment], |
| 500 | assts: Assertions, |
| 501 | ) -> Vec<Script> { |
| 502 | let bitcom_msg = utils_deserialize_assertions(assts); |
| 503 | let mut bitcom_msg_arr = vec![]; |
| 504 | bitcom_msg_arr.extend_from_slice(&bitcom_msg.0); |
| 505 | bitcom_msg_arr.extend_from_slice(&bitcom_msg.1); |
| 506 | bitcom_msg_arr.extend_from_slice(&bitcom_msg.2); |
| 507 | |
| 508 | let mut all_bc_hints = vec![]; |
| 509 | for i in 0..segments.len() { |
| 510 | let mut index_of_bitcommitted_msg: Vec<u32> = vec![]; |
| 511 | |
| 512 | let seg = &segments[i]; |
| 513 | |
| 514 | // final script doesn't have output |
| 515 | if !seg.scr_type.is_final_script() { |
| 516 | let sec_out = ( |
| 517 | seg.id, |
| 518 | segments[seg.id as usize].result.0.output_is_field_element(), |
| 519 | ); |
| 520 | index_of_bitcommitted_msg.push(sec_out.0); |
| 521 | } |
| 522 | |
| 523 | let sec_in: Vec<u32> = seg.parameter_ids.iter().map(|(k, _)| *k).collect(); |
| 524 | index_of_bitcommitted_msg.extend_from_slice(&sec_in); |
| 525 | // index_of_bitcom_msg => [output, inputn-1, ..input0] |
| 526 | |
| 527 | let mut bc_hint = script! {}; |
| 528 | for skey in index_of_bitcommitted_msg { |
| 529 | let bcelem = bitcom_msg_arr[skey as usize].clone(); |
| 530 | let h = bcelem.as_hint_type(); |
| 531 | bc_hint = script! { |
| 532 | {bc_hint} |
| 533 | {h.push()} |
| 534 | {Fq::toaltstack()} |
| 535 | }; // Altstack: [outputhash, inputN-1Hash, ..., input0Hash] |
| 536 | } |
| 537 | |
| 538 | all_bc_hints.push(bc_hint); |
| 539 | } |
| 540 | all_bc_hints |
| 541 | } |
| 542 | |
| 543 | // collect partial scripts |
| 544 | let partial_scripts: Vec<ScriptBuf> = partial_scripts_from_segments(segments) |
| 545 | .into_iter() |
| 546 | .collect(); |
| 547 | let partial_scripts: [ScriptBuf; NUM_TAPS] = partial_scripts.try_into().unwrap(); |
| 548 | // collect witness |
| 549 | let mul_hints = utils_collect_mul_hints_per_segment(segments); |