openvm_ecc_guest/
group.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use core::{
    fmt::Debug,
    ops::{Add, AddAssign, Neg, Sub, SubAssign},
};

pub trait Group:
    Clone
    + Debug
    + Eq
    + Sized
    + Add<Output = Self>
    + Sub<Output = Self>
    + Neg<Output = Self>
    + for<'a> Add<&'a Self, Output = Self>
    + for<'a> Sub<&'a Self, Output = Self>
    + AddAssign
    + SubAssign
    + for<'a> AddAssign<&'a Self>
    + for<'a> SubAssign<&'a Self>
{
    type SelfRef<'a>: Add<&'a Self, Output = Self> + Sub<&'a Self, Output = Self>
    where
        Self: 'a;

    const IDENTITY: Self;

    fn is_identity(&self) -> bool {
        self == &Self::IDENTITY
    }

    fn double(&self) -> Self;
    fn double_assign(&mut self);
}

pub trait CyclicGroup: Group {
    const GENERATOR: Self;
    const NEG_GENERATOR: Self;
}