20 #include <ripple/basics/strHex.h>
21 #include <ripple/net/RPCErr.h>
22 #include <ripple/protocol/ErrorCodes.h>
23 #include <ripple/protocol/KeyType.h>
24 #include <ripple/protocol/PublicKey.h>
25 #include <ripple/protocol/SecretKey.h>
26 #include <ripple/protocol/Seed.h>
27 #include <ripple/protocol/jss.h>
28 #include <ripple/rpc/Context.h>
29 #include <ripple/rpc/handlers/WalletPropose.h>
30 #include <ripple/rpc/impl/RPCHelpers.h>
45 for (
auto const& c : input)
50 for (
auto const& [_, f] : freq)
53 auto x = f / input.length();
77 bool rippleLibSeed =
false;
81 if (!params[jss::key_type].isString())
96 if (params.
isMember(jss::passphrase))
103 rippleLibSeed =
true;
140 auto const seedHex =
strHex(*seed);
141 auto const seedBase58 =
toBase58(*seed);
143 obj[jss::master_seed] = seedBase58;
144 obj[jss::master_seed_hex] = seedHex;
145 obj[jss::master_key] = seed1751;
148 obj[jss::key_type] =
to_string(*keyType);
149 obj[jss::public_key_hex] =
strHex(publicKey);
154 if (!rippleLibSeed && params.
isMember(jss::passphrase))
156 auto const passphrase = params[jss::passphrase].
asString();
158 if (passphrase != seed1751 && passphrase != seedBase58 &&
159 passphrase != seedHex)
165 "This wallet was generated using a user-supplied "
166 "passphrase that has low entropy and is vulnerable "
167 "to brute-force attacks.";
170 "This wallet was generated using a user-supplied "
171 "passphrase. It may be vulnerable to brute-force "
Json::Value rpcError(int iError)
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.
Json::Value expected_field_error(std::string const &name, std::string const &type)
std::optional< Seed > parseRippleLibSeed(Json::Value const &value)
@ objectValue
object value (collection of name/value pairs).
std::string seedAs1751(Seed const &seed)
Encode a Seed in RFC1751 format.
AccountID calcAccountID(PublicKey const &pk)
Json::Value doWalletPropose(RPC::JsonContext &)
Seed randomSeed()
Create a seed using secure random numbers.
bool isMember(const char *key) const
Return true if the object has a member named key.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< Seed > getSeedFromRPC(Json::Value const ¶ms, Json::Value &error)
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
std::string strHex(FwdIt begin, FwdIt end)
Json::Value walletPropose(Json::Value const ¶ms)
double estimate_entropy(std::string const &input)
std::string asString() const
Returns the unquoted string value.