diff --git a/src/ripple/basics/Slice.h b/src/ripple/basics/Slice.h index 83ab9a7a0..8b320e3ad 100644 --- a/src/ripple/basics/Slice.h +++ b/src/ripple/basics/Slice.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_BASICS_SLICE_H_INCLUDED #define RIPPLE_BASICS_SLICE_H_INCLUDED +#include #include #include #include @@ -96,6 +97,13 @@ operator== (Slice const& lhs, Slice const& rhs) noexcept lhs.data(), rhs.data(), lhs.size()) == 0; } +inline +bool +operator!= (Slice const& lhs, Slice const& rhs) noexcept +{ + return !(lhs == rhs); +} + inline bool operator< (Slice const& lhs, Slice const& rhs) noexcept @@ -105,6 +113,13 @@ operator< (Slice const& lhs, Slice const& rhs) noexcept rhs.data(), rhs.data() + rhs.size()); } +template +Stream& operator<<(Stream& s, Slice const& v) +{ + s << strHex(v.data(), v.size()); + return s; +} + } // ripple #endif diff --git a/src/ripple/crypto/KeyType.h b/src/ripple/crypto/KeyType.h index e555e8e5f..9e2f809ae 100644 --- a/src/ripple/crypto/KeyType.h +++ b/src/ripple/crypto/KeyType.h @@ -37,6 +37,13 @@ KeyType keyTypeFromString (std::string const& s); const char* to_string (KeyType type); +template +inline +Stream& operator<<(Stream& s, KeyType type) +{ + return s << to_string(type); +} + } #endif diff --git a/src/ripple/protocol/AnyPublicKey.h b/src/ripple/protocol/AnyPublicKey.h index f909c681e..52f779966 100644 --- a/src/ripple/protocol/AnyPublicKey.h +++ b/src/ripple/protocol/AnyPublicKey.h @@ -102,9 +102,16 @@ private: public: AnyPublicKey() = delete; - AnyPublicKey (AnyPublicKey const&) = delete; AnyPublicKey& operator= (AnyPublicKey const&) = delete; + AnyPublicKey (AnyPublicKey const& other) + : buffer_type(other.buffer_type::member.data(), + other.buffer_type::member.size()) + , AnyPublicKeySlice (buffer_type::member.data(), + buffer_type::member.size()) + { + } + #ifdef _MSC_VER AnyPublicKey (AnyPublicKey&& other) : buffer_type(std::move(other.buffer_type::member)) diff --git a/src/ripple/protocol/impl/AnySecretKey.cpp b/src/ripple/protocol/impl/AnySecretKey.cpp index 702d5a7f4..c3b3dd800 100644 --- a/src/ripple/protocol/impl/AnySecretKey.cpp +++ b/src/ripple/protocol/impl/AnySecretKey.cpp @@ -77,7 +77,7 @@ AnySecretKey::publicKey() const { unsigned char buf[33]; buf[0] = 0xED; - ed25519_publickey(p_.data() + 1, &buf[1]); + ed25519_publickey(p_.data(), &buf[1]); return AnyPublicKey(buf, sizeof(buf)); } default: @@ -94,7 +94,7 @@ AnySecretKey::sign ( { case KeyType::ed25519: { - auto const sk = p_.data() + 1; + auto const sk = p_.data(); ed25519_public_key pk; ed25519_publickey(sk, pk); Buffer b(64); diff --git a/src/ripple/unity/protocol.cpp b/src/ripple/unity/protocol.cpp index 94c18b296..62c4acab8 100644 --- a/src/ripple/unity/protocol.cpp +++ b/src/ripple/unity/protocol.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include