From 17affe28619e1c761c384c048229369518c12ea1 Mon Sep 17 00:00:00 2001 From: Jonas Nick Date: Mon, 9 Nov 2026 20:49:09 +0000 Subject: [PATCH] bip-0327: add test vectors for a public key and its negation A public key and its negation have the same X coordinate, and their compressed encodings differ only in the first byte. Add a Sign test vector with a secnonce generated for the negation of the signer's public key, and a KeyAgg test vector with a public key and its negation. They detect implementations that compare public keys only by their X coordinates, in the public key check of Sign, in GetSecondKey, or in KeyAggCoeffInternal. Distinct public keys in the previous test vectors also have distinct X coordinates. The public key check in Sign ensures that the secret key provided to Sign is determined when NonceGen is invoked. Comparing only X coordinates determines the secret key only up to negation. --- bip-0327/vectors/key_agg_vectors.json | 8 +++++++- bip-0327/vectors/sign_verify_vectors.json | 14 +++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/bip-0327/vectors/key_agg_vectors.json b/bip-0327/vectors/key_agg_vectors.json index b2e623de..45d12e94 100644 --- a/bip-0327/vectors/key_agg_vectors.json +++ b/bip-0327/vectors/key_agg_vectors.json @@ -6,7 +6,8 @@ "020000000000000000000000000000000000000000000000000000000000000005", "02FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC30", "04F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9", - "03935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9" + "03935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9", + "03F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9" ], "tweaks": [ "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141", @@ -28,6 +29,11 @@ { "key_indices": [0, 0, 1, 1], "expected": "69BC22BFA5D106306E48A20679DE1D7389386124D07571D0D872686028C26A3E" + }, + { + "key_indices": [0, 7], + "expected": "A886A992E178FB725FA308586018634D0936AE8CC27299675D90947FFCE0B4A6", + "comment": "The second public key is the negation of the first. Detects implementations that compare public keys only by X coordinate in GetSecondKey or KeyAggCoeffInternal." } ], "error_test_cases": [ diff --git a/bip-0327/vectors/sign_verify_vectors.json b/bip-0327/vectors/sign_verify_vectors.json index 08384fc7..c4a74bd4 100644 --- a/bip-0327/vectors/sign_verify_vectors.json +++ b/bip-0327/vectors/sign_verify_vectors.json @@ -12,7 +12,8 @@ "508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61000000000000000000000000000000000000000000000000000000000000000003935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9", "508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FA27FD49B1D50085B481285E1CA205D55C82CC1B31FF5CD54A489829355901F702F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9", "508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD036414103935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9", - "508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD036414203935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9" + "508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD036414203935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9", + "508B81A611F100A6B2B6B29656590898AF488BCF2E1F55CF22E5CFB84421FE61FA27FD49B1D50085B481285E1CA205D55C82CC1B31FF5CD54A489829355901F702935F972DA013F80AE011890FA89B67A27B7BE6CCB24D3274D18B2D4067F261A9" ], "pnonces": [ "0337C87821AFD50A8644D820A8F3E02E499C931865C2360FB43D0A0D20DAFE07EA0287BF891D2A6DEAEBADC909352AA9405D1428C15F4B75F04DAE642A95C2548480", @@ -211,6 +212,17 @@ "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." + }, + { + "key_indices": [0, 1, 2], + "aggnonce_index": 0, + "msg_index": 0, + "secnonce_index": 6, + "error": { + "type": "value", + "message": "Public key does not match nonce_gen argument" + }, + "comment": "Secnonce was generated for the negation of the signer's public key. Detects implementations that compare secnonce[64:97] with the signer's public key only by X coordinate." } ], "verify_fail_test_cases": [