polkascan / py-substrate-interface

Python Substrate Interface
https://polkascan.github.io/py-substrate-interface/
Apache License 2.0
240 stars 114 forks source link

Some derivation paths cause Keypair.createUri errors #176

Closed PierreBesson closed 2 years ago

PierreBesson commented 2 years ago

I am encountering an error when creating a Keypair with certain derivation paths.

For example with (//rococo-validator-profiled-node-0):

Keypair.create_from_uri('fabric soldier unable infant mix test nuclear movie into decorate scheme slide//rococo-validator-profiled-node-0')

results in this error:

{ValueError}Expected bytes of length 32, got 33

While the following works fine (//rococo-validator-profile-node-0, without the d):

Keypair.create_from_uri('fabric soldier unable infant mix test nuclear movie into decorate scheme slide//rococo-validator-profile-node-0')

Thank you in advance.

arjanz commented 2 years ago

This was caused because of an incorrect HDKD path length determination (the str length instead of the SCALE bytes length), paths above 32 bytes need to be hashed. Thanks for reporting!

PierreBesson commented 2 years ago

Thank you @arjanz for the incredible quick-fix response. <1h between bug report and fixed release ! I confirm that the issue doesn't happen anymore in v1.1.7