18 #include <boost/test/unit_test.hpp>
21 static const std::string strSecret1 =
"87vK7Vayi3QLsuiva5yWSuVwSMhMcRM9dBsaD6JXMD1P5vnjRFn";
22 static const std::string strSecret2 =
"87FGYGFDg5SYfdD4XL593hr7do6f52czPecVsYSAXi8N4RGeS9i";
23 static const std::string strSecret1C =
"YRYJwfAyJ9c2jhi3T2xQyLijGvM7yLTw4izDaNQLxBzgUYrQiPmJ";
24 static const std::string strSecret2C =
"YNZyazHkwUbkmUpEYsBGWwHnHQTy2n9rJy1gS5k54YXVx3pE8n6N";
25 static const std::string addr1 =
"DBFi8XAE1rcdCQfkv9w22n8Y9RxgaJnrDD";
26 static const std::string addr2 =
"DPvKfv1FVp69yZMDzeuugvfZ9pzYiMv1bs";
27 static const std::string addr1C =
"DNPrHK9ezAAUVExFDpZ7EE1xWpPskgp1gP";
28 static const std::string addr2C =
"DNBVSAoc2whPFjZVAZ1pQbXPJk1LRrDC8Q";
31 static const std::string strAddressBad =
"Xta1praZQjyELweyMByXyiREw1ZRsjXzVP";
49 CPubKey pubkey1 = key1. GetPubKey();
50 CPubKey pubkey2 = key2. GetPubKey();
79 for (
int n=0; n<16; n++)
81 std::string strMsg =
strprintf(
"Very secret message %i: 11", n);
82 uint256 hashMsg =
Hash(strMsg.begin(), strMsg.end());
86 std::vector<unsigned char> sign1, sign2, sign1C, sign2C;
115 std::vector<unsigned char> csign1, csign2, csign1C, csign2C;
122 CPubKey rkey1, rkey2, rkey1C, rkey2C;
137 std::vector<unsigned char> detsig, detsigc;
138 std::string strMsg =
"Very deterministic message";
139 uint256 hashMsg =
Hash(strMsg.begin(), strMsg.end());
143 BOOST_CHECK(detsig ==
ParseHex(
"30450221009071d4fead181ea197d6a23106c48ee5de25e023b38afaf71c170e3088e5238a02200dcbc7f1aad626a5ee812e08ef047114642538e423a94b4bd6a272731cf500d0"));
147 BOOST_CHECK(detsig ==
ParseHex(
"304402204f304f1b05599f88bc517819f6d43c69503baea5f253c55ea2d791394f7ce0de02204f23c0d4c1f4d7a89bf130fed755201d22581911a8a44cf594014794231d325a"));
150 BOOST_CHECK(detsig ==
ParseHex(
"1b9071d4fead181ea197d6a23106c48ee5de25e023b38afaf71c170e3088e5238a0dcbc7f1aad626a5ee812e08ef047114642538e423a94b4bd6a272731cf500d0"));
151 BOOST_CHECK(detsigc ==
ParseHex(
"1f9071d4fead181ea197d6a23106c48ee5de25e023b38afaf71c170e3088e5238a0dcbc7f1aad626a5ee812e08ef047114642538e423a94b4bd6a272731cf500d0"));
154 BOOST_CHECK(detsig ==
ParseHex(
"1b4f304f1b05599f88bc517819f6d43c69503baea5f253c55ea2d791394f7ce0de4f23c0d4c1f4d7a89bf130fed755201d22581911a8a44cf594014794231d325a"));
155 BOOST_CHECK(detsigc ==
ParseHex(
"1f4f304f1b05599f88bc517819f6d43c69503baea5f253c55ea2d791394f7ce0de4f23c0d4c1f4d7a89bf130fed755201d22581911a8a44cf594014794231d325a"));
An encapsulated private key.
bool IsValid() const
Check whether this private key is valid.
bool IsCompressed() const
Check whether the public key corresponding to this private key is (to be) compressed.
CPubKey GetPubKey() const
Compute the public key from a private key.
bool Sign(const uint256 &hash, std::vector< unsigned char > &vchSig, uint32_t test_case=0) const
Create a DER-serialized signature.
bool VerifyPubKey(const CPubKey &vchPubKey) const
Verify thoroughly whether a private key and a public key match.
bool SignCompact(const uint256 &hash, std::vector< unsigned char > &vchSig) const
Create a compact signature (65 bytes), which allows reconstructing the used public key.
An encapsulated public key.
bool RecoverCompact(const uint256 &hash, const std::vector< unsigned char > &vchSig)
Recover a public key from a compact signature.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
bool Verify(const uint256 &hash, const std::vector< unsigned char > &vchSig) const
Verify a DER signature (~72 bytes).
BOOST_AUTO_TEST_SUITE_END()
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
BOOST_AUTO_TEST_CASE(key_test1)
CKey DecodeSecret(const std::string &str)
CWDestination DecodeDestination(const std::string &strAddress)
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK(expr)
boost::variant< CNoDestination, CKeyID, CScriptID, CExchangeKeyID > CTxDestination
A txout script template with a specific destination.
std::vector< unsigned char > ParseHex(const char *psz)