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
#[macro_export]
macro_rules! group_operation {
    ($field:ident, $p:ident, $g:ident, $r:ident, $inv:ident) => {
        impl Group for $field {
            const GENERATOR: Self = $field($g);

            const IDENTITY: Self = $field($r);

            fn invert(self) -> Option<Self> {
                match invert(self.0, little_fermat($p), $r, $p, $inv) {
                    Some(x) => Some(Self(x)),
                    None => None,
                }
            }
        }

        impl PartialEq for $field {
            fn eq(&self, other: &Self) -> bool {
                self.0[0] == other.0[0]
                    && self.0[1] == other.0[1]
                    && self.0[2] == other.0[2]
                    && self.0[3] == other.0[3]
            }
        }

        impl Eq for $field {}
    };
}

pub use group_operation;