| 643 | run_for_invalid_inputs(f_n, g_n, false); |
| 644 | |
| 645 | fn run_for_invalid_inputs(f_n: ark_bn254::Fq12, g_n: ark_bn254::Fq12, is_valid_in: bool) { |
| 646 | let h_n = f_n * g_n; |
| 647 | |
| 648 | let h_n = if h_n.c0 != ark_bn254::Fq6::ZERO { |
| 649 | ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, h_n.c1 / h_n.c0) |
| 650 | } else { |
| 651 | ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, ark_bn254::Fq6::ZERO) |
| 652 | }; |
| 653 | |
| 654 | let (hint_out, is_valid_input, h_scr, mul_hints) = utils_fq12_dd_mul(f_n.c1, g_n.c1); |
| 655 | assert!(is_valid_input == is_valid_in); |
| 656 | |
| 657 | let f_n_c1 = DataType::Fp6Data(f_n.c1); |
| 658 | let g_n_c1 = DataType::Fp6Data(g_n.c1); |
| 659 | let h_n_c1 = DataType::Fp6Data(h_n.c1); |
| 660 | |
| 661 | let mut preimage_hints = vec![]; |
| 662 | let f6_hints = f_n_c1.to_witness(ElementType::Fp6); |
| 663 | let g6_hints = g_n_c1.to_witness(ElementType::Fp6); |
| 664 | let h6_hints = h_n_c1.to_witness(ElementType::Fp6); |
| 665 | preimage_hints.extend_from_slice(&f6_hints); |
| 666 | preimage_hints.extend_from_slice(&g6_hints); |
| 667 | preimage_hints.extend_from_slice(&h6_hints); |
| 668 | |
| 669 | let tap_len = h_scr.len(); |
| 670 | let scr = script! { |
| 671 | for h in mul_hints { |
| 672 | {h.push()} |
| 673 | } |
| 674 | for h in &preimage_hints { |
| 675 | {h.push()} |
| 676 | } |
| 677 | // [hints, f, g, h] |
| 678 | {h_scr} |
| 679 | // [f, g, hint_out, 0/1] |
| 680 | if !is_valid_in { |
| 681 | OP_NOT |
| 682 | } |
| 683 | OP_VERIFY |
| 684 | {Fq6::push(hint_out)} |
| 685 | {Fq6::equalverify()} |
| 686 | for h in g6_hints.iter().rev() { |
| 687 | {h.push()} |
| 688 | {Fq::equalverify(1, 0)} |
| 689 | } |
| 690 | for h in f6_hints.iter().rev() { |
| 691 | {h.push()} |
| 692 | {Fq::equalverify(1, 0)} |
| 693 | } |
| 694 | OP_TRUE |
| 695 | }; |
| 696 | let res = execute_script(scr); |
| 697 | if res.final_stack.len() > 1 { |
| 698 | for i in 0..res.final_stack.len() { |
| 699 | println!("{i:} {:?}", res.final_stack.get(i)); |
| 700 | } |
| 701 | } |
| 702 | assert!(res.success); |