-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
naive FRI #1
naive FRI #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
book | ||
book |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
## How does FRI work? | ||
FRI protocol relies on a fact that if a source polynomial $p_0$ can be recursively folded into a constant polynomial, then $p_0$ has an expected upper bound degree. By folding, we mean each round halves the degree of $p_0$. | ||
|
||
Simply put, it is a protocol for verifier to quickly check if a polynomial has a upper degree bound claimed by prover. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for a verifier ... by a prover |
||
|
||
This post will explain the intuition of the math behind how polynomial folding works through some simple calculation examples end to end. These examples will demonstrate a naive version of FRI protocol without the the uses of commitment, which will explained in another post. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: "the the" it'd be cool to incrementally build FRI here, so first fri is naive fri and doesn't use commitments, then get rid of g and h via the optimization, then add commitments, then add commitments that group some evaluations, then show how we can choose evaluations on each layer to reduce the number of queries, etc. |
||
|
||
## What is folding? | ||
|
||
The core of the protocol relies on a technique to recursively fold the original polynomial and derive a constant value at the end. Here is an example: | ||
|
||
$$ | ||
\begin{align*} | ||
p_0\text{ : } & 1 + 2x + 3x^2 & \\ | ||
p_1\text{ : } & 3 + 3y & \\ | ||
p_2\text{ : } & 6 & | ||
\end{align*} | ||
$$ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe use a list instead of |
||
|
||
|
||
$p_0$ is the source polynomial. After a round of folding, it results in $p_1$. Then, the final round results in a constant polynomial $p_2$. | ||
|
||
To see how this folding algorithm works, please refer to the [code](https://github.com/katat/fri/blob/ab5aad54b8fd1e37b881ed7558d6ad22b6911442/src/poly.rs#L77). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think an english/math explanation would be better :p There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think your explanation using the |
||
|
||
These folded polynomials have the following relationship with their source polynomials: | ||
|
||
$$p_i\left(x^2\right)=\frac{p_{i-1}\left(x\right)+p_{i-1}\left(-x\right)}{2}+\beta_i \frac{p_{i-1}\left(x\right)-p_{i-1}\left(-x\right)}{2 x}$$ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this equation sorts of fall from the sky. I think it'd be better to explain the recipe of the reduction:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. This is easier to explain on where the folded polynomial comes from. The "fall from sky" equation is a step further and indeed difficult for others to reason where it is from without explaining the recipe of the reduction. |
||
|
||
|
||
*For simplicity, the random number $\beta$ will be assumed as 1 in this post. We would touch the implication behind this random number in another post that explains the commitment.* | ||
|
||
$p_0$ is the original polynomial, and $p_2$ is a constant polynomial that can't be folded anymore. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I should be able to fold a constant polynomial without breaking the protocol (so FRI enforces an upper bound on the degree, but not a lower bound) |
||
|
||
These folded polynomials can be traced back to their source polynomials. Thus, the evaluations in a folded polynomial can be accumulated from the corresponding source polynomial. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure I understand this ^ |
||
|
||
These relationships can serve as a proof for verifier to the consistency among the evaluations. The consistency check implies if there is a $p_0$ exists that the prover claimed. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure I get this one either ^ |
||
|
||
With the same folding setup, the final polynomial will be always the same value. Verifier can check against the same final value against the reduced values from different evaluation points. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is a folding setup? you mean with the same polynomial and if the verifier sends the same randomness? I'm not sure I understand the paragraph here |
||
|
||
If the final polynomial can be derived after expected rounds of folding, it implies the $p_0$ has an expected upper bound degree. In other words, if the final $p_k$ can be derived after $k=log(d)$ rounds of folding from $p_0$ which is of degree $d$, then $p_0$ has upper bound degree $d$. | ||
|
||
More formally, there are two properties: | ||
- the number of rounds $k=log(d)$ to derive the final polynomial implies the expected upper bound degree $d$ | ||
- the same final value can be re-used to check consistency of the evaluation claims across layers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (that second point is still not clear to me) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the final layer is a constant polynomial, the verifier can expect the derived value from above layers to be always that same constant value, no matter which evaluation point is used. Take the folding example above, the derived value should equal to 6, which is the constant polynomial |
||
|
||
We will refer this folding example again with some actual evaluations to demonstrate the interesting relationship among them. | ||
|
||
## What is the problem? | ||
|
||
Using the notation from [what is proving](https://nmohnblatt.github.io/zk-jargon-decoder/intro_to_zk/what_is_proving.html), we define the following: | ||
|
||
$$ | ||
\mathcal{L}(\mathcal{R}_{\text{consistent-layers}}) | ||
$$ | ||
|
||
for instance, $\left(a_1, w_1\right) \in \mathcal{R}$, where $a_1$ can represent a FRI query and constant value from $p_2$, while $w_1$ represents the corresponding evaluations across layers. | ||
|
||
So the problem is to do the check to see if $a_1$ is in $\mathcal{L}$. In other words, the verifier checks if the prover can provide $w_1$ satisfying the query $a_1$. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ not sure how useful this notation is here, and also what is exactly the relation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I try to remark the problem that the FRI can help resolve in a compact way. I think the relation I was trying to emphasis |
||
|
||
## naive FRI | ||
|
||
Let's assume prover is honest guy in this naive version of FRI. The goal is for verifier to do fast low degree test using the proof from prover. | ||
|
||
### Hard honest work by prover | ||
|
||
Prover can use the folded polynomial to obtain the evaluations for each layers. These evaluations of layers can serve as a proof for the verifier to sample for their consistency across layers. | ||
|
||
Using the same polynomial example shown earlier, here are two simple calculation examples. | ||
|
||
For evaluation point at *1*: | ||
|
||
$$ | ||
\begin{align} | ||
\text{Layer 1:} & \\ | ||
x_0&=1 \\ | ||
p_0(x_0) &= 1 + 2x_0 + 3x_0^2 \\ | ||
p_0(1) &= 6 \\ | ||
p_0(-1) &= 2 \\\\ | ||
\text{Layer 2:} & \\ | ||
x_1&=x_0^2 \\ | ||
p_1(x_1) &= 3 + 3x_1 \\ | ||
p_1(1^2) &= 6 \\ | ||
p_1(-1^2) &= 0 \\\\ | ||
\text{Layer 3:} & \\ | ||
x_2&=x_1^2 \\ | ||
p_2(x_2) &= 6 \\ | ||
p_2((1^2)^2) &= 6 \\\\ | ||
\end{align} | ||
$$ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a think a list would render better here as well, doesn't render super well at least on github There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also I don't understand why you evaluate at 1 and -1 here? Aren't you just doing the reduction at this point? Why evaluate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is the prover need to evaluate the full domain and then commit the evaluations. Evaluating at 1 and -1 is an example of evaluating at point 1 and its symmetric point -1. Here I try to explain how these evaluations are done at the prover side. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, I guess it is part of committing to the polynomial at each layer (but you were not talking about commitments so far). Grouping v and -v under the same leaf is an optimization :o |
||
|
||
Similarly, for evaluation point at *2*: | ||
|
||
$$ | ||
\begin{align} | ||
\text{Layer 1:} & \\ | ||
x_0&=2 \\ | ||
p_0(x_0) &= 1 + 2x_0 + 3x_0^2 \\ | ||
p_0(2) &= 17 \\ | ||
p_0(-2) &= 9 \\\\ | ||
\text{Layer 2:} & \\ | ||
x_1&=x_0^2 \\ | ||
p_1(x_1) &= 3 + 3x_1 \\ | ||
p_1(2^2) &= 15 \\ | ||
p_1(-2^2) &= 9 \\\\ | ||
\text{Layer 3:} & \\ | ||
x_2&=x_1^2 \\ | ||
p_2(x_2) &= 6 \\ | ||
p_2((2^2)^2) &= 6 \\\\ | ||
\end{align} | ||
$$ | ||
|
||
|
||
|
||
In this manner, the prover can keep calculating for the whole domain. Then they would response the verifier query with the evaluations across layers for checking if an instance $a_i$ corresponding to the query is in the $\mathcal{L}\left(\mathcal{R}_{\text{consistent-layers }}\right)$ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
what do you mean by that? also it's the first time you talk about the verifier doing queries here. I think the typical explanations of FRI (ethstark, thaler, etc.) are usually clearer because they explain the commit phase and then the query phase, but here it's not clear what the protocol to follow is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to focus on describing how the evaluations can be done using the polynomials in different layers at the prover side, with the intention to avoid touching the commitment part for now. Then I plan to explain on why it is necessary to incorporate the challenge by verifier and commit to these evaluations in another post or later section. I guess this arrangement might help separate the concepts between the "basic core calculations" and the security component. Maybe I should explain this intention in this section to give a better clue on the role of this part in the protocol. |
||
|
||
### Consistency check | ||
|
||
Supposed the verifier samples the evaluation point *2* as demonstrated in the example above, these evaluations across layers for that point will be provided by the prover. | ||
|
||
Based on the relationship implied from the equation of folding polynomial, the verifier can check the consistency among the evaluations between layers. Let's review and put this equation into use: | ||
|
||
$$p_i\left(x^2\right)=\frac{p_{i-1}\left(x\right)+p_{i-1}\left(-x\right)}{2}+\beta_i \frac{p_{i-1}\left(x\right)-p_{i-1}\left(-x\right)}{2 x}$$ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here again the equation falls out of the sky. IMO a first naive FRI that doesn't do that, and use g and h would be easier. And then you can move to an optimized version of FRI that gets rid of g and h. For example: Notice that if the verifier chooses the points they want to query carefully, for example
which is possible as we have 2 linearly independent equations of 2 unknowns then the next layer can be obtained locally without any further queries by the verifier: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIUC, the Then, does it mean that, in the equation Another question is, in this method, in order for the verifier to check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the ethstark paper says the prover will send the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah at each layer you query both the evaluation at v and -v, BUT as an optimization the prover commits to both these optimization under the same leaf in the merkle tree |
||
|
||
|
||
This equation is useful for the verifier to check the consistency of the evaluations across layers. That is, $p_i$ can be evaluated using two symmetric evaluations from its source polynomial $p_{i-1}$ by connecting the source domain $x$ and folded domain $x^2$. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is a source domain and a folded domain? These seems like elements, not domains :o |
||
|
||
Take the `query = 2` or $a_2$, which corresponds to the $x_0=2$ for example, the prover send the following evaluations as witness $w_2$: | ||
|
||
|
||
$$ | ||
\begin{align} | ||
\text{Layer 0:} & \quad p_0(2) = 17, \quad p_0(-2) = 9 \\ | ||
\text{Layer 1:} & \quad p_1(2^2) = 15, \quad p_1(-(2^2)) = -9 \\ | ||
\text{Layer 2:} & \quad p_2((2^2)^2) = 6 | ||
\end{align} | ||
$$ | ||
|
||
Then the verifier recursively plug in these evaluations to the equation $p_i$: | ||
|
||
$$ | ||
\begin{align} | ||
\text{Check layer 2: } & \\ | ||
p_1(2^2) &= \frac{p_0(2) + p_0(-2)}{2} + \frac{p_0(2) - p_0(-2)}{2 \times 2} \\ | ||
& \\ | ||
&= \frac{17 + 9}{2} + \frac{17 - 9}{4} = 13 + 2 = 15 \\\\ | ||
\text{Check layer 3(final):} & \\ | ||
p_2((2^2)^2) &= \frac{p_1(2^2) + p_1(-2^2)}{2} + \frac{p_1(2^2) - p_1(-2^2)}{2 \times 2^2} \\ | ||
&= \frac{15 - 9}{2} + \frac{15 + 9}{2 \times 2^2} = 3 + 3 = 6 \end{align} | ||
$$ | ||
|
||
Indeed, the value provided by prover, $p_2((2^2)^2)$, is consistent with the recursively accumulated sum from symmetric points on previous layers. | ||
|
||
Therefore, $(a_2,w_2)$ is a pair in $\mathcal{R}_{\text {consistent-layers }}$. So through a single query, the prover tries to convince the verifier that $p_0$ has an expected degree bound. The verifier may want to sample more points to ensure the soundness, which we will try to answer what it means in FRI. | ||
|
||
For the next, we will see how to deal with a malicious prover by improving this naive version. | ||
|
||
*Keep in mind the verifier only knows the evaluations of these polynomials. Here the notation $p_i$, where the i represent the layer number, is just to relate to the evaluations at required points for checking consistency instead of doing the polynomial evaluation directly at verifier side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the word "source" here because it's not clear what a "source polynomial" really is.
It's also not clear what that upper bound on the degree is. Perhaps rephrased like this: