Author

Topic: Decipher xprv or seed from keystore when I know the password (Read 266 times)

full member
Activity: 297
Merit: 133
Code:
>>> from mnemonic import Mnemonic
>>> mnemo = Mnemonic("english")
>>> xprv = '419ff3b824753f296223325a300a694a9641135558eedda79d9cb74f046e1457'
>>> len(xprv)
64
>>> xprv_bytes = bytes.fromhex(xprv)
>>> len(xprv_bytes)
32
>>> mnemo.to_mnemonic(xprv_bytes)
'dose zebra unlock employ fault net mass green focus leopard olympic news goat meadow fever build tank diagram grunt hub utility damage eyebrow view'

Yes, that works! Thank you!
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
--snip--
Both xprv and seed are in hex. I've already told you.
I need xprv and seed to be converted to xprv in base58 format, seed to words.
--snip--

At least from seed (in hex format) to words it should be straightforward. An example,

Code:
>>> from mnemonic import Mnemonic
>>> mnemo = Mnemonic("english")
>>> xprv = '419ff3b824753f296223325a300a694a9641135558eedda79d9cb74f046e1457'
>>> len(xprv)
64
>>> xprv_bytes = bytes.fromhex(xprv)
>>> len(xprv_bytes)
32
>>> mnemo.to_mnemonic(xprv_bytes)
'dose zebra unlock employ fault net mass green focus leopard olympic news goat meadow fever build tank diagram grunt hub utility damage eyebrow view'

Take note it require library from https://github.com/trezor/python-mnemonic. And in case i also misunderstood what you want to achieve, i would suggest you to add expected input/output with some examples to your question.
full member
Activity: 297
Merit: 133
...

Always please read the first post - it is all explained there.

No, this script does not do what I need.
It does more encode the xprv (not this direction which I need) by sha256 and does not give seed phrase in text.

Please stop trolling.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
Both xprv and seed are in hex. I've already told you.
Maybe, but you haven't cleared up what you want to do, and it's difficult to understand what is what from your wording.

I need xprv and seed to be converted to xprv in base58 format, seed to words.
So you want hexadecimally represented xprv to base58 and hexadecimally represented seed to words (AKA, seed phrase).

I don't know python, so I asked ChatGPT. Isn't this what you want basically? (for xprv only)
Code:
import base58
import binascii

def encode_xprv(hex_xprv):
    # Convert hex xprv to bytes
    xprv_bytes = binascii.unhexlify(hex_xprv)
    
    # Add version byte (0x0488ADE4) to the beginning
    version_bytes = bytes.fromhex('0488ADE4')
    xprv_bytes = version_bytes + xprv_bytes
    
    # Add 4-byte checksum to the end
    checksum_bytes = hash256(xprv_bytes)[:4]
    xprv_bytes += checksum_bytes
    
    # Encode the result in base58
    encoded_xprv = base58.b58encode(xprv_bytes).decode('utf-8')
    
    return encoded_xprv

def hash256(data):
    # Compute SHA256 hash of data
    import hashlib
    sha256_hash = hashlib.sha256(data).digest()
    
    # Compute SHA256 hash of SHA256 hash
    sha256_twice = hashlib.sha256(sha256_hash).digest()
    
    return sha256_twice

# Example usage
hex_xprv = "0488ade4000000000000000000d094cde7b1ca97a07c82d73bbd6b018f6b3e6d94c6c122f1b883e2e8fa6e76c261d96e4c4baebf8af4b4d05cfef4b1c2b47fa8f8640eb9a16f4d39473df7"
encoded_xprv = encode_xprv(hex_xprv)
print(encoded_xprv)
full member
Activity: 297
Merit: 133
These are hex numbers.
Which are represented in hex?

I need at least seed to be converted to text.
But seed is supposed to be in hex. Seed phrase is in text.

Also xprv is in hex format that modern wallets do not accept.
It sounds very weird that you have a master private key in hex, as it always comes in base58.

It seems to me your situation is an XY problem.

Both xprv and seed are in hex. I've already told you.
I need xprv and seed to be converted to xprv in base58 format, seed to words.

No, it is not XY problem.

Just need to convert xprv and seed to "readable" values, using given password. Mostly by Python code.
I already said that three times.
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
These are hex numbers.
Which are represented in hex?

I need at least seed to be converted to text.
But seed is supposed to be in hex. Seed phrase is in text.

Also xprv is in hex format that modern wallets do not accept.
It sounds very weird that you have a master private key in hex, as it always comes in base58.

It seems to me your situation is an XY problem.
full member
Activity: 297
Merit: 133
What do you mean you want to decipher an xprv / seed? If you have the keystore and the password to unlock it, then you can decrypt everything encrypted in it.

I don't know - I have only .json file and password for it.
Something tells me you bought someone else's wallet which supposedly have coins you try to gain access to. If that's the case, it's most certainly a scam.

These are hex numbers. I need at least seed to be converted to text.
Also xprv is in hex format that modern wallets do not accept.

I have no code to decrypt neither and convert them to "readable" format.
legendary
Activity: 1624
Merit: 2594
Top Crypto Casino
Wallet Client? electrum i guess?

I don't know - I have only .json file and password for it.

So how did you manage to get your hands on that JSON file and its password?
Hope you're not trying anything illegal! Wink
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
What do you mean you want to decipher an xprv / seed? If you have the keystore and the password to unlock it, then you can decrypt everything encrypted in it.

I don't know - I have only .json file and password for it.
Something tells me you bought someone else's wallet which supposedly have coins you try to gain access to. If that's the case, it's most certainly a scam.
full member
Activity: 297
Merit: 133
Wallet Client? electrum i guess?

I don't know - I have only .json file and password for it.
sr. member
Activity: 356
Merit: 268
Wallet Client? electrum i guess?
full member
Activity: 297
Merit: 133
...

If you know the password for your Keystore file, you should be able to access your wallet using a compatible software or wallet. Many wallets support importing Keystore/JSON file, which would allow you to access your funds. You don't need any special tool for that.

What software did you use to create the Kystore/JSON backup file?


I am asking for code (mostly Python) way.

If the JSON would be whole I could import it, it isn't.

No wallet software is applicable here.
legendary
Activity: 1624
Merit: 2594
Top Crypto Casino
I want to decipher xprv and/or seed because I know the password, but I have no tool to do that.

How can I do that?

If you know the password for your Keystore file, you should be able to access your wallet using a compatible software or wallet. Many wallets support importing Keystore/JSON file, which would allow you to access your funds. You don't need any special tool for that.

What software did you use to create the Kystore/JSON backup file?
full member
Activity: 297
Merit: 133
I have .json file with keystore.
I know http://iancoleman.io/ but it does not help me as this is the other way around.
I have JSON dump with: keystore = xprv and seed.
I want to decipher xprv and/or seed because I know the password, but I have no tool to do that.

How can I do that?
Jump to: