Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the first two test vectors of verify fail test #1591

Merged
merged 1 commit into from
May 14, 2024

Conversation

siv2r
Copy link
Contributor

@siv2r siv2r commented May 11, 2024

Two vectors of the sign_verify test use different partial signatures even though their signer set, message, and nonces are the same. These are those two vectors:

Vector 1 (in valid_test_ cases):

"key_indices": [0, 1, 2],
"nonce_indices": [0, 1, 2],
"aggnonce_index": 0,
"msg_index": 0,
"signer_index": 0,
"expected": "012ABBCB52B3016AC03AD82395A1A415C48B93DEF78718E62A7A90052FE224FB"

Vector 2 (in verify_fail_test_cases):

"sig": "68537CC5234E505BD14061F8DA9E90C220A181855FD8BDB7F127BB12403B4D3B",
"key_indices": [0, 1, 2],
"nonce_indices": [0, 1, 2],
"msg_index": 0,
"signer_index": 1,
"comment": "Wrong signer"

In Vector 2, if we change the signer_index to 0 (the correct index), partial_sig_verify will still fail. Therefore, it has the incorrect partial signature. As a result, creating another vector by negating this paritalsig is also incorrect.

This PR fixes Vector 2 and the one created by negating Vector 2’s partial signature.

cc @jonasnick @real-or-random

Copy link
Contributor

@jonasnick jonasnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK, thanks @siv2r

Can confirm that the comments of vector 1 and 2 of "verify_fail_test_cases" are incorrect and that the suggested vector fixes this. Check existing and suggested vector 1 with this script:

def parse_hex(x):
    return int.from_bytes(bytes.fromhex(x), byteorder="big")

wrong_s = parse_hex("68537CC5234E505BD14061F8DA9E90C220A181855FD8BDB7F127BB12403B4D3B")
assert((n - wrong_s) == parse_hex("97AC833ADCB1AFA42EBF9E0725616F3C9A0D5B614F6FE283CEAAA37A8FFAF406"))

corr_s = parse_hex("012ABBCB52B3016AC03AD82395A1A415C48B93DEF78718E62A7A90052FE224FB")
assert((n - corr_s) == parse_hex("FED54434AD4CFE953FC527DC6A5E5BE8F6234907B7C187559557CE87A0541C46"))

I doubt it's worth incrementing the patch version of the spec but it would be nice if we could somehow reflect this in the change log, for example by adding a line to the top like

* 1.0.0 (2024-05-11):
    * Fix minor issue in two test vectors.

@siv2r siv2r force-pushed the bip327-fix-verify-fail-vector branch from 0c6aff6 to 921536b Compare May 11, 2024 14:18
@siv2r
Copy link
Contributor Author

siv2r commented May 11, 2024

I updated the change log as suggested. Also, the verify_error_test used the same wrong sig, so I updated those too.

@jonatack jonatack added the Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified label May 11, 2024
@jonatack jonatack requested a review from jonasnick May 11, 2024 14:58
bip-0327.mediawiki Outdated Show resolved Hide resolved
bip-0327.mediawiki Outdated Show resolved Hide resolved
@siv2r siv2r force-pushed the bip327-fix-verify-fail-vector branch from 921536b to 83f831b Compare May 13, 2024 13:04
@siv2r
Copy link
Contributor Author

siv2r commented May 13, 2024

Addressed the change log comments

bip-0327.mediawiki Outdated Show resolved Hide resolved
Copy link
Contributor

@real-or-random real-or-random left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 83f831b -- mod the date change (Yeah, it's better to set it to the commit date, but two days more or less don't make that big of a difference in the end :D

It took me a while to understand what's going on, but it all makes sense now. Nice catch!

@jonatack jonatack added PR Author action required Needs updates, has unaddressed review comments, or is otherwise waiting for PR author and removed Pending acceptance This BIP modification requires sign-off by the champion of the BIP being modified labels May 13, 2024
- first two vectors of verify_fail_test
- first two vectors of verify_error_test
@siv2r siv2r force-pushed the bip327-fix-verify-fail-vector branch from 83f831b to 508e3a6 Compare May 14, 2024 02:11
Copy link
Contributor

@real-or-random real-or-random left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 508e3a6

@jonatack jonatack removed the PR Author action required Needs updates, has unaddressed review comments, or is otherwise waiting for PR author label May 14, 2024
@jonatack jonatack merged commit 96161ae into bitcoin:master May 14, 2024
3 checks passed
@jonasnick
Copy link
Contributor

Yeah, it's better to set it to the commit date, but two days more or less don't make that big of a difference in the end

I think the purpose of the date is to make it easier for people to look up the changes in the commit history. However, the date is wrong now anyway because github UI does not show the correct date of the commit 🤷.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants