1pub mod rotation;
2
3use crypto_primitives::SetConfig;
4use std::fmt::{Debug, Display, Formatter};
5use thiserror::Error;
6use zinc_utils::from_ref::FromRef;
7
8pub trait Ideal: FromRef<Self> + Clone + Debug + Display + Send + Sync {}
10
11pub trait IdealCheck<C: SetConfig> {
14 fn contains(&self, cfg: &C, value: &C::Element) -> Result<bool, IdealCheckError>;
16}
17
18#[derive(Clone, Copy, Debug)]
21pub struct ImpossibleIdeal;
22
23impl Ideal for ImpossibleIdeal {}
24
25impl Display for ImpossibleIdeal {
26 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
27 write!(f, "ImpossibleIdeal")
28 }
29}
30
31impl<C: SetConfig> IdealCheck<C> for ImpossibleIdeal {
32 #[inline(always)]
33 fn contains(&self, _cfg: &C, _value: &C::Element) -> Result<bool, IdealCheckError> {
34 Ok(false)
35 }
36}
37
38impl<I: Ideal> FromRef<I> for ImpossibleIdeal {
39 #[inline(always)]
40 fn from_ref(_ideal: &I) -> Self {
41 ImpossibleIdeal
42 }
43}
44
45pub type DegreeOneIdeal<F> = rotation::RotationIdeal<F, 1>;
48
49#[derive(Clone, Debug, Error)]
50#[error("Ideal check failed: {0}")]
51pub struct IdealCheckError(String);