Skip to content

Commit 87ff5bb

Browse files
committed
python: fix sign_verify_vector.json bug
It misclassifed a "verify error" vector as "verify fail" vector. context: bitcoin/bips#2070 (comment)
1 parent d91eb8e commit 87ff5bb

4 files changed

Lines changed: 48 additions & 44 deletions

File tree

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
```
2-
BIP: 445
3-
Title: FROST Signing Protocol for BIP340 Signatures
4-
Authors: Sivaram Dhakshinamoorthy <siv2ram@gmail.com>
5-
Status: Draft
6-
Type: Specification
7-
Assigned: 2026-01-30
8-
License: CC0-1.0
9-
Discussion: 2024-07-31: https://groups.google.com/g/bitcoindev/c/PeMp2HQl-H4/m/AcJtK0aKAwAJ
10-
Requires: 340
2+
BIP: 445
3+
Title: FROST Signing Protocol for BIP340 Signatures
4+
Authors: Sivaram Dhakshinamoorthy <siv2ram@gmail.com>
5+
Status: Draft
6+
Type: Specification
7+
Assigned: 2026-01-30
8+
License: CC0-1.0
9+
Discussion: 2024-07-31: https://groups.google.com/g/bitcoindev/c/PeMp2HQl-H4/m/AcJtK0aKAwAJ
10+
Requires: 340
1111
```
1212

1313
## Abstract
@@ -534,6 +534,7 @@ Algorithm *PartialSigVerify(psig, pubnonce<sub>1..u</sub>, signers_ctx, tweak<su
534534
- The list of tweak modes *is_xonly_t<sub>1..v</sub>* : *v* booleans
535535
- The message *m*: a byte array[^max-msg-len]
536536
- The index *i* of the signer in the list of public nonces where *0 < i ≤ u*
537+
- ValidateSignersCtx(signers_ctx); fail if that fails
537538
- Let *(_, _, u, id<sub>1..u</sub>, pubshare<sub>1..u</sub>, _) = signers_ctx*
538539
- Let *aggnonce = NonceAgg(pubnonce<sub>1..u</sub>, id<sub>1..u</sub>)*; fail if that fails
539540
- Let *session_ctx = (signers_ctx, aggnonce, v, tweak<sub>1..v</sub>, is_xonly_t<sub>1..v</sub>, m)*

python/gen_vectors.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -736,18 +736,6 @@ def generate_sign_verify_vectors():
736736
}
737737
)
738738
# --- Verify Fail Test Cases 3 ---
739-
vectors["verify_fail_test_cases"].append(
740-
{
741-
"psig": bytes_to_hex(psig),
742-
"id_indices": id_indices,
743-
"pubshare_indices": [2] + pubshare_indices[1:],
744-
"pubnonce_indices": pubnonce_indices,
745-
"msg_index": msg_idx,
746-
"signer_index": signer_idx,
747-
"comment": "The signer's pubshare is not in the list of pubshares",
748-
}
749-
)
750-
# --- Verify Fail Test Cases 4 ---
751739
vectors["verify_fail_test_cases"].append(
752740
{
753741
"psig": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141",
@@ -790,6 +778,15 @@ def generate_sign_verify_vectors():
790778
"error": "value",
791779
"comment": "public nonces count is greater than ids and pubshares",
792780
},
781+
{
782+
"ids": [0, 1],
783+
"pubshares": [2, 1],
784+
"pubnonces": [0, 1],
785+
"msg": 0,
786+
"signer": 0,
787+
"error": "value",
788+
"comment": "The signer's pubshare is not in the list of pubshares",
789+
},
793790
]
794791
for case in verify_error_cases:
795792
curr_ids = [ids[i] for i in case["ids"]]

python/tests.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,14 @@ def test_sign_verify_vectors():
233233
signer_index = test_case["signer_index"]
234234

235235
signers_tmp = SignersContext(n, t, ids_tmp, pubshares_tmp, thresh_pk)
236-
assert not partial_sig_verify_internal(
236+
assert not partial_sig_verify(
237237
psig,
238-
ids_tmp[signer_index],
239-
pubnonces_tmp[signer_index],
240-
pubshares_tmp[signer_index],
241-
session_ctx,
238+
pubnonces_tmp,
239+
signers_tmp,
240+
[],
241+
[],
242+
msg,
243+
signer_index,
242244
)
243245

244246
for test_case in verify_error_test_cases:

python/vectors/sign_verify_vectors.json

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -398,24 +398,6 @@
398398
"signer_index": 1,
399399
"comment": "Wrong signer index"
400400
},
401-
{
402-
"psig": "79DEFC679CF419BA7C48AF8F9526B5D510AAA4115B04DECDDE10CE9E06105334",
403-
"id_indices": [
404-
0,
405-
1
406-
],
407-
"pubshare_indices": [
408-
2,
409-
1
410-
],
411-
"pubnonce_indices": [
412-
0,
413-
1
414-
],
415-
"msg_index": 0,
416-
"signer_index": 0,
417-
"comment": "The signer's pubshare is not in the list of pubshares"
418-
},
419401
{
420402
"psig": "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141",
421403
"id_indices": [
@@ -504,6 +486,28 @@
504486
"message": "The pubnonces and ids arrays must have the same length."
505487
},
506488
"comment": "public nonces count is greater than ids and pubshares"
489+
},
490+
{
491+
"psig": "79DEFC679CF419BA7C48AF8F9526B5D510AAA4115B04DECDDE10CE9E06105334",
492+
"id_indices": [
493+
0,
494+
1
495+
],
496+
"pubshare_indices": [
497+
2,
498+
1
499+
],
500+
"pubnonce_indices": [
501+
0,
502+
1
503+
],
504+
"msg_index": 0,
505+
"signer_index": 0,
506+
"error": {
507+
"type": "ValueError",
508+
"message": "The provided key material is incorrect."
509+
},
510+
"comment": "The signer's pubshare is not in the list of pubshares"
507511
}
508512
]
509513
}

0 commit comments

Comments
 (0)