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
39
40
41
42
43
44
45
46
47
48
49
50
51
// This trait resresents zkSNARKs trait

use core::ops::Mul;

use super::{
    curve::{Affine, Projective},
    field::PrimeField,
};

#[cfg(feature = "std")]
use super::{algebra::Field, comp::ParallelCmp};

/// This is fft field
/// This is used for fft and has roots of unity
#[cfg(feature = "std")]
pub trait FftField: PrimeField + ParallelCmp + From<u64> {
    // factor power of two
    const S: usize;
    // 2^s th root of unity
    const ROOT_OF_UNITY: Self;

    fn pow(self, val: u64) -> Self;
}

/// This is polynomial
/// This has fft functionality and represents polynomial ring
#[cfg(feature = "std")]
pub trait Polynomial: Field + ParallelCmp {
    // domain of polynomial
    type Domain: FftField;

    fn evaluate(self, at: Self::Domain) -> Self::Domain;
}

/// This is commitment
pub trait Commitment {
    // g1 group affine point
    type G1Affine: Affine + From<Self::G1Projective>;
    // g1 group projective point
    type G1Projective: Projective
        + From<Self::G1Affine>
        + Mul<Self::ScalarField, Output = Self::G1Projective>;
    // g2 group affine point
    type G2Affine: Affine + From<Self::G2Projective>;
    // g2 group projective point
    type G2Projective: Projective
        + From<Self::G2Affine>
        + Mul<Self::ScalarField, Output = Self::G2Projective>;
    // scalar field of point
    type ScalarField: FftField;
}