Closed siv2r closed 3 months ago
I can think of the following solutions:
We can rename the “test type” column to “target api” which will contain the APIs that the test vectors are used for
adapt
and extract_secadaptor
return False instead of raiseValueError
extract_adaptor
return [isValid, Point]
type instead
raiseValueError
instead of returning Falsepresig_verify
, schnorr_verify
, and secadaptor_verify
in reference.py
I am leaning toward soln 2.
@jonasnick @ZhePang What do you guys suggest?
Side Note 2: The API return types are inconsistent.
Yeah, there are multiple places where types are wrong:
❯ mypy test-vector.py
reference.py:143: error: Incompatible types in assignment (expression has type "tuple[int, int]", variable has type "bytes") [assignment]
reference.py:144: error: Argument 2 to "point_add" has incompatible type "bytes"; expected "tuple[int, int] | None" [arg-type]
reference.py:145: error: Argument 1 to "has_even_y" has incompatible type "tuple[int, int] | None"; expected "tuple[int, int]" [arg-type]
reference.py:148: error: Argument 1 to "bytes_from_point" has incompatible type "tuple[int, int] | None"; expected "tuple[int, int]" [arg-type]
reference.py:149: error: Argument 1 to "parity_from_point" has incompatible type "tuple[int, int] | None"; expected "tuple[int, int]" [arg-type]
reference.py:149: error: Argument 1 to "bytes_from_point" has incompatible type "tuple[int, int] | None"; expected "tuple[int, int]" [arg-type]
reference.py:151: error: Argument 2 to "schnorr_pre_verify" has incompatible type "bytes"; expected "tuple[int, int]" [arg-type]
reference.py:175: error: Incompatible return value type (got "bool", expected "tuple[int, int] | None") [return-value]
reference.py:179: error: Incompatible return value type (got "bool", expected "tuple[int, int] | None") [return-value]
reference.py:184: error: Incompatible return value type (got "bool", expected "tuple[int, int] | None") [return-value]
reference.py:194: error: Incompatible return value type (got "bool", expected "tuple[int, int] | None") [return-value]
reference.py:295: error: Incompatible types in assignment (expression has type "tuple[int, int]", variable has type "bytes") [assignment]
reference.py:296: error: Argument 2 to "schnorr_pre_verify" has incompatible type "bytes"; expected "tuple[int, int]" [arg-type]
reference.py:368: error: Argument 1 to "compress_point" has incompatible type "tuple[int, int] | None"; expected "tuple[int, int]" [arg-type]
reference.py:403: error: Missing return statement [return]
reference.py:413: error: Argument 1 to "compress_point" has incompatible type "tuple[int, int] | None"; expected "tuple[int, int]" [arg-type]
reference.py:427: error: Argument 1 to "compress_point" has incompatible type "tuple[int, int] | None"; expected "tuple[int, int]" [arg-type]
test-vector.py:154: error: Argument 1 to "compress_point" has incompatible type "tuple[int, int] | None"; expected "tuple[int, int]" [arg-type]
Found 18 errors in 2 files (checked 1 source file)
I agree that extract_t
, adapt
and extract_adaptor
should not raise Errors except for the length of the inputs.
Side note: We should rename the functions and variables to be more understandable, similar what we've done in the C implementation.
We could also have separate CSV files for testing different API functions with sensible columns for the specific API tested.
We could also have separate CSV files for testing different API functions with sensible columns for the specific API tested.
I like this idea. This would simplify things.
How does four CSV files (one for each API) sound?
seckey | pubkey | message | aux_rand | adaptor | pre-signature | result | comment |
---|
The result column is AND of the following boolean values:
pubkey | message | pre-signature | adaptor | result | comment |
---|
The result column is: _adaptor == extractadaptor(pre-signature, msg, pubkey)
pre-signature | secadaptor | bip340 signature | result | comment |
---|
The result column is: _schnorrverify(adapt(pre-signature, secadaptor))
pre-signature | bip340 signature | secadaptor | result | comment |
---|
The result column is: _secadaptor == extractsecadaptor(pre-signature, bip340 signature)
How does four CSV files (one for each API) sound?
We can also combine them into two CSV files instead: [1] Presign & Extract Adaptor [2] Adapt & Extract Secadaptor, as their columns are similar.
Did this issue close automatically after #8 merged? If so, we need to reopen it.
Initially, I had planned to fix this issue in the #8 pull request, but I decided against it to keep the PR brief. I will create a separate pull request for this.
Yeah I think it automatically closed it. I'll reopen it.
The CSV file's test type and result columns are ambiguous, especially when we test the
adapt
andextract_secadaptor
APIs. For instance,TRUE
orFALSE
represent for test type Adapting & Extract Adaptor?adapt
, andextract_secadapt
APIs don’t output boolean valuessig64 == sig_actual
schnorr_verify
to verify the output of theadapt
API?t == adaptor
Side Note 1: All the BIP340 test vectors were verified with only the
schnorr_verify
function. Therefore, the result column was the output of this function and didn’t need a test-type column. In our case, we require three different verification functions:presig_verify
→ tests validity ofextract_adaptor
resultschnorr_verify
→ tests validity ofadapt
resultsecadaptor_verify
→ tests validity ofextract_secadaptor
resultSide Note 2: The API return types are inconsistent.
extract_adaptor
API (return typeOptional[Point]
) can return [1] Point, [2] None, or [3] False. However,extract_secadaptor
&adapt
will never return False. This inconsistency affects the value of the result column in the CSV table.