ToolszkEVMSpecIndex

Public Values

Public Values refers to values of committed polynomials that are known to both the prover and the verifier, as part of the arithmetization process. Public Value

Public Values refers to values of committed polynomials that are known to both the prover and the verifier, as part of the arithmetization process.

Public Values refers to values of committed polynomials that are known to both the prover and the verifier, as part of the arithmetization process. For example, if the prover is claiming to know the output of a certain computation, then its arithmetization would lead to the inclusion of a public value to some of the polynomials representing such a computation.

In this section, we build a PIL program that arithmetizes a Fibonacci sequence, and illustrate how it makes use of public values.

Modular Fibonacci sequence

Suppose one wants to prove knowledge of the first two terms F1F_1 and F2F_2 of a Fibonacci sequence (Fn)nN(F_n)_{n \in N} whose 10241024-th term F1024F_{1024} is:

F1024=180312667050811804,F_{1024} = 180312667050811804,

modulo the prime p=264232+1p = 2^{64} - 2^{32} + 1.

The witness (that is, the input kept private by the prover) is F1=2F_1 = 2 and F2=1F_2 = 1.

The modular Fibonacci sequence can be arithmetized with 33 columns (i.e., 33 polynomials):

  • First, two committed polynomials a\texttt{a} and b\texttt{b} that keep track of the sequence elements. We naturally obtain the following constraints on a\texttt{a} and b\texttt{b},
a= bb= a+b\begin{aligned} \texttt{a}' =\ \texttt{b}\qquad\\ \texttt{b}' =\ \texttt{a} + \texttt{b} \end{aligned}
  • Second, the constant polynomial ISLAST\texttt{ISLAST}, which is defined as,
ISLAST(gi) =0,  for all  i[N1] andISLAST(gi) =1,  for i=N.\begin{aligned} &\texttt{ISLAST}(g^i)\ = 0,\ \text{ for all}\ \ i \in [\texttt{N}-1]\ \text{and}\\ &\texttt{ISLAST}(g^i)\ = 1,\ \text{ for}\ i = \texttt{N}. \end{aligned}

With the introduction of the ISLAST\texttt{ISLAST} polynomial, the above constraints can be rewritten as follows:

(1ISLAST)(ab)=0(1ISLAST)(bab)=0.\begin{aligned} (1-\texttt{ISLAST}) \cdot (a'-b) = 0\quad\quad \\ (1-\texttt{ISLAST}) \cdot (b'-a-b) = 0. \end{aligned}

This way, ISLAST\texttt{ISLAST} ensures that the above constraints are valid in all rows of the execution trace, including the last row. Note that this last row is precisely the point where it is checked whether the claimed 10241024-th term is correct or not.

Based on the above description, the PIL code for the Fibonacci sequence is as follows:

// Filename: "fib.pil"

namespace Fibonacci(2**10);
pol constant ISLAST;
pol commit a, b;

(1-ISLAST) * (a' - b) = 0;
(1-ISLAST) * (b' - a - b) = 0;
ISLAST * (a - 180312667050811804) = 0;

Notice that the 10241024-th Fibonacci term is hardcoded as 180312667050811804180312667050811804 in the above PIL code.

This means, every time one uses the same PIL with a different witness (F1F_1, F2F_2) or even a different Fibonacci term, the PIL code would need to be modified.

We solve this by introducing mutable public values which the Prover can use to change the witness (F1F_1, F2F_2) or the N\texttt{N}-th Fibonacci term without the need to alter the PIL code.

public result = a(%N-1);

The compiler distinguishes between public values identifier and other identifiers with the colon ":\mathtt{:}". So the syntax for public value result\mathtt{result} is ":result\mathtt{:result}".

The updated PIL file is as follows:

// Filename: "fib.pil"

include "config.pil";

namespace Fibonacci(%N);
pol constant ISLAST;
pol commit a, b;

public result = a(%N-1);

(1-ISLAST) * (a' - b) = 0;
(1-ISLAST) * (b' - a - b) = 0;
ISLAST * (a - :result) = 0;
Edit on GitHub

Last updated on