Post
Topic
Board Development & Technical Discussion
Re: BIP0032 Hierarchical Deterministic Wallet key generator bip32utils (Python)
by
teukon
on 05/02/2014, 18:50:31 UTC
Disclaimer: Don't expect much from me.  I'm not a programmer and only created a GitHub account so I could comment on a Regex Golf Gist.

So far I've just been playing with the basics.

I generated BIP0032 test vector #1 using the command in your readme and got the desired result.

I then created my own master key with bip32gen and used your Base58 module to decompose the output and compare it with the serialisation format as specified by BIP0032.  I managed to recover the private key just fine.

Code:
$ bip32gen -i entropy -f /dev/random -n 128 -o privkey,xprv -F - -X m
aec8cfc47b43d518e1c6ce27ca2035af7f598f39e10748be395a27be23dcf1ee
xprv9s21ZrQH143K3E8CHFyZactH1tY5gnofwvtELcdtUeZuewTYh32z1sQdBfCdUdc1CcGAMVLddqUK9ioP6NGRtPNRAbFRp6RLbte1iVqduC2

Code:
>>> Base58.decode('xprv9s21ZrQH143K3E8CHFyZactH1tY5gnofwvtELcdtUeZuewTYh32z1sQdBfCdUdc1CcGAMVLddqUK9ioP6NGRtPNRAbFRp6RLbte1iVqduC2').encode('hex')[92:-8]
'aec8cfc47b43d518e1c6ce27ca2035af7f598f39e10748be395a27be23dcf1ee'

I did have a quick look at the code but I didn't get so far with it.  I got a little confused as your style changed.  For example, compare the extended key version handling in fromExtendedKey
Code:
       # Verify address version/type
        version = raw[:4]
        if version.encode('hex') == '0488ade4':
            keytype = 'xprv'
        elif version.encode('hex') == '0488b21e':
            keytype = 'xpub'
        else:
            raise ValueError("unknown extended key version")
to that in ExtendedKey
Code:
       version = '\x04\x88\xB2\x1E' if private is False else '\x04\x88\xAD\xE4'

On this topic:  Would 0x0488ade4 and 0x0488b21e be better as module constants?  How easy would it be to add support for testnet keys?

That's all I have time for today.  Hopefully I'll find time to move some funds around tomorrow.