openvm_ecc_guest/
group.rs

1use core::{
2    fmt::Debug,
3    ops::{Add, AddAssign, Neg, Sub, SubAssign},
4};
5
6pub trait Group:
7    Clone
8    + Debug
9    + Eq
10    + Sized
11    + Add<Output = Self>
12    + Sub<Output = Self>
13    + Neg<Output = Self>
14    + for<'a> Add<&'a Self, Output = Self>
15    + for<'a> Sub<&'a Self, Output = Self>
16    + AddAssign
17    + SubAssign
18    + for<'a> AddAssign<&'a Self>
19    + for<'a> SubAssign<&'a Self>
20{
21    type SelfRef<'a>: Add<&'a Self, Output = Self> + Sub<&'a Self, Output = Self>
22    where
23        Self: 'a;
24
25    const IDENTITY: Self;
26
27    fn is_identity(&self) -> bool {
28        self == &Self::IDENTITY
29    }
30
31    fn double(&self) -> Self;
32    fn double_assign(&mut self);
33}
34
35pub trait CyclicGroup: Group {
36    const GENERATOR: Self;
37    const NEG_GENERATOR: Self;
38}