arnaucube
arnaucube/ark-curves-cherry-pickedPublic Self-hosted repository
ark-curves-cherry-picked/bls12_377/src/constraints/curves.rs
bls12_377/src/constraints/curves.rsRaw
 1use ark_ec::{bls12::Bls12Config, CurveConfig};
 2use ark_r1cs_std::{
 3    fields::fp::FpVar,
 4    groups::{bls12, curves::twisted_edwards::AffineVar as TEAffineVar},
 5};
 6
 7use crate::Config;
 8
 9/// An element of G1 in the BLS12-377 bilinear group.
10pub type G1Var = bls12::G1Var<Config>;
11/// An element of G2 in the BLS12-377 bilinear group.
12pub type G2Var = bls12::G2Var<Config>;
13
14/// An element of G1 (in TE Affine form) in the BLS12-377 bilinear group.
15pub type G1TEAffineVar = TEAffineVar<
16    <Config as Bls12Config>::G1Config,
17    FpVar<<<Config as Bls12Config>::G1Config as CurveConfig>::BaseField>,
18>;
19
20/// Represents the cached precomputation that can be performed on a G1 element
21/// which enables speeding up pairing computation.
22pub type G1PreparedVar = bls12::G1PreparedVar<Config>;
23/// Represents the cached precomputation that can be performed on a G2 element
24/// which enables speeding up pairing computation.
25pub type G2PreparedVar = bls12::G2PreparedVar<Config>;
26
27#[test]
28fn test() {
29    use ark_ec::models::bls12::Bls12Config;
30    ark_curve_constraint_tests::curves::sw_test::<<Config as Bls12Config>::G1Config, G1Var>()
31        .unwrap();
32    ark_curve_constraint_tests::curves::te_test::<
33        <Config as Bls12Config>::G1Config,
34        G1TEAffineVar,
35    >()
36    .unwrap();
37    ark_curve_constraint_tests::curves::sw_test::<<Config as Bls12Config>::G2Config, G2Var>()
38        .unwrap();
39}