()
| 558 | |
| 559 | #[test] |
| 560 | fn test_utils_fq12_dd_mul_valid_data() { |
| 561 | let mut prng = ChaCha20Rng::seed_from_u64(0); |
| 562 | let f = ark_bn254::Fq12::rand(&mut prng); |
| 563 | let f_n = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, f.c1 / f.c0); |
| 564 | |
| 565 | let g = ark_bn254::Fq12::rand(&mut prng); |
| 566 | let g_n = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, g.c1 / g.c0); |
| 567 | |
| 568 | let h = f * g; |
| 569 | let h_n = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, h.c1 / h.c0); |
| 570 | |
| 571 | let (hint_out, is_valid_input, h_scr, mul_hints) = utils_fq12_dd_mul(f_n.c1, g_n.c1); |
| 572 | assert_eq!(h_n.c1, hint_out); |
| 573 | assert!(is_valid_input); |
| 574 | |
| 575 | let f_n_c1 = DataType::Fp6Data(f_n.c1); |
| 576 | let g_n_c1 = DataType::Fp6Data(g_n.c1); |
| 577 | let h_n_c1 = DataType::Fp6Data(h_n.c1); |
| 578 | |
| 579 | let mut preimage_hints = vec![]; |
| 580 | let f6_hints = f_n_c1.to_witness(ElementType::Fp6); |
| 581 | let g6_hints = g_n_c1.to_witness(ElementType::Fp6); |
| 582 | let h6_hints = h_n_c1.to_witness(ElementType::Fp6); |
| 583 | preimage_hints.extend_from_slice(&f6_hints); |
| 584 | preimage_hints.extend_from_slice(&g6_hints); |
| 585 | preimage_hints.extend_from_slice(&h6_hints); |
| 586 | |
| 587 | let tap_len = h_scr.len(); |
| 588 | let scr = script! { |
| 589 | for h in mul_hints { |
| 590 | {h.push()} |
| 591 | } |
| 592 | for h in &preimage_hints { |
| 593 | {h.push()} |
| 594 | } |
| 595 | // [hints, f, g, h] |
| 596 | {h_scr} |
| 597 | // [f, g, h, 1] |
| 598 | OP_VERIFY |
| 599 | {Fq6::push(hint_out)} |
| 600 | {Fq6::equalverify()} |
| 601 | for h in g6_hints.iter().rev() { |
| 602 | {h.push()} |
| 603 | {Fq::equalverify(1, 0)} |
| 604 | } |
| 605 | for h in f6_hints.iter().rev() { |
| 606 | {h.push()} |
| 607 | {Fq::equalverify(1, 0)} |
| 608 | } |
| 609 | OP_TRUE |
| 610 | }; |
| 611 | let res = execute_script(scr); |
| 612 | if res.final_stack.len() > 1 { |
| 613 | for i in 0..res.final_stack.len() { |
| 614 | println!("{i:} {:?}", res.final_stack.get(i)); |
| 615 | } |
| 616 | } |
| 617 | assert!(res.success); |
nothing calls this directly
no test coverage detected