4

Sorry if I post it at wrong place, do tell if I post to wrong place so I get post it to right place.

Dear all fellow reddit, I did trying to get private view key but somewhat I cant get it to work. However, I do manage Hash of seed from Hexadecimal Seed created from mnemonic.

The Hexadecimal seed was obtained from https://github.com/moneroexamples/mymonero-keys for testing. I seem managed to get correct Hash of seed by keccak_256 hexadecimal seed.

I read many sites state that Private view key was obtained by sc_reduce32 the hash of seed. But I dont get it working.

Here is my code https://pastebin.com/fNDrTtS8 run in Python 2.7.

Can someone kind to show me how to get private view key from hash of seed?

If can I do prefer the method to work in Python 2.7 since most of the previous was created on python.

Thank you very much.

1

Your sc_reduce32 function was using the wrong value to reduce by, and you had not reversed the endianness of your bytes. Here is working code:

import sha3

l = 2 ** 252 + 27742317777372353535851937790883648493


def reverse_byte_order(hex):
    if(len(hex)%2==1): hex = '0' + hex
    return "".join(reversed([hex[i:i+2] for i in range(0, len(hex), 2)]))


def sc_reduce32(key):
    return reverse_byte_order("%x" % int((int(reverse_byte_order(key), 16) % l)))


def cn_fast_hash(hex):
    k = sha3.keccak_256()
    k.update(bytearray.fromhex(hex))
    return k.hexdigest()


hexadecimal_seed = "852249bca4446e65501cc7f8338027ec"
hash_of_seed = cn_fast_hash(hexadecimal_seed)
private_spend_key = sc_reduce32(hash_of_seed)
private_view_key = sc_reduce32(cn_fast_hash(hash_of_seed))

print "Non-standard Seed = ", hexadecimal_seed
print "Normalized Seed   = ", hash_of_seed
print "Private Spend Key = ", private_spend_key
print "Private View Key  = ", private_view_key
  • Thank you. I have completed the python code that will generate public address by giving seed of mymonero. Here is the final code link in case the community need it. The code will work Python 2.7. – Choon Boon Khoo Jul 3 '18 at 18:42
  • @ChoonBoonKhoo Thanks for sharing your link. Please could you also share your base58 encoder, for completeness? – knaccc Jul 3 '18 at 19:22
  • 1
    The base58 code was obtained from here link. Should be open-source and I don't own the code. – Choon Boon Khoo Jul 4 '18 at 14:10

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.