Simplify RipplePublicKey:

This implements the bare minimum necessary to store a 33 byte public
key and use it in ordered containers. It is an efficient and well
defined alternative to RippleAddress when the caller only needs
a node public key.
This commit is contained in:
Vinnie Falco
2014-12-12 14:20:28 -08:00
parent 2f6af906f4
commit 28b09bde4b
7 changed files with 89 additions and 40 deletions

View File

@@ -26,6 +26,7 @@
#include <ripple/crypto/RFC1751.h>
#include <ripple/protocol/RippleAddress.h>
#include <ripple/protocol/Serializer.h>
#include <ripple/types/RipplePublicKey.h>
#include <beast/unit_test/suite.h>
#include <openssl/ripemd.h>
#include <openssl/bn.h>
@@ -137,6 +138,13 @@ RippleAddress RippleAddress::createNodePublic (std::string const& strPublic)
return naNew;
}
RipplePublicKey
RippleAddress::toPublicKey() const
{
assert (nVersion == VER_NODE_PUBLIC);
return RipplePublicKey (vchData.begin(), vchData.end());
}
NodeID RippleAddress::getNodeID () const
{
switch (nVersion)
@@ -969,7 +977,7 @@ public:
expect (deprecatedPublicKey.humanNodePublic () ==
"n94a1u4jAz288pZLtw6yFWVbi89YamiC6JBXPVUj5zmExe5fTVg9",
deprecatedPublicKey.humanNodePublic ());
RipplePublicKey publicKey (deprecatedPublicKey);
RipplePublicKey publicKey = deprecatedPublicKey.toPublicKey();
expect (publicKey.to_string() == deprecatedPublicKey.humanNodePublic(),
publicKey.to_string());