openvm_native_recursion/
commit.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use openvm_native_compiler::ir::{Array, Builder, Config, Ext, FromConstant, RVar};
use openvm_stark_backend::p3_commit::{LagrangeSelectors, PolynomialSpace};

use crate::{
    challenger::ChallengerVariable,
    fri::types::{FriConfigVariable, TwoAdicPcsRoundVariable},
};

pub trait PolynomialSpaceVariable<C: Config>: Sized + FromConstant<C> {
    type Constant: PolynomialSpace<Val = C::F>;

    fn next_point(&self, builder: &mut Builder<C>, point: Ext<C::F, C::EF>) -> Ext<C::F, C::EF>;

    fn selectors_at_point(
        &self,
        builder: &mut Builder<C>,
        point: Ext<C::F, C::EF>,
    ) -> LagrangeSelectors<Ext<C::F, C::EF>>;

    fn zp_at_point(&self, builder: &mut Builder<C>, point: Ext<C::F, C::EF>) -> Ext<C::F, C::EF>;

    fn split_domains(
        &self,
        builder: &mut Builder<C>,
        log_num_chunks: impl Into<RVar<C::N>>,
        num_chunks: impl Into<RVar<C::N>>,
    ) -> Array<C, Self>;

    fn split_domains_const(&self, _: &mut Builder<C>, log_num_chunks: usize) -> Vec<Self>;

    fn create_disjoint_domain(
        &self,
        builder: &mut Builder<C>,
        log_degree: RVar<C::N>,
        config: Option<FriConfigVariable<C>>,
    ) -> Self;
}

pub trait PcsVariable<C: Config> {
    type Domain: PolynomialSpaceVariable<C>;

    type Commitment;

    type Proof;

    fn natural_domain_for_log_degree(
        &self,
        builder: &mut Builder<C>,
        log_degree: RVar<C::N>,
    ) -> Self::Domain;

    fn verify(
        &self,
        builder: &mut Builder<C>,
        rounds: Array<C, TwoAdicPcsRoundVariable<C>>,
        proof: Self::Proof,
        challenger: &mut impl ChallengerVariable<C>,
    );
}