ark_ec/models/mod.rs
1use ark_ff::{Field, PrimeField, Zero};
2
3pub mod bls12;
4pub mod bn;
5pub mod bw6;
6pub mod mnt4;
7pub mod mnt6;
8
9pub mod double_odd;
10pub mod short_weierstrass;
11pub mod twisted_edwards;
12
13/// Elliptic curves can be represented via different "models" with varying
14/// efficiency properties.
15///
16/// `CurveConfig` bundles together the types that are common
17/// to all models of the given curve, namely the `BaseField` over which the
18/// curve is defined, and the `ScalarField` defined by the appropriate
19/// prime-order subgroup of the curve.
20pub trait CurveConfig: Send + Sync + Sized + 'static {
21 /// Base field that the curve is defined over.
22 type BaseField: Field;
23 /// Finite prime field corresponding to an appropriate prime-order subgroup
24 /// of the curve group.
25 type ScalarField: PrimeField + Into<<Self::ScalarField as PrimeField>::BigInt>;
26
27 /// The cofactor of this curve, represented as a sequence of little-endian limbs.
28 const COFACTOR: &[u64];
29 const COFACTOR_INV: Self::ScalarField;
30
31 fn cofactor_is_one() -> bool {
32 Self::COFACTOR[0] == 1 && Self::COFACTOR.iter().skip(1).all(Zero::is_zero)
33 }
34}