Chapter Six: Groth16 Protocol
Exploring the Groth16 protocol
Last updated
Exploring the Groth16 protocol
Last updated
Rust Implementation:
prerequisite for this study are;
Bilinear pairings and elliptic curves
Quadratic arithmetic programs (QAPs)
Bilinear pairings and elliptic curves are fundamental to the Groth16 proving system and many other advanced cryptographic protocols. Elliptic curves provide a secure and efficient foundation, while bilinear pairings enable the construction of succinct, non-interactive proofs that are both powerful and practical for real-world applications.
Elliptic Curves
Elliptic Curves Overview: An elliptic curve is a set of points that satisfy a specific mathematical equation. Over a finite field , an elliptic curve is typically defined by an equation of the form: where and are coefficients in , and the curve is non-singular (i.e., it has no cusps or self-intersections), which requires the discriminant .
In the context of the Groth16 proving system, bilinear pairings are used to construct efficient proofs that are both small in size and quick to verify. The system relies on the properties of bilinear pairings to ensure that the proof verification can be performed using simple algebraic operations, making the process efficient even for complex statements.
Example Use in Groth16:
Setup Phase: During the setup phase, a trusted party generates public parameters that include elements in β, β, and β.
Proving Phase: The prover uses these parameters to create a proof that certain computations were performed correctly. This involves operations in β and .
Verification Phase: The verifier checks the proof by performing pairing operations and ensures that certain equations hold in β. The bilinear nature of the pairing allows these checks to be performed efficiently.
The Groth16
protocol in most cases, starts with a Circuit. A Circuit
in ZKP is a structured way to represent a computation. It is analogous to a digital logic circuit used in computer engineering.
Structure:
A circuit is composed of inputs, gates, and outputs.
Inputs: These are the values that the prover knows and wants to keep private (often called witnesses) along with the public inputs.
Gates: These perform basic operations (such as addition, multiplication, logical AND, OR) on the inputs.
Outputs: These are the results of the computations performed by the gates.
Types of Circuits:
Arithmetic Circuits: These circuits use arithmetic gates (addition, multiplication) over a finite field. They are often used in zk-SNARKs because they can efficiently represent the types of computations involved in many cryptographic applications.
Boolean Circuits: These circuits use logical gates (AND, OR, NOT) and are more common in classical computer science but can be transformed into arithmetic circuits for use in zk-SNARKs.
The next stage of the protocol is to convert this Circuit
to a format called R1CS
After obtaining this R1CS representation, it needs to be transformed into its QAP representation to go further in this proof system.
Trusted Setup
This next stage of the groth16 protocol is the trusted setup stage, in this stage, something called the Common reference string
or Public parameter
is obtained. This Groth16
proof system has two phases;
The Powers of Tau
Circuit Specific Common reference string generation
Powers of Tau
This completes the phase one process of the trusted setup.
Circuit Specific Common reference string generation This phase involves doing some operations that are circuit-specific.
Verification key;
We would have to break this down;
Reference;
https://www.rareskills.io/post/groth16
A rank-1 constraint system (R1CS) with n variables and m constraints and p public inputs has a witness vector . By convention, the first p elements of w are the public input and the first public input is fixed to 1. The m constraints in R1CS are a product equation between three inner products:
where vectors specify the constraint. The constraint vectors are usually very sparse, typically only nonzero for a single or few values. These constraint vectors can be aggregated in matrices so that the whole constraint system can be concisely written using an element-wise product.
During this process, we would be generating having in mind that the number of constraints in the Circuit is , we would compute the following;
Given circuit polynomials β, generate random values and define the polynomials β by:
We can not compute the directly since we don't know and , but we can still construct using linear combinations of the values from the previous step. This way, we compute the proving key:
Instead of providing β and we could also provide in the verifying key, but βelements tend to be big and weird so we avoid them.
The Phase 2 ceremony is critical for soundness. If is known the prover can construct any β of degree where otherwise it is constraint to the form β. The forced factorization into and is critical for soundness.
Linear combination if you are as smart as I am Phase two is very confusing, but before we can break this down, we need to look into linear combination; how we can construct information concerning from secret even though we have just the encrypted version of this secret ().
Keep your eyes on this
Having in mind that are the elements of the powers of tau.
To achieve this ,