MCPcopy Create free account
hub / github.com/BitVM/BitVM / test_tap_verify_fp12_is_unity

Function test_tap_verify_fp12_is_unity

bitvm/src/chunk/taps_ext_miller.rs:760–825  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

758
759 #[test]
760 fn test_tap_verify_fp12_is_unity() {
761 // runtime
762 let mut prng = ChaCha20Rng::seed_from_u64(0);
763 let f = ark_bn254::Fq12::rand(&mut prng);
764 let g = f.inverse().unwrap();
765 let f = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, f.c1 / f.c0);
766 let g = ark_bn254::Fq12::new(ark_bn254::Fq6::ONE, g.c1 / g.c0);
767
768 let q4 = ark_bn254::G2Affine::rand(&mut prng);
769 let t = frob_q_power(q4, 3).neg();
770 let t4 = ElemG2Eval {
771 t,
772 p2le: [ark_bn254::Fq2::ONE; 2],
773 one_plus_ab_j_sq: ark_bn254::Fq6::ONE,
774 a_plus_b: [ark_bn254::Fq2::ONE; 2],
775 };
776
777 let (is_valid, tap_scr, mut hint_script) = chunk_final_verify(f.c1, g.c1, t4.t, q4);
778 assert!(is_valid);
779
780 let f_c1 = DataType::Fp6Data(f.c1);
781 let t4 = DataType::G2EvalData(t4);
782
783 // [f, t]
784 hint_script.extend_from_slice(&f_c1.to_witness(ElementType::Fp6));
785 hint_script.extend_from_slice(&t4.to_witness(ElementType::G2EvalPoint));
786
787 let bitcom_scr = script! {
788 // thash
789 {t4.to_hash().as_hint_type().push()}
790 {Fq::toaltstack()}
791 // fhash
792 {f_c1.to_hash().as_hint_type().push()}
793 {Fq::toaltstack()}
794
795 {Fq::push(q4.y.c1)}
796 {Fq::toaltstack()}
797 {Fq::push(q4.y.c0)}
798 {Fq::toaltstack()}
799 {Fq::push(q4.x.c1)}
800 {Fq::toaltstack()}
801 {Fq::push(q4.x.c0)}
802 {Fq::toaltstack()}
803 };
804
805 let tap_len = tap_scr.len();
806 let script = script! {
807 for h in hint_script {
808 { h.push() }
809 }
810 {bitcom_scr}
811 {tap_scr}
812 };
813 let res = execute_script(script);
814 if res.final_stack.len() > 1 {
815 for i in 0..res.final_stack.len() {
816 println!("{i:} {:?}", res.final_stack.get(i));
817 }

Callers

nothing calls this directly

Calls 6

frob_q_powerFunction · 0.85
chunk_final_verifyFunction · 0.85
execute_scriptFunction · 0.85
to_witnessMethod · 0.80
lenMethod · 0.80
negMethod · 0.45

Tested by

no test coverage detected