From 0fbd492381e4b161e8781095bd6def730544a6be Mon Sep 17 00:00:00 2001 From: Olga Kunyavskaya Date: Thu, 30 Nov 2023 14:18:18 +0200 Subject: [PATCH] separate error cases --- neps/nep-0488.md | 55 +++++++----------------------------------------- 1 file changed, 8 insertions(+), 47 deletions(-) diff --git a/neps/nep-0488.md b/neps/nep-0488.md index a14bac787..2fcc9c15c 100644 --- a/neps/nep-0488.md +++ b/neps/nep-0488.md @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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:*** @@ -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 @@ -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: @@ -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: