<p>It turns out I was using master seed + sequence + subsequence, while I should've been using public generator + sequence + subsequence. So in my example:</p>

<ul>
<li>I take <code>0388E5BA87A000CB807240DF8C848EB0B5FFA5C8E5A521BC8E105C0F0A442178280000000000000000</code> and half-SHA512 hash it, I get <code>28F3E125EDB203022C7D22C486284706058C209DBF4A98C3923705A4E5347C7A</code></li>
<li>Adding <code>7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8</code> (private generator) and <code>28F3E125EDB203022C7D22C486284706058C209DBF4A98C3923705A4E5347C7A</code> I get <code>A5EF877564D096EA445E72FDA77C77BB45002261087C69D57CEA56B008102D52</code> - the private key</li>
<li>The corresponding address is <code>rhcfR9Cg98qCxHpCcPBmMonbDBXo84wyTn</code>, which is exactly what I needed to generate.</li>
</ul>

CC BY-SA 3.0
2014-05-06T17:54:08.157Z
2014-05-06T17:54:08.157Z
ThePiachu
<p>You can reference the <a href="https://bitbucket.org/dchapes/ripple/src/default/crypto/rkey/familyseed_test.go" rel="nofollow noreferrer">test cases</a> in my Go implementation of this
that I linked to in an <a href="https://bitcoin.stackexchange.com/a/18880/3364">answer</a> to a <a href="https://bitcoin.stackexchange.com/questions/18858/what-is-the-algorithm-for-generating-a-ripple-address-from-a-ecdsa-public-key">similar question</a>.</p>

<p>For the case given on the wiki page the values should be:</p>

<ul>
<li>secret: shHM53KPZ87Gwdqarm1bAmPeXg8Tn ==
0x71ED064155FFADFA38782C5E0158CB26</li>
<li>private generator: 0x7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8</li>
<li>public generator: fht5yrLWh3P8DrJgQuVNDPQVXGTMyPpgRHFKGQzFQ66o3ssesk3o</li>
<li>first private key: pwMPbuE25rnajigDPBEh9Pwv8bMV2ebN9gVPTWTh4c3DtB14iGL</li>
<li>first public key: aBRoQibi2jpDofohooFuzZi9nEzKw9Zdfc4ExVNmuXHaJpSPh8uJ</li>
<li>first Ripple address: rhcfR9Cg98qCxHpCcPBmMonbDBXo84wyTn</li>
</ul>

<p>Many of those are in Ripple's base58 encoding. I can provide the hex equivalent if required but it's probably easier for people to get the above linked Go package and run the test cases themselves. It should be trivial for any programer (whether they know Go or not) to tweak the test code to show them whatever details they need.</p>

<p>Edit:
With the private/public generators you specify (0x7CFBA64F… and 0x0388E5BA…) you should be hashing <code>0x0388e5ba87a000cb807240df8c848eb0b5ffa5c8e5a521bc8e105c0f0a442178280000000000000000</code> into <code>0x28f3e125edb203022c7d22c486284706058c209dbf4a98c3923705a4e5347c7a</code> which is good and doesn't requre incrementing the sub-sequence.
That is added to the private generator mod N to result in a private key of <code>0xa5ef877564d096ea445e72fda77c77bb45002261087c69d57cea56b008102d52</code>.</p>

CC BY-SA 3.0
2014-05-06T17:00:54.300Z
Okay, but how was the private key derived? It should be a sum of the private generator and another key generated from secret+sequense+subsequence half-SHA512'd.
ThePiachu
CC BY-SA 3.0
2014-05-06T17:15:42.830Z
The private generator (also confusingly referred to as the root key) is all that is needed to generate the private key(s). The secret isn't used at this step. The secret is only used to make the generator. Currently the "account family" feature is mostly unused and only the first (index 0) private/public key is used. The generator takes the index of the key desired, and loops with an additional sub-index until it finds a valid key using it's hashing as described on the wiki.
dchapes
CC BY-SA 3.0
2014-05-06T17:17:14.120Z
In the linked Go code, the hashing is in publicgenerator.go:hashGenerate() and used by both the PrivateGenerator.Generate() and PublicGenerator.Generate() methods.
dchapes
CC BY-SA 3.0
2014-05-06T17:35:41.157Z
Hmm, looking at hashGenerate(), `sum = hash.Sum(sum[:0])` doesn't make much sense to me. Other than that, it appears that the private key is set to  appended `private generator`, `idx` and `subseq`. So the private key should be `71ED064155FFADFA38782C5E0158CB260000000000000000`?
ThePiachu
CC BY-SA 3.0
2014-05-06T17:49:00.753Z
Okay, got my mistake - I was using the master seed + sequence + subsequence, while I should've been using public generator + sequence + subsequence...
ThePiachu
CC BY-SA 3.0
2014-05-06T17:51:06.510Z
(BTW, I referenced specific methods within my Go code cause I happen to know that you're familiar with Go; others reading this wish to look elsewhere :).) `hash.Sum()`'s argument is a byte slice that it __appends__ the resultant hash to so `sum=hash.Sum(sum[:0])` is used in the loop for the hash to over-write the existing `sum` slice and avoid re-alloactions.
dchapes
CC BY-SA 3.0
2014-05-06T16:17:27.843Z
2014-05-06T17:46:33.860Z
2017-04-13T12:47:33.660Z
dchapes
<p>I am trying to recreate the Ripple address from <a href="https://ripple.com/wiki/Account_Family#Test_Vectors" rel="nofollow">Account Family wiki page</a> and I am having some problems.</p>

<ul>
<li>I have the private generator of <code>7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8</code>, and the hex public generator of <code>0388E5BA87A000CB807240DF8C848EB0B5FFA5C8E5A521BC8E105C0F0A44217828</code>.</li>
<li>I start generating the " the hash of (the 33-byte public generator + 32-bit sequence number in big-endian order + the 32-bit sub-sequence number in big-endian order".</li>
<li>I try <code>71ED064155FFADFA38782C5E0158CB260000000000000000</code>, which generates <code>9F407F7EC35B9AB44831BF0D47CDDAEF7BC11107CE1D10A65368A12B9338F82E</code> - this result is bigger than the generator, so I increment the sub-sequence</li>
<li>I try <code>71ED064155FFADFA38782C5E0158CB260000000000000001</code>, which generates <code>3545C8FE25A89E83287B79D186018D8600A7D5249673FB6D44A77FB12062203B</code> - which is good.</li>
<li>I add private generator <code>7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8</code> to what I just generated <code>3545C8FE25A89E83287B79D186018D8600A7D5249673FB6D44A77FB12062203B</code>, and I get the result <code>B2416F4D9CC7326B405CCA0AA755BE3B401BD6E7DFA5CC7F2F5AD0BC433DD113</code></li>
<li>The compressed public key corresponding to that is <code>02FA95E05F5DA5A433F7B1EE4682DAB44AF28FBC04B485993EC2E516C1D3C30D73</code>, but in the example the compressed public key is <code>03fa25b68da6ff6832e4462fdfb9a2aaa58888c0ed17285ffe92e4465e0c6e782a</code></li>
</ul>

<p>Where did I make a mistake?</p>

CC BY-SA 3.0
2014-05-06T16:18:04.887Z
Is this considered a duplicate of http://bitcoin.stackexchange.com/questions/18858/what-is-the-algorithm-for-generating-a-ripple-address-from-a-ecdsa-public-key ?
dchapes
<address><development><ripple><address-generation>
Generating Ripple address
ThePiachu
# Generating Ripple address

(Asked by: username_0 on 2014-05-06)

I am trying to recreate the Ripple address from [Account Family wiki page](https://ripple.com/wiki/Account_Family#Test_Vectors) and I am having some problems.

* I have the private generator of `7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8`, and the hex public generator of `0388E5BA87A000CB807240DF8C848EB0B5FFA5C8E5A521BC8E105C0F0A44217828`.
* I start generating the " the hash of (the 33-byte public generator + 32-bit sequence number in big-endian order + the 32-bit sub-sequence number in big-endian order".
* I try `71ED064155FFADFA38782C5E0158CB260000000000000000`, which generates `9F407F7EC35B9AB44831BF0D47CDDAEF7BC11107CE1D10A65368A12B9338F82E` - this result is bigger than the generator, so I increment the sub-sequence
* I try `71ED064155FFADFA38782C5E0158CB260000000000000001`, which generates `3545C8FE25A89E83287B79D186018D8600A7D5249673FB6D44A77FB12062203B` - which is good.
* I add private generator `7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8` to what I just generated `3545C8FE25A89E83287B79D186018D8600A7D5249673FB6D44A77FB12062203B`, and I get the result `B2416F4D9CC7326B405CCA0AA755BE3B401BD6E7DFA5CC7F2F5AD0BC433DD113`
* The compressed public key corresponding to that is `02FA95E05F5DA5A433F7B1EE4682DAB44AF28FBC04B485993EC2E516C1D3C30D73`, but in the example the compressed public key is `03fa25b68da6ff6832e4462fdfb9a2aaa58888c0ed17285ffe92e4465e0c6e782a`

Where did I make a mistake?

**Tags:** address, development, ripple, address-generation

> **Comments:**
> **username_1**: Is this considered a duplicate of http://bitcoin.stackexchange.com/questions/18858/what-is-the-algorithm-for-generating-a-ripple-address-from-a-ecdsa-public-key ?  

---

## 2 answers

### Answer by username_0 on 2014-05-06. Score: 0 | Accepted answer

It turns out I was using master seed + sequence + subsequence, while I should've been using public generator + sequence + subsequence. So in my example:

* I take `0388E5BA87A000CB807240DF8C848EB0B5FFA5C8E5A521BC8E105C0F0A442178280000000000000000` and half-SHA512 hash it, I get `28F3E125EDB203022C7D22C486284706058C209DBF4A98C3923705A4E5347C7A`
* Adding `7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8` (private generator) and `28F3E125EDB203022C7D22C486284706058C209DBF4A98C3923705A4E5347C7A` I get `A5EF877564D096EA445E72FDA77C77BB45002261087C69D57CEA56B008102D52` - the private key
* The corresponding address is `rhcfR9Cg98qCxHpCcPBmMonbDBXo84wyTn`, which is exactly what I needed to generate.


---

### Answer by username_1 on 2014-05-06. Score: 1

You can reference the [test cases](https://bitbucket.org/username_1/ripple/src/default/crypto/rkey/familyseed_test.go) in my Go implementation of this
that I linked to in an [answer](https://bitcoin.stackexchange.com/a/18880/3364) to a [similar question](https://bitcoin.stackexchange.com/questions/18858/what-is-the-algorithm-for-generating-a-ripple-address-from-a-ecdsa-public-key).

For the case given on the wiki page the values should be:

* secret: shHM53KPZ87Gwdqarm1bAmPeXg8Tn ==
  0x71ED064155FFADFA38782C5E0158CB26
* private generator: 0x7CFBA64F771E93E817E15039215430B53F7401C34931D111EAB3510B22DBB0D8
* public generator: fht5yrLWh3P8DrJgQuVNDPQVXGTMyPpgRHFKGQzFQ66o3ssesk3o
* first private key: pwMPbuE25rnajigDPBEh9Pwv8bMV2ebN9gVPTWTh4c3DtB14iGL
* first public key: aBRoQibi2jpDofohooFuzZi9nEzKw9Zdfc4ExVNmuXHaJpSPh8uJ
* first Ripple address: rhcfR9Cg98qCxHpCcPBmMonbDBXo84wyTn

Many of those are in Ripple's base58 encoding. I can provide the hex equivalent if required but it's probably easier for people to get the above linked Go package and run the test cases themselves. It should be trivial for any programer (whether they know Go or not) to tweak the test code to show them whatever details they need.

Edit:
With the private/public generators you specify (0x7CFBA64F… and 0x0388E5BA…) you should be hashing `0x0388e5ba87a000cb807240df8c848eb0b5ffa5c8e5a521bc8e105c0f0a442178280000000000000000` into `0x28f3e125edb203022c7d22c486284706058c209dbf4a98c3923705a4e5347c7a` which is good and doesn't requre incrementing the sub-sequence.
That is added to the private generator mod N to result in a private key of `0xa5ef877564d096ea445e72fda77c77bb45002261087c69d57cea56b008102d52`.

> **Comments:**
> **username_0**: Okay, but how was the private key derived? It should be a sum of the private generator and another key generated from secret+sequense+subsequence half-SHA512'd.  
> **username_1**: The private generator (also confusingly referred to as the root key) is all that is needed to generate the private key(s). The secret isn't used at this step. The secret is only used to make the generator. Currently the "account family" feature is mostly unused and only the first (index 0) private/public key is used. The generator takes the index of the key desired, and loops with an additional sub-index until it finds a valid key using it's hashing as described on the wiki.  
> **username_1**: In the linked Go code, the hashing is in publicgenerator.go:hashGenerate() and used by both the PrivateGenerator.Generate() and PublicGenerator.Generate() methods.  
> **username_0**: Hmm, looking at hashGenerate(), `sum = hash.Sum(sum[:0])` doesn't make much sense to me. Other than that, it appears that the private key is set to  appended `private generator`, `idx` and `subseq`. So the private key should be `71ED064155FFADFA38782C5E0158CB260000000000000000`?  
> **username_0**: Okay, got my mistake - I was using the master seed + sequence + subsequence, while I should've been using public generator + sequence + subsequence...  
> **username_1**: (BTW, I referenced specific methods within my Go code cause I happen to know that you're familiar with Go; others reading this wish to look elsewhere :).) `hash.Sum()`'s argument is a byte slice that it __appends__ the resultant hash to so `sum=hash.Sum(sum[:0])` is used in the loop for the hash to over-write the existing `sum` slice and avoid re-alloactions.  

---

