binius_core/protocols/gkr_exp/
common.rs1use binius_field::Field;
4
5use crate::protocols::sumcheck::prove::eq_ind::{EqIndSumcheckProver, EqIndSumcheckProverBuilder};
6
7#[derive(Debug, Clone, Default)]
13pub struct LayerClaim<F: Field> {
14 pub eval_point: Vec<F>,
15 pub eval: F,
16}
17
18impl<F: Field> LayerClaim<F> {
19 pub fn isomorphic<FI>(self) -> LayerClaim<FI>
20 where
21 F: Into<FI>,
22 FI: Field,
23 {
24 let Self { eval_point, eval } = self;
25
26 LayerClaim {
27 eval_point: eval_point.into_iter().map(|x| x.into()).collect::<Vec<_>>(),
28 eval: eval.into(),
29 }
30 }
31}
32
33#[derive(Clone)]
35pub struct ExpClaim<F: Field> {
36 pub eval_point: Vec<F>,
37 pub eval: F,
38 pub exponent_bit_width: usize,
40 pub n_vars: usize,
41 pub static_base: Option<F>,
44}
45
46impl<F: Field> From<ExpClaim<F>> for LayerClaim<F> {
47 fn from(value: ExpClaim<F>) -> Self {
48 Self {
49 eval: value.eval,
50 eval_point: value.eval_point,
51 }
52 }
53}
54
55impl<F: Field> ExpClaim<F> {
56 pub fn isomorphic<FI: Field + From<F>>(self) -> ExpClaim<FI> {
57 let Self {
58 eval_point,
59 eval,
60 exponent_bit_width,
61 n_vars,
62 static_base,
63 } = self;
64
65 ExpClaim {
66 eval_point: eval_point.into_iter().map(|x| x.into()).collect::<Vec<_>>(),
67 eval: eval.into(),
68 exponent_bit_width,
69 n_vars,
70 static_base: static_base.map(|base| base.into()),
71 }
72 }
73}
74
75pub struct BaseExpReductionOutput<F: Field> {
76 pub layers_claims: Vec<Vec<LayerClaim<F>>>,
84}
85
86impl<F: Field> BaseExpReductionOutput<F> {
87 pub fn isomorphic<FI>(self) -> BaseExpReductionOutput<FI>
88 where
89 F: Into<FI>,
90 FI: Field,
91 {
92 let Self { layers_claims } = self;
93
94 BaseExpReductionOutput {
95 layers_claims: layers_claims
96 .into_iter()
97 .map(|claims| {
98 claims
99 .into_iter()
100 .map(|claim| claim.isomorphic())
101 .collect::<Vec<_>>()
102 })
103 .collect::<Vec<_>>(),
104 }
105 }
106}
107
108pub type GKRExpProverBuilder<'a, P, Backend> = EqIndSumcheckProverBuilder<'a, P, Backend>;
109
110pub type GKRExpProver<'a, FDomain, P, Composition, M, Backend> =
111 EqIndSumcheckProver<'a, FDomain, P, Composition, M, Backend>;