mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 11:57:28 -03:00
Unit test for ellswift creation/decoding roundtrip
Co-authored-by: Pieter Wuille <bitcoin-dev@wuille.net>
This commit is contained in:
parent
eff72a0dff
commit
aae432a764
1 changed files with 20 additions and 0 deletions
|
@ -344,4 +344,24 @@ BOOST_AUTO_TEST_CASE(bip340_test_vectors)
|
|||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(key_ellswift)
|
||||
{
|
||||
for (const auto& secret : {strSecret1, strSecret2, strSecret1C, strSecret2C}) {
|
||||
CKey key = DecodeSecret(secret);
|
||||
BOOST_CHECK(key.IsValid());
|
||||
|
||||
uint256 ent32 = InsecureRand256();
|
||||
auto ellswift = key.EllSwiftCreate(AsBytes(Span{ent32}));
|
||||
|
||||
CPubKey decoded_pubkey = ellswift.Decode();
|
||||
if (!key.IsCompressed()) {
|
||||
// The decoding constructor returns a compressed pubkey. If the
|
||||
// original was uncompressed, we must decompress the decoded one
|
||||
// to compare.
|
||||
decoded_pubkey.Decompress();
|
||||
}
|
||||
BOOST_CHECK(key.GetPubKey() == decoded_pubkey);
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
Loading…
Reference in a new issue