Skip to content

Commit f953b59

Browse files
committed
wip frost signing
1 parent 46898e6 commit f953b59

8 files changed

Lines changed: 3028 additions & 0 deletions

File tree

btcec/schnorr/threshold/frost/frost.go

Lines changed: 712 additions & 0 deletions
Large diffs are not rendered by default.

btcec/schnorr/threshold/frost/frost_test.go

Lines changed: 829 additions & 0 deletions
Large diffs are not rendered by default.

btcec/schnorr/threshold/frost/test_vectors/det_sign_vectors.json

Lines changed: 399 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"pubnonces": [
3+
"020151C80F435648DF67A22B749CD798CE54E0321D034B92B709B567D60A42E66603BA47FBC1834437B3212E89A84D8425E7BF12E0245D98262268EBDCB385D50641",
4+
"03FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A60248C264CDD57D3C24D79990B0F865674EB62A0F9018277A95011B41BFC193B833",
5+
"020151C80F435648DF67A22B749CD798CE54E0321D034B92B709B567D60A42E6660279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798",
6+
"03FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A60379BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798",
7+
"04FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A60248C264CDD57D3C24D79990B0F865674EB62A0F9018277A95011B41BFC193B833",
8+
"03FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A60248C264CDD57D3C24D79990B0F865674EB62A0F9018277A95011B41BFC193B831",
9+
"03FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A602FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC30"
10+
],
11+
"valid_test_cases": [
12+
{
13+
"pubnonce_indices": [
14+
0,
15+
1
16+
],
17+
"expected_aggnonce": "035FE1873B4F2967F52FEA4A06AD5A8ECCBE9D0FD73068012C894E2E87CCB5804B024725377345BDE0E9C33AF3C43C0A29A9249F2F2956FA8CFEB55C8573D0262DC8"
18+
},
19+
{
20+
"pubnonce_indices": [
21+
2,
22+
3
23+
],
24+
"expected_aggnonce": "035FE1873B4F2967F52FEA4A06AD5A8ECCBE9D0FD73068012C894E2E87CCB5804B000000000000000000000000000000000000000000000000000000000000000000",
25+
"comment": "Sum of second points encoded in the nonces is point at infinity which is serialized as 33 zero bytes"
26+
}
27+
],
28+
"error_test_cases": [
29+
{
30+
"pubnonce_indices": [
31+
0,
32+
4
33+
],
34+
"error": {
35+
"type": "InvalidContributionError",
36+
"signer_index": 1,
37+
"contrib": "pubnonce"
38+
},
39+
"comment": "Public nonce from signer 1 is invalid due wrong tag, 0x04, in the first half"
40+
},
41+
{
42+
"pubnonce_indices": [
43+
5,
44+
1
45+
],
46+
"error": {
47+
"type": "InvalidContributionError",
48+
"signer_index": 0,
49+
"contrib": "pubnonce"
50+
},
51+
"comment": "Public nonce from signer 0 is invalid because the second half does not correspond to an X coordinate"
52+
},
53+
{
54+
"pubnonce_indices": [
55+
6,
56+
1
57+
],
58+
"error": {
59+
"type": "InvalidContributionError",
60+
"signer_index": 0,
61+
"contrib": "pubnonce"
62+
},
63+
"comment": "Public nonce from signer 0 is invalid because second half exceeds field size"
64+
}
65+
]
66+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"test_cases": [
3+
{
4+
"rand_": "0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F",
5+
"secshare": "CCD2EF4559DB05635091D80189AB3544D6668EFC0500A8D5FF51A1F4D32CC1F1",
6+
"pubshare": "022B02109FBCFB4DA3F53C7393B22E72A2A51C4AFBF0C01AAF44F73843CFB4B74B",
7+
"threshold_pubkey": "B02645D79ABFC494338139410F9D7F0A72BE86C952D6BDE1A66447B8A8D69237",
8+
"msg": "0101010101010101010101010101010101010101010101010101010101010101",
9+
"extra_in": "0808080808080808080808080808080808080808080808080808080808080808",
10+
"expected_secnonce": "0CE17C117FFA8F4BC63E5A01250216F3AE329A212DDAB8ACC146E7EBA5580E7AC176FB8455FEA8C93C29E2A1F572E2998CC316C8685534EFDC9656193D7B6E1B",
11+
"expected_pubnonce": "023F8BD569195D02FA2F70CD9B0BA611E32E0CE984A1BBB0E739F4B4AFBB08CCE902D692CE44EBEE93F9EC8E1503F7DE0D4A926178321A5DAF9AB41E1EA89E8F88E8",
12+
"comment": ""
13+
},
14+
{
15+
"rand_": "0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F",
16+
"secshare": "CCD2EF4559DB05635091D80189AB3544D6668EFC0500A8D5FF51A1F4D32CC1F1",
17+
"pubshare": "022B02109FBCFB4DA3F53C7393B22E72A2A51C4AFBF0C01AAF44F73843CFB4B74B",
18+
"threshold_pubkey": "B02645D79ABFC494338139410F9D7F0A72BE86C952D6BDE1A66447B8A8D69237",
19+
"msg": "",
20+
"extra_in": "0808080808080808080808080808080808080808080808080808080808080808",
21+
"expected_secnonce": "2889110F994409F9F7AB5EFEDAC0F0D20C0083A3BD174F80E1C67B86127A4DE46600C968FFA50DE5B5D9EDE17081930C018E9D937A16C673889587817D4B796F",
22+
"expected_pubnonce": "03B98FAFF2B60C56DC584AF1E7EEBDE6B300B514557EA627208608BA69E386C94E021A423749CA1C3B06E063C7F9DA9A894C9CC2D8B7C927F6605CEC7ED638B127F2",
23+
"comment": "Empty Message"
24+
},
25+
{
26+
"rand_": "0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F",
27+
"secshare": "CCD2EF4559DB05635091D80189AB3544D6668EFC0500A8D5FF51A1F4D32CC1F1",
28+
"pubshare": "022B02109FBCFB4DA3F53C7393B22E72A2A51C4AFBF0C01AAF44F73843CFB4B74B",
29+
"threshold_pubkey": "B02645D79ABFC494338139410F9D7F0A72BE86C952D6BDE1A66447B8A8D69237",
30+
"msg": "2626262626262626262626262626262626262626262626262626262626262626262626262626",
31+
"extra_in": "0808080808080808080808080808080808080808080808080808080808080808",
32+
"expected_secnonce": "A9841123FC252ED4AA0239B0138B973B18300B6F527F29CF450EAE53BF3E4A96A7B2E49AB947C13B79103C29C12B2B991DBDAE5A04485AE2F1F56FCD3B6AA35E",
33+
"expected_pubnonce": "02EE71AAF852F44EEBD7FAB088F37A8D5904D421F1DB0428E64E58FE67E1CD76FA021DDE4E68AAC676E36CBD98C0F86822A77EAE67B904A76BD41864898985F4FB1C",
34+
"comment": "38-byte message"
35+
},
36+
{
37+
"rand_": "0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F",
38+
"secshare": null,
39+
"pubshare": null,
40+
"threshold_pubkey": null,
41+
"msg": null,
42+
"extra_in": null,
43+
"expected_secnonce": "E8E239B64F9A4D2B03508C029EEFC8156A3AD899FD58B15759C93C7DA745C3550FABE3F7CDD361407B97C1353056310D1610D478633C5DDE04DEC4917591D2E5",
44+
"expected_pubnonce": "0399059E50AF7B23F89E1ED7B17A7B24F2D746C663057F6C3B696A416C99C7A1070383C53B9CF236EADF8BDFEB1C3E9A188A1A84190687CD67916DF9BC60CD2D80EC",
45+
"comment": "Every optional parameter is absent"
46+
}
47+
]
48+
}
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
{
2+
"n": 3,
3+
"t": 2,
4+
"threshold_pubkey": "03B02645D79ABFC494338139410F9D7F0A72BE86C952D6BDE1A66447B8A8D69237",
5+
"identifiers": [
6+
0,
7+
1,
8+
2
9+
],
10+
"pubshares": [
11+
"022B02109FBCFB4DA3F53C7393B22E72A2A51C4AFBF0C01AAF44F73843CFB4B74B",
12+
"02EC6444271D791A1DA95300329DB2268611B9C60E193DABFDEE0AA816AE512583",
13+
"03113F810F612567D9552F46AF9BDA21A67D52060F95BD4A723F4B60B1820D3676"
14+
],
15+
"pubnonces": [
16+
"0330935948101543C50AF2FA7A7A4F7073CEB73290CA141497EF06E0269363162D0358785EB5CD7C1626CAB55C59B484E1B3147FA4EB919224ECB04BAB1271022A5C",
17+
"0244D225137BC9390069C9D4D230B6D0942A1A3D72678B638B81F3416B6FEA719C02B1C7E637FD51FE2BC2C91CB6ACA0EA6A8BB30A33A0589D369687EAA33BFC5FA8",
18+
"0332DAA54E451217D6F14747B72634D1E9E21B247C8E92397ABFEE296BD714772403FE1674C2B2B8076D641CEC4B2E6DF054C3D60AA77352A55233B40AC12046C312"
19+
],
20+
"tweaks": [
21+
"B511DA492182A91B0FFB9A98020D55F260AE86D7ECBD0399C7383D59A5F2AF7C",
22+
"A815FE049EE3C5AAB66310477FBC8BCCCAC2F3395F59F921C364ACD78A2F48DC",
23+
"75448A87274B056468B977BE06EB1E9F657577B7320B0A3376EA51FD420D18A8"
24+
],
25+
"msg": "599C67EA410D005B9DA90817CF03ED3B1C868E4DA4EDF00A5880B0082C237869",
26+
"valid_test_cases": [
27+
{
28+
"id_indices": [
29+
0,
30+
1
31+
],
32+
"pubshare_indices": [
33+
0,
34+
1
35+
],
36+
"pubnonce_indices": [
37+
0,
38+
1
39+
],
40+
"aggnonce": "022AAC6A4960DE35FC36D8E2DC06255C5CB7FD28250DFD84EBF1AC943B1EA22C3502178AD06BB0490BAD857446FEF55C15FD9FF4329F4EE2F23CA8B7CA0598014910",
41+
"tweak_indices": [],
42+
"is_xonly": [],
43+
"psigs": [
44+
"09CA21FA4AE22BBB49EE5ABC091519C8695FB74FC3D39C1437019EF6FE6C7AB4",
45+
"D0750AE90E8475A6E984AE9159E0C4510851672D6D5C26260F643448FF0AC3EB"
46+
],
47+
"expected": "90495647B268390A2ABA2518AEEEF699620C783EF21DF2800BB3C38CAE6755C7DA3F2CE35966A1623373094D62F5DE1971B11E7D312FC23A4665D33FFD773E9F",
48+
"comment": "Signing with minimum number of participants"
49+
},
50+
{
51+
"id_indices": [
52+
1,
53+
0
54+
],
55+
"pubshare_indices": [
56+
1,
57+
0
58+
],
59+
"pubnonce_indices": [
60+
1,
61+
0
62+
],
63+
"aggnonce": "022AAC6A4960DE35FC36D8E2DC06255C5CB7FD28250DFD84EBF1AC943B1EA22C3502178AD06BB0490BAD857446FEF55C15FD9FF4329F4EE2F23CA8B7CA0598014910",
64+
"tweak_indices": [],
65+
"is_xonly": [],
66+
"psigs": [
67+
"D0750AE90E8475A6E984AE9159E0C4510851672D6D5C26260F643448FF0AC3EB",
68+
"09CA21FA4AE22BBB49EE5ABC091519C8695FB74FC3D39C1437019EF6FE6C7AB4"
69+
],
70+
"expected": "90495647B268390A2ABA2518AEEEF699620C783EF21DF2800BB3C38CAE6755C7DA3F2CE35966A1623373094D62F5DE1971B11E7D312FC23A4665D33FFD773E9F",
71+
"comment": "Order of the singer set shouldn't affect the aggregate signature. The expected value must match the previous test vector."
72+
},
73+
{
74+
"id_indices": [
75+
0,
76+
1
77+
],
78+
"pubshare_indices": [
79+
0,
80+
1
81+
],
82+
"pubnonce_indices": [
83+
0,
84+
1
85+
],
86+
"aggnonce": "022AAC6A4960DE35FC36D8E2DC06255C5CB7FD28250DFD84EBF1AC943B1EA22C3502178AD06BB0490BAD857446FEF55C15FD9FF4329F4EE2F23CA8B7CA0598014910",
87+
"tweak_indices": [
88+
0,
89+
1,
90+
2
91+
],
92+
"is_xonly": [
93+
true,
94+
false,
95+
false
96+
],
97+
"psigs": [
98+
"19689B0B3F32C7696FF2C90CF1E6DC8311F96EC7D6307EF56085C78C3FF6C828",
99+
"B7290A65BE76B17C8756D77EF0395D5F219CDF7EA8D63886132C9011938F241C"
100+
],
101+
"expected": "7430808B048AD9EAA6240B047B790CF24DB878DC3AC31C1B528289ED3AA70C067CA7AA1E418135268A336415D4B634E1F845A981F21B69FD3ADDF7D81D41FAB8",
102+
"comment": "Signing with tweaked threshold public key"
103+
},
104+
{
105+
"id_indices": [
106+
0,
107+
1,
108+
2
109+
],
110+
"pubshare_indices": [
111+
0,
112+
1,
113+
2
114+
],
115+
"pubnonce_indices": [
116+
0,
117+
1,
118+
2
119+
],
120+
"aggnonce": "0282E58B733AB1B74D1C54B960D668E4298C3EF9F406D44249FB30C403568A1B14039B38604D0FD33E07C3EB81BBDAE39A38A82A1D9E325112A24F0F5480582C9CEE",
121+
"tweak_indices": [],
122+
"is_xonly": [],
123+
"psigs": [
124+
"13036985653E36780C30AFB253D9E506EA2FD5E30439C507D337DA4062898066",
125+
"C665E007CC6D1294105580FC46764C8F49D1A44DE9D574F5C3DF72E6636B383E",
126+
"F5352AB8BD2C34F466ACF16046A222DAFB45FBF6327AC4E8EE6C10C8FED9EF33"
127+
],
128+
"expected": "553247A24AF9A15C4D495968C0467FE6651F3584FDD671CBAE05BBC850577DD8CE9E7445EED77E008333220EE0F254727498994071415EAAC5B0FF62F4986696",
129+
"comment": "Signing with max number of participants and tweaked threshold public key"
130+
}
131+
],
132+
"error_test_cases": [
133+
{
134+
"id_indices": [
135+
0,
136+
1
137+
],
138+
"pubshare_indices": [
139+
0,
140+
1
141+
],
142+
"pubnonce_indices": [
143+
0,
144+
1
145+
],
146+
"aggnonce": "022AAC6A4960DE35FC36D8E2DC06255C5CB7FD28250DFD84EBF1AC943B1EA22C3502178AD06BB0490BAD857446FEF55C15FD9FF4329F4EE2F23CA8B7CA0598014910",
147+
"tweak_indices": [],
148+
"is_xonly": [],
149+
"psigs": [
150+
"09CA21FA4AE22BBB49EE5ABC091519C8695FB74FC3D39C1437019EF6FE6C7AB4",
151+
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"
152+
],
153+
"error": {
154+
"type": "InvalidContributionError",
155+
"signer_index": 1,
156+
"contrib": "psig"
157+
},
158+
"comment": "Partial signature is invalid because it exceeds group size"
159+
},
160+
{
161+
"id_indices": [
162+
0,
163+
1
164+
],
165+
"pubshare_indices": [
166+
0,
167+
1
168+
],
169+
"pubnonce_indices": [
170+
0,
171+
1
172+
],
173+
"aggnonce": "022AAC6A4960DE35FC36D8E2DC06255C5CB7FD28250DFD84EBF1AC943B1EA22C3502178AD06BB0490BAD857446FEF55C15FD9FF4329F4EE2F23CA8B7CA0598014910",
174+
"tweak_indices": [],
175+
"is_xonly": [],
176+
"psigs": [
177+
"09CA21FA4AE22BBB49EE5ABC091519C8695FB74FC3D39C1437019EF6FE6C7AB4"
178+
],
179+
"error": {
180+
"type": "ValueError",
181+
"message": "The psigs and ids arrays must have the same length."
182+
},
183+
"comment": "Partial signature count doesn't match the signer set count"
184+
}
185+
]
186+
}

0 commit comments

Comments
 (0)