Documentation Index
Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
Use this file to discover all available pages before exploring further.
Secure Evaluations
Similar to CircleEvaluation, SecureEvaluation is a point-value representation of a polynomial whose evaluations over the CircleDomain are from the SecureField (an alias for QM31). This is implemented as follows:
pub struct SecureEvaluation<B: ColumnOps<BaseField>, EvalOrder> {
pub domain: CircleDomain,
pub values: SecureColumnByCoords<B>,
_eval_order: PhantomData<EvalOrder>,
}
As discussed in the previous subsection, each SecureField element is represented by four base field elements and stored in four consecutive columns. Thus the evaluations are represented as SecureColumnByCoords, as shown above.
Similar to CircleEvaluation, we can interpolate a SecureCirclePoly with coefficients from the SecureField as shown below:
impl<B: PolyOps> SecureEvaluation<B, BitReversedOrder> {
/// Computes a minimal [`SecureCirclePoly`] that evaluates to the same values as this
/// evaluation, using precomputed twiddles.
pub fn interpolate_with_twiddles(self, twiddles: &TwiddleTree<B>) -> SecureCirclePoly<B> {
let domain = self.domain;
let cols = self.values.columns;
SecureCirclePoly(cols.map(|c| {
CircleEvaluation::<B, BaseField, BitReversedOrder>::new(domain, c)
.interpolate_with_twiddles(twiddles)
}))
}
}
Secure Circle Polynomials
Similar to CirclePoly, SecureCirclePoly is a coefficient representation of a polynomial whose coefficients are from the SecureField. As discussed in the earlier section, we can define a circle polynomial as follows:
p(x,y)=∑j=02n−1vj⋅yj0⋅xj1⋅π(x)j2⋅π2(x)j3⋯πn−2(x)jn−1
Here, vj are the coefficients from SecureField (i.e. QM31). We can represent the coefficient vj using four elements from the BaseField (i.e. M31) as follows:
vj=(aj+i⋅bj)+(cj+i⋅dj)⋅u
where aj,bj,cj,dj∈M31. Substituting the above representation in the equation of p(x,y) we get:
p(x,y)=∑j=02n−1(aj+i⋅bj+u⋅cj+i⋅u⋅dj)⋅yj0⋅xj1⋅π(x)j2⋅π2(x)j3⋯πn−2(x)jn−1
p(x,y)=∑j=02n−1aj⋅yj0⋅xj1⋅π(x)j2⋯πn−2(x)jn−1+i⋅∑j=02n−1bj⋅yj0⋅xj1⋅π(x)j2⋯πn−2(x)jn−1+
u⋅∑j=02n−1cj⋅yj0⋅xj1⋅π(x)j2⋯πn−2(x)jn−1+iu⋅∑j=02n−1dj⋅yj0⋅xj1⋅π(x)j2⋯πn−2(x)jn−1
Thus we can represent a SecureCirclePoly using four CirclePoly: pa(x,y),pb(x,y),pc(x,y) and pd(x,y) as follows:
p(x,y)=pa(x,y)+i⋅pb(x,y)+u⋅pc(x,y)+iu⋅pd(x,y)
where pa(x,y) is a CirclePoly with coefficients aj∈M31, similarly for pb(x,y),pc(x,y) and pd(x,y). This is implemented as follows:
pub struct SecureCirclePoly<B: ColumnOps<BaseField>>(pub [CirclePoly<B>; SECURE_EXTENSION_DEGREE]);
Here, SECURE_EXTENSION_DEGREE is the degree of extension of the SecureField, which is 4.
Similar to CirclePoly, we can evaluate the SecureCirclePoly at points on the given CircleDomain which outputs the SecureEvaluation.
pub fn evaluate_with_twiddles(
&self,
domain: CircleDomain,
twiddles: &TwiddleTree<B>,
) -> SecureEvaluation<B, BitReversedOrder> {
let polys = self.0.each_ref();
let columns = polys.map(|poly| poly.evaluate_with_twiddles(domain, twiddles).values);
SecureEvaluation::new(domain, SecureColumnByCoords { columns })
}
In the next section, we will see how the interpolate and evaluate functions convert between the two polynomial representations using Circle FFT. As you may have noticed, the twiddles are precomputed for efficiency, and we will explore this in the next section on Circle FFT.