20#include <xrpld/rpc/Context.h>
21#include <xrpld/rpc/detail/RPCHelpers.h>
22#include <xrpld/rpc/handlers/WalletPropose.h>
24#include <xrpl/basics/strHex.h>
25#include <xrpl/protocol/ErrorCodes.h>
26#include <xrpl/protocol/KeyType.h>
27#include <xrpl/protocol/PublicKey.h>
28#include <xrpl/protocol/RPCErr.h>
29#include <xrpl/protocol/SecretKey.h>
30#include <xrpl/protocol/Seed.h>
31#include <xrpl/protocol/jss.h>
46 for (
auto const& c : input)
51 for (
auto const& [_, f] : freq)
54 auto x = f / input.
length();
78 bool rippleLibSeed =
false;
82 if (!params[jss::key_type].isString())
97 if (params.
isMember(jss::passphrase))
104 rippleLibSeed =
true;
141 auto const seedHex =
strHex(*seed);
142 auto const seedBase58 =
toBase58(*seed);
144 obj[jss::master_seed] = seedBase58;
145 obj[jss::master_seed_hex] = seedHex;
146 obj[jss::master_key] = seed1751;
149 obj[jss::key_type] =
to_string(*keyType);
150 obj[jss::public_key_hex] =
strHex(publicKey);
155 if (!rippleLibSeed && params.
isMember(jss::passphrase))
157 auto const passphrase = params[jss::passphrase].
asString();
159 if (passphrase != seed1751 && passphrase != seedBase58 &&
160 passphrase != seedHex)
166 "This wallet was generated using a user-supplied "
167 "passphrase that has low entropy and is vulnerable "
168 "to brute-force attacks.";
171 "This wallet was generated using a user-supplied "
172 "passphrase. It may be vulnerable to brute-force "
std::string asString() const
Returns the unquoted string value.
bool isMember(const char *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 &)