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

Function chunk_init_t4

bitvm/src/chunk/taps_point_ops.rs:848–937  ·  view source on GitHub ↗
(ts: [ark_ff::BigInt<4>; 4])

Source from the content-addressed store, hash-verified

846}
847
848pub(crate) fn chunk_init_t4(ts: [ark_ff::BigInt<4>; 4]) -> (ElemG2Eval, bool, Script, Vec<Hint>) {
849 let mut hints = vec![];
850
851 let mock_t = ark_bn254::G2Affine::new_unchecked(ark_bn254::Fq2::ONE, ark_bn254::Fq2::ONE);
852
853 let are_valid_fps = ts.iter().filter(|f| **f < ark_bn254::Fq::MODULUS).count() == ts.len();
854
855 let mut t4: ElemG2Eval = ElemG2Eval {
856 t: mock_t,
857 p2le: [ark_bn254::Fq2::ZERO; 2],
858 one_plus_ab_j_sq: ark_bn254::Fq6::ZERO,
859 a_plus_b: [ark_bn254::Fq2::ZERO; 2],
860 };
861 if are_valid_fps {
862 t4.t = ark_bn254::G2Affine::new_unchecked(
863 ark_bn254::Fq2::new(ts[0].into(), ts[1].into()),
864 ark_bn254::Fq2::new(ts[2].into(), ts[3].into()),
865 );
866 }
867
868 let (on_curve_scr, on_curve_hints) = G2Affine::hinted_is_on_curve(t4.t.x, t4.t.y);
869 if are_valid_fps {
870 hints.extend_from_slice(&on_curve_hints);
871 }
872 let is_valid_input = are_valid_fps && t4.t.is_on_curve();
873
874 let aux_hash_le = t4.hash_le(); // aux_hash_le doesn't include t4.t, is constant, so hash_le can be hardcoded
875
876 let ops_scr = script! {
877 // [hints] [f_hash_claim, y1, y0, x1, x0]
878 for _ in 0..4 {
879 {Fq::fromaltstack()}
880 }
881
882 {Fq2::copy(2)} {Fq2::copy(2)}
883 for _ in 0..4 {
884 { Fq::is_valid() }
885 OP_TOALTSTACK
886 }
887 {1}
888 for _ in 0..4 {
889 OP_FROMALTSTACK
890 OP_BOOLAND
891 }
892
893 OP_IF
894 // [hints, x0, x1, y0, y1] [f_hash_claim]
895 {Fq2::copy(2)} {Fq2::copy(2)}
896 // [hints, x0, x1, y0, y1, x0, x1, y0, y1] [f_hash_claim]
897 {on_curve_scr}
898 OP_IF
899 // [x0, x1, y0, y1] [f_hash_claim]
900 for le in extern_nibbles_to_limbs(aux_hash_le) {
901 {le}
902 }
903 // [x0, x1, y0, y1, aux_hash_le] [f_hash_claim]
904 {1}
905 OP_ELSE

Callers 3

test_tap_init_t4Function · 0.85
verify_pairing_scriptedFunction · 0.85
wrap_hint_init_t4Function · 0.85

Calls 3

lenMethod · 0.80
hash_leMethod · 0.80
intoMethod · 0.45

Tested by 1

test_tap_init_t4Function · 0.68