bip32 / bip32.github.io

BIP32 is a Brainwallet-based implementation for BIP0032 deterministic wallet generation
Other
114 stars 71 forks source link

Custom child derivation path does not parse 'p' correctly. #1

Open sbuss opened 10 years ago

sbuss commented 10 years ago

While using your awesome tool to build some test vectors in https://github.com/sbuss/bitmerchant/pull/10 I noticed that custom child derivation paths are not parsed correctly if the path contains a 'p' character.

Reproducing the failure

Given the BIP32 key dgpv51eADS3spNJh8qd8KgFeT3V2QZBDSkYUqbaKDwZpDN4jd3uLcR7i6CruVDsbacyx3NL2puToxM9MQYhZSsD8tBkXeQkm5btsKxpZawwPQND on DogecoinMainNet, consider the paths m/0, m/0p, and m/0'.

The path m/0 produces expected results:

screen shot 2014-02-23 at 1 50 53 am

But if you try to do a standard path using p instead of ' it ignores the p and treats it as a non-prime derivation (You can see these results are the same as m/0):

screen shot 2014-02-23 at 1 54 22 am

Finally, the m/0' path works and produces expected results (different from above): screen shot 2014-02-23 at 1 53 21 am

sarchar commented 10 years ago

Should m/0p be evaluated just like m/0'? Or should m/0p (and any other non-standard characters) raise an error?

sbuss commented 10 years ago

Should m/0p be evaluated just like m/0'? Or should m/0p (and any other non-standard characters) raise an error?

I think so, yes. This syntax is supported in money tree, pycoin, and bitmerchant. (Note that I'm currently developing bitmerchant.)

I just realized that the 'p' derivation isn't actually in the BIP32 spec. Parts of the BIP32 spec are a little vague and so I was using the money tree readme as a supplementary reference, and its support of this alternate syntax made me think it was official. I guess this isn't actually a bug, but an improvement request. The tools that I've seen all support this alternate syntax, so I think this tool should also support it.

Feel free to mark this as a feature request and put it on the back burner.

sarchar commented 10 years ago

@sbuss

I've followed a little bit of your work on Bitmerchant, so it's pretty cool you've found bip32.org useful. Unfortunately as you said, 'p' isn't actually part of the official BIP32 spec, so I think I want to not implement it (at this time). My goal is to be as close as possible to the spec (which is hard to say for litecoin and dogecoin, but whatever)...

@sipa is making some larger changes to BIP32, so let's see where that goes first.