Skip to content

Commit

Permalink
separate error cases
Browse files Browse the repository at this point in the history
  • Loading branch information
olga24912 committed Nov 30, 2023
1 parent 9aa6123 commit 0fbd492
Showing 1 changed file with 8 additions and 47 deletions.
55 changes: 8 additions & 47 deletions neps/nep-0488.md
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,6 @@ This section focuses on validating the summation functionality with an arbitrary
- Sum with the maximum number of elements
- A single point

***Error cases (execution is terminated):***

- The input length is not divisible by 97.
- The input is beyond memory bounds.

***Annotation:***

```rust
Expand Down Expand Up @@ -627,11 +622,6 @@ The ERROR_CODE is returned.

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})$.

***Error cases (execution is terminated):***

- The input length is not divisible by 193.
- The input is beyond memory bounds.

***Annotation:***

```rust
Expand Down Expand Up @@ -718,11 +708,6 @@ These are identical test cases to those in the `bls12381_g1_sum` section.

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

***Error cases (execution is terminated):***

- The input length is not divisible by 128.
- The input is beyond memory bounds.

***Annotation:***

```rust
Expand Down Expand Up @@ -772,11 +757,6 @@ The ERROR_CODE is returned.

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})$

***Error cases (execution is terminated):***

- The input length is not divisible by 224.
- The input is beyond memory bounds.

***Annotation:***

```rust
Expand Down Expand Up @@ -837,11 +817,6 @@ Edge cases:
- $a = p$
- Random number $\ge p$

***Error cases (execution is terminated):***

- The input length is not divisible by 48.
- The input is beyond memory bounds.

***Annotation:***

```rust
Expand Down Expand Up @@ -899,11 +874,6 @@ Edge cases:
- (random number $\ge p$, 0)
- (0, random number $\ge p$)

***Error cases (execution is terminated):***

- The input length is not divisible by 96.
- The input is beyond memory bounds.

***Annotation:***

```rust
Expand Down Expand Up @@ -997,11 +967,6 @@ For an empty input, the function returns ERROR_CODE = 0.
- Incorrect decompression bit.
- Coordinates greater than or equal to 'p'.

***Error cases (execution is terminated):***

- The input length is not divisible by 288.
- The input is beyond memory bounds.

***Annotation:***

```rust
Expand Down Expand Up @@ -1054,11 +1019,6 @@ The ERROR_CODE is returned.
- Incorrectly encoded infinity point.
- Point with a coordinate larger than 'p'.

***Error cases (execution is terminated):***

- The input length is not divisible by 48.
- The input is beyond memory bounds.

***Annotation:***

```rust
Expand All @@ -1072,7 +1032,7 @@ pub fn bls12381_decompress_g1(&mut self,

***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.

***Input:*** A sequence of points $p_i \in E'(F_{p^2})$, with each point encoded in compressed form. The expected input size is 96*k bytes, interpreted as the byte concatenation of k slices. Each slice represents the compressed point from $E'(F_{p^2})$. Additional details are available in the Curve Points Encoding section.
***Input:*** A sequence of points $p_i \in E'(F_{p^2})$, with each point encoded in compressed form. The expected input size is `96*k` bytes, interpreted as the byte concatenation of k slices. Each slice represents the compressed point from $E'(F_{p^2})$. Additional details are available in the Curve Points Encoding section.

***Output:***

Expand All @@ -1088,11 +1048,6 @@ The ERROR_CODE is returned.

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

***Error cases (execution is terminated):***

- The input length is not divisible by 96.
- The input is beyond memory bounds.

***Annotation:***

```rust
Expand All @@ -1115,7 +1070,6 @@ If the `ERROR_CODE` equals 0, the output data will be written to
the register with the `register_id` identifier.
Otherwise, nothing will be written to the register.


***Gas Estimation:***

The algorithms described above exhibit linear complexity concerning the number of elements. Gas estimation can be calculated using the following formula:
Expand All @@ -1129,6 +1083,13 @@ Here, A and B denote empirically calculated constants unique to each algorithm.

For gas estimation, the benchmark vectors outlined in EIP-2537[^46] can be used where applicable.

***Error cases (execution is terminated):***

For all functions, execution will terminate in the following cases:

- The input length is not divisible by `item_size`.
- The input is beyond memory bounds.

## Reference Implementation

Primarily, concerning integration with nearcore, our interest lies in Rust language libraries. The current implementations of BLS12-381 in Rust are:
Expand Down

0 comments on commit 0fbd492

Please sign in to comment.