mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 15:50:07 +01:00
refactor: remove unused CKey::Negate method
This method was introduced as a pre-requirement for the v2 transport
protocol back then (see PR #14047, commit 463921bb), when it was still
BIP151. With the replacement BIP324, this is not needed anymore, and
it's also unlikely that any other proposal would need to negate private
keys at this abstraction level.
(If there is really demand, it's trivial to reintroduce the method.)
This commit is contained in:
@@ -201,37 +201,6 @@ BOOST_AUTO_TEST_CASE(key_signature_tests)
|
||||
BOOST_CHECK(found_small);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(key_key_negation)
|
||||
{
|
||||
// create a dummy hash for signature comparison
|
||||
unsigned char rnd[8];
|
||||
std::string str = "Bitcoin key verification\n";
|
||||
GetRandBytes(rnd);
|
||||
uint256 hash{Hash(str, rnd)};
|
||||
|
||||
// import the static test key
|
||||
CKey key = DecodeSecret(strSecret1C);
|
||||
|
||||
// create a signature
|
||||
std::vector<unsigned char> vch_sig;
|
||||
std::vector<unsigned char> vch_sig_cmp;
|
||||
key.Sign(hash, vch_sig);
|
||||
|
||||
// negate the key twice
|
||||
BOOST_CHECK(key.GetPubKey().data()[0] == 0x03);
|
||||
key.Negate();
|
||||
// after the first negation, the signature must be different
|
||||
key.Sign(hash, vch_sig_cmp);
|
||||
BOOST_CHECK(vch_sig_cmp != vch_sig);
|
||||
BOOST_CHECK(key.GetPubKey().data()[0] == 0x02);
|
||||
key.Negate();
|
||||
// after the second negation, we should have the original key and thus the
|
||||
// same signature
|
||||
key.Sign(hash, vch_sig_cmp);
|
||||
BOOST_CHECK(vch_sig_cmp == vch_sig);
|
||||
BOOST_CHECK(key.GetPubKey().data()[0] == 0x03);
|
||||
}
|
||||
|
||||
static CPubKey UnserializePubkey(const std::vector<uint8_t>& data)
|
||||
{
|
||||
DataStream stream{};
|
||||
|
||||
Reference in New Issue
Block a user