Skip to content

Commit

Permalink
fix functions description
Browse files Browse the repository at this point in the history
  • Loading branch information
olga24912 committed Dec 12, 2023
1 parent 5401f53 commit b279616
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions neps/nep-0488.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,29 @@ we must efficiently verify BLS signatures based on BLS12-381, as these are the s

In this NEP, we propose to add the following host functions:

- ***bls12381_g1_sum*** computes the sum of signed points from $G_1$ on an elliptic curve. This function is useful for aggregating public keys in the BLS signature scheme. It can be employed for simple addition in $G_1$. It is kept separate from the `multiexp` function due to gas cost considerations.
- ***bls12381_g2_sum*** computes the sum of signed points from $G_2$ on an elliptic curve. This function is useful for aggregating signatures in the BLS signature scheme.
- ***bls12381_g1_multiexp*** calculates $\sum g_i s_i$ for points $g_i \in G_1$ and scalars $s_i$. This operation can be used to multiply a group element by a scalar.
- ***bls12381_g2_multiexp*** calculates $\sum g_i s_i$ for points $g_i \in G_2$ and scalars $s_i$.
- ***bls12381_p1_sum*** computes the sum of signed points from $E(F_p)$ elliptic curve. This function is useful for aggregating public keys in the BLS signature scheme. It can be employed for simple addition in $E(F_p)$. It is kept separate from the `multiexp` function due to gas cost considerations.
- ***bls12381_p2_sum*** computes the sum of signed points from $E'(F_{p^2})$ elliptic curve. This function is useful for aggregating signatures in the BLS signature scheme.
- ***bls12381_p1_multiexp*** calculates $\sum g_i s_i$ for points $g_i \in E(F_p)$ and scalars $s_i$. This operation can be used to multiply a group element by a scalar.
- ***bls12381_p2_multiexp*** calculates $\sum g_i s_i$ for points $g_i \in E'(F_{p^2})$ and scalars $s_i$.
- ***bls12381_map_fp_to_g1 —*** maps base field elements into $G_1$ points. It does not perform the mapping of byte strings into field elements.
- ***bls12381_map_fp2_to_g2 —*** maps extension field elements into $G_2$ points. This function does not perform the mapping of byte strings into extension field elements, which would be needed to efficiently map a message into a group element. We are not implementing the `hash_to_field`[^60] function because the latter can be executed within a contract and various hashing algorithms can be used within this function.
- ***bls12381_decompress_g1*** decompresses points from $G_1$ provided in a compressed form. Certain protocols offer points on the curve in a compressed form (e.g., the light client updates in Ethereum 2.0), and decompression is a time-consuming operation. All the other functions in this NEP only accept decompressed points for simplicity and optimized gas consumption.
- ***bls12381_decompress_g2*** decompresses points from $G_2$ provided in a compressed form.
- ***bls12381_p1_decompress*** decompresses points from $E(F_p)$ provided in a compressed form. Certain protocols offer points on the curve in a compressed form (e.g., the light client updates in Ethereum 2.0), and decompression is a time-consuming operation. All the other functions in this NEP only accept decompressed points for simplicity and optimized gas consumption.
- ***bls12381_p2_decompress*** decompresses points from $E'(F_{p^2})$ provided in a compressed form.
- ***bls12381_pairing_check —*** verifies that $\prod e(p_i, q_i) = 1$, where $e$ is a pairing operation and $p_i \in G_1 \land q_i \in G_2$. This function is used to verify BLS signatures or zkSNARKs.

Functions required for verifying BLS signatures[^59]:

- bls12381_g1_sum
- bls12381_g2_sum
- bls12381_p1_sum
- bls12381_p2_sum
- bls12381_map_fp2_to_g2
- bls12381_decompress_g1
- bls12381_decompress_g2
- bls12381_p1_decompress
- bls12381_p2_decompress
- bls12381_pairing_check

Functions required for verifying zkSNARKs:

- bls12381_g1_sum
- bls12381_g1_multiexp
- bls12381_p1_sum
- bls12381_p1_multiexp
- bls12381_pairing_check

Both zkSNARKs and BLS signatures can be implemented alternatively by swapping $G_1$ and $G_2$.
Expand Down Expand Up @@ -495,7 +495,7 @@ The encoding rules for curve points and field elements align with the standards

### Host functions

#### bls12381_g1_sum
#### bls12381_p1_sum

***Description:***

Expand Down Expand Up @@ -585,13 +585,13 @@ Edge cases:
***Annotation:***

```rust
pub fn bls12381_g1_sum(&mut self,
pub fn bls12381_p1_sum(&mut self,
value_len: u64,
value_ptr: u64,
register_id: u64) -> Result<u64>;
```

#### bls12381_g2_sum
#### bls12381_p2_sum

***Description:***

Expand Down Expand Up @@ -620,18 +620,18 @@ The ERROR_CODE is returned.

***Test cases:***

The test cases are identical to those of `bls12381_g1_sum`, with the only alteration being the substitution of points from $G_1$ and $E(F_p)$ with points from $G_2$ and $E'(F_{p^2})$.
The test cases are identical to those of `bls12381_p1_sum`, with the only alteration being the substitution of points from $G_1$ and $E(F_p)$ with points from $G_2$ and $E'(F_{p^2})$.

***Annotation:***

```rust
pub fn bls12381_g2_sum(&mut self,
pub fn bls12381_p2_sum(&mut self,
value_len: u64,
value_ptr: u64,
register_id: u64) -> Result<u64>;
```

#### ***bls12381_g1_multiexp***
#### ***bls12381_p1_multiexp***

***Description:***

Expand Down Expand Up @@ -686,7 +686,7 @@ Edge cases:

<ins>Tests for sum of two points</ins>

These are identical test cases to those in the `bls12381_g1_sum` section.
These are identical test cases to those in the `bls12381_p1_sum` section.

- Generate random points P and Q, then compare the results with the sum function.

Expand All @@ -706,20 +706,20 @@ These are identical test cases to those in the `bls12381_g1_sum` section.

<ins>Tests for error cases</ins>

The same test cases as those in the `bls12381_g1_sum` section will be applied.
The same test cases as those in the `bls12381_p1_sum` section will be applied.

***Annotation:***

```rust
pub fn bls12381_g1_multiexp(
pub fn bls12381_p1_multiexp(
&mut self,
value_len: u64,
value_ptr: u64,
register_id: u64,
) -> Result<u64>;
```

#### ***bls12381_g2_multiexp***
#### ***bls12381_p2_multiexp***

***Description:***

Expand Down Expand Up @@ -755,12 +755,12 @@ The ERROR_CODE is returned.

***Test cases:***

The test cases are identical to those for `bls12381_g1_multiexp`, except that the points from $G_1$ and $E(F_p)$ are replaced with points from $G_2$ and $E'(F_{p^2})$
The test cases are identical to those for `bls12381_p1_multiexp`, except that the points from $G_1$ and $E(F_p)$ are replaced with points from $G_2$ and $E'(F_{p^2})$

***Annotation:***

```rust
pub fn bls12381_g2_multiexp(
pub fn bls12381_p2_multiexp(
&mut self,
value_len: u64,
value_ptr: u64,
Expand Down Expand Up @@ -978,7 +978,7 @@ pub fn bls12381_pairing_check(&mut self,
register_id: u64) -> Result<u64>;
```

#### bls12381_decompress_g1
#### bls12381_p1_decompress

***Description:*** The function decompresses compressed points from $E(F_p)$. It takes an arbitrary number of points $p_i \in E(F_p)$ in compressed format as input and outputs the same number of points from $E(F_p)$ in decompressed format. Further details about the decompressed and compressed formats are available in the Curve Points Encoding section.

Expand Down Expand Up @@ -1024,13 +1024,13 @@ The ERROR_CODE is returned.
***Annotation:***

```rust
pub fn bls12381_decompress_g1(&mut self,
pub fn bls12381_p1_decompress(&mut self,
value_len: u64,
value_ptr: u64,
register_id: u64) -> Result<u64>;
```

#### bls12381_decompress_g2
#### bls12381_p2_decompress

***Description:*** The function decompresses compressed points from $E'(F_{p^2})$. It takes an arbitrary number of points $p_i \in E'(F_{p^2})$ in compressed format as input and outputs the same number of points from $E'(F_{p^2})$ in decompressed format. For more information about the decompressed and compressed formats, refer to the Curve Points Encoding section.

Expand All @@ -1048,12 +1048,12 @@ The ERROR_CODE is returned.

***Test cases:***

The same test cases as `bls12381_decompress_g1`, but with points from $G_2$, and the input length should be divisible by 96.
The same test cases as `bls12381_p1_decompress`, but with points from $G_2$, and the input length should be divisible by 96.

***Annotation:***

```rust
pub fn bls12381_decompress_g2(&mut self,
pub fn bls12381_p2_decompress(&mut self,
value_len: u64,
value_ptr: u64,
register_id: u64) -> Result<u64>;
Expand Down

0 comments on commit b279616

Please sign in to comment.