mirror of
https://github.com/bitcoin/bips.git
synced 2026-11-16 19:48:35 +00:00
bip-0327: add test vectors for k2' >= n and 256-byte messages
Add Sign test vectors with k2' = n and k2' = n + 1. Together they detect implementations that check the secret nonce values only for zero, that check k2' <= n instead of k2' < n, or that reduce k2' mod n before checking it for zero. No single value detects the last two: among values of at least n, checking k2' <= n accepts only n, while reducing first rejects only n. For k2' = n, the optional correctness check at the end of Sign also fails, because k2'*G is infinity, so this vector detects the k2' <= n mistake only in implementations that omit that check. Add NonceGen and DeterministicSign test vectors with a 256-byte message. They detect implementations that encode only the low byte of len(m); the longest message in the previous test vectors has 38 bytes. DeterministicSign needs its own vector because it encodes len(m) separately.
This commit is contained in:
1 parent
6e8dafd3c3
commit
0ba8e56a02
3 files changed
+52
-2
No files matched your search
@@ -8,7 +8,8 @@
|
||||
],
|
||||
"msgs": [
|
||||
"F95466D086770E689964664219266FE5ED215C92AE20BAB5C9D79ADDDDF3C0CF",
|
||||
"2626262626262626262626262626262626262626262626262626262626262626262626262626"
|
||||
"2626262626262626262626262626262626262626262626262626262626262626262626262626",
|
||||
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF"
|
||||
],
|
||||
"valid_test_cases": [
|
||||
{
|
||||
@@ -78,6 +79,20 @@
|
||||
"324600EDB5B0321F47C27D7843EA38A4B61A80C276AB3EA5E9435B254D135B6B"
|
||||
],
|
||||
"comment": "Plain and x-only tweaks. Detects implementations that treat every tweak as x-only."
|
||||
},
|
||||
{
|
||||
"rand": "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"aggothernonce": "0337C87821AFD50A8644D820A8F3E02E499C931865C2360FB43D0A0D20DAFE07EA0287BF891D2A6DEAEBADC909352AA9405D1428C15F4B75F04DAE642A95C2548480",
|
||||
"key_indices": [0, 1, 2],
|
||||
"tweaks": [],
|
||||
"is_xonly": [],
|
||||
"msg_index": 2,
|
||||
"signer_index": 0,
|
||||
"expected": [
|
||||
"02CB9B7D4A7EC68635468B52755DD0314879F0E9EAE728817559B6DD213C4B4210024CDABB29C9BC46921F57FC622BA72A7E1AC431B4286DBB23927FFD2ECFF63A51",
|
||||
"D6CCC452B5C1277001A9178467AD697ECAB99E383B1C6F592A1C07F3723E541A"
|
||||
],
|
||||
"comment": "Message of 256 bytes. Detects implementations that encode only the low byte of the message length."
|
||||
}
|
||||
],
|
||||
"error_test_cases": [
|
||||
|
||||
@@ -50,6 +50,17 @@
|
||||
"expected_secnonce": "8BEDC2ABC2D7F00976C8A932314683C9A9BE9B8A71A7C2F3F54B9C303215AE7C13C471707BA3CDC623D7B4F9B6BF3AFD140B9A3C936F6FE05FF22F344387D853024D4B6CD1361032CA9BD2AEB9D900AA4D45D9EAD80AC9423374C451A7254D0766",
|
||||
"expected_pubnonce": "0357C9EEBFFA55BF667E0AACF5412C1E9EBDEBEFFC764F9FCBEA748BBFD275C4400303C378032670DCBC1D9ACDF8EC113FE863A249FC74D3E88F898C1B2540A7CC00",
|
||||
"comment": "extra_in shorter than 32 bytes. Detects implementations that encode the length of extra_in as 32 whenever extra_in is present. This test case is optional: it can be skipped by implementations that only support a 32-byte extra_in."
|
||||
},
|
||||
{
|
||||
"rand_": "0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F",
|
||||
"sk": "0202020202020202020202020202020202020202020202020202020202020202",
|
||||
"pk": "024D4B6CD1361032CA9BD2AEB9D900AA4D45D9EAD80AC9423374C451A7254D0766",
|
||||
"aggpk": "0707070707070707070707070707070707070707070707070707070707070707",
|
||||
"msg": "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF",
|
||||
"extra_in": "0808080808080808080808080808080808080808080808080808080808080808",
|
||||
"expected_secnonce": "A7DA22BD150F412D85E5DB863DE9E3DB3BD1185AC3EFBB2C187EB6385140DC9F979ABE5529FDA821A31081A521687C6D95C940F34FD7F088129A4599025E960D024D4B6CD1361032CA9BD2AEB9D900AA4D45D9EAD80AC9423374C451A7254D0766",
|
||||
"expected_pubnonce": "029AE00806C1C5D4650A86BD252B71360BCB46CB8F55E25F1D1963EF2E63BA10CF0394C3255F45ED9271C49ECE4B92F6863344E169206FFC2158036AB102BED040E8",
|
||||
"comment": "Message of 256 bytes. Detects implementations that encode only the low byte of the message length."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -10,7 +10,9 @@
|
||||
"508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FA27FD49B1D50085B481285E1CA205D55C82CC1B31FF5CD54A489829355901F703935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9",
|
||||
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9",
|
||||
"508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61000000000000000000000000000000000000000000000000000000000000000003935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9",
|
||||
"508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FA27FD49B1D50085B481285E1CA205D55C82CC1B31FF5CD54A489829355901F702F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9"
|
||||
"508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FA27FD49B1D50085B481285E1CA205D55C82CC1B31FF5CD54A489829355901F702F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9",
|
||||
"508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD036414103935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9",
|
||||
"508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD036414203935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9"
|
||||
],
|
||||
"pnonces": [
|
||||
"0337C87821AFD50A8644D820A8F3E02E499C931865C2360FB43D0A0D20DAFE07EA0287BF891D2A6DEAEBADC909352AA9405D1428C15F4B75F04DAE642A95C2548480",
|
||||
@@ -187,6 +189,28 @@
|
||||
"message": "Public key does not match nonce_gen argument"
|
||||
},
|
||||
"comment": "Secnonce was generated for another signer's public key. Detects implementations that check only that secnonce[64:97] is one of the public keys."
|
||||
},
|
||||
{
|
||||
"key_indices": [0, 1, 2],
|
||||
"aggnonce_index": 0,
|
||||
"msg_index": 0,
|
||||
"secnonce_index": 4,
|
||||
"error": {
|
||||
"type": "value",
|
||||
"message": "second secnonce value is out of range."
|
||||
},
|
||||
"comment": "Secnonce is invalid because its second half equals group size. Detects implementations that check k2' <= n instead of k2' < n and omit the optional verification at the end of Sign."
|
||||
},
|
||||
{
|
||||
"key_indices": [0, 1, 2],
|
||||
"aggnonce_index": 0,
|
||||
"msg_index": 0,
|
||||
"secnonce_index": 5,
|
||||
"error": {
|
||||
"type": "value",
|
||||
"message": "second secnonce value is out of range."
|
||||
},
|
||||
"comment": "Secnonce is invalid because its second half exceeds group size. Detects implementations that reduce k2' mod n and then check only that it is nonzero."
|
||||
}
|
||||
],
|
||||
"verify_fail_test_cases": [
|
||||
|
||||
Reference in new issue
Block a user