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

Function test_point_add_eval

bitvm/src/chunk/taps_point_ops.rs:1023–1115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1021
1022 #[test]
1023 fn test_point_add_eval() {
1024 let mut prng = ChaCha20Rng::seed_from_u64(0);
1025 let t = ark_bn254::G2Affine::rand(&mut prng);
1026 let q = ark_bn254::G2Affine::rand(&mut prng);
1027 let p = ark_bn254::G1Affine::rand(&mut prng);
1028
1029 let beta_22x = BigUint::from_str(
1030 "21888242871839275220042445260109153167277707414472061641714758635765020556616",
1031 )
1032 .unwrap();
1033 let beta_22y = BigUint::from_str("0").unwrap();
1034 let beta_22 = ark_bn254::Fq2::from_base_prime_field_elems([
1035 ark_bn254::Fq::from(beta_22x.clone()),
1036 ark_bn254::Fq::from(beta_22y.clone()),
1037 ])
1038 .unwrap();
1039 let qb = ark_bn254::G2Affine::new_unchecked(q.x * beta_22, q.y);
1040
1041 let zero = ark_bn254::G2Affine::identity();
1042
1043 for (t, q, p, frob, ate) in vec![
1044 // test vectors
1045 (zero, q, p, false, 1), // t = 0
1046 (t, zero, p, false, 1), // q = 0
1047 (t, zero, p, false, -1), // q = neg 0
1048 (zero, q, p, false, -1), // t = zero, q = neg
1049 (zero, q, p, true, 1), // t = 0
1050 (t, zero, p, true, 1), // q = 0
1051 (t, zero, p, true, -1), // q = neg 0
1052 (zero, q, p, true, -1), // t = zero, q = neg
1053 (t, q, p, false, 1), // add
1054 (t, q, p, false, -1), // neg
1055 (t, -t, p, false, 1), // t = -q
1056 (t, t, p, false, -1), // t = -q
1057 (t, t, p, false, 1), // t = q
1058 (t, -t, p, false, -1), // t = q
1059 (t, q, p, true, 1), // frob pow 1
1060 (t, q, p, true, -1), // frob pow 2
1061 (qb, q, p, true, -1), // frob pow 2
1062 (qb, -q, p, true, -1), // frob pow 2
1063 ] {
1064 let ((r, le), hinted_check_add, hints) = utils_point_add_eval(t, q, p, frob, ate);
1065
1066 let script = script! {
1067 for hint in hints {
1068 { hint.push() }
1069 }
1070
1071 { Fq2::push(t.x) }
1072 { Fq2::push(t.y) }
1073 { Fq2::push(q.x) }
1074 { Fq2::push(q.y) }
1075 { G1Affine::push(p) }
1076 { hinted_check_add.clone() }
1077 // [x']
1078
1079
1080 {Fq2::push(le.1)}

Callers

nothing calls this directly

Calls 4

utils_point_add_evalFunction · 0.85
execute_scriptFunction · 0.85
cloneMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected