Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 9 additions & 29 deletions src/ValidatorKeys.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
//------------------------------------------------------------------------------
/*
This file is part of validator-keys-tool:
https://github.com/ripple/validator-keys-tool
Copyright (c) 2016 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 <ValidatorKeys.h>

#include <xrpl/basics/StringUtilities.h>
Expand All @@ -33,7 +13,7 @@

#include <fstream>

namespace ripple {
namespace xrpl {

std::string
ValidatorToken::toString() const
Expand All @@ -42,7 +22,7 @@ ValidatorToken::toString() const
jv["validation_secret_key"] = strHex(secretKey);
jv["manifest"] = manifest;

return ripple::base64_encode(to_string(jv));
return xrpl::base64_encode(to_string(jv));
}

ValidatorKeys::ValidatorKeys(KeyType const& keyType)
Expand Down Expand Up @@ -229,8 +209,8 @@ ValidatorKeys::createValidatorToken(KeyType const& keyType)
if (!domain_.empty())
st[sfDomain] = makeSlice(domain_);

ripple::sign(st, HashPrefix::manifest, keyType, tokenSecret);
ripple::sign(
xrpl::sign(st, HashPrefix::manifest, keyType, tokenSecret);
xrpl::sign(
st, HashPrefix::manifest, keyType_, keys_.secretKey, sfMasterSignature);

Serializer s;
Expand All @@ -241,7 +221,7 @@ ValidatorKeys::createValidatorToken(KeyType const& keyType)
std::copy(s.begin(), s.end(), std::back_inserter(manifest_));

return ValidatorToken{
ripple::base64_encode(manifest_.data(), manifest_.size()), tokenSecret};
xrpl::base64_encode(manifest_.data(), manifest_.size()), tokenSecret};
}

std::string
Expand All @@ -253,7 +233,7 @@ ValidatorKeys::revoke()
st[sfSequence] = std::numeric_limits<std::uint32_t>::max();
st[sfPublicKey] = keys_.publicKey;

ripple::sign(
xrpl::sign(
st, HashPrefix::manifest, keyType_, keys_.secretKey, sfMasterSignature);

Serializer s;
Expand All @@ -263,14 +243,14 @@ ValidatorKeys::revoke()
manifest_.reserve(s.size());
std::copy(s.begin(), s.end(), std::back_inserter(manifest_));

return ripple::base64_encode(manifest_.data(), manifest_.size());
return xrpl::base64_encode(manifest_.data(), manifest_.size());
}

std::string
ValidatorKeys::sign(std::string const& data) const
{
return strHex(
ripple::sign(keys_.publicKey, keys_.secretKey, makeSlice(data)));
xrpl::sign(keys_.publicKey, keys_.secretKey, makeSlice(data)));
}

void
Expand Down Expand Up @@ -311,4 +291,4 @@ ValidatorKeys::domain(std::string d)
domain_ = std::move(d);
}

} // namespace ripple
} // namespace xrpl
24 changes: 2 additions & 22 deletions src/ValidatorKeys.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
//------------------------------------------------------------------------------
/*
This file is part of validator-keys-tool:
https://github.com/ripple/validator-keys-tool
Copyright (c) 2016 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 <xrpl/protocol/KeyType.h>
#include <xrpl/protocol/SecretKey.h>

Expand All @@ -33,7 +13,7 @@ class path;
}
} // namespace boost

namespace ripple {
namespace xrpl {

struct ValidatorToken
{
Expand Down Expand Up @@ -175,4 +155,4 @@ class ValidatorKeys
}
};

} // namespace ripple
} // namespace xrpl
44 changes: 12 additions & 32 deletions src/ValidatorKeysTool.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
//------------------------------------------------------------------------------
/*
This file is part of validator-keys-tool:
https://github.com/ripple/validator-keys-tool
Copyright (c) 2016 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 <ValidatorKeys.h>
#include <ValidatorKeysTool.h>

Expand Down Expand Up @@ -73,7 +53,7 @@ runUnitTests()
void
createKeyFile(boost::filesystem::path const& keyFile)
{
using namespace ripple;
using namespace xrpl;

if (exists(keyFile))
throw std::runtime_error(
Expand All @@ -89,7 +69,7 @@ createKeyFile(boost::filesystem::path const& keyFile)
void
createToken(boost::filesystem::path const& keyFile)
{
using namespace ripple;
using namespace xrpl;

auto keys = ValidatorKeys::make_ValidatorKeys(keyFile);

Expand All @@ -107,7 +87,7 @@ createToken(boost::filesystem::path const& keyFile)
keys.writeToFile(keyFile);

std::cout
<< "Update rippled.cfg file with these values and restart rippled:\n\n";
<< "Update rippled.cfg file with these values and restart xrpld:\n\n";
std::cout << "# validator public key: "
<< toBase58(TokenType::NodePublic, keys.publicKey()) << "\n\n";
std::cout << "[validator_token]\n";
Expand All @@ -123,7 +103,7 @@ createToken(boost::filesystem::path const& keyFile)
void
createRevocation(boost::filesystem::path const& keyFile)
{
using namespace ripple;
using namespace xrpl;

auto keys = ValidatorKeys::make_ValidatorKeys(keyFile);

Expand All @@ -138,7 +118,7 @@ createRevocation(boost::filesystem::path const& keyFile)
keys.writeToFile(keyFile);

std::cout
<< "Update rippled.cfg file with these values and restart rippled:\n\n";
<< "Update rippled.cfg file with these values and restart xrpld:\n\n";
std::cout << "# validator public key: "
<< toBase58(TokenType::NodePublic, keys.publicKey()) << "\n\n";
std::cout << "[validator_key_revocation]\n";
Expand All @@ -151,9 +131,9 @@ createRevocation(boost::filesystem::path const& keyFile)
}

void
attestDomain(ripple::ValidatorKeys const& keys)
attestDomain(xrpl::ValidatorKeys const& keys)
{
using namespace ripple;
using namespace xrpl;

if (keys.domain().empty())
{
Expand All @@ -180,7 +160,7 @@ attestDomain(ripple::ValidatorKeys const& keys)
void
attestDomain(boost::filesystem::path const& keyFile)
{
using namespace ripple;
using namespace xrpl;

auto keys = ValidatorKeys::make_ValidatorKeys(keyFile);

Expand All @@ -194,7 +174,7 @@ attestDomain(boost::filesystem::path const& keyFile)
void
setDomain(std::string const& domain, boost::filesystem::path const& keyFile)
{
using namespace ripple;
using namespace xrpl;

auto keys = ValidatorKeys::make_ValidatorKeys(keyFile);

Expand Down Expand Up @@ -230,7 +210,7 @@ setDomain(std::string const& domain, boost::filesystem::path const& keyFile)

std::cout << "\n";
std::cout << "You also need to update the rippled.cfg file to add a new\n";
std::cout << "validator token and restart rippled:\n\n";
std::cout << "validator token and restart xrpld:\n\n";
std::cout << "# validator public key: "
<< toBase58(TokenType::NodePublic, keys.publicKey()) << "\n\n";
std::cout << "[validator_token]\n";
Expand All @@ -246,7 +226,7 @@ setDomain(std::string const& domain, boost::filesystem::path const& keyFile)
void
signData(std::string const& data, boost::filesystem::path const& keyFile)
{
using namespace ripple;
using namespace xrpl;

if (data.empty())
throw std::runtime_error(
Expand All @@ -266,7 +246,7 @@ generateManifest(
std::string const& type,
boost::filesystem::path const& keyFile)
{
using namespace ripple;
using namespace xrpl;

auto keys = ValidatorKeys::make_ValidatorKeys(keyFile);

Expand Down
20 changes: 0 additions & 20 deletions src/ValidatorKeysTool.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
//------------------------------------------------------------------------------
/*
This file is part of validator-keys-tool:
https://github.com/ripple/validator-keys-tool
Copyright (c) 2016 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 <boost/optional.hpp>

#include <vector>
Expand Down
23 changes: 2 additions & 21 deletions src/test/KeyFileGuard.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright 2016 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 <xrpl/beast/unit_test.h>

#include <boost/filesystem.hpp>

#include <fstream>

namespace ripple {
namespace xrpl {

/**
Write a key file dir and remove when done.
Expand Down Expand Up @@ -75,4 +56,4 @@ class KeyFileGuard
}
};

} // namespace ripple
} // namespace xrpl
25 changes: 3 additions & 22 deletions src/test/ValidatorKeysTool_test.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright 2016 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 <ValidatorKeys.h>
#include <ValidatorKeysTool.h>

#include <test/KeyFileGuard.h>

#include <xrpl/protocol/SecretKey.h>

namespace ripple {
namespace xrpl {

namespace tests {

Expand Down Expand Up @@ -309,8 +290,8 @@ class ValidatorKeysTool_test : public beast::unit_test::suite
}
};

BEAST_DEFINE_TESTSUITE(ValidatorKeysTool, keys, ripple);
BEAST_DEFINE_TESTSUITE(ValidatorKeysTool, keys, xrpl);

} // namespace tests

} // namespace ripple
} // namespace xrpl
Loading
Loading