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

Function test_tap_precompute_p_from_hash

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

Source from the content-addressed store, hash-verified

703
704 #[test]
705 fn test_tap_precompute_p_from_hash() {
706 // runtime
707 let mut prng = ChaCha20Rng::seed_from_u64(0);
708 let p1 = ark_bn254::G1Affine::rand(&mut prng);
709 let p2 = ark_bn254::G1Affine::new_unchecked(ark_bn254::Fq::ONE, ark_bn254::Fq::ZERO);
710 let p3 = ark_bn254::G1Affine::new_unchecked(ark_bn254::Fq::ZERO, ark_bn254::Fq::ZERO);
711 let p4 = ark_bn254::G1Affine::new_unchecked(p1.x, p1.x);
712 let dataset = vec![(p1, false), (p2, true), (p3, true), (p4, true)];
713
714 for (p, disprovable) in dataset {
715 let (hint_out, input_is_valid, tap_prex, hint_script) = chunk_precompute_p_from_hash(p);
716 assert_eq!(input_is_valid, !disprovable);
717 let hint_out = DataType::G1Data(hint_out);
718 let p = DataType::G1Data(p);
719
720 let bitcom_scr = script! {
721 {hint_out.to_hash().as_hint_type().push()}
722 {Fq::toaltstack()}
723 {p.to_hash().as_hint_type().push()}
724 {Fq::toaltstack()}
725 };
726 let preim_hints = p.to_witness(ElementType::G1);
727 let hash_scr = script! {
728 {hash_messages(vec![ElementType::G1, ElementType::G1])}
729 OP_TRUE
730 };
731
732 let tap_len = tap_prex.len();
733 let script = script! {
734 for h in hint_script {
735 { h.push() }
736 }
737 for h in preim_hints {
738 {h.push()}
739 }
740 {bitcom_scr}
741 {tap_prex}
742 {hash_scr}
743 };
744 let res = execute_script(script);
745 if res.final_stack.len() > 1 {
746 for i in 0..res.final_stack.len() {
747 println!("{i:} {:?}", res.final_stack.get(i));
748 }
749 }
750 assert_eq!(res.success, disprovable);
751 assert!(res.final_stack.len() == 1);
752 println!(
753 "chunk_precompute_p_from_hash disprovable({}) script {} stack {}",
754 disprovable, tap_len, res.stats.max_nb_stack_items
755 );
756 }
757 }
758
759 #[test]
760 fn test_tap_verify_fp12_is_unity() {

Callers

nothing calls this directly

Calls 4

execute_scriptFunction · 0.85
to_witnessMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected