diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj index 2244008968..3e08997d20 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj +++ b/Builds/VisualStudio2013/RippleD.vcxproj @@ -3166,12 +3166,6 @@ - - - - - - True @@ -3181,30 +3175,15 @@ True - - True - True - - - - - - - - - - - - diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters index 1cb10beeb2..042774126b 100644 --- a/Builds/VisualStudio2013/RippleD.vcxproj.filters +++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters @@ -4308,15 +4308,6 @@ ripple\types - - ripple\types - - - ripple\types - - - ripple\types - ripple\types\impl @@ -4326,39 +4317,18 @@ ripple\types\impl - - ripple\types\impl - ripple\types\impl ripple\types - - ripple\types - - - ripple\types - - - ripple\types - ripple\types - - ripple\types - ripple\types - - ripple\types - - - ripple\types - ripple\types diff --git a/src/ripple/nodestore/impl/DecodedBlob.cpp b/src/ripple/nodestore/impl/DecodedBlob.cpp index 7c09f5a9b4..a2c6912821 100644 --- a/src/ripple/nodestore/impl/DecodedBlob.cpp +++ b/src/ripple/nodestore/impl/DecodedBlob.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include namespace ripple { diff --git a/src/ripple/protocol/RippleAddress.h b/src/ripple/protocol/RippleAddress.h index 938d1498bc..08b012e601 100644 --- a/src/ripple/protocol/RippleAddress.h +++ b/src/ripple/protocol/RippleAddress.h @@ -25,11 +25,6 @@ #include #include #include -#include -#include -#include -#include -#include namespace ripple { @@ -284,61 +279,6 @@ operator>=(RippleAddress const& lhs, RippleAddress const& rhs) return !(lhs < rhs); } -/** RipplePublicKeyHash */ -template <> -struct RipplePublicKeyHashTraits::assign -{ - void operator() (value_type& value, RippleAddress const& v) const - { - auto const ui (v.getNodeID ()); - construct (ui.begin(), ui.end(), value); - } -}; - -/** RipplePrivateKey */ -template <> -struct RipplePrivateKeyTraits::assign -{ - void operator() (value_type& value, RippleAddress const& v) const - { - uint256 const ui (v.getNodePrivate ()); - construct (ui.begin(), ui.end(), value); - } -}; - -/** RippleAccountID */ -template <> -struct RippleAccountIDTraits::assign -{ - void operator() (value_type& value, RippleAddress const& v) const - { - auto const ui (v.getAccountID ()); - construct (ui.begin(), ui.end(), value); - } -}; - -/** RippleAccountPublicKey */ -template <> -struct RippleAccountPublicKeyTraits::assign -{ - void operator() (value_type& value, RippleAddress const& v) const - { - Blob const& b (v.getAccountPublic ()); - construct (&b.front(), &b.back()+1, value); - } -}; - -/** RippleAccountPrivateKey */ -template <> -struct RippleAccountPrivateKeyTraits::assign -{ - void operator() (value_type& value, RippleAddress const& v) const - { - uint256 const ui (v.getAccountPrivate ()); - construct (ui.begin(), ui.end(), value); - } -}; - } // ripple #endif diff --git a/src/ripple/protocol/impl/RippleAddress.cpp b/src/ripple/protocol/impl/RippleAddress.cpp index 84e142a8f6..bb9f145232 100644 --- a/src/ripple/protocol/impl/RippleAddress.cpp +++ b/src/ripple/protocol/impl/RippleAddress.cpp @@ -981,47 +981,11 @@ public: expect (publicKey.to_string() == deprecatedPublicKey.humanNodePublic(), publicKey.to_string()); - testcase ("RipplePrivateKey"); - RippleAddress deprecatedPrivateKey (RippleAddress::createNodePrivate (seed)); - expect (deprecatedPrivateKey.humanNodePrivate () == - "pnen77YEeUd4fFKG7iycBWcwKpTaeFRkW2WFostaATy1DSupwXe", - deprecatedPrivateKey.humanNodePrivate ()); - RipplePrivateKey privateKey (deprecatedPrivateKey); - expect (privateKey.to_string() == deprecatedPrivateKey.humanNodePrivate(), - privateKey.to_string()); - testcase ("Generator"); RippleAddress generator (RippleAddress::createGeneratorPublic (seed)); expect (generator.humanGenerator () == "fhuJKrhSDzV2SkjLn9qbwm5AaRmrxDPfFsHDCP6yfDZWcxDFz4mt", generator.humanGenerator ()); - - testcase ("RippleAccountID"); - RippleAddress deprecatedAccountPublicKey ( - RippleAddress::createAccountPublic (generator, 0)); - expect (deprecatedAccountPublicKey.humanAccountID () == - "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", - deprecatedAccountPublicKey.humanAccountID ()); - RippleAccountID accountID (deprecatedAccountPublicKey); - expect (accountID.to_string() == - deprecatedAccountPublicKey.humanAccountID(), - accountID.to_string()); - - testcase ("RippleAccountPublicKey"); - expect (deprecatedAccountPublicKey.humanAccountPublic () == - "aBQG8RQAzjs1eTKFEAQXr2gS4utcDiEC9wmi7pfUPTi27VCahwgw", - deprecatedAccountPublicKey.humanAccountPublic ()); - - testcase ("RippleAccountPrivateKey"); - RippleAddress deprecatedAccountPrivateKey ( - RippleAddress::createAccountPrivate (generator, seed, 0)); - expect (deprecatedAccountPrivateKey.humanAccountPrivate () == - "p9JfM6HHi64m6mvB6v5k7G2b1cXzGmYiCNJf6GHPKvFTWdeRVjh", - deprecatedAccountPrivateKey.humanAccountPrivate ()); - RippleAccountPrivateKey accountPrivateKey (deprecatedAccountPrivateKey); - expect (accountPrivateKey.to_string() == - deprecatedAccountPrivateKey.humanAccountPrivate(), - privateKey.to_string()); } }; diff --git a/src/ripple/types/Base58.h b/src/ripple/types/Base58.h index f1de7d2570..47d4bb2b76 100644 --- a/src/ripple/types/Base58.h +++ b/src/ripple/types/Base58.h @@ -87,9 +87,8 @@ public: static Alphabet const& getBitcoinAlphabet (); static Alphabet const& getRippleAlphabet (); - static std::string raw_encode ( - unsigned char const* begin, unsigned char const* end, - Alphabet const& alphabet, bool withCheck); + static std::string raw_encode (unsigned char const* begin, + unsigned char const* end, Alphabet const& alphabet); static void fourbyte_hash256 (void* out, void const* in, std::size_t bytes); @@ -122,7 +121,7 @@ public: std::back_inserter (v)); // Pad zero to make the BIGNUM positive v.push_back (0); - return raw_encode (&v.front(), &v.back()+1, alphabet, withCheck); + return raw_encode (&v.front(), &v.back()+1, alphabet); } template diff --git a/src/ripple/types/CryptoIdentifier.h b/src/ripple/types/CryptoIdentifier.h deleted file mode 100644 index 4c70a8ecf8..0000000000 --- a/src/ripple/types/CryptoIdentifier.h +++ /dev/null @@ -1,137 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_CRYPTOIDENTIFIER_H_INCLUDED -#define RIPPLE_TYPES_CRYPTOIDENTIFIER_H_INCLUDED - -#include -#include -#include -#include -#include -#include - -namespace ripple { - -/** Shared IdentifierType traits for Ripple crypto identifiers. - - @tparam Size The number of bytes in the identifier, exclusive of version, - checksum, or padding. - - @tparam Token A byte prepended to the binary data that distinguishes - the type of identifier. - - @tparam Checked A `bool` indicating whether or not the string - representation includes an appended a four byte checksum on - the data including the Token. -*/ -template -class CryptoIdentifier -{ -public: - typedef std::size_t size_type; - - // 1 token byte, - static std::size_t const pre_size = 1; - static size_type const size = Size; - // 4 checksum bytes (optional) - static std::size_t const post_size = (Checked ? 4 : 0); - static std::uint8_t const token = Token; - static bool const checked = Checked; - - // This is what the wrapper creates, it includes the padding. - typedef IdentifierStorage < - pre_size, size, post_size> value_type; - - typedef typename value_type::hasher hasher; - typedef typename value_type::key_equal key_equal; - - /** Initialize from an input sequence. */ - static void construct ( - std::uint8_t const* begin, std::uint8_t const* end, - value_type& value) - { - value.storage()[0] = Token; - assert (std::distance (begin, end) == size); - std::copy (begin, end, value.begin()); - if (Checked) - { - beast::Sha256::digest_type digest; - auto const& vs = value.storage(); - beast::Sha256::hash (beast::Sha256::hash (vs.data(), - vs.data() + (vs.size() - post_size)), - digest); - // We use the first 4 bytes as a checksum - std::copy (digest.begin(), digest.begin() + 4, - value.end()); - } - } - - /** Base class for IdentifierType. */ - class base - { - public: - template - static value_type createFromInteger (UnsignedIntegralType i) - { - static_assert (size >= sizeof (UnsignedIntegralType), ""); - std::array data; - data.fill (0); - i = beast::toNetworkByteOrder (i); - std::memcpy (data.data () + (data.size() - sizeof (i)), &i, std::min (size, sizeof (i))); - value_type value; - construct (data.data(), data.data() + data.size(), value); - return value; - } - }; - - /** Convert to std::string. */ - static std::string to_string (value_type const& value) - { - typename value_type::storage_type const& storage (value.storage()); - // We will convert to little endian with an extra pad byte - std::array le; - std::reverse_copy (storage.begin(), storage.end(), le.begin()); - // Set pad byte zero to make BIGNUM always positive - le.back() = 0; - return Base58::raw_encode (le.data(), le.data() + le.size(), - Base58::getRippleAlphabet(), Checked); - } - - /** Convert from std::string. */ - static std::pair from_string (std::string const& s) - { - value_type value; - bool success (! s.empty()); - if (success && !Base58::raw_decode (&s.front(), &s.back()+1, - value.storage().data(), value_type::storage_size, Checked, - Base58::getRippleAlphabet())) - success = false; - if (success && value.storage()[0] != Token) - success = false; - return std::make_pair (value, success); - } -}; - -template - typename CryptoIdentifier ::size_type - const CryptoIdentifier ::size; -} - -#endif diff --git a/src/ripple/types/IdentifierStorage.h b/src/ripple/types/IdentifierStorage.h deleted file mode 100644 index 7bccec0f98..0000000000 --- a/src/ripple/types/IdentifierStorage.h +++ /dev/null @@ -1,189 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_IDENTIFIERSTORAGE_H_INCLUDED -#define RIPPLE_TYPES_IDENTIFIERSTORAGE_H_INCLUDED - -#include -#include -#include - -namespace ripple { - -/** A padded std::array used with IdentifierType traits. */ -template -class IdentifierStorage -{ -public: - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef std::uint8_t value_type; - typedef value_type* iterator; - typedef value_type const* const_iterator; - typedef value_type& reference; - typedef value_type const& const_reference; - - static size_type const pre_size = PreSize; - static size_type const size = Size; - static size_type const post_size = PostSize; - static size_type const storage_size = pre_size + size + post_size; - - typedef std::array < - std::uint8_t, storage_size> storage_type; - - /** Value hashing function. - The seed prevents crafted inputs from causing degenarate parent containers. - */ - typedef beast::hardened_hash <> hasher; - - /** Container equality testing function. */ - class key_equal - { - public: - bool operator() (IdentifierStorage const& lhs, - IdentifierStorage const& rhs) const - { - return lhs == rhs; - } - }; - - // iterator access - iterator begin() { return &m_storage[pre_size]; } - const_iterator begin() const { return &m_storage[pre_size]; } - const_iterator cbegin() const { return &m_storage[pre_size]; } - iterator end() { return &m_storage[storage_size-post_size]; } - const_iterator end() const { return &m_storage[storage_size-post_size]; } - const_iterator cend() const { return &m_storage[storage_size-post_size]; } - - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } - const_reverse_iterator crbegin() const { return const_reverse_iterator(end()); } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } - const_reverse_iterator crend() const { return const_reverse_iterator(begin()); } - - reference operator[](size_type i) - { - assert (i < size); - return m_storage[pre_size+i]; - } - - const_reference operator[](size_type i) const - { - assert (i < size); - return m_storage[pre_size+i]; - } - - reference front() { return m_storage[pre_size]; } - reference back() { return m_storage[storage_size-post_size-1]; } - const_reference front () const { return m_storage[pre_size]; } - const_reference back() const { return m_storage[storage_size-post_size-1]; } - - value_type const* data() const { return &m_storage[pre_size]; } - value_type* data() { return &m_storage[pre_size]; } - value_type* c_array() { return &m_storage[pre_size]; } - - void assign (value_type value) { fill (value); } - void fill (value_type value) { std::fill_n (begin(), size, value); } - void clear () { fill (value_type ()); } - - // Access storage - storage_type& storage() { return m_storage; } - storage_type const& storage() const { return m_storage; } - - void rangecheck (size_type i) - { - if (i >= size) - throw std::out_of_range ("IdentifierStorage<>: index out of range"); - } - - bool isZero() const - { - for (const_iterator iter(begin()); iter != end(); ++iter) - if ((*iter)!=0) - return false; - return true; - } - - bool isNotZero() const - { - return !isZero(); - } - - template - friend void hash_append (Hasher& h, IdentifierStorage const& a) noexcept - { - using beast::hash_append; - hash_append (h, a.m_storage); - } - -private: - storage_type m_storage; -}; - -//------------------------------------------------------------------------------ - -template -bool operator== (IdentifierStorage const& lhs, - IdentifierStorage const& rhs) -{ - return std::equal (lhs.begin(), lhs.end(), rhs.begin()); -} - -template -bool operator!= (IdentifierStorage const& lhs, - IdentifierStorage const& rhs) -{ - return !(lhs==rhs); -} - -template -bool operator< (IdentifierStorage const& lhs, - IdentifierStorage const& rhs) -{ - return std::lexicographical_compare (lhs.begin(), lhs.end(), rhs.begin(), rhs.end()); -} - -template -bool operator> (IdentifierStorage const& lhs, - IdentifierStorage const& rhs) -{ - return rhs -bool operator<= (IdentifierStorage const& lhs, - IdentifierStorage const& rhs) -{ - return !(rhs -bool operator>= (IdentifierStorage const& lhs, - IdentifierStorage const& rhs) -{ - return !(lhs -#include -#include -#include -#include -#include -#include - -namespace ripple { - -//------------------------------------------------------------------------------ - -/** Template for generalizing the cryptographic primitives used. */ -template -class IdentifierType : public Traits::base -{ -public: - static std::size_t const size = Traits::size; - typedef typename Traits::value_type value_type; - typedef typename value_type::const_iterator const_iterator; - typedef typename value_type::const_reverse_iterator const_reverse_iterator; - - /** Wraps Traits::hasher. */ - class hasher - { - public: - hasher() - { } - template - hasher (Arg arg) : m_hasher (arg) - { } - std::size_t operator() (IdentifierType const& id) const noexcept - { return m_hasher(id.value()); } - private: - typename Traits::hasher m_hasher; - }; - - /** Wraps Traits::equal. */ - class key_equal - { - public: - key_equal() - { } - template - key_equal (Arg arg) : m_equal (arg) - { } - bool operator() (IdentifierType const& lhs, - IdentifierType const& rhs) const noexcept - { return m_equal (lhs.value(), rhs.value()); } - private: - typename Traits::key_equal m_equal; - }; - - /** Create an uninitialized value. */ - IdentifierType () - { } - - /** Implicit conversion construction from value_type. - This allows the IdentifierType to appear as an lvalue where the - rvalue is the underlying container type. - */ - IdentifierType (value_type const& value) - : m_value (value) - { } - - /** Create a copy of the value from range of bytes. */ - IdentifierType (std::uint8_t const* begin, std::uint8_t const* end) - { Traits::construct (begin, end, m_value); } - - /** Conversion construction from any specialized type. */ - template - explicit IdentifierType (Other const& other) - { - this->operator= (other); - } - - /** Assign a copy from another value. */ - IdentifierType& operator= (value_type const& value) - { - m_value = value; - return *this; - } - - /** Copy conversion from any specialized type. */ - template - IdentifierType& operator= (Other const& other) - { - typename Traits::template assign () ( - m_value, other); - return *this; - } - - /** Access the value. */ - value_type const& value() const - { return m_value; } - - /** Smart dereference. - This provides access to the underlying container for compatibility. - For example, to call member functions that are otherwise not - available. - */ - /** @{ */ - value_type const* operator->() const - { return &value(); } - value_type const& operator*() const - { return value(); } - /** @} */ - - /** Implicit conversion to value_type. - This lets the IdentifierType appear as an rvalue in an assignment - where the lvalue is of type value_type. - */ - operator value_type const& () const - { - return value(); - } - - /** Iterator access. */ - /** @{ */ - const_iterator begin() const { return value().begin(); } - const_iterator end() const { return value().end(); } - const_iterator cbegin() const { return value().cbegin(); } - const_iterator cend() const { return value().cend(); } - const_reverse_iterator rbegin() const { return value().rbegin(); } - const_reverse_iterator rend() const { return value().rend(); } - const_reverse_iterator crbegin() const { return value().crbegin(); } - const_reverse_iterator crend() const { return value().crend(); } - /** @} */ - - /** Conversion to std::string. */ - std::string to_string() const - { - return Traits::to_string (m_value); - } - - /** Conversion from std::string. - The `bool` indicates the success of the conversion. - */ - static std::pair from_string (std::string const& s) - { - return Traits::from_string (s); - } - - -private: - value_type m_value; -}; - -template -inline -void -hash_append(Hasher& h, IdentifierType const& id) -{ - using beast::hash_append; - hash_append (h, id.value()); -} - -//------------------------------------------------------------------------------ - -template -bool operator== (IdentifierType const& lhs, - IdentifierType const& rhs) -{ return lhs.value() == rhs.value(); } - -template -bool operator!= (IdentifierType const& lhs, - IdentifierType const& rhs) -{ return lhs.value() != rhs.value(); } - -template -bool operator< (IdentifierType const& lhs, - IdentifierType const& rhs) -{ return lhs.value() < rhs.value(); } - -template -bool operator> (IdentifierType const& lhs, - IdentifierType const& rhs) -{ return lhs.value() > rhs.value(); } - -template -bool operator<= (IdentifierType const& lhs, - IdentifierType const& rhs) -{ return lhs.value() <= rhs.value(); } - -template -bool operator>= (IdentifierType const& lhs, - IdentifierType const& rhs) -{ return lhs.value() >= rhs.value(); } - -//------------------------------------------------------------------------------ - -template -std::ostream& operator<< (std::ostream& os, - IdentifierType const& id) -{ - os << id.to_string(); - return os; -} - -template -std::istream& operator>> (std::istream& is, - IdentifierType const& id) -{ - return is; -} - -//------------------------------------------------------------------------------ - -} - -namespace std { - -/** Specialization for hash. */ -template -struct hash > -{ -public: - typedef ripple::IdentifierType argument_type; - typedef std::size_t result_type; - - hash () - { - static typename argument_type::hasher s_hash; - m_hash = s_hash; - } - - template - explicit hash (Arg arg) - : m_hash (arg) - { - } - - result_type operator() (argument_type const& key) const - { - return m_hash (key); - } - -private: - typename argument_type::hasher m_hash; -}; - -//------------------------------------------------------------------------------ - -/** Specialization for equal_to. */ -template -struct equal_to > -{ -public: - typedef bool result_type; - typedef ripple::IdentifierType argument_type; - typedef argument_type first_argument_type; - typedef argument_type second_argument_type; - - equal_to () - { - } - - template - explicit equal_to (Arg arg) - : m_equal (arg) - { - } - - result_type operator() (argument_type const& lhs, - argument_type const& rhs) const - { - return m_equal (lhs, rhs); - } - -private: - typename argument_type::key_equal m_equal; -}; - -} - -#endif diff --git a/src/ripple/types/RippleAccountID.h b/src/ripple/types/RippleAccountID.h deleted file mode 100644 index c7261ac0e6..0000000000 --- a/src/ripple/types/RippleAccountID.h +++ /dev/null @@ -1,65 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_RIPPLEACCOUNTID_H_INCLUDED -#define RIPPLE_TYPES_RIPPLEACCOUNTID_H_INCLUDED - -#include -#include - -#include - -namespace ripple { - -class RippleAccountIDTraits - : public CryptoIdentifier <20, 0, true> -{ -public: - template - struct assign - { - void operator() (value_type& value, Other const& other) - { - value = other; - } - }; - - /** Convert to std::string. - */ - // VFALCO TODO Cache results in an associative map, to replicated - // the optimization performed in RippledAddress.cp - // - static std::string to_string (value_type const& value) - { - value_type::storage_type const& storage (value.storage()); - // We will convert to little endian with an extra pad byte - std::array le; - std::reverse_copy (storage.begin(), storage.end(), le.begin()); - // Set pad byte zero to make BIGNUM always positive - le.back() = 0; - return Base58::raw_encode (le.data(), le.data() + le.size(), - Base58::getRippleAlphabet(), checked); - } -}; - -typedef IdentifierType RippleAccountID; - -} - -#endif diff --git a/src/ripple/types/RippleAccountPrivateKey.h b/src/ripple/types/RippleAccountPrivateKey.h deleted file mode 100644 index 68b64a1a32..0000000000 --- a/src/ripple/types/RippleAccountPrivateKey.h +++ /dev/null @@ -1,45 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_RIPPLEACCOUNTPRIVATEKEY_H_INCLUDED -#define RIPPLE_TYPES_RIPPLEACCOUNTPRIVATEKEY_H_INCLUDED - -#include - -namespace ripple { - -class RippleAccountPrivateKeyTraits - : public CryptoIdentifier <32, 34, true> -{ -public: - template - struct assign - { - void operator() (value_type& value, Other const& other) - { - value = other; - } - }; -}; - -typedef IdentifierType RippleAccountPrivateKey; - -} - -#endif diff --git a/src/ripple/types/RippleAccountPublicKey.h b/src/ripple/types/RippleAccountPublicKey.h deleted file mode 100644 index 8f69435a9d..0000000000 --- a/src/ripple/types/RippleAccountPublicKey.h +++ /dev/null @@ -1,45 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_RIPPLEACCOUNTPUBLICKEY_H_INCLUDED -#define RIPPLE_TYPES_RIPPLEACCOUNTPUBLICKEY_H_INCLUDED - -#include - -namespace ripple { - -class RippleAccountPublicKeyTraits - : public CryptoIdentifier <33, 35, true> -{ -public: - template - struct assign - { - void operator() (value_type& value, Other const& other) - { - value = other; - } - }; -}; - -typedef IdentifierType RippleAccountPublicKey; - -} - -#endif diff --git a/src/ripple/types/RippleLedgerHash.h b/src/ripple/types/RippleLedgerHash.h index cecb75a894..aaa7e8a0e3 100644 --- a/src/ripple/types/RippleLedgerHash.h +++ b/src/ripple/types/RippleLedgerHash.h @@ -20,36 +20,11 @@ #ifndef RIPPLE_TYPES_RIPPLELEDGERHASH_H_INCLUDED #define RIPPLE_TYPES_RIPPLELEDGERHASH_H_INCLUDED -#include -#include -#include +#include namespace ripple { -/* - Hashes are used to uniquely identify objects like - transactions, peers, validators, and accounts. - - For historical reasons, some hashes are 256 bits and some are 160. - - David: - "The theory is that you may need to communicate public keys - to others, so having them be shorter is a good idea. plus, - you can't arbitrarily tweak them because you wouldn't know - the corresponding private key anyway. So the security - requirements aren't as great." -*/ -/** The SHA256 bit hash of a signed ledger. */ -class RippleLedgerHashTraits : public SimpleIdentifier <32> -{ -public: -}; - -/** A ledger hash. */ -typedef IdentifierType RippleLedgerHash; - -// Legacy -typedef uint256 LedgerHash; +using LedgerHash = uint256; } diff --git a/src/ripple/types/RipplePrivateKey.h b/src/ripple/types/RipplePrivateKey.h deleted file mode 100644 index 5ae833e9f3..0000000000 --- a/src/ripple/types/RipplePrivateKey.h +++ /dev/null @@ -1,45 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_RIPPLEPRIVATEKEY_H_INCLUDED -#define RIPPLE_TYPES_RIPPLEPRIVATEKEY_H_INCLUDED - -#include - -namespace ripple { - -class RipplePrivateKeyTraits - : public CryptoIdentifier <32, 32, true> -{ -public: - template - struct assign - { - void operator() (value_type& value, Other const& other) - { - value = other; - } - }; -}; - -typedef IdentifierType RipplePrivateKey; - -} - -#endif diff --git a/src/ripple/types/RipplePublicKey.h b/src/ripple/types/RipplePublicKey.h index 4f461abbd4..3fb42563b1 100644 --- a/src/ripple/types/RipplePublicKey.h +++ b/src/ripple/types/RipplePublicKey.h @@ -85,7 +85,7 @@ RipplePublicKey::to_string() const std::reverse_copy (e.begin(), e.end(), le.begin()); le.back() = 0; // make BIGNUM positive return Base58::raw_encode (le.data(), - le.data() + le.size(), Base58::getRippleAlphabet(), true); + le.data() + le.size(), Base58::getRippleAlphabet()); } inline diff --git a/src/ripple/types/RipplePublicKeyHash.h b/src/ripple/types/RipplePublicKeyHash.h deleted file mode 100644 index b858faeed2..0000000000 --- a/src/ripple/types/RipplePublicKeyHash.h +++ /dev/null @@ -1,47 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_RIPPLEPUBLICKEYHASH_H_INCLUDED -#define RIPPLE_TYPES_RIPPLEPUBLICKEYHASH_H_INCLUDED - -#include - -namespace ripple { - -/** Traits for the public key hash. */ -class RipplePublicKeyHashTraits : public SimpleIdentifier <20> -{ -public: - template - struct assign - { - void operator() (value_type& value, Other const& other) - { - value = other; - } - }; -}; - -/** A container holding the 160-bit hash of the 257-bit public key. */ -typedef IdentifierType RipplePublicKeyHash; - -} - -#endif - diff --git a/src/ripple/types/SimpleIdentifier.h b/src/ripple/types/SimpleIdentifier.h deleted file mode 100644 index e6b3c3d2ec..0000000000 --- a/src/ripple/types/SimpleIdentifier.h +++ /dev/null @@ -1,73 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_TYPES_SIMPLEIDENTIFIER_H_INCLUDED -#define RIPPLE_TYPES_SIMPLEIDENTIFIER_H_INCLUDED - -#include - -namespace ripple { - -/** Provides common traits for non-signing identifiers like ledger hashes. - The storage is a suitably sized instance of base_uint. -*/ -template -class SimpleIdentifier -{ -public: - static std::size_t const size = Bytes; - - typedef std::size_t size_type; - typedef base_uint value_type; - typedef typename value_type::hasher hasher; - typedef typename value_type::key_equal key_equal; - - /** Initialize from an input sequence. */ - static void construct ( - std::uint8_t const* begin, std::uint8_t const* end, - value_type& value) - { - std::copy (begin, end, value.begin()); - } - - /** Base class for IdentifierType. */ - struct base { }; - - /** Convert to std::string. */ - static std::string to_string (value_type const& value) - { - return strHex (value.cbegin(), size); - } - - /** Assignment specializations. - When Other is the same as value_type, this is a copy assignment. - */ - template - struct assign - { - void operator() (value_type& value, Other const& other) - { - value = other; - } - }; -}; - -} - -#endif diff --git a/src/ripple/types/impl/Base58.cpp b/src/ripple/types/impl/Base58.cpp index 84dd1ca863..c14ef15536 100644 --- a/src/ripple/types/impl/Base58.cpp +++ b/src/ripple/types/impl/Base58.cpp @@ -66,9 +66,8 @@ Base58::Alphabet const& Base58::getRippleAlphabet () return alphabet; } -std::string Base58::raw_encode ( - unsigned char const* begin, unsigned char const* end, - Alphabet const& alphabet, bool withCheck) +std::string Base58::raw_encode (unsigned char const* begin, + unsigned char const* end, Alphabet const& alphabet) { CAutoBN_CTX pctx; CBigNum bn58 = 58; diff --git a/src/ripple/types/impl/RippleIdentifierTests.cpp b/src/ripple/types/impl/RippleIdentifierTests.cpp deleted file mode 100644 index a9a2ea5865..0000000000 --- a/src/ripple/types/impl/RippleIdentifierTests.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -namespace ripple { - -// Relocated to RippleAddress.cpp - -} diff --git a/src/ripple/unity/types.cpp b/src/ripple/unity/types.cpp index f5834592a2..d7a553b398 100644 --- a/src/ripple/unity/types.cpp +++ b/src/ripple/unity/types.cpp @@ -22,5 +22,4 @@ #include #include #include -#include #include