BitShares Forum

Main => Technical Support => Topic started by: madforstrength on June 22, 2016, 06:16:36 AM

Title: How to restore backup from .bin file programmatically
Post by: madforstrength on June 22, 2016, 06:16:36 AM
@xeroc Hi again,

Can you tell me if python-graphenelib has any method to import backup from bin file?

Or any other way I can import backup from bin file in my wallet?

Thanks and Regards
Title: Re: How to restore backup from .bin file programmatically
Post by: xeroc on June 22, 2016, 09:23:52 AM
Quote from: madforstrength on June 22, 2016, 06:16:36 AM
@xeroc Hi again,

Can you tell me if python-graphenelib has any method to import backup from bin file?
Nop. Don't even know what format that is.

Quote
Or any other way I can import backup from bin file in my wallet?
Where did you get that file? Does it not load in the Web wallet?
Title: Re: How to restore backup from .bin file programmatically
Post by: madforstrength on June 22, 2016, 09:43:15 AM
@xeroc , This is the backup file that we export from webwallet, it is importing fine in other webwallet as well as desktop wallet.

What I am trying to do is adding "import from backup .bin file" functionality in my application. So I was wondering if you or someone can tell me how this file is decoded to get wallet json keys.
Title: Re: How to restore backup from .bin file programmatically
Post by: xeroc on June 22, 2016, 11:00:02 AM
Seems to be aLZMA compressm JSON object
https://github.com/cryptonomex/graphene-ui/blob/master/dl/src/actions/BackupActions.js#L80-L96
Title: Re: How to restore backup from .bin file programmatically
Post by: madforstrength on June 22, 2016, 11:25:18 AM
Yes @xeroc I have been trying to reverse engineer its decryptWalletBackup method.
Can you tell me python/graphene equivalent of this method ?

PublicKey.fromBuffer
Title: Re: How to restore backup from .bin file programmatically
Post by: xeroc on June 22, 2016, 01:20:05 PM
Quote from: madforstrength on June 22, 2016, 11:25:18 AM
Yes @xeroc I have been trying to reverse engineer its decryptWalletBackup method.
Can you tell me python/graphene equivalent of this method ?

PublicKey.fromBuffer


Erm .. it would probably be something like this

from graphenebase.account import PublicKey
frim binascii import unhexlify
b = rawPublicKey
pubKey = PublicKey(unhexlify(b))
Title: Re: How to restore backup from .bin file programmatically
Post by: madforstrength on June 27, 2016, 11:29:01 AM
Hi @xeroc can you tell me how can i decrypt encrypted private keys?

Also I got encrypted brain key alongwith its encryption key, would appreciate if you can tell me to decrypt brainkey as well.

Thanks
Title: Re: How to restore backup from .bin file programmatically
Post by: xeroc on June 27, 2016, 11:40:52 AM
Quote from: madforstrength on June 27, 2016, 11:29:01 AM
Hi @xeroc can you tell me how can i decrypt encrypted private keys?

Also I got encrypted brain key alongwith its encryption key, would appreciate if you can tell me to decrypt brainkey as well.

Thanks
I don't know many details about how the GUI encrypts the wallet.
But once you have a brain key (12 english words) you can use the BrainKey object in graphenebase.account (https://github.com/xeroc/python-graphenelib/blob/master/graphenebase/account.py#L47-L65) to get the private key(s)
Title: Re: How to restore backup from .bin file programmatically
Post by: madforstrength on June 27, 2016, 11:50:33 AM
yup I know that, but the problem is I am getting encrypted brainkey with an encryption key but i dont know what type of encryption is that. :(

DO you know anyone in this forum who can guide me about it? who knows how gui wallet works?
Title: Re: How to restore backup from .bin file programmatically
Post by: svk on June 27, 2016, 11:58:48 AM
Quote from: madforstrength on June 27, 2016, 11:50:33 AM
yup I know that, but the problem is I am getting encrypted brainkey with an encryption key but i dont know what type of encryption is that. :(

DO you know anyone in this forum who can guide me about it? who knows how gui wallet works?

@jcalfee1 is the one who wrote the code for it, I haven't looked too much at this part myself.

Found this though:

var brainkey_plaintext = aes_private.decryptHexToText( wallet.encrypted_brainkey )

aes_private is an instance of Aes, the method decryptHexToText can be found here:

https://github.com/svk31/graphenejs-lib/blob/master/lib/ecc/src/aes.js#L228