diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj
index 4c59cff8eb..4b7d562e61 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj
+++ b/Builds/VisualStudio2013/RippleD.vcxproj
@@ -2711,10 +2711,6 @@
-
-
-
-
@@ -2729,14 +2725,6 @@
True
True
-
- True
- True
-
-
- True
- True
-
True
True
diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters
index 65c2f9f706..7a6ef94178 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters
@@ -3435,12 +3435,6 @@
ripple\protocol
-
- ripple\protocol
-
-
- ripple\protocol
-
ripple\protocol
@@ -3459,12 +3453,6 @@
ripple\protocol\impl
-
- ripple\protocol\impl
-
-
- ripple\protocol\impl
-
ripple\protocol\impl
diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp
index 9f4421648a..ed57303f01 100644
--- a/src/ripple/app/ledger/Ledger.cpp
+++ b/src/ripple/app/ledger/Ledger.cpp
@@ -38,6 +38,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -134,8 +135,7 @@ makeGenesisAccount (AccountID const& id,
// other constructor with appropriate parameters, and
// then create the master account / flush dirty.
//
-// VFALCO Use `AnyPublicKey masterPublicKey`
-Ledger::Ledger (RippleAddress const& masterPublicKey,
+Ledger::Ledger (AccountID const& masterAccountID,
std::uint64_t balanceInDrops)
: mTotCoins (balanceInDrops)
, mCloseResolution (ledgerDefaultTimeResolution)
@@ -151,8 +151,7 @@ Ledger::Ledger (RippleAddress const& masterPublicKey,
// first ledger
info_.seq = 1;
auto const sle = makeGenesisAccount(
- calcAccountID(masterPublicKey),
- balanceInDrops);
+ masterAccountID, balanceInDrops);
WriteLog (lsTRACE, Ledger)
<< "root account: " << sle->getJson(0);
rawInsert(sle);
diff --git a/src/ripple/app/ledger/Ledger.h b/src/ripple/app/ledger/Ledger.h
index d380fcb6a1..d3e5dd0a37 100644
--- a/src/ripple/app/ledger/Ledger.h
+++ b/src/ripple/app/ledger/Ledger.h
@@ -82,10 +82,10 @@ public:
/** Construct the genesis ledger.
- @param masterPublicKey The public of the account that
- will hold `startAmount` XRP in drops.
+ @param masterAccountID The public of the account that
+ will hold `balanceInDrops` XRP in drops.
*/
- Ledger (RippleAddress const& masterPublicKey,
+ Ledger (AccountID const& masterAccountID,
std::uint64_t balanceInDrops);
// Used for ledgers loaded from JSON files
diff --git a/src/ripple/app/ledger/LedgerProposal.cpp b/src/ripple/app/ledger/LedgerProposal.cpp
index c53bbe62d8..c390dd71d6 100644
--- a/src/ripple/app/ledger/LedgerProposal.cpp
+++ b/src/ripple/app/ledger/LedgerProposal.cpp
@@ -33,6 +33,7 @@ LedgerProposal::LedgerProposal (
uint256 const& tx,
std::uint32_t closeTime,
RippleAddress const& publicKey,
+ PublicKey const& pk,
uint256 const& suppression)
: mPreviousLedger (pLgr)
, mCurrentHash (tx)
@@ -40,6 +41,7 @@ LedgerProposal::LedgerProposal (
, mCloseTime (closeTime)
, mProposeSeq (seq)
, mPublicKey (publicKey)
+ , publicKey_ (pk)
{
mPeerID = mPublicKey.getNodeID ();
mTime = std::chrono::steady_clock::now ();
@@ -72,12 +74,47 @@ uint256 LedgerProposal::getSigningHash () const
mCurrentHash);
}
+struct HashStream
+{
+ static beast::endian const endian =
+ beast::endian::big;
+
+ std::vector v;
+
+ std::uint8_t const*
+ data() const
+ {
+ return v.data();
+ }
+
+ std::size_t
+ size() const
+ {
+ return v.size();
+ }
+
+ void
+ operator()(void const* data,
+ std::size_t size) noexcept
+ {
+ auto const p = reinterpret_cast<
+ std::uint8_t const*>(data);
+ v.insert(v.end(), p, p + size);
+ }
+};
+
bool LedgerProposal::checkSign (std::string const& signature) const
{
- return mPublicKey.verifyNodePublic (
- getSigningHash (),
- signature,
- ECDSA::not_strict);
+ auto const valid = mPublicKey.verifyNodePublic(
+ getSigningHash(), signature, ECDSA::not_strict);
+
+ HashStream h;
+ hash_append(h);
+ assert(valid == (publicKey_.verify(
+ Slice(h.data(), h.size()),
+ makeSlice(signature), false)));
+
+ return valid;
}
bool LedgerProposal::changePosition (
diff --git a/src/ripple/app/ledger/LedgerProposal.h b/src/ripple/app/ledger/LedgerProposal.h
index 4f9f0139d1..cce4d7a1f7 100644
--- a/src/ripple/app/ledger/LedgerProposal.h
+++ b/src/ripple/app/ledger/LedgerProposal.h
@@ -23,7 +23,10 @@
#include
#include
#include
+#include
+#include
#include
+#include
#include
#include
#include
@@ -53,6 +56,7 @@ public:
uint256 const& propose,
std::uint32_t closeTime,
RippleAddress const& publicKey,
+ PublicKey const& pk,
uint256 const& suppress);
// Our own proposal: the publicKey, if set, indicates we are a validating
@@ -116,11 +120,24 @@ public:
Json::Value getJson () const;
private:
+ template
+ void
+ hash_append (Hasher& h) const
+ {
+ using beast::hash_append;
+ hash_append(h, HashPrefix::proposal);
+ hash_append(h, std::uint32_t(mProposeSeq));
+ hash_append(h, std::uint32_t(mCloseTime));
+ hash_append(h, mPreviousLedger);
+ hash_append(h, mCurrentHash);
+ }
+
uint256 mPreviousLedger, mCurrentHash, mSuppression;
std::uint32_t mCloseTime, mProposeSeq;
NodeID mPeerID;
RippleAddress mPublicKey;
+ PublicKey publicKey_;
std::chrono::steady_clock::time_point mTime;
};
diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp
index e0c8f0a598..1550d195b3 100644
--- a/src/ripple/app/main/Application.cpp
+++ b/src/ripple/app/main/Application.cpp
@@ -59,6 +59,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -1048,7 +1049,13 @@ void ApplicationImp::startNewLedger ()
m_journal.info << "Root account: " << toBase58(calcAccountID(rootAddress));
{
- Ledger::pointer firstLedger = std::make_shared (rootAddress, SYSTEM_CURRENCY_START);
+ auto const masterAccountID =
+ calcAccountID(generateKeyPair(
+ KeyType::secp256k1,
+ generateSeed("masterpassphrase")).first);
+
+ auto firstLedger = std::make_shared(
+ masterAccountID, SYSTEM_CURRENCY_START);
assert (firstLedger->exists(keylet::account(
calcAccountID(rootAddress))));
// TODO(david): Add any default amendments
diff --git a/src/ripple/app/misc/UniqueNodeList.cpp b/src/ripple/app/misc/UniqueNodeList.cpp
index fc33590fd8..ecc1a5fbdf 100644
--- a/src/ripple/app/misc/UniqueNodeList.cpp
+++ b/src/ripple/app/misc/UniqueNodeList.cpp
@@ -93,18 +93,6 @@ strJoin (Iterator first, Iterator last, std::string strSeparator)
return ossValues.str ();
}
-static
-std::string
-encodeCredential (AnyPublicKey const& pk, unsigned char type)
-{
- Blob buffer;
- buffer.reserve(1 + pk.size());
- buffer.push_back (type);
- auto const data = pk.data();
- buffer.insert (buffer.end(), data, data + pk.size());
- return Base58::encodeWithCheck (buffer);
-}
-
template
void selectBlobsIntoStrings (
soci::session& s,
@@ -229,7 +217,7 @@ private:
// XXX Make this faster, make this the contents vector unsigned char or raw public key.
// XXX Contents needs to based on score.
hash_set mUNL;
- hash_map ephemeralValidatorKeys_;
+ hash_map ephemeralValidatorKeys_;
boost::posix_time::ptime mtpScoreNext; // When to start scoring.
boost::posix_time::ptime mtpScoreStart; // Time currently started scoring.
@@ -260,8 +248,8 @@ public:
// Get update times and start fetching and scoring as needed.
void start();
- void insertEphemeralKey (AnyPublicKey pk, std::string comment);
- void deleteEphemeralKey (AnyPublicKey const& pk);
+ void insertEphemeralKey (PublicKey pk, std::string comment);
+ void deleteEphemeralKey (PublicKey const& pk);
// Add a trusted node. Called by RPC or other source.
void nodeAddPublic (RippleAddress const& naNodePublic, ValidatorSource vsWhy, std::string const& strComment);
@@ -487,14 +475,14 @@ void UniqueNodeListImp::start()
//--------------------------------------------------------------------------
-void UniqueNodeListImp::insertEphemeralKey (AnyPublicKey pk, std::string comment)
+void UniqueNodeListImp::insertEphemeralKey (PublicKey pk, std::string comment)
{
ScopedUNLLockType sl (mUNLLock);
ephemeralValidatorKeys_.insert (std::make_pair(std::move(pk), std::move(comment)));
}
-void UniqueNodeListImp::deleteEphemeralKey (AnyPublicKey const& pk)
+void UniqueNodeListImp::deleteEphemeralKey (PublicKey const& pk)
{
ScopedUNLLockType sl (mUNLLock);
@@ -648,7 +636,7 @@ void UniqueNodeListImp::nodeScore()
bool UniqueNodeListImp::nodeInUNL (RippleAddress const& naNodePublic)
{
auto const& blob = naNodePublic.getNodePublic();
- AnyPublicKey const pk (blob.data(), blob.size());
+ PublicKey const pk (Slice(blob.data(), blob.size()));
ScopedUNLLockType sl (mUNLLock);
@@ -932,7 +920,7 @@ Json::Value UniqueNodeListImp::getUnlJson()
{
Json::Value node (Json::objectValue);
- node["publicKey"] = encodeCredential (key.first, TOKEN_NODE_PUBLIC);
+ node["publicKey"] = toBase58(TokenType::TOKEN_NODE_PUBLIC, key.first);
node["comment"] = key.second;
ret.append (node);
diff --git a/src/ripple/app/misc/UniqueNodeList.h b/src/ripple/app/misc/UniqueNodeList.h
index 83b6c82695..fdafbd482a 100644
--- a/src/ripple/app/misc/UniqueNodeList.h
+++ b/src/ripple/app/misc/UniqueNodeList.h
@@ -21,7 +21,7 @@
#define RIPPLE_APP_PEERS_UNIQUENODELIST_H_INCLUDED
#include
-#include
+#include
#include
#include //
#include
@@ -55,8 +55,8 @@ public:
// VFALCO TODO Roll this into the constructor so there is one less state.
virtual void start () = 0;
- virtual void insertEphemeralKey (AnyPublicKey pk, std::string comment) = 0;
- virtual void deleteEphemeralKey (AnyPublicKey const& pk) = 0;
+ virtual void insertEphemeralKey (PublicKey pk, std::string comment) = 0;
+ virtual void deleteEphemeralKey (PublicKey const& pk) = 0;
// VFALCO TODO rename all these, the "node" prefix is redundant (lol)
virtual void nodeAddPublic (RippleAddress const& naNodePublic, ValidatorSource vsWhy, std::string const& strComment) = 0;
diff --git a/src/ripple/ledger/tests/View_test.cpp b/src/ripple/ledger/tests/View_test.cpp
index 09383a1cbb..8e644a03bd 100644
--- a/src/ripple/ledger/tests/View_test.cpp
+++ b/src/ripple/ledger/tests/View_test.cpp
@@ -147,10 +147,7 @@ class View_test
testLedger()
{
using namespace jtx;
- Account const master("master");
- auto const ledger =
- std::make_shared(
- master.pk(), 1000000000);
+ auto const ledger = Env::genesis();
wipe(*ledger);
ReadView& v = *ledger;
succ(v, 0, boost::none);
@@ -391,10 +388,7 @@ class View_test
// ApplyView on that, then another ApplyView,
// erase the item, apply.
{
- Account const master("master");
- auto const ledger =
- std::make_shared(
- master.pk(), 1000000000);
+ auto const ledger = Env::genesis();
wipe(*ledger);
ledger->rawInsert(sle(1));
ReadView& v0 = *ledger;
diff --git a/src/ripple/overlay/impl/Manifest.cpp b/src/ripple/overlay/impl/Manifest.cpp
index 60a8daca30..528e452bde 100644
--- a/src/ripple/overlay/impl/Manifest.cpp
+++ b/src/ripple/overlay/impl/Manifest.cpp
@@ -36,8 +36,8 @@ make_Manifest (std::string s)
STObject st (sfGeneric);
SerialIter sit (s.data (), s.size ());
st.set (sit);
- auto const opt_pk = get(st, sfPublicKey);
- auto const opt_spk = get(st, sfSigningPubKey);
+ auto const opt_pk = get(st, sfPublicKey);
+ auto const opt_spk = get(st, sfSigningPubKey);
auto const opt_seq = get (st, sfSequence);
auto const opt_sig = get (st, sfSignature);
if (!opt_pk || !opt_spk || !opt_seq || !opt_sig)
@@ -57,11 +57,11 @@ Stream&
logMftAct (
Stream& s,
std::string const& action,
- AnyPublicKey const& pk,
+ PublicKey const& pk,
std::uint32_t seq)
{
s << "Manifest: " << action <<
- ";Pk: " << toString (pk) <<
+ ";Pk: " << toBase58 (TokenType::TOKEN_NODE_PUBLIC, pk) <<
";Seq: " << seq << ";";
return s;
}
@@ -70,20 +70,20 @@ template
Stream& logMftAct (
Stream& s,
std::string const& action,
- AnyPublicKey const& pk,
+ PublicKey const& pk,
std::uint32_t seq,
std::uint32_t oldSeq)
{
s << "Manifest: " << action <<
- ";Pk: " << toString (pk) <<
+ ";Pk: " << toBase58 (TokenType::TOKEN_NODE_PUBLIC, pk) <<
";Seq: " << seq <<
";OldSeq: " << oldSeq << ";";
return s;
}
Manifest::Manifest (std::string s,
- AnyPublicKey pk,
- AnyPublicKey spk,
+ PublicKey pk,
+ PublicKey spk,
std::uint32_t seq)
: serialized (std::move (s))
, masterKey (std::move (pk))
@@ -97,7 +97,7 @@ bool Manifest::verify () const
STObject st (sfGeneric);
SerialIter sit (serialized.data (), serialized.size ());
st.set (sit);
- return ripple::verify (st, HashPrefix::manifest, masterKey);
+ return ripple::verify (st, HashPrefix::manifest, masterKey, true);
}
uint256 Manifest::hash () const
@@ -146,11 +146,11 @@ ManifestCache::configValidatorKey(
throw std::runtime_error ("Expected Ed25519 key (0xED)");
}
- auto const masterKey = AnyPublicKey (key.data() + 1, key.size() - 1);
+ auto const masterKey = PublicKey (Slice(key.data() + 1, key.size() - 1));
std::string comment = std::move(words[1]);
if (journal.debug) journal.debug
- << masterKey << " " << comment;
+ << toBase58(TokenType::TOKEN_NODE_PUBLIC, masterKey) << " " << comment;
addTrustedKey (masterKey, std::move(comment));
}
@@ -172,7 +172,7 @@ ManifestCache::configManifest(Manifest m, beast::Journal const& journal)
}
void
-ManifestCache::addTrustedKey (AnyPublicKey const& pk, std::string comment)
+ManifestCache::addTrustedKey (PublicKey const& pk, std::string comment)
{
std::lock_guard lock (mutex_);
@@ -188,7 +188,7 @@ ManifestCache::addTrustedKey (AnyPublicKey const& pk, std::string comment)
}
ManifestDisposition
-ManifestCache::canApply (AnyPublicKey const& pk, std::uint32_t seq,
+ManifestCache::canApply (PublicKey const& pk, std::uint32_t seq,
beast::Journal const& journal) const
{
auto const iter = map_.find(pk);
diff --git a/src/ripple/overlay/impl/Manifest.h b/src/ripple/overlay/impl/Manifest.h
index 90e46d3c5a..6865a17872 100644
--- a/src/ripple/overlay/impl/Manifest.h
+++ b/src/ripple/overlay/impl/Manifest.h
@@ -22,7 +22,7 @@
#include
#include
-#include
+#include
#include
#include
#include
@@ -85,11 +85,11 @@ namespace ripple {
struct Manifest
{
std::string serialized;
- AnyPublicKey masterKey;
- AnyPublicKey signingKey;
+ PublicKey masterKey;
+ PublicKey signingKey;
std::uint32_t sequence;
- Manifest(std::string s, AnyPublicKey pk, AnyPublicKey spk, std::uint32_t seq);
+ Manifest(std::string s, PublicKey pk, PublicKey spk, std::uint32_t seq);
#ifdef _MSC_VER
Manifest(Manifest&& other)
@@ -166,7 +166,7 @@ private:
#endif
MappedType(std::string comment,
std::string serialized,
- AnyPublicKey pk, AnyPublicKey spk, std::uint32_t seq)
+ PublicKey pk, PublicKey spk, std::uint32_t seq)
:comment (std::move(comment))
{
m.emplace (std::move(serialized), std::move(pk), std::move(spk),
@@ -177,13 +177,13 @@ private:
boost::optional m;
};
- using MapType = hash_map;
+ using MapType = hash_map;
mutable std::mutex mutex_;
MapType map_;
ManifestDisposition
- canApply (AnyPublicKey const& pk, std::uint32_t seq,
+ canApply (PublicKey const& pk, std::uint32_t seq,
beast::Journal const& journal) const;
public:
@@ -195,7 +195,7 @@ public:
void configValidatorKey(std::string const& line, beast::Journal const& journal);
void configManifest(Manifest m, beast::Journal const& journal);
- void addTrustedKey (AnyPublicKey const& pk, std::string comment);
+ void addTrustedKey (PublicKey const& pk, std::string comment);
ManifestDisposition
applyManifest (Manifest m, beast::Journal const& journal);
diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp
index 4d469a3589..35a62ad9dc 100644
--- a/src/ripple/overlay/impl/PeerImp.cpp
+++ b/src/ripple/overlay/impl/PeerImp.cpp
@@ -1147,13 +1147,14 @@ PeerImp::onMessage (std::shared_ptr const& m)
if ((set.closetime() + 180) < getApp().getOPs().getCloseTimeNC())
return;
+ auto const type = publicKeyType(
+ makeSlice(set.nodepubkey()));
+
// VFALCO Magic numbers are bad
// Roll this into a validation function
- if (
+ if ((! type) ||
(set.currenttxhash ().size () != 32) ||
- (set.nodepubkey ().size () < 28) ||
(set.signature ().size () < 56) ||
- (set.nodepubkey ().size () > 128) ||
(set.signature ().size () > 128)
)
{
@@ -1215,7 +1216,8 @@ PeerImp::onMessage (std::shared_ptr const& m)
auto proposal = std::make_shared (
prevLedger, set.proposeseq (), proposeHash, set.closetime (),
- signerPublic, suppression);
+ signerPublic, PublicKey(makeSlice(set.nodepubkey())),
+ suppression);
getApp().getJobQueue ().addJob (isTrusted ? jtPROPOSAL_t : jtPROPOSAL_ut,
"recvPropose->checkPropose", std::bind(beast::weak_fn(
diff --git a/src/ripple/overlay/tests/manifest_test.cpp b/src/ripple/overlay/tests/manifest_test.cpp
index 93fd3b66a1..00409360ba 100644
--- a/src/ripple/overlay/tests/manifest_test.cpp
+++ b/src/ripple/overlay/tests/manifest_test.cpp
@@ -22,6 +22,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -85,18 +86,18 @@ public:
Manifest
make_Manifest
- (AnySecretKey const& sk, AnyPublicKey const& spk, int seq,
+ (KeyType type, SecretKey const& sk, PublicKey const& spk, int seq,
bool broken = false)
{
- auto const pk = sk.publicKey();
+ auto const pk = derivePublicKey(type, sk);
STObject st(sfGeneric);
set(st, sfSequence, seq);
set(st, sfPublicKey, pk);
set(st, sfSigningPubKey, spk);
- sign(st, HashPrefix::manifest, sk);
- expect(verify(st, HashPrefix::manifest, pk));
+ sign(st, HashPrefix::manifest, type, sk);
+ expect(verify(st, HashPrefix::manifest, pk, true));
if (broken)
{
@@ -191,19 +192,19 @@ public:
beast::Journal journal;
- auto const sk_a = AnySecretKey::make_ed25519 ();
- auto const sk_b = AnySecretKey::make_ed25519 ();
- auto const pk_a = sk_a.publicKey ();
- auto const pk_b = sk_b.publicKey ();
- auto const kp_a = AnySecretKey::make_secp256k1_pair ();
- auto const kp_b = AnySecretKey::make_secp256k1_pair ();
+ auto const sk_a = randomSecretKey();
+ auto const pk_a = derivePublicKey(KeyType::ed25519, sk_a);
+ auto const kp_a = randomKeyPair(KeyType::secp256k1);
+ auto const s_a0 = make_Manifest (KeyType::ed25519, sk_a, kp_a.first, 0);
+ auto const s_a1 = make_Manifest (KeyType::ed25519, sk_a, kp_a.first, 1);
- auto const s_a0 = make_Manifest (sk_a, kp_a.second, 0);
- auto const s_a1 = make_Manifest (sk_a, kp_a.second, 1);
- auto const s_b0 = make_Manifest (sk_b, kp_b.second, 0);
- auto const s_b1 = make_Manifest (sk_b, kp_b.second, 1);
+ auto const sk_b = randomSecretKey();
+ auto const pk_b = derivePublicKey(KeyType::ed25519, sk_b);
+ auto const kp_b = randomKeyPair(KeyType::secp256k1);
+ auto const s_b0 = make_Manifest (KeyType::ed25519, sk_b, kp_b.first, 0);
+ auto const s_b1 = make_Manifest (KeyType::ed25519, sk_b, kp_b.first, 1);
auto const s_b2 =
- make_Manifest (sk_b, kp_b.second, 2, true); // broken
+ make_Manifest (KeyType::ed25519, sk_b, kp_b.first, 2, true); // broken
auto const fake = s_b1.serialized + '\0';
expect (cache.applyManifest (clone (s_a0), journal) == untrusted,
diff --git a/src/ripple/protocol/AccountID.h b/src/ripple/protocol/AccountID.h
index 854fb36bb4..3cafab39a6 100644
--- a/src/ripple/protocol/AccountID.h
+++ b/src/ripple/protocol/AccountID.h
@@ -22,7 +22,7 @@
#include
// VFALCO Uncomment when the header issues are resolved
-//#include
+//#include
#include
#include
#include
@@ -33,9 +33,6 @@
namespace ripple {
-// VFALCO Forward declared due to header issues
-class AnyPublicKey;
-
namespace detail {
class AccountIDTag { };
@@ -96,8 +93,9 @@ parseHexOrBase58 (std::string const& s);
guard bytes included in the base58 representation.
*/
-AccountID
-calcAccountID (AnyPublicKey const& pk);
+// VFALCO In PublicKey.h for now
+//AccountID
+//calcAccountID (PublicKey const& pk);
/** A special account that's used as the "issuer" for XRP. */
AccountID const&
diff --git a/src/ripple/protocol/AnyPublicKey.h b/src/ripple/protocol/AnyPublicKey.h
deleted file mode 100644
index 9b83c38574..0000000000
--- a/src/ripple/protocol/AnyPublicKey.h
+++ /dev/null
@@ -1,188 +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_PROTOCOL_ANYPUBLICKEY_H_INCLUDED
-#define RIPPLE_PROTOCOL_ANYPUBLICKEY_H_INCLUDED
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace ripple {
-
-/** Variant container for all public keys. */
-class AnyPublicKeySlice
- : public Slice
-{
-public:
-#ifdef _MSC_VER
- AnyPublicKeySlice (
- void const* data, std::size_t size)
- : Slice (data, size)
- {
- }
-#else
- using Slice::Slice;
-#endif
-
- AnyPublicKeySlice() = delete;
-
- AnyPublicKeySlice (
- AnyPublicKeySlice const&) = default;
-
- AnyPublicKeySlice& operator= (
- AnyPublicKeySlice const&) = default;
-
- /** Returns the type of key stored. */
- KeyType
- type() const noexcept;
-
- /** Verify a signature using this public key. */
- bool
- verify (void const* msg, std::size_t msg_size,
- void const* sig, std::size_t sig_size) const;
-};
-
-template <>
-struct STExchange
-{
- using value_type = AnyPublicKeySlice;
-
- static
- void
- get (boost::optional& t,
- STBlob const& u)
- {
- t = boost::in_place(u.data(), u.size());
- }
-
- static
- std::unique_ptr
- set (SField const& f, AnyPublicKeySlice const& t)
- {
- return std::make_unique(
- f, t.data(), t.size());
- }
-};
-
-//------------------------------------------------------------------------------
-
-/** Variant container for all public keys, with ownership. */
-class AnyPublicKey
- : private boost::base_from_member
- , public AnyPublicKeySlice
-{
-private:
- using buffer_type = boost::base_from_member;
-
-public:
- AnyPublicKey() = 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))
- , AnyPublicKeySlice (buffer_type::member.data(),
- buffer_type::member.size())
- {
- }
-
- AnyPublicKey& operator= (AnyPublicKey&& other)
- {
- buffer_type::member =
- std::move (other.buffer_type::member);
- AnyPublicKeySlice::operator= (other);
- return *this;
- }
-#else
- AnyPublicKey (AnyPublicKey&&) = default;
- AnyPublicKey& operator= (AnyPublicKey&&) = default;
-#endif
-
- AnyPublicKey (void const* data_, std::size_t size_)
- : buffer_type (data_, size_)
- , AnyPublicKeySlice (
- member.data(), member.size())
- {
- }
-
- /** Returns ownership of the underlying Buffer.
- After calling this function, only the destructor
- or the move assignment operator may be called.
- */
- Buffer
- releaseBuffer() noexcept
- {
- return std::move(buffer_type::member);
- }
-};
-
-template <>
-struct STExchange
-{
- using value_type = AnyPublicKey;
-
- static
- void
- get (boost::optional& t,
- STBlob const& u)
- {
- t = boost::in_place(u.data(), u.size());
- }
-
- static
- std::unique_ptr
- set (SField const& f, AnyPublicKey const& t)
- {
- return std::make_unique(
- f, t.data(), t.size());
- }
-
- static
- std::unique_ptr
- set (SField const& f, AnyPublicKey&& t)
- {
- return std::make_unique(
- f, t.releaseBuffer());
- }
-};
-
-std::string
-toString (AnyPublicKey const& pk);
-
-} // ripple
-
-#endif
diff --git a/src/ripple/protocol/AnySecretKey.h b/src/ripple/protocol/AnySecretKey.h
deleted file mode 100644
index a92cc82812..0000000000
--- a/src/ripple/protocol/AnySecretKey.h
+++ /dev/null
@@ -1,85 +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_PROTOCOL_ANYSECRETKEY_H_INCLUDED
-#define RIPPLE_PROTOCOL_ANYSECRETKEY_H_INCLUDED
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace ripple {
-
-/** Variant container for secret key, with ownership. */
-class AnySecretKey
-{
-private:
- Buffer p_;
- KeyType type_;
-
-public:
- AnySecretKey() = delete;
- AnySecretKey (AnySecretKey const&) = delete;
- AnySecretKey& operator= (AnySecretKey const&) = delete;
-
- /** Destroy the key.
- The memory area is secure erased.
- */
- ~AnySecretKey();
-
- AnySecretKey (AnySecretKey&& other);
-
- AnySecretKey& operator= (AnySecretKey&& other);
-
- AnySecretKey (KeyType type,
- void const* data, std::size_t size);
-
- /** Returns the type of secret key. */
- KeyType
- type() const noexcept
- {
- return type_;
- }
-
- /** Returns the corresponding public key. */
- AnyPublicKey
- publicKey() const;
-
- /** Create a signature for the given message. */
- Buffer
- sign (void const* msg, std::size_t msg_len) const;
-
- /** Securely generate a new ed25519 secret key. */
- static
- AnySecretKey
- make_ed25519();
-
- /** Securely generate a new secp256k1 key pair. */
- static
- std::pair
- make_secp256k1_pair();
-};
-
-} // ripple
-
-#endif
diff --git a/src/ripple/protocol/Sign.h b/src/ripple/protocol/Sign.h
index 292aca5612..7c8cde49b2 100644
--- a/src/ripple/protocol/Sign.h
+++ b/src/ripple/protocol/Sign.h
@@ -20,9 +20,9 @@
#ifndef RIPPLE_PROTOCOL_SIGN_H_INCLUDED
#define RIPPLE_PROTOCOL_SIGN_H_INCLUDED
-#include
-#include
#include
+#include
+#include
#include
#include
@@ -35,7 +35,7 @@ namespace ripple {
void
sign (STObject& st,
HashPrefix const& prefix,
- AnySecretKey const& sk);
+ KeyType type, SecretKey const& sk);
/** Verify the signature on a STObject.
The signature must be contained in sfSignature.
@@ -43,7 +43,8 @@ sign (STObject& st,
bool
verify (STObject const& st,
HashPrefix const& prefix,
- AnyPublicKeySlice const& pk);
+ PublicKey const& pk,
+ bool mustBeFullyCanonical);
} // ripple
diff --git a/src/ripple/protocol/impl/AccountID.cpp b/src/ripple/protocol/impl/AccountID.cpp
index 8ebd679a39..5ca27f03e0 100644
--- a/src/ripple/protocol/impl/AccountID.cpp
+++ b/src/ripple/protocol/impl/AccountID.cpp
@@ -19,7 +19,7 @@
#include
#include
-#include
+#include
#include
#include
#include
@@ -139,9 +139,8 @@ parseHexOrBase58 (std::string const& s)
less secure than Bitcoin. So where there was no good reason
to change something, it was not changed."
*/
-
AccountID
-calcAccountID (AnyPublicKey const& pk)
+calcAccountID (PublicKey const& pk)
{
ripesha_hasher rsh;
rsh(pk.data(), pk.size());
diff --git a/src/ripple/protocol/impl/AnyPublicKey.cpp b/src/ripple/protocol/impl/AnyPublicKey.cpp
deleted file mode 100644
index a4ebae4e65..0000000000
--- a/src/ripple/protocol/impl/AnyPublicKey.cpp
+++ /dev/null
@@ -1,104 +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.
-*/
-//==============================================================================
-
-#include
-#include
-#include
-#include
-#include
-
-namespace ripple {
-
-/** Verify a secp256k1 signature. */
-bool
-verify_secp256k1 (void const* pk,
- void const* msg, std::size_t msg_size,
- void const* sig, std::size_t sig_size)
-{
- return false;
-}
-
-bool
-verify_ed25519 (void const* pk,
- void const* msg, std::size_t msg_size,
- void const* sig, std::size_t sig_size)
-{
- if (sig_size != 64)
- return false;
- ed25519_public_key epk;
- ed25519_signature es;
- std::memcpy(epk, pk, 32);
- std::memcpy(es, sig, sig_size);
- return ed25519_sign_open(
- reinterpret_cast(msg),
- msg_size, epk, es) == 0;
-}
-
-//------------------------------------------------------------------------------
-
-KeyType
-AnyPublicKeySlice::type() const noexcept
-{
- auto const pk = data();
- auto const pk_size = size();
-
- if (pk_size < 1)
- return KeyType::unknown;
- auto const len = pk_size - 1;
- if (len == 32 &&
- pk[0] == 0xED)
- return KeyType::ed25519;
- if (len == 33 &&
- (pk[0] == 0x02 || pk[0] == 0x03))
- return KeyType::secp256k1;
- return KeyType::unknown;
-}
-
-bool
-AnyPublicKeySlice::verify (
- void const* msg, std::size_t msg_size,
- void const* sig, std::size_t sig_size) const
-{
- switch(type())
- {
- case KeyType::ed25519:
- return verify_ed25519(data() + 1,
- msg, msg_size, sig, sig_size);
- case KeyType::secp256k1:
- return verify_secp256k1(data() + 1,
- msg, msg_size, sig, sig_size);
- default:
- break;
- }
- // throw?
- return false;
-}
-
-std::string
-toString (AnyPublicKey const& pk)
-{
- Blob buffer;
- buffer.reserve (1 + pk.size ());
- buffer.push_back (TOKEN_NODE_PUBLIC);
- auto const data = pk.data ();
- buffer.insert (buffer.end (), data, data + pk.size ());
- return Base58::encodeWithCheck (buffer);
-}
-
-} // ripple
diff --git a/src/ripple/protocol/impl/AnySecretKey.cpp b/src/ripple/protocol/impl/AnySecretKey.cpp
deleted file mode 100644
index c3b3dd800f..0000000000
--- a/src/ripple/protocol/impl/AnySecretKey.cpp
+++ /dev/null
@@ -1,143 +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.
-*/
-//==============================================================================
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-namespace ripple {
-
-AnySecretKey::~AnySecretKey()
-{
- // secure erase
- std::fill(p_.data(), p_.data() + p_.size(), 0);
-}
-
-AnySecretKey::AnySecretKey (AnySecretKey&& other)
- : p_ (std::move(other.p_))
- , type_ (other.type_)
-{
- other.type_ = KeyType::unknown;
-}
-
-AnySecretKey&
-AnySecretKey::operator= (AnySecretKey&& other)
-{
- p_ = std::move(other.p_);
- type_ = other.type_;
- other.type_ = KeyType::unknown;
- return *this;
-}
-
-AnySecretKey::AnySecretKey (KeyType type,
- void const* data, std::size_t size)
- : p_ (data, size)
- , type_ (type)
-{
- if (type_ == KeyType::unknown)
- throw std::runtime_error(
- "AnySecretKey: unknown type");
- if (type_ == KeyType::ed25519 &&
- size != 32)
- throw std::runtime_error(
- "AnySecretKey: wrong ed25519 size");
- if (type_ == KeyType::secp256k1 &&
- size != 32)
- throw std::runtime_error(
- "AnySecretKey: wrong secp256k1 size");
-}
-
-AnyPublicKey
-AnySecretKey::publicKey() const
-{
- switch (type())
- {
- case KeyType::ed25519:
- {
- unsigned char buf[33];
- buf[0] = 0xED;
- ed25519_publickey(p_.data(), &buf[1]);
- return AnyPublicKey(buf, sizeof(buf));
- }
- default:
- throw std::runtime_error(
- "AnySecretKey: unknown type");
- };
-}
-
-Buffer
-AnySecretKey::sign (
- void const* msg, std::size_t msg_len) const
-{
- switch(type_)
- {
- case KeyType::ed25519:
- {
- auto const sk = p_.data();
- ed25519_public_key pk;
- ed25519_publickey(sk, pk);
- Buffer b(64);
- ed25519_sign(reinterpret_cast<
- unsigned char const*>(msg), msg_len,
- sk, pk, b.data());
- return b;
- }
- default:
- break;
- }
- throw std::runtime_error(
- "AnySecretKey: unknown type");
-}
-
-AnySecretKey
-AnySecretKey::make_ed25519()
-{
- std::uint8_t buf[32];
- random_fill(&buf[0], sizeof(buf));
- AnySecretKey ask(KeyType::ed25519,
- buf, sizeof(buf));
- // secure erase
- std::fill(buf, buf + sizeof(buf), 0);
- return ask;
-}
-
-std::pair
-AnySecretKey::make_secp256k1_pair()
-{
- // VFALCO What a pile
- RippleAddress s;
- s.setSeedRandom();
- RippleAddress const g =
- RippleAddress::createGeneratorPublic(s);
- RippleAddress sk;
- sk.setAccountPrivate (g, s, 0);
- RippleAddress pk;
- pk.setAccountPublic (g, 0);
- return std::pair(
- std::piecewise_construct, std::make_tuple(
- KeyType::secp256k1, sk.data(), sk.size()),
- std::make_tuple(pk.data(), pk.size()));
-}
-
-} // ripple
diff --git a/src/ripple/protocol/impl/STVar.cpp b/src/ripple/protocol/impl/STVar.cpp
index 0f69219f60..aaa21b19cc 100644
--- a/src/ripple/protocol/impl/STVar.cpp
+++ b/src/ripple/protocol/impl/STVar.cpp
@@ -17,6 +17,7 @@
*/
//==============================================================================
+#include
#include
#include
#include
diff --git a/src/ripple/protocol/impl/Sign.cpp b/src/ripple/protocol/impl/Sign.cpp
index 6ee99bcad0..c99bf0e993 100644
--- a/src/ripple/protocol/impl/Sign.cpp
+++ b/src/ripple/protocol/impl/Sign.cpp
@@ -17,25 +17,27 @@
*/
//==============================================================================
+#include
#include
namespace ripple {
void
sign (STObject& st, HashPrefix const& prefix,
- AnySecretKey const& sk)
+ KeyType type, SecretKey const& sk)
{
Serializer ss;
ss.add32(prefix);
st.addWithoutSigningFields(ss);
set(st, sfSignature,
- sk.sign(ss.data(), ss.size()));
+ sign(type, sk, ss.slice()));
}
bool
verify (STObject const& st,
HashPrefix const& prefix,
- AnyPublicKeySlice const& pk)
+ PublicKey const& pk,
+ bool mustBeFullyCanonical)
{
auto const sig = get(st, sfSignature);
if (! sig)
@@ -44,8 +46,9 @@ verify (STObject const& st,
ss.add32(prefix);
st.addWithoutSigningFields(ss);
return pk.verify(
- ss.data(), ss.size(),
- sig->data(), sig->size());
+ Slice(ss.data(), ss.size()),
+ Slice(sig->data(), sig->size()),
+ true);
}
} // ripple
diff --git a/src/ripple/protocol/impl/tokens.cpp b/src/ripple/protocol/impl/tokens.cpp
index 320cb25beb..e7d412bc82 100644
--- a/src/ripple/protocol/impl/tokens.cpp
+++ b/src/ripple/protocol/impl/tokens.cpp
@@ -17,6 +17,7 @@
*/
//==============================================================================
+#include
#include
#include
#include
diff --git a/src/ripple/protocol/tests/STTx.test.cpp b/src/ripple/protocol/tests/STTx.test.cpp
index b110b2e33b..0a1bed0262 100644
--- a/src/ripple/protocol/tests/STTx.test.cpp
+++ b/src/ripple/protocol/tests/STTx.test.cpp
@@ -88,7 +88,7 @@ public:
txnSeed.setSeedRandom ();
// VFALCO Generators are no longer supported
RippleAddress txnGenerator = txnSeed.createGeneratorPublic (txnSeed);
- // VFALCO Use AnyPublicKey here
+ // VFALCO Use PublicKey here
RippleAddress txnPublicAcct = txnSeed.createAccountPublic (txnGenerator, 1);
STTx txn (ttACCOUNT_SET);
diff --git a/src/ripple/rpc/impl/Accounts.cpp b/src/ripple/rpc/impl/Accounts.cpp
index 05f5cbe315..b0b183b0ff 100644
--- a/src/ripple/rpc/impl/Accounts.cpp
+++ b/src/ripple/rpc/impl/Accounts.cpp
@@ -39,7 +39,7 @@ Json::Value accounts (
do
{
- // VFALCO Should be AnyPublicKey
+ // VFALCO Should be PublicKey and Generator
RippleAddress pk;
pk.setAccountPublic (naMasterGenerator, uIndex++);
diff --git a/src/ripple/rpc/tests/JSONRPC.test.cpp b/src/ripple/rpc/tests/JSONRPC.test.cpp
index 5bd50494dc..e017d6511f 100644
--- a/src/ripple/rpc/tests/JSONRPC.test.cpp
+++ b/src/ripple/rpc/tests/JSONRPC.test.cpp
@@ -21,6 +21,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -920,8 +921,14 @@ public:
= RippleAddress::createAccountPublic (rootGeneratorMaster, 0);
std::uint64_t startAmount (100000);
+
+ auto const masterAccountID =
+ calcAccountID(generateKeyPair(
+ KeyType::secp256k1,
+ generateSeed("masterpassphrase")).first);
+
Ledger::pointer ledger (std::make_shared (
- rootAddress, startAmount));
+ masterAccountID, startAmount));
using namespace detail;
TxnSignApiFacade apiFacade (TxnSignApiFacade::noNetOPs, ledger);
diff --git a/src/ripple/test/jtx/Account.h b/src/ripple/test/jtx/Account.h
index 18dd663554..36781e1567 100644
--- a/src/ripple/test/jtx/Account.h
+++ b/src/ripple/test/jtx/Account.h
@@ -20,7 +20,7 @@
#ifndef RIPPLE_TEST_JTX_ACCOUNT_H_INCLUDED
#define RIPPLE_TEST_JTX_ACCOUNT_H_INCLUDED
-#include
+#include
#include
#include
#include
@@ -37,10 +37,8 @@ class Account
{
private:
std::string name_;
- // VFALCO TODO use AnyPublicKey, AnySecretKey
- // instead of RippleAddress
- RippleAddress pk_;
- RippleAddress sk_;
+ PublicKey pk_;
+ SecretKey sk_;
AccountID id_;
std::string human_; // base58 public key string
@@ -58,12 +56,14 @@ public:
#endif
/** Create an account from a key pair. */
- Account (std::string name, KeyPair&& keys);
+ Account (std::string name,
+ std::pair const& keys);
/** Create an account from a simple string name. */
/** @{ */
Account (std::string name,
KeyType type = KeyType::secp256k1);
+
Account (char const* name,
KeyType type = KeyType::secp256k1)
: Account(std::string(name), type)
@@ -79,14 +79,14 @@ public:
}
/** Return the public key. */
- RippleAddress const&
+ PublicKey const&
pk() const
{
return pk_;
}
/** Return the secret key. */
- RippleAddress const&
+ SecretKey const&
sk() const
{
return sk_;
diff --git a/src/ripple/test/jtx/Env.h b/src/ripple/test/jtx/Env.h
index 68dc3e6d45..893220f811 100644
--- a/src/ripple/test/jtx/Env.h
+++ b/src/ripple/test/jtx/Env.h
@@ -34,7 +34,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -154,7 +153,7 @@ public:
as a public member for interested callers.
*/
static
- std::shared_ptr
+ std::shared_ptr
genesis();
/** Returns the open ledger.
diff --git a/src/ripple/test/jtx/impl/Account.cpp b/src/ripple/test/jtx/impl/Account.cpp
index 7484e137bc..6b9eb31a86 100644
--- a/src/ripple/test/jtx/impl/Account.cpp
+++ b/src/ripple/test/jtx/impl/Account.cpp
@@ -48,14 +48,14 @@ Account::operator= (Account&& rhs)
}
#endif
-Account::Account(
- std::string name, KeyPair&& keys)
+Account::Account(std::string name,
+ std::pair const& keys)
: name_(std::move(name))
+ , pk_ (keys.first)
+ , sk_ (keys.second)
+ , id_ (calcAccountID(pk_))
+ , human_ (toBase58(id_))
{
- pk_ = std::move(keys.publicKey);
- sk_ = std::move(keys.secretKey);
- id_ = calcAccountID(pk_);
- human_ = toBase58(id_);
}
Account::Account (std::string name,
@@ -66,9 +66,7 @@ Account::Account (std::string name,
// Fails on Clang and possibly gcc
: Account(std::move(name),
#endif
- generateKeysFromSeed(type,
- RippleAddress::createSeedGeneric(
- name)))
+ generateKeyPair(type, generateSeed(name)))
{
}
diff --git a/src/ripple/test/jtx/impl/Env.cpp b/src/ripple/test/jtx/impl/Env.cpp
index 4de9b8f4f5..b0c5cbe3ea 100644
--- a/src/ripple/test/jtx/impl/Env.cpp
+++ b/src/ripple/test/jtx/impl/Env.cpp
@@ -44,22 +44,21 @@
#include
#include
#include
-// VFALCO TODO Use AnyPublicKey, AnySecretKey, AccountID
namespace ripple {
namespace test {
namespace jtx {
-std::shared_ptr
+std::shared_ptr
Env::genesis()
{
- Account master("master", generateKeysFromSeed(
- KeyType::secp256k1, RippleAddress::createSeedGeneric(
- "masterpassphrase")));
+ Account const master("master",
+ generateKeyPair(KeyType::secp256k1,
+ generateSeed("masterpassphrase")));
auto const ledger =
- std::make_shared(master.pk(),
- SYSTEM_CURRENCY_START);
+ std::make_shared(
+ master.id(), SYSTEM_CURRENCY_START);
ledger->setClosed();
return ledger;
}
@@ -67,9 +66,9 @@ Env::genesis()
// VFALCO Could wrap the log in a Journal here
Env::Env (beast::unit_test::suite& test_)
: test(test_)
- , master("master", generateKeysFromSeed(
- KeyType::secp256k1, RippleAddress::createSeedGeneric(
- "masterpassphrase")))
+ , master("master", generateKeyPair(
+ KeyType::secp256k1,
+ generateSeed("masterpassphrase")))
, closed_ (genesis())
, cachedSLEs_ (std::chrono::seconds(5), clock)
, openLedger (closed_, config, cachedSLEs_, journal)
diff --git a/src/ripple/test/jtx/impl/multisign.cpp b/src/ripple/test/jtx/impl/multisign.cpp
index 00cecd7145..6d26f38f3e 100644
--- a/src/ripple/test/jtx/impl/multisign.cpp
+++ b/src/ripple/test/jtx/impl/multisign.cpp
@@ -102,17 +102,18 @@ msig::operator()(Env const& env, JTx& jt) const
auto const& e = accounts[i];
auto& jo = js[i]["SigningAccount"];
jo[jss::Account] = e.human();
- jo[jss::SigningPubKey] = strHex(makeSlice(
- e.pk().getAccountPublic()));
+ jo[jss::SigningPubKey] = strHex(e.pk().slice());
Serializer ss;
ss.add32 (HashPrefix::txMultiSign);
st->addWithoutSigningFields(ss);
ss.add160(*signFor);
ss.add160(e.id());
- jo["MultiSignature"] = strHex(makeSlice(
- e.sk().accountPrivateSign(ss.getData())));
-
+ auto const sig = ripple::sign(
+ *publicKeyType(e.pk().slice()),
+ e.sk(), ss.slice());
+ jo["MultiSignature"] =
+ strHex(Slice{ sig.data(), sig.size() });
}
};
}
@@ -165,17 +166,19 @@ msig2_t::operator()(Env const& env, JTx& jt) const
{
auto& jj = js[j.first]["SigningAccount"];
jj[jss::Account] = j.second->human();
- jj[jss::SigningPubKey] = strHex(makeSlice(
- j.second->pk().getAccountPublic()));
+ jj[jss::SigningPubKey] = strHex(
+ j.second->pk().slice());
Serializer ss;
ss.add32 (HashPrefix::txMultiSign);
st->addWithoutSigningFields(ss);
ss.add160(sign_for.id());
ss.add160(j.second->id());
- jj["MultiSignature"] = strHex(makeSlice(
- j.second->sk().accountPrivateSign(
- ss.getData())));
+ auto const sig = ripple::sign(
+ *publicKeyType(j.second->pk().slice()),
+ j.second->sk(), ss.slice());
+ jj["MultiSignature"] =
+ strHex(Slice{ sig.data(), sig.size() });
}
}
};
diff --git a/src/ripple/test/jtx/impl/utility.cpp b/src/ripple/test/jtx/impl/utility.cpp
index 822f0e942d..cd397041e2 100644
--- a/src/ripple/test/jtx/impl/utility.cpp
+++ b/src/ripple/test/jtx/impl/utility.cpp
@@ -46,14 +46,15 @@ sign (Json::Value& jv,
Account const& account)
{
jv[jss::SigningPubKey] =
- strHex(makeSlice(
- account.pk().getAccountPublic()));
+ strHex(account.pk().slice());
Serializer ss;
ss.add32 (HashPrefix::txSign);
parse(jv).add(ss);
- jv[jss::TxnSignature] = strHex(makeSlice(
- account.sk().accountPrivateSign(
- ss.getData())));
+ auto const sig = ripple::sign(
+ *publicKeyType(account.pk().slice()),
+ account.sk(), ss.slice());
+ jv[jss::TxnSignature] =
+ strHex(Slice{ sig.data(), sig.size() });
}
void
diff --git a/src/ripple/unity/protocol.cpp b/src/ripple/unity/protocol.cpp
index 9c41985b03..7aba59f52c 100644
--- a/src/ripple/unity/protocol.cpp
+++ b/src/ripple/unity/protocol.cpp
@@ -20,8 +20,6 @@
#include
#include
-#include
-#include
#include
#include
#include