Skip to content

Commit

Permalink
fix ERROR_CODE encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
olga24912 committed Dec 12, 2023
1 parent b939207 commit 8453fed
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions neps/nep-0488.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,14 @@ will successfully complete its work but return an ERROR_CODE.
This enables users to handle error cases independently. It's important to note that host functions
might terminate with an error if it's straightforward to avoid it (e.g., incorrect input size).

The ERROR_CODE is encoded as a little-endian u64 and can hold the following values:
The ERROR_CODE is an u64 and can hold the following values:

- 0: No error, execution was successful.
- 0: No error, execution was successful. For `bls12381_pairing_check` function, the pairing result equals the multiplicative identity.
- 1: Execution finished with error due to:
- Incorrect encoding (e.g., incorrectly set compression/decompression bit, coordinate >= p, etc.).
- A point not on the curve (where applicable).
- A point not in the expected subgroup (where applicable).
- 2: Can be returned only in `bls12381_pairing_check`. No error, execution was successful, but the pairing result doesn't equal the multiplicative identity.

#### General comments

Expand Down Expand Up @@ -916,14 +917,12 @@ We don’t need to calculate the pairing function itself as the result would lie

The ERROR_CODE is returned.

- ERROR_CODE = 0: the input is correct
- <ins>Output:</ins> 1 byte with two possible values: 1 if the pairing result equals the multiplicative identity, and 0 otherwise.
- ERROR_CODE = 0: the input is correct, the pairing result equals the multiplicative identity.
- ERROR_CODE = 1:
- Points encoded incorrectly (refer to the Curve Points Encoded section).
- Point not on the curve.
- Point not in $G_1/G_2$.

For an empty input, the function returns ERROR_CODE = 0.
- ERROR_CODE = 2: the input is correct, the pairing result doesn't equal the multiplicative identity.

***Test cases:***

Expand Down

0 comments on commit 8453fed

Please sign in to comment.