20 #include <ripple/core/DatabaseCon.h>
21 #include <ripple/app/main/Application.h>
22 #include <ripple/app/main/NodeIdentity.h>
23 #include <ripple/basics/Log.h>
24 #include <ripple/core/Config.h>
25 #include <ripple/core/ConfigSections.h>
26 #include <boost/format.hpp>
27 #include <boost/optional.hpp>
37 auto const seed = parseBase58<Seed>(
41 Throw<std::runtime_error>(
42 "NodeIdentity: Bad [" SECTION_NODE_SEED
"] specified");
49 return { publicKey, secretKey };
53 boost::optional<PublicKey> publicKey;
54 boost::optional<SecretKey> secretKey;
59 boost::optional<std::string> pubKO, priKO;
60 soci::statement st = (db->prepare <<
61 "SELECT PublicKey, PrivateKey FROM NodeIdentity;",
67 auto const sk = parseBase58<SecretKey>(
69 auto const pk = parseBase58<PublicKey>(
82 if (!publicKey || !secretKey)
86 *db << str (boost::format (
87 "INSERT INTO NodeIdentity (PublicKey,PrivateKey) VALUES ('%s','%s');")
92 return { *publicKey, *secretKey };
std::pair< PublicKey, SecretKey > loadNodeIdentity(Application &app)
The cryptographic credentials identifying this server instance.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
virtual DatabaseCon & getWalletDB()=0
Retrieve the "wallet database".
LockedSociSession checkoutDb()
PublicKey derivePublicKey(KeyType type, SecretKey const &sk)
Derive the public key from a secret key.
virtual Config & config()=0
std::vector< std::string > const & lines() const
Returns all the lines in the section.
SecretKey generateSecretKey(KeyType type, Seed const &seed)
Generate a new secret key deterministically.
std::pair< PublicKey, SecretKey > randomKeyPair(KeyType type)
Create a key pair using secure random numbers.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool exists(std::string const &name) const
Returns true if a section with the given name exists.
Section & section(std::string const &name)
Returns the section with the given name.