Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
doc: support multi-inputs for pairing
Browse files Browse the repository at this point in the history
  • Loading branch information
KimiWu123 committed Nov 1, 2023
1 parent 578fdf1 commit 1bf08a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
22 changes: 13 additions & 9 deletions specs/ecc-proof.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ EccCircuit supports three ECC operations which are addition, multiplication and

EccTable built inside zkevm-circuits is used to verify ECC operations. It has the following columns:
- `op_type`: Types of ecc operations, `Add`, `Mul` and `Pairing`
- `px`: x-coordinate of point 1
- `py`: y-coordinate of point 1
- `qx`: scalar number if `op_type` is `Mul` otherwise it's x-coordinate of point 2
- `qy`: zero if `op_type` is `Mul` otherwise it's y-coordinate of point 2
- `px`: x-coordinate of point 1 if `op_type` is `Mul` or `Add` otherwise it's zero
- `py`: y-coordinate of point 1 if `op_type` is `Mul` or `Add` otherwise it's zero
- `qx`: x-coordinate of point 2 if `op_type` is `Add`. Scalar number if `op_type` is `Mul` otherwise it's zero
- `qy`: y-coordinate of point 2 if `op_type` is `Add` otherwise it's zero
- `input_rlc`: rlc of input data if `op_type` is `Pairing` otherwise it's zero
- `outx`: x-coordinate of output
- `outy`: y-coordinate of output
- `is_valid`: Indicates whether the operation is valid or not.

`Pairing` allows multiple input points, and `p` and `q` are not enough to represent multiple points so we introduce `input_rlc` to represent all the input points. Therefore, `input_rlc` is a non-zero value only when `op_type` is `Pairing` otherwise it should be zero.

Constraints on the shape of the table is like:

| 0 op_type | 1 px | 2 py | 3 qx | 2 qy | 2 outx | 2 outy | 4 is_valid |
| --------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ---------- |
| $tag | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | bool |
| 0 op_type | 1 px | 2 py | 3 qx | 4 qy | 5 input_rlc | 6 outx | 7 outy | 8 is_valid |
| --------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ---------- |
| $tag | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $input_rlc | $value{Lo,Hi} | $value{Lo,Hi} | bool |

- tag: `Add`, `Mul` and `Pairing`

Expand All @@ -27,8 +30,9 @@ Constraints on the shape of the table is like:

This mainly includes the following type of constraints:
- Checking `op_type` is one of `Add`, `Mul` or `Pairing`.
- Checking p and q are valid curve points.
- Checking the correctness amon p, q and out. This is done by `ECCVerifyChip`.
- Checking p and q are valid curve points if `op_type` is `Add` or `Mul`, and `input_rlc` is zero.
- Checking `input_rlc` is valid if `op_type` is `Pairing`, and p and q are zero.
- Checking the correctness among p, q and out. This is done by `ECCVerifyChip`.


## Code
Expand Down
7 changes: 4 additions & 3 deletions specs/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,9 @@ NOTE:

Proved by the ecc_circuit. The circuit verifies the correctness of ECC operations.

| 0 op_type | 1 px | 2 py | 3 qx | 2 qy | 2 outx | 2 outy | 4 is_valid |
| --------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ---------- |
| $tag | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | bool |
| 0 op_type | 1 px | 2 py | 3 qx | 4 qy | 5 input_rlc | 6 outx | 7 outy | 8 is_valid |
| --------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ---------- |
| $tag | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $value{Lo,Hi} | $input_rlc | $value{Lo,Hi} | $value{Lo,Hi} | bool |

- tag: supports `Add`, `Mul` and `Pairing`
- input_rlc: only has value when `op_type` is `Pairing`

0 comments on commit 1bf08a6

Please sign in to comment.