Skip to content
This repository has been archived by the owner on Jan 18, 2019. It is now read-only.

Commit

Permalink
Changed verifyNodePublic to use ed25519 in libsodium. NOT FUNCTIONAL.
Browse files Browse the repository at this point in the history
None of the key generation or signature functions have been updated.
  • Loading branch information
David Mazieres committed Jul 10, 2014
1 parent 2e2c68a commit 1ecc992
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
2 changes: 2 additions & 0 deletions SConstruct
Expand Up @@ -99,6 +99,8 @@ else:
env.ParseConfig('pkg-config --static --cflags --libs openssl')
# Use protobuf
env.ParseConfig('pkg-config --static --cflags --libs protobuf')
# Use libsodium
env.ParseConfig('pkg-config --static --cflags --libs libsodium')

# Beast uses kvm on FreeBSD
if FreeBSD:
Expand Down
7 changes: 7 additions & 0 deletions src/ripple_app/ripple_app.cpp
Expand Up @@ -27,6 +27,8 @@
#include <boost/optional.hpp>
#include <boost/version.hpp>

#include <sodium.h>

#include "ripple_app.h"

#include "../ripple_net/ripple_net.h"
Expand Down Expand Up @@ -123,6 +125,11 @@ int main (int argc, char** argv)

static_assert (BOOST_VERSION >= 105500,
"Boost version 1.55 or later is required to compile rippled");

if (sodium_init() == -1) {
std::cerr << "sodium_init failed\n";
return 1;
}

//
// These debug heap calls do nothing in release or non Visual Studio builds.
Expand Down
28 changes: 13 additions & 15 deletions src/ripple_data/protocol/RippleAddress.cpp
Expand Up @@ -18,6 +18,7 @@
//==============================================================================

#include "../../beast/beast/unit_test/suite.h"
#include <sodium.h>

namespace ripple {

Expand Down Expand Up @@ -165,24 +166,21 @@ void RippleAddress::setNodePublic (Blob const& vPublic)
SetData (VER_NODE_PUBLIC, vPublic);
}

bool RippleAddress::verifyNodePublic (uint256 const& hash, Blob const& vchSig, ECDSA fullyCanonical) const
bool RippleAddress::verifyNodePublic (uint256 const& hash, Blob const& vchSig, ECDSA) const
{
CKey pubkey = CKey ();
bool bVerified;
if (getNodePublic().size() != crypto_sign_PUBLICKEYBYTES
|| vchSig.size () != crypto_sign_BYTES)
return false;

bVerified = isCanonicalECDSASig (vchSig, fullyCanonical);
unsigned char signed_buf[crypto_sign_BYTES + hash.bytes];
memcpy (signed_buf, vchSig.data(), crypto_sign_BYTES);
memcpy (signed_buf+crypto_sign_BYTES, hash.data(), hash.bytes);

if (bVerified && !pubkey.SetPubKey (getNodePublic ()))
{
// Failed to set public key.
bVerified = false;
}
else
{
bVerified = pubkey.Verify (hash, vchSig);
}

return bVerified;
unsigned char ignored_buf[hash.bytes];
unsigned long long ignored_len;
return crypto_sign_open (ignored_buf, &ignored_len,
signed_buf, sizeof (signed_buf),
getNodePublic().data()) == 0;
}

bool RippleAddress::verifyNodePublic (uint256 const& hash, const std::string& strSig, ECDSA fullyCanonical) const
Expand Down

0 comments on commit 1ecc992

Please sign in to comment.