-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1894 from Roasbeef/musig2-1-0
btcec/schnorr/musig2: update to musig 1.0.0
- Loading branch information
Showing
17 changed files
with
1,642 additions
and
1,550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= | ||
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= | ||
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= | ||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= | ||
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | ||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= | ||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= | ||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
{ | ||
"pubkeys": [ | ||
"02F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9", | ||
"03DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", | ||
"023590A94E768F8E1815C2F24B4D80A8E3149316C3518CE7B7AD338368D038CA66", | ||
"020000000000000000000000000000000000000000000000000000000000000005", | ||
"02FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC30", | ||
"04F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9", | ||
"03935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9" | ||
], | ||
"tweaks": [ | ||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", | ||
"252E4BD67410A76CDF933D30EAA1608214037F1B105A013ECCD3C5C184A6110B" | ||
], | ||
"valid_test_cases": [ | ||
{ | ||
"key_indices": [0, 1, 2], | ||
"expected": "90539EEDE565F5D054F32CC0C220126889ED1E5D193BAF15AEF344FE59D4610C" | ||
}, | ||
{ | ||
"key_indices": [2, 1, 0], | ||
"expected": "6204DE8B083426DC6EAF9502D27024D53FC826BF7D2012148A0575435DF54B2B" | ||
}, | ||
{ | ||
"key_indices": [0, 0, 0], | ||
"expected": "B436E3BAD62B8CD409969A224731C193D051162D8C5AE8B109306127DA3AA935" | ||
}, | ||
{ | ||
"key_indices": [0, 0, 1, 1], | ||
"expected": "69BC22BFA5D106306E48A20679DE1D7389386124D07571D0D872686028C26A3E" | ||
} | ||
], | ||
"error_test_cases": [ | ||
{ | ||
"key_indices": [0, 3], | ||
"tweak_indices": [], | ||
"is_xonly": [], | ||
"error": { | ||
"type": "invalid_contribution", | ||
"signer": 1, | ||
"contrib": "pubkey" | ||
}, | ||
"comment": "Invalid public key" | ||
}, | ||
{ | ||
"key_indices": [0, 4], | ||
"tweak_indices": [], | ||
"is_xonly": [], | ||
"error": { | ||
"type": "invalid_contribution", | ||
"signer": 1, | ||
"contrib": "pubkey" | ||
}, | ||
"comment": "Public key exceeds field size" | ||
}, | ||
{ | ||
"key_indices": [5, 0], | ||
"tweak_indices": [], | ||
"is_xonly": [], | ||
"error": { | ||
"type": "invalid_contribution", | ||
"signer": 0, | ||
"contrib": "pubkey" | ||
}, | ||
"comment": "First byte of public key is not 2 or 3" | ||
}, | ||
{ | ||
"key_indices": [0, 1], | ||
"tweak_indices": [0], | ||
"is_xonly": [true], | ||
"error": { | ||
"type": "value", | ||
"message": "The tweak must be less than n." | ||
}, | ||
"comment": "Tweak is out of range" | ||
}, | ||
{ | ||
"key_indices": [6], | ||
"tweak_indices": [1], | ||
"is_xonly": [false], | ||
"error": { | ||
"type": "value", | ||
"message": "The result of tweaking cannot be infinity." | ||
}, | ||
"comment": "Intermediate tweaking result is point at infinity" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"pubkeys": [ | ||
"02DD308AFEC5777E13121FA72B9CC1B7CC0139715309B086C960E18FD969774EB8", | ||
"02F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9", | ||
"03DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659", | ||
"023590A94E768F8E1815C2F24B4D80A8E3149316C3518CE7B7AD338368D038CA66", | ||
"02DD308AFEC5777E13121FA72B9CC1B7CC0139715309B086C960E18FD969774EB8" | ||
], | ||
"sorted_pubkeys": [ | ||
"023590A94E768F8E1815C2F24B4D80A8E3149316C3518CE7B7AD338368D038CA66", | ||
"02DD308AFEC5777E13121FA72B9CC1B7CC0139715309B086C960E18FD969774EB8", | ||
"02DD308AFEC5777E13121FA72B9CC1B7CC0139715309B086C960E18FD969774EB8", | ||
"02F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9", | ||
"03DFF1D77F2A671C5F36183726DB2341BE58FEAE1DA2DECED843240F7B502BA659" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"pnonces": [ | ||
"020151C80F435648DF67A22B749CD798CE54E0321D034B92B709B567D60A42E66603BA47FBC1834437B3212E89A84D8425E7BF12E0245D98262268EBDCB385D50641", | ||
"03FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A60248C264CDD57D3C24D79990B0F865674EB62A0F9018277A95011B41BFC193B833", | ||
"020151C80F435648DF67A22B749CD798CE54E0321D034B92B709B567D60A42E6660279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", | ||
"03FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A60379BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", | ||
"04FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A60248C264CDD57D3C24D79990B0F865674EB62A0F9018277A95011B41BFC193B833", | ||
"03FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A60248C264CDD57D3C24D79990B0F865674EB62A0F9018277A95011B41BFC193B831", | ||
"03FF406FFD8ADB9CD29877E4985014F66A59F6CD01C0E88CAA8E5F3166B1F676A602FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC30" | ||
], | ||
"valid_test_cases": [ | ||
{ | ||
"pnonce_indices": [0, 1], | ||
"expected": "035FE1873B4F2967F52FEA4A06AD5A8ECCBE9D0FD73068012C894E2E87CCB5804B024725377345BDE0E9C33AF3C43C0A29A9249F2F2956FA8CFEB55C8573D0262DC8" | ||
}, | ||
{ | ||
"pnonce_indices": [2, 3], | ||
"expected": "035FE1873B4F2967F52FEA4A06AD5A8ECCBE9D0FD73068012C894E2E87CCB5804B000000000000000000000000000000000000000000000000000000000000000000", | ||
"comment": "Sum of second points encoded in the nonces is point at infinity which is serialized as 33 zero bytes" | ||
} | ||
], | ||
"error_test_cases": [ | ||
{ | ||
"pnonce_indices": [0, 4], | ||
"error": { | ||
"type": "invalid_contribution", | ||
"signer": 1, | ||
"contrib": "pubnonce" | ||
}, | ||
"comment": "Public nonce from signer 1 is invalid due wrong tag, 0x04, in the first half", | ||
"btcec_err": "invalid public key: unsupported format: 4" | ||
}, | ||
{ | ||
"pnonce_indices": [5, 1], | ||
"error": { | ||
"type": "invalid_contribution", | ||
"signer": 0, | ||
"contrib": "pubnonce" | ||
}, | ||
"comment": "Public nonce from signer 0 is invalid because the second half does not correspond to an X coordinate", | ||
"btcec_err": "invalid public key: x coordinate 48c264cdd57d3c24d79990b0f865674eb62a0f9018277a95011b41bfc193b831 is not on the secp256k1 curve" | ||
}, | ||
{ | ||
"pnonce_indices": [6, 1], | ||
"error": { | ||
"type": "invalid_contribution", | ||
"signer": 0, | ||
"contrib": "pubnonce" | ||
}, | ||
"comment": "Public nonce from signer 0 is invalid because second half exceeds field size", | ||
"btcec_err": "invalid public key: x >= field prime" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"test_cases": [ | ||
{ | ||
"rand_": "0000000000000000000000000000000000000000000000000000000000000000", | ||
"sk": "0202020202020202020202020202020202020202020202020202020202020202", | ||
"aggpk": "0707070707070707070707070707070707070707070707070707070707070707", | ||
"msg": "0101010101010101010101010101010101010101010101010101010101010101", | ||
"extra_in": "0808080808080808080808080808080808080808080808080808080808080808", | ||
"expected": "BC6C683EBBCC39DCB3C29B3D010D2AAA7C86CFB562FC41ED9A460EE061013E75FB4AD2F0B816713269800D018803906D5481E00A940EAB4F4AC49B4A372EB0F4" | ||
}, | ||
{ | ||
"rand_": "0000000000000000000000000000000000000000000000000000000000000000", | ||
"sk": "0202020202020202020202020202020202020202020202020202020202020202", | ||
"aggpk": "0707070707070707070707070707070707070707070707070707070707070707", | ||
"msg": "", | ||
"extra_in": "0808080808080808080808080808080808080808080808080808080808080808", | ||
"expected": "AAC4BFD707F4953B4063851D7E4AAD5C59D5D0BFB0E71012788A85698B5ACF8F11834D5051928424BA501C8CD064F3F942F8D4A07D8A2ED79F153E4ABD9EBBE9" | ||
}, | ||
{ | ||
"rand_": "0000000000000000000000000000000000000000000000000000000000000000", | ||
"sk": "0202020202020202020202020202020202020202020202020202020202020202", | ||
"aggpk": "0707070707070707070707070707070707070707070707070707070707070707", | ||
"msg": "2626262626262626262626262626262626262626262626262626262626262626262626262626", | ||
"extra_in": "0808080808080808080808080808080808080808080808080808080808080808", | ||
"expected": "DF54500DD2B503DBA3753C48A9D6B67E6C11EC4325EDD1DC256C7F75D6A85DBECA6D9857A6F3F292FB3B50DBCBF69FADB67B1CDDB0EA6EB693F6455C4C9088E1" | ||
}, | ||
{ | ||
"rand_": "0000000000000000000000000000000000000000000000000000000000000000", | ||
"sk": null, | ||
"aggpk": null, | ||
"msg": null, | ||
"extra_in": null, | ||
"expected": "7B3B5A002356471AF0E961DE2549C121BD0D48ABCEEDC6E034BDDF86AD3E0A187ECEE674CEF7364B0BC4BEEFB8B66CAD89F98DE2F8C5A5EAD5D1D1E4BD7D04CD" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"pubkeys": [ | ||
"03935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9", | ||
"02D2DC6F5DF7C56ACF38C7FA0AE7A759AE30E19B37359DFDE015872324C7EF6E05", | ||
"03C7FB101D97FF930ACD0C6760852EF64E69083DE0B06AC6335724754BB4B0522C", | ||
"02352433B21E7E05D3B452B81CAE566E06D2E003ECE16D1074AABA4289E0E3D581" | ||
], | ||
"pnonces": [ | ||
"0300A32F8548F59C533F55DB9754E3C0BA3C2544F085649FDCE42B8BD3F244C2CA0384449BED61004E8863452A38534E91875516C3CC543122CE2BE1F31845025588", | ||
"03F66B072A869BC2A57D776D487151D707E82B4F1B885066A589858C1BF3871DB603ED391C9658AB6031A96ACBD5E2D9FEC465EFDC8C0D0B765C9B9F3579D520FB6F", | ||
"03A5791CA078E278126EF457C25B5C835F7282C0A47BDBF464BA35C3769427D5CD034D40350F8A5590985E38AAEFC3C695DF671C2E5498E2B60C082C546E06ECAF78", | ||
"020DE6382B8C0550E8174D5263B981224EBCFEF7706588B6936177FEB68E639B8C02BA5F18DDB3487AD087F63CEF7D7818AC8ECA3D6B736113FF36FB25D113F514F6", | ||
"031883080513BB69B31367F9A7B5F4E81246C627060A7414B7F137FA8459F261990345445505F158EDCFDF0D4BF26E04E018C143BF76B5D457AE57DF06CA41371DF0", | ||
"0300028E83123E7FAB1E1F230547CE8B96CC23F13197312972DE72AACBA98EF9870274C2D8566E9E021AA7E2DDDA01B52AE670E0742418F147610528B65ACDB4D0B3" | ||
], | ||
"tweaks": [ | ||
"B511DA492182A91B0FFB9A98020D55F260AE86D7ECBD0399C7383D59A5F2AF7C", | ||
"A815FE049EE3C5AAB66310477FBC8BCCCAC2F3395F59F921C364ACD78A2F48DC", | ||
"75448A87274B056468B977BE06EB1E9F657577B7320B0A3376EA51FD420D18A8" | ||
], | ||
"psigs": [ | ||
"7918521F42E5727FE2E82D802876E0C8844336FDA1B58C82696A55B0188C8B3D", | ||
"599044037AE15C4A99FB94F022B48E7AB215BF703954EC0B83D0E06230476001", | ||
"F05BE3CA783AD1FAF68C5059B43F859BFD4EBB0242459DF2C6BF013F4217F7E7", | ||
"BF85B2A751066466C24A5E7FA6C90DBAADAC2DF1F0BB48546AE239E340437CEB", | ||
"142076B034A7401123EFB07E2317DF819B86B3FFA17180DDD093997D018270D0", | ||
"B7A0C7F5B325B7993925E56B60F53EF8198169F31E1AF7E62BBEF1C5DCD1BA22", | ||
"C717ECA32C148CE8EB8882CD9656DF9C64929DCAE9AF798E381B1E888DDF0F8F", | ||
"5988823E78488D8005311E16E5EA67AF70514CB44F5A5CD51FFA262BEEAA21CE", | ||
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141" | ||
], | ||
"msg": "599C67EA410D005B9DA90817CF03ED3B1C868E4DA4EDF00A5880B0082C237869", | ||
"valid_test_cases": [ | ||
{ | ||
"aggnonce": "02BC34CDF6FA1298D7B6A126812FAD0739005BC44E45C21276EEFE41AAF841C86F03F3562AED52243BB99F43D1677DB59F0FEFB961633997F7AC924B78FBD0B0334F", | ||
"nonce_indices": [0, 1], | ||
"key_indices": [0, 1], | ||
"tweak_indices": [], | ||
"is_xonly": [], | ||
"psig_indices": [0, 1], | ||
"expected": "CA3C28729659E50F829F55DC5DB1DE88A05D1702B4165B85F95B627FC57733F8D2A89622BDC6CECA7CE3C2704B2B6F433658F66DDB0A788DED3B361248D3EB3E" | ||
}, | ||
{ | ||
"aggnonce": "035538518B8043CF4EACD0E701A80657B741C0E6445EC1D6C6177964D22C642971030CFE657EC882F4E08E751B883A78AC1491B30FC86CB57AF2DFF012C2BE6DF1F2", | ||
"nonce_indices": [0, 2], | ||
"key_indices": [0, 2], | ||
"tweak_indices": [], | ||
"is_xonly": [], | ||
"psig_indices": [2, 3], | ||
"expected": "3997A11DFF76349532CF25E761365EA1D4F24B62EB23A12A9DAABD5976C3DB9FAFE19671C9413661B8D6AED95B089357F04C0C0D83B8460B71CEDC95B2253391" | ||
}, | ||
{ | ||
"aggnonce": "024366775E6FFBEBBB954225936BAED71A3884C7933B18225088D19E7AF12D8D5D028D79A520B347B793FFE897A7EB79A4366A3FDCDC652C243FAC3976B3D6DF8AB2", | ||
"nonce_indices": [0, 3], | ||
"key_indices": [0, 2], | ||
"tweak_indices": [0], | ||
"is_xonly": [false], | ||
"psig_indices": [4, 5], | ||
"expected": "5AF759C2839B7FEE59D31DAB800F82FC21258457773A3B1F69F5228C80CAD4317EA39AD756601030E4D4051B7C9A25AB4DE7CB39BED26E0A03A1B2ED5B747F7F" | ||
}, | ||
{ | ||
"aggnonce": "03B25098C6D0B72DC5717314AF26C126609B4776AA468553DD4354EE20B216B227027D242E9203499173A74E286C1F796F2711E171EE937706BBEA2F4DB10C4E6809", | ||
"nonce_indices": [0, 4], | ||
"key_indices": [0, 3], | ||
"tweak_indices": [0, 1, 2], | ||
"is_xonly": [true, false, true], | ||
"psig_indices": [6, 7], | ||
"expected": "B495A478F91D6E10BF08A156E46D9E62B4C5399C1AEDDA1A9D306F06AFB8A52F2C078FD6B50DDBC33BFFE583C3C1E3D0D5E52891E190101C70D2278BCA943457" | ||
} | ||
], | ||
"error_test_cases": [ | ||
{ | ||
"aggnonce": "03B25098C6D0B72DC5717314AF26C126609B4776AA468553DD4354EE20B216B227027D242E9203499173A74E286C1F796F2711E171EE937706BBEA2F4DB10C4E6809", | ||
"nonce_indices": [0, 4], | ||
"key_indices": [0, 3], | ||
"tweak_indices": [0, 1, 2], | ||
"is_xonly": [true, false, true], | ||
"psig_indices": [7, 8], | ||
"error": { | ||
"type": "invalid_contribution", | ||
"signer": 1 | ||
}, | ||
"comment": "Partial signature is invalid because it exceeds group size" | ||
} | ||
] | ||
} |
Oops, something went wrong.