@@ -327,6 +327,16 @@ BOOST_AUTO_TEST_CASE(bip340_test_vectors)
327
327
// Verify those signatures for good measure.
328
328
BOOST_CHECK (pubkey.VerifySchnorr (msg256, sig64));
329
329
330
+ // Repeat the same check, but use the KeyPair directly without any merkle tweak
331
+ KeyPair keypair = key.ComputeKeyPair (/* merkle_root=*/ nullptr );
332
+ CKey keypair_seckey;
333
+ BOOST_CHECK (keypair.GetKey (keypair_seckey));
334
+ BOOST_CHECK (key == keypair_seckey);
335
+ bool kp_ok = keypair.SignSchnorr (msg256, sig64, aux256);
336
+ BOOST_CHECK (kp_ok);
337
+ XOnlyPubKey keypair_xonly{keypair_seckey.GetPubKey ()};
338
+ BOOST_CHECK (keypair_xonly.VerifySchnorr (msg256, sig64));
339
+
330
340
// Do 10 iterations where we sign with a random Merkle root to tweak,
331
341
// and compare against the resulting tweaked keys, with random aux.
332
342
// In iteration i=0 we tweak with empty Merkle tree.
@@ -340,6 +350,16 @@ BOOST_AUTO_TEST_CASE(bip340_test_vectors)
340
350
bool ok = key.SignSchnorr (msg256, sig64, &merkle_root, aux256);
341
351
BOOST_CHECK (ok);
342
352
BOOST_CHECK (tweaked_key.VerifySchnorr (msg256, sig64));
353
+
354
+ // Repeat the same check, but use the KeyPair class directly
355
+ KeyPair keypair = key.ComputeKeyPair (&merkle_root);
356
+ CKey keypair_seckey;
357
+ BOOST_CHECK (keypair.GetKey (keypair_seckey));
358
+ XOnlyPubKey keypair_xonly{keypair_seckey.GetPubKey ()};
359
+ BOOST_CHECK (tweaked_key == keypair_xonly);
360
+ bool kp_ok = keypair.SignSchnorr (msg256, sig64, aux256);
361
+ BOOST_CHECK (kp_ok);
362
+ BOOST_CHECK (keypair_xonly.VerifySchnorr (msg256, sig64));
343
363
}
344
364
}
345
365
}
0 commit comments