From 8453fed5d464661da199f54339a34765f4986a06 Mon Sep 17 00:00:00 2001 From: Olga Kunyavskaya Date: Tue, 12 Dec 2023 12:44:05 +0200 Subject: [PATCH] fix ERROR_CODE encoding --- neps/nep-0488.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/neps/nep-0488.md b/neps/nep-0488.md index 088e807e7..9d315af6e 100644 --- a/neps/nep-0488.md +++ b/neps/nep-0488.md @@ -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 @@ -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 - - Output: 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:***