Skip to main content

cggmp24/
supported_curves.rs

1//! Curves supported by this crate
2//!
3//! This crate re-exports curves that are checked to work correctly with our CGGMP implementation.
4//! Generally, this crate can work with any curve as long as it satisfies constraints (check out
5//! [`SigningBuilder`](crate::signing::SigningBuilder) generic constraints), but it might have
6//! unexpected consequences: for instance, [default security level](crate::security_level::SecurityLevel128)
7//! might not be compatible with another curve, which might result into unexpected runtime error or
8//! reduced security of the protocol.
9
10#[cfg(feature = "curve-secp256k1")]
11pub use generic_ec::curves::Secp256k1;
12#[cfg(feature = "curve-secp256r1")]
13pub use generic_ec::curves::Secp256r1;
14#[cfg(feature = "curve-secp384r1")]
15pub use generic_ec::curves::Secp384r1;
16#[cfg(feature = "curve-stark")]
17pub use generic_ec::curves::Stark;
18
19pub use generic_ec::Curve;
20
21#[cfg(test)]
22#[allow(dead_code)]
23mod check_compatibility {
24    use generic_ec::{coords::AlwaysHasAffineX, Curve, NonZero, Point};
25
26    fn curve_is_compatible<E: Curve>()
27    where
28        NonZero<Point<E>>: AlwaysHasAffineX<E>,
29    {
30    }
31
32    fn supported_curves_are_compatible() {
33        #[cfg(feature = "curve-secp256k1")]
34        curve_is_compatible::<super::Secp256k1>();
35        #[cfg(feature = "curve-secp256r1")]
36        curve_is_compatible::<super::Secp256r1>();
37        #[cfg(feature = "curve-secp384r1")]
38        curve_is_compatible::<super::Secp384r1>();
39        #[cfg(feature = "curve-stark")]
40        curve_is_compatible::<super::Stark>();
41    }
42}