<p>I'm not 100% sure how this API works, but it looks like it lets you supply the entropy. Test to see if you always get the same address and secret if you supply the same entropy. If you do, then just use the mnemonic and any HD scheme you want to derive a secret of any kind (you can use the same algorithm you'd use for bitcoin) and pass that secret as the entropy to that API call.</p>

<p>Two cautions with this approach:</p>

<p>1) You must test to make sure that API really is deterministic. Try it on a few different machines and a few different JS implementations and make sure the same entropy always leads to the same address and secret.</p>

<p>2) Your ability to recover keys from the mnemonic would be tied to your access to this library. If the library ever changed its key generation algorithm, you might be unable to recover the keys. So pick a version that works and don't ever change it.</p>

CC BY-SA 3.0
2018-01-22T16:28:32.940Z
2018-01-22T16:28:32.940Z
David Schwartz
<blockquote>
  <p>Test to see if you always get the same address and secret if you
  supply the same entropy.</p>
</blockquote>

<p>I have tested this and can confirm that you always generate the same secret and public address when you supply the same entropy.</p>

<p>Here's my example code for submitting the entropy to the <strong>generateAddress</strong> method.</p>

<pre><code>// This functions works on modern browswers, not sure about Node.js. Try https://www.npmjs.com/package/js-sha512 or https://nodejs.org/api/crypto.html
async function fun_SHA512_array(entropy) {
    'use strict';

    // Turns a string into an array of integers.
    // Made possible by https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest

    const msgUint8 = new TextEncoder().encode(entropy);                           // encode as (utf-8) Uint8Array
    const hashBuffer = await crypto.subtle.digest('SHA-512', msgUint8);           // hash the message
    const hashArray = Array.from(new Uint8Array(hashBuffer));                     // convert buffer to byte array
    // const hashHex = hashArray.map(b =&gt; b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string

    return hashArray;
}

const str_entropy = "Use a cryptographically strong, randomly created string of characters here.";
// Or, your passphrase string would go here.
// Or, you could use a BIP39 Mnemonic but you'd have to remember how you constructed the string. e.g. Did you separate the words with a comma or with a space?
// Or, on the linux terminal you can use: openssl rand -base64 n
// Where n = the number of characters you wish to randomly generate. Which are then converted to base64, therefore the amount of characters ends up being more than n.

var array_sha512 = [];

fun_SHA512_array(str_entropy).then(array_sha512 =&gt; {
    var obj_new_account = api.generateAddress({"entropy": array_sha512});
    var str_secret = obj_new_account.secret;
    var str_public_address = obj_new_account.address;

    console.log(str_secret);
    console.log(str_public_address);
});
</code></pre>

CC BY-SA 4.0
2019-10-17T04:38:48.997Z
2019-10-17T04:38:48.997Z
SimpleXRPTools
<p>I am trying to write a ripple wallet. I want it to be HD wallet.
So I am generating 12 word mnemonics but I am not sure how to give this as a seed to ripple javascript api. See:
<a href="https://ripple.com/build/rippleapi/#generateaddress" rel="nofollow noreferrer">https://ripple.com/build/rippleapi/#generateaddress</a></p>

<wallet><ripple><bip32-hd-wallets><ripple-api>
mnemonics for ripple wallet
Cem Karay
# mnemonics for ripple wallet

(Asked by: username_0 on 2018-01-22)

I am trying to write a ripple wallet. I want it to be HD wallet.
So I am generating 12 word mnemonics but I am not sure how to give this as a seed to ripple javascript api. See:
<https://ripple.com/build/rippleapi/#generateaddress>

**Tags:** wallet, ripple, bip32-hd-wallets, ripple-api


---

## 2 answers

### Answer by username_1 on 2018-01-22. Score: 1 | Accepted answer

I'm not 100% sure how this API works, but it looks like it lets you supply the entropy. Test to see if you always get the same address and secret if you supply the same entropy. If you do, then just use the mnemonic and any HD scheme you want to derive a secret of any kind (you can use the same algorithm you'd use for bitcoin) and pass that secret as the entropy to that API call.

Two cautions with this approach:

1) You must test to make sure that API really is deterministic. Try it on a few different machines and a few different JS implementations and make sure the same entropy always leads to the same address and secret.

2) Your ability to recover keys from the mnemonic would be tied to your access to this library. If the library ever changed its key generation algorithm, you might be unable to recover the keys. So pick a version that works and don't ever change it.


---

### Answer by username_2 on 2019-10-17. Score: 0

> Test to see if you always get the same address and secret if you
> supply the same entropy.

I have tested this and can confirm that you always generate the same secret and public address when you supply the same entropy.

Here's my example code for submitting the entropy to the **generateAddress** method.

```
// This functions works on modern browswers, not sure about Node.js. Try https://www.npmjs.com/package/js-sha512 or https://nodejs.org/api/crypto.html
async function fun_SHA512_array(entropy) {
    'use strict';

    // Turns a string into an array of integers.
    // Made possible by https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest

    const msgUint8 = new TextEncoder().encode(entropy);                           // encode as (utf-8) Uint8Array
    const hashBuffer = await crypto.subtle.digest('SHA-512', msgUint8);           // hash the message
    const hashArray = Array.from(new Uint8Array(hashBuffer));                     // convert buffer to byte array
    // const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string

    return hashArray;
}

const str_entropy = "Use a cryptographically strong, randomly created string of characters here.";
// Or, your passphrase string would go here.
// Or, you could use a BIP39 Mnemonic but you'd have to remember how you constructed the string. e.g. Did you separate the words with a comma or with a space?
// Or, on the linux terminal you can use: openssl rand -base64 n
// Where n = the number of characters you wish to randomly generate. Which are then converted to base64, therefore the amount of characters ends up being more than n.

var array_sha512 = [];

fun_SHA512_array(str_entropy).then(array_sha512 => {
    var obj_new_account = api.generateAddress({"entropy": array_sha512});
    var str_secret = obj_new_account.secret;
    var str_public_address = obj_new_account.address;

    console.log(str_secret);
    console.log(str_public_address);
});

```


---

