1#include <xrpld/rpc/Context.h>
2#include <xrpld/rpc/detail/RPCHelpers.h>
3#include <xrpld/rpc/handlers/WalletPropose.h>
5#include <xrpl/basics/strHex.h>
6#include <xrpl/protocol/ErrorCodes.h>
7#include <xrpl/protocol/KeyType.h>
8#include <xrpl/protocol/PublicKey.h>
9#include <xrpl/protocol/RPCErr.h>
10#include <xrpl/protocol/SecretKey.h>
11#include <xrpl/protocol/Seed.h>
12#include <xrpl/protocol/jss.h>
27 for (
auto const& c : input)
32 for (
auto const& [_, f] : freq)
35 auto x = f / input.
length();
59 bool rippleLibSeed =
false;
63 if (!params[jss::key_type].isString())
78 if (params.
isMember(jss::passphrase))
122 auto const seedHex =
strHex(*seed);
123 auto const seedBase58 =
toBase58(*seed);
125 obj[jss::master_seed] = seedBase58;
126 obj[jss::master_seed_hex] = seedHex;
127 obj[jss::master_key] = seed1751;
130 obj[jss::key_type] =
to_string(*keyType);
131 obj[jss::public_key_hex] =
strHex(publicKey);
136 if (!rippleLibSeed && params.
isMember(jss::passphrase))
138 auto const passphrase = params[jss::passphrase].
asString();
140 if (passphrase != seed1751 && passphrase != seedBase58 &&
141 passphrase != seedHex)
147 "This wallet was generated using a user-supplied "
148 "passphrase that has low entropy and is vulnerable "
149 "to brute-force attacks.";
152 "This wallet was generated using a user-supplied "
153 "passphrase. It may be vulnerable to brute-force "
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
@ objectValue
object value (collection of name/value pairs).
std::optional< Seed > getSeedFromRPC(Json::Value const ¶ms, Json::Value &error)
Json::Value expected_field_error(std::string const &name, std::string const &type)
std::optional< Seed > parseRippleLibSeed(Json::Value const &value)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< KeyType > keyTypeFromString(std::string const &s)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::pair< PublicKey, SecretKey > generateKeyPair(KeyType type, Seed const &seed)
Generate a key pair deterministically.
Seed randomSeed()
Create a seed using secure random numbers.
AccountID calcAccountID(PublicKey const &pk)
Json::Value rpcError(int iError)
std::string seedAs1751(Seed const &seed)
Encode a Seed in RFC1751 format.
std::string strHex(FwdIt begin, FwdIt end)
std::string to_string(base_uint< Bits, Tag > const &a)
Json::Value walletPropose(Json::Value const ¶ms)
double estimate_entropy(std::string const &input)
Json::Value doWalletPropose(RPC::JsonContext &)