7

Can I enter my seed in as hex data instead of typing words in like normal?

edit: I'm hoping to increase entropy of my key if I'm able to go past the 7F ascii Hex boundary.

4 Answers 4

9

When recovering by mnemonic seed, you must actually type your mnemonic seed (or at least the first 3 letters of each word, 4 in some languages). You are able to recover a wallet with hex data but in a different manner:

With simplewallet(monero-wallet-cli) the private key is the hexadecimal representation of the 25 word mnemonic seed. Recovery options from that hexadecimal representation are found here

With Mymonero the private key is the hash of hexadecimal representation of the 13 word mnemonic seed as demonstrated in the code below:

int main(int ac, const char* av[]) {

    // get command line options
    xmreg::CmdLineOptions opts {ac, av};

    auto help_opt = opts.get_option<bool>("help");

    // if help was chosen, display help text and finish
    if (*help_opt)
    {
        return 0;
    }

    // default language for the mnemonic
    // representation of the private spend key
    string language {"English"};

    // get 13 word mnemonic seed from MyMonero
    auto mnemonic_opt = opts.get_option<string>("mnemonic");

    // get the program command line options, or
    // some default values for quick check
    string mnemonic_str = mnemonic_opt
                          ? *mnemonic_opt
                          : "slid otherwise jeers lurk swung tawny zodiac tusks twang cajun swagger peaches tawny";

    cout << "\n"
         << "Mnemonic seed    : " << mnemonic_str << endl;


    // change the MyMonero 13 word mnemonic seed
    // to its 16 byte hexadecimal version
    xmreg::secret_key16 hexadecimal_seed;

    // use modified words_to_bytes function.
    xmreg::ElectrumWords::words_to_bytes(mnemonic_str, hexadecimal_seed, language);

    cout << "\n"
         << "Hexadecimal seed : " << hexadecimal_seed << endl;


    // take the 16 byte hexadecimal_seed, and
    // and perform Keccak hash on it. It will
    // produce 32 byte hash.
    crypto::hash hash_of_seed;

    cn_fast_hash(hexadecimal_seed.data, sizeof(hexadecimal_seed.data), hash_of_seed);

    cout << "\n"
         << "Hash of seed     : " << hash_of_seed<< endl;


    // having the hashed seed, we can proceed
    // with generation of private and public spend keys.
    // the keccak hash of the seed is used as a seed
    // to generate the spend keys.
    crypto::public_key public_spend_key;
    crypto::secret_key private_spend_key;

    crypto::generate_keys(public_spend_key, private_spend_key,
                          xmreg::get_key_from_hash<crypto::secret_key>(hash_of_seed),
                          true);

    cout << "\n"
         << "Private spend key: " << private_spend_key << "\n"
         << "Public spend key : " << public_spend_key  << endl;

    // now we get private and public view keys.
    // to do this, we keccak hash the hash_of_seed again
    crypto::hash hash_of_hash;
    cn_fast_hash(hash_of_seed.data, sizeof(hash_of_seed.data), hash_of_hash);

    crypto::public_key public_view_key;
    crypto::secret_key private_view_key;


    crypto::generate_keys(public_view_key, private_view_key,
                          xmreg::get_key_from_hash<crypto::secret_key>(hash_of_hash),
                          true);

    cout << "\n"
         << "Private view key : " << private_view_key << "\n"
         << "Public view key  : " << public_view_key  << endl;



    // having all keys, we can get the corresponding monero address
    cryptonote::account_public_address address {public_spend_key, public_view_key};


    cout << "\n"
         << "Monero address   : " << address << endl;


    cout << "\nEnd of program." << endl;

    return 0;
}
1
  • Warning, this post says 3 letters can be enough. For English BIP39, you need 4 letters! blockplate.com/pages/… It would be better to rephrase the post to mention 4 letters are required, for some languages 3 to avoid confusion.
    – ph4r05
    Commented Mar 4, 2022 at 10:25
7

You can restore a wallet/account with the private keys as hexadecimal data, rather than their mnemonic form, using either the --generate-from-keys or --generate-from-json options to simplewallet.

See the answer to If I saved my view key and spend key can I recover my wallet if my mnemonic seed is lost? for the full instructions.

6

The mnemonic seed is actually just a human-readable encoding of a what is otherwise a random key. This key is first generated in binary, then the mnemonic seed is derived from it. The mnemonic seed should be able to fully represent any possible binary combination, so changing the encoding won't provide more bits of entropy.

From https://getmonero.org/knowledge-base/moneropedia/mnemonicseed :

Those words correspond to a 256-bit integer, which is the account's private spend key.

2

See https://github.com/skaht/XMR for bytes_to_words, inverse_mnemonics, and sc_reduce32 standalone executables.

1% echo -n "ABC_brain__FART" | bx base16-encode | bx sha256 | ./sc_reduce32

17dad864c22ac1e8c4c34ec3445893aaf7c7723d23f82b764bc784e114b54e08

2% echo -n "ABC_brain__FART" | bx base16-encode | bx sha256 | ./sc_reduce32 | ./bytes_to_words

gels exotic pliers ringing relic orange happens roared liar dove owner fitting stellar sabotage wounded vane spiders ethics bowling dexterity auctions akin sanity sixteen akin

3% echo -n "ABC_brain__FART" | bx base16-encode | bx sha256 | ./sc_reduce32 | ./bytes_to_words | ./inverse_mnemonics

17dad864c22ac1e8c4c34ec3445893aaf7c7723d23f82b764bc784e114b54e08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.