0

I am trying to recreate the Ripple address from Account Family wiki page 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?

1

2 Answers 2

1

You can reference the test cases in my Go implementation of this that I linked to in an answer to a similar question.

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.

6
  • 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
    May 6, 2014 at 17:00
  • 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
    May 6, 2014 at 17:15
  • In the linked Go code, the hashing is in publicgenerator.go:hashGenerate() and used by both the PrivateGenerator.Generate() and PublicGenerator.Generate() methods.
    – dchapes
    May 6, 2014 at 17:17
  • 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
    May 6, 2014 at 17:35
  • 1
    Okay, got my mistake - I was using the master seed + sequence + subsequence, while I should've been using public generator + sequence + subsequence...
    – ThePiachu
    May 6, 2014 at 17:49
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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