# PLONK Proof System

The essence of zero-knowledge proofs is to provide an asymmetrically verifiable computation model. The computational logic, written in circuits, generates corresponding proofs during execution. Validators no longer need to execute the computational logic; they only need to verify the proof to trust that the computation result adheres to the agreed-upon logic.

In the specific design of our system, all computations result in changes to user accounts. Therefore, circuits need to be written for all transactions to ensure the legitimacy of user account changes. For the underlying proof system, PLONK has been chosen.

## Circuit Development

Circuits serve as the programming language for zero-knowledge proofs. PLONK algorithm uses two constraint relations to describe the entire circuit:

1. Addition and Multiplication Gate Constraints
2. Copy Constraints

Since addition and multiplication gates only describe the dependency of individual gates, copy constraints are necessary to depict a complete circuit. Copy constraints represent the "shared" connections between gates.The following transaction logics have been implemented in the circuit:

1. Deposit
2. Withdrawal
3. Forced Withdrawal
4. Pool Creation
5. Swap
6. RFQ (Request for Quotation)
7. Liquidity Addition
8. Liquidity Removal

## Circuit Principles and Constraint System

The constraint system in the circuit is a representation of constraints in circuit form. Each gate in the circuit represents a constraint. Assuming a circuit composed of n gates and m wires, where n <= m <= 2n. The constraint system consists of two parts: 1) input information for each gate, 2) coefficient vector for gate constraints.

<figure><img src="https://1294477177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FflKJ5L7VKztexLApM9K3%2Fuploads%2FxiihklVyno8XkmcffmkF%2Fimage.png?alt=media&#x26;token=2d53bfc4-f59c-4011-8b04-5ed0f4d98355" alt=""><figcaption><p><em>Figure : Constraint System Definition</em></p></figcaption></figure>

V is a vector composed of left input a, right input b, and output c. Note that a/b/c are just indices. qL, qR, qO, qM, qC are selector vectors for gates. L stands for left, R for right, O for output, M for multiplication, and C for constant.

<figure><img src="https://1294477177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FflKJ5L7VKztexLApM9K3%2Fuploads%2FQ59NXNh2uLCOdRrYE3QX%2Fimage.png?alt=media&#x26;token=c9b2b40e-9935-46e5-a564-5d8e92302ef9" alt=""><figcaption><p><em>Figure : Unified Definition of Satisfying Constraints</em></p></figcaption></figure>

The entire circuit satisfies the above equation. In other words, a constraint can represent both addition and multiplication. Three specific circuit representation methods are: 1) Arithmetic circuits (addition and multiplication) 2) Boolean value constraints 3) Public input constraints. Public input constraints can be understood as restricting a certain input to a fixed value, and that value is public.The protocol for the entire constraint system is shown in the following figure.

<figure><img src="https://1294477177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FflKJ5L7VKztexLApM9K3%2Fuploads%2FI3U2073cOngL4GsDHIyl%2Fimage.png?alt=media&#x26;token=eade459e-3c34-491e-bd65-9434a39228a4" alt=""><figcaption><p><em>Figure : Constraint System Protocol</em></p></figcaption></figure>

fL/fR/fO are the function representations of left/right/output. This constraint system enforces two logics: 1) copy constraint - ensuring wires shared between gates are correct. 2) Each gate's constraint holds.

## Plonk Protocol

The entire PlonK protocol is based on polynomial commitments and the Fiat-Shamir heuristic algorithm. Given 3n witnesses and the polynomial's gate coefficient vector and permutation function, it proves the constraints for each gate.

### Public Information

Public information in the PlonK protocol includes gate coefficients, permutation functions, and public inputs.

### Proof Process

The proof calculation process is divided into 5 rounds.

* First Round: Compute the polynomial representations of a(X), b(X), c(X), and calculate the elliptic points corresponding to the SRS. a/b/c corresponds to fL/fR/fO in the protocol.

<figure><img src="https://1294477177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FflKJ5L7VKztexLApM9K3%2Fuploads%2FpcpjYF4Cr75n8lUOXehE%2Fimage.png?alt=media&#x26;token=30db8c0c-5611-437c-8d21-917900c5b1d9" alt=""><figcaption><p><em>Figure : Proof Calculation - First Round</em></p></figcaption></figure>

* Second Round: Use the Fiat-Shamir heuristic algorithm to generate random numbers, compute the polynomial representation of z(X), and calculate the elliptic points corresponding to the SRS.

<figure><img src="https://1294477177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FflKJ5L7VKztexLApM9K3%2Fuploads%2FgbiVqVpPYjCuzAfWmRNV%2Fimage.png?alt=media&#x26;token=9915e971-25f5-4e11-b86b-b01f2256abea" alt=""><figcaption><p><em>Figure : Proof Calculation - Second Round</em></p></figcaption></figure>

* Third Round: Use the Fiat-Shamir heuristic algorithm to generate random numbers, compute the polynomial representation of t(X), and calculate the elliptic points corresponding to the SRS.

<figure><img src="https://1294477177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FflKJ5L7VKztexLApM9K3%2Fuploads%2FCaKvB70KJlGTnyYcl5BP%2Fimage.png?alt=media&#x26;token=eab6be8b-1207-49b6-be6f-946b6c6039e6" alt=""><figcaption><p><em>Figure : Proof Calculation - Third Round</em></p></figcaption></figure>

* Fourth Round: From the fourth round onwards, the calculation involves specific points corresponding to elliptic points. Use the Fiat-Shamir heuristic algorithm to generate random numbers. Calculate values for a/b/c/t/z and permutation functions.

<figure><img src="https://1294477177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FflKJ5L7VKztexLApM9K3%2Fuploads%2F6C3oltusjhcFZPyaLEzO%2Fimage.png?alt=media&#x26;token=272bdd84-9a3c-4265-9324-7d95f15e7bdb" alt=""><figcaption><p><em>Figure : Proof Calculation - Fourth Round</em></p></figcaption></figure>

* Fifth Round: Use the Fiat-Shamir heuristic algorithm to generate random numbers and compute proofs for multiple polynomial commitments.

<figure><img src="https://1294477177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FflKJ5L7VKztexLApM9K3%2Fuploads%2FlGcSkLrmPMsweIoQTyiI%2Fimage.png?alt=media&#x26;token=172785c3-1a97-4752-a327-1e49307606a0" alt=""><figcaption><p><em>Figure : Proof Calculation - Fifth Round</em></p></figcaption></figure>

### Verification Process

The verification process, apart from some simple data checks, revolves around verifying a multi-class polynomial commitment. The core calculation is F - E. F represents commitment values for multiple polynomials, and E represents challenge values for multiple polynomials. The multi-class polynomial commitment algorithm ensures that the challenge values are consistent with the commitment. The D in the F calculation is composed of r and z functions.

<figure><img src="https://1294477177-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FflKJ5L7VKztexLApM9K3%2Fuploads%2FVZZP2eWUxfAM7WBTqSVx%2Fimage.png?alt=media&#x26;token=96858085-98a3-4da9-89d8-194da784ff45" alt=""><figcaption><p><em>Figure : Verification Process</em></p></figcaption></figure>

## Proof Architecture Design

In the system's architecture design, a multi-prover architecture is employed. Multiple provers receive proof tasks from the server and generate proofs in parallel. This means the system supports horizontal scalability, allowing proof efficiency to be enhanced by adding computational resources.This detailed design ensures that the PlonK proof system is not only theoretically sound but also practically efficient in handling various transactions and maintaining the security of the overall system.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://openbitbtc.gitbook.io/docs/plonk-proof-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
