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::Bls12Parameters, CurveConfig};
 2use ark_r1cs_std::{
 3    fields::fp::FpVar,
 4    groups::{bls12, curves::twisted_edwards::AffineVar as TEAffineVar},
 5};
 6
 7use crate::Parameters;
 8
 9/// An element of G1 in the BLS12-377 bilinear group.
10pub type G1Var = bls12::G1Var<Parameters>;
11/// An element of G2 in the BLS12-377 bilinear group.
12pub type G2Var = bls12::G2Var<Parameters>;
13
14/// An element of G1 (in TE Affine form) in the BLS12-377 bilinear group.
15pub type G1TEAffineVar = TEAffineVar<
16    <Parameters as Bls12Parameters>::G1Parameters,
17    FpVar<<<Parameters as Bls12Parameters>::G1Parameters 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<Parameters>;
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<Parameters>;
26
27#[test]
28fn test() {
29    use ark_ec::models::bls12::Bls12Parameters;
30    ark_curve_constraint_tests::curves::sw_test::<
31        <Parameters as Bls12Parameters>::G1Parameters,
32        G1Var,
33    >()
34    .unwrap();
35    ark_curve_constraint_tests::curves::te_test::<
36        <Parameters as Bls12Parameters>::G1Parameters,
37        G1TEAffineVar,
38    >()
39    .unwrap();
40    ark_curve_constraint_tests::curves::sw_test::<
41        <Parameters as Bls12Parameters>::G2Parameters,
42        G2Var,
43    >()
44    .unwrap();
45}