1#include <xrpld/rpc/handlers/admin/keygen/WalletPropose.h>
3#include <xrpld/rpc/Context.h>
4#include <xrpld/rpc/detail/RPCHelpers.h>
6#include <xrpl/basics/strHex.h>
7#include <xrpl/json/json_value.h>
8#include <xrpl/protocol/AccountID.h>
9#include <xrpl/protocol/ErrorCodes.h>
10#include <xrpl/protocol/KeyType.h>
11#include <xrpl/protocol/PublicKey.h>
12#include <xrpl/protocol/RPCErr.h>
13#include <xrpl/protocol/SecretKey.h>
14#include <xrpl/protocol/Seed.h>
15#include <xrpl/protocol/jss.h>
16#include <xrpl/protocol/tokens.h>
33 for (
auto const& c : input)
38 for (
auto const& [_, f] : freq)
41 auto x = f / input.
length();
69 if (!params[jss::key_type].isString())
84 if (params.
isMember(jss::passphrase))
132 auto const seedHex =
strHex(*seed);
133 auto const seedBase58 =
toBase58(*seed);
135 obj[jss::master_seed] = seedBase58;
136 obj[jss::master_seed_hex] = seedHex;
137 obj[jss::master_key] = seed1751;
140 obj[jss::key_type] =
to_string(*keyType);
141 obj[jss::public_key_hex] =
strHex(publicKey);
146 if (!libSeed && params.
isMember(jss::passphrase))
148 auto const passphrase = params[jss::passphrase].
asString();
150 if (passphrase != seed1751 && passphrase != seedBase58 && passphrase != seedHex)
157 "This wallet was generated using a user-supplied "
158 "passphrase that has low entropy and is vulnerable "
159 "to brute-force attacks.";
164 "This wallet was generated using a user-supplied "
165 "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.
@ Object
object value (collection of name/value pairs).
std::optional< Seed > parseXrplLibSeed(json::Value const &value)
Parses a XrplLib seed from RPC parameters.
std::optional< Seed > getSeedFromRPC(json::Value const ¶ms, json::Value &error)
Extracts a Seed from RPC parameters.
json::Value expectedFieldError(std::string const &name, std::string const &type)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
json::Value doWalletPropose(RPC::JsonContext &context)
std::optional< KeyType > keyTypeFromString(std::string const &s)
Seed randomSeed()
Create a seed using secure random numbers.
std::string strHex(FwdIt begin, FwdIt end)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::string seedAs1751(Seed const &seed)
Encode a Seed in RFC1751 format.
std::pair< PublicKey, SecretKey > generateKeyPair(KeyType type, Seed const &seed)
Generate a key pair deterministically.
std::string to_string(BaseUInt< Bits, Tag > const &a)
json::Value rpcError(ErrorCodeI iError)
json::Value walletPropose(json::Value const ¶ms)
AccountID calcAccountID(PublicKey const &pk)
double estimateEntropy(std::string const &input)