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