barretenberg
Loading...
Searching...
No Matches
pow.hpp
1#pragma once
2
3namespace barretenberg {
4
93template <typename FF> struct PowUnivariate {
94 // ζ_{l}, initialized as ζ_{0} = ζ
95 // At round l, equals ζ^{ 2^l }
96 FF zeta_pow;
97 // ζ_{l+1}, initialized as ζ_{1} = ζ^2
98 // Always equal to zeta_pow^2
99 // At round l, equals ζ^{ 2^{l+1} }
100 FF zeta_pow_sqr;
101 // c_{l}, initialized as c_{0} = 1
102 // c_{l} = ∏_{0 ≤ k < l-1} ( (1-u_{k}) + u_{k}⋅ζ_{k} )
103 // At round d-1, equals pow(u_{0}, ..., u_{d-1}).
104 FF partial_evaluation_constant = FF(1);
105
106 // Initialize with the random zeta
107 explicit PowUnivariate(FF zeta_pow)
108 : zeta_pow(zeta_pow)
109 , zeta_pow_sqr(zeta_pow.sqr())
110 {}
111
112 // Evaluate the monomial ((1−X_{l}) + X_{l}⋅ζ_{l}) in the challenge point X_{l}=u_{l}.
113 FF univariate_eval(FF challenge) const { return (FF(1) + (challenge * (zeta_pow - FF(1)))); };
114
121 void partially_evaluate(FF challenge)
122 {
123 FF current_univariate_eval = univariate_eval(challenge);
124 zeta_pow = zeta_pow_sqr;
125 // TODO(luke): for native FF, this could be self_sqr()
126 zeta_pow_sqr = zeta_pow_sqr.sqr();
127
128 partial_evaluation_constant *= current_univariate_eval;
129 }
130};
131} // namespace barretenberg
constexpr_utils defines some helper methods that perform some stl-equivalent operations but in a cons...
Definition: constexpr_utils.hpp:16
Definition: pow.hpp:93
void partially_evaluate(FF challenge)
Parially evaluate the polynomial in the new challenge, by updating the constant c_{l} -> c_{l+1}....
Definition: pow.hpp:121
BBERG_INLINE constexpr field sqr() const noexcept
Definition: field_impl.hpp:61