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
52
53
54
55
56
57
58
59
// This trait resresents zkSNARKs trait

use core::ops::Mul;

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

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

/// This is pairing field
/// This is used for pairing
pub trait PairingField: PrimeField + ParityCmp {}

/// 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 one() -> Self;
}

/// This is polynomial
/// This has fft functionality and represents polynomial ring
#[cfg(feature = "std")]
pub trait Polynomial: Ring + 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;

    // g2 group projective point
    type G2Projective: Projective;

    // scalar field of point
    type ScalarField: PrimeField;
}