let's play with a quick example on transforming R1CS to QAP.
The Rank one constraint system is a very flexible way to represent an arithmetic circuit and to most proving systems, R1CS is the data structure in which the compute is presented to to the proving system.
In this write-up, I will be exploring how to go from an arithmetic circuit (in polynomial form) to QAP.
Example;
x3āx+5=21
reducing this equation to a format that can be reduced to R1CS
a=xāx
b=aāx
outā5=bāx
this is what the witness would look like, recall the witness consists of the;
w=[1,x,a,b,out]
w=[1,2,4,8,21]
recall the R1CS format is as follows; Cw=Awā Bw
to represent this in this format;
C would be influenced by [a,b,outā5]A would be influenced by [x,a,b]B would be influenced by [x]
C=ā00ā5ā000ā100ā010ā001āā
A=ā000ā100ā010ā001ā000āā
B=ā000ā111ā000ā000ā000āā
The R1CS representation of this would be given as;
Now transforming this R1CS to its QAP representation.
In QAP we would be representing the R1CS structure using polynomials, but these polynomials completely implement the same logic done by the R1CS.
In the construction used, the number of polynomials & their degree would depend on the length of the solution vector & the number of gates. The solution vector contains 5 elements, so we can construct 5 polynomials. Each gate contributes 1 point to each polynomial. We have 3 gates here, we get 3 points per polynomial. 3 points allows us to define a polynomial of maximum degree 2. So we can construct 5 polynomials each with a maximum degree of 2. So we can transform our matrices collectively into 5 polynomials, each of degree 2.
But we are not done yet, there is just one more step,
We have to multiply C and w, C is of the dimension of 3X5 and w is of the dimension of 5X1 this would result in a matrix of dimension 3x1, take this array as the co-efficient of a polynomial, that Polynomial is the QAP representation of C.
It is truly epic seeing these huge matrices reduced to a single polynomial!