-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Implement BIP32 HD account class - 2 #31
Conversation
👍 as long as there is progress being made. |
I think this is clear but adding I would advocate porting over the necessary components (and cleaning them up). This would also include test cases to demonstrate how the various utils are intended to function. |
I will do so. |
…ed code to required entropy byte count be an element of [16,20,24,28,32], as described in BIP32
…path to setup.py, debugged mnemonic.py to work with python3, adapted function commenting style for the most functions
Today I have:
Output from the current tests:
|
TODOs
|
…path argument support for init. Added and implemented decodePath(...) function to represent the derivation path as a string in format (m/)idx_0/.../idx_n . Added path property to return the string formatted derivation path. Added __repr__ and __str__, adjusted __eq__ and __hash__. Included (very basic) unit test for deriveChild(...) . Adapted function describing commenting style for every function.
Today I have:
Output of basic unit tests:
|
Today I have:
The BIP32 implementation is now complete, only the Ethereum address derivation function and transaction signing function are missing. Test outputs (compares derived path results with single child derivation results):
|
…..), signTransaction(...) . Added value check to deterministic.py
Today I have:
The class is now complete and fully functional. You can inspect one successful outgoing transaction using a key in the path "m/1H/1/42": https://rinkeby.etherscan.io/address/0x56fe41bd2f1993a2b460bbfa1eac838188e0c5c3 Class test outputs - click to expand--- TEST 1: Create HDAccount ---Creating new Account --- TEST2: Init account --- Key: xprv9s21ZrQH143K2uW37T4nqFGRnYQmGCSirH2DU7w7TSVawKQAjcfXdFF7U4moHYuw8BtFKejYjh7GZCjk8Xxa2Qgngen3VpdMX9ehjNDFLdw --- TEST3: Derive children --- Encoded key: xprv9u5ZNQNQnoxqbGtoeH8vqcCcHM6e8tu3MG1PR1TjJKrA3DzjKxTssm3tnqgS8aDzHxqHzQiauWrCbsjmAh2Xg6LsxaBCrzFL9HYgYkC4uyA --- TEST4: Remove private key (only public key derivation possible) --- Encoded key: xpub68DbfiPkyyZPwSJ6xhAtWTbxU4aubRNP7Hog1azeuAztmaXGPXPCtCNd56C4Fqp8GnvfPDofzKjs4ctrfqnoCSY1HDgFw4F6PzdSWg93Sry --- TEST 5: Derive path --- Encoded key: xprv9xyMrSmyo6JvTvX8QQU78ynuHRD6SdwcGtwLB5nxQCd84vje6F4b1HCT6EPbh6hkL8oqEyLp9uqZtxLxGaJTC2JXDwV5Je298Z9FakJbGad --- TEST 6: Get address from xprv and xpub encoded keys --- 0xDF512A1E0Cbe32b63cEc8387BccA63A3b78a8c22 Success! --- TEST 7: Sign message hash --- signing key : xprv9xyMrSmyo6JvTvX8QQU78ynuHRD6SdwcGtwLB5nxQCd84vje6F4b1HCT6EPbh6hkL8oqEyLp9uqZtxLxGaJTC2JXDwV5Je298Z9FakJbGad --- TEST 8: Create and sign Transaction --- Encoded key: xprv9y8Gw5q3qFv42CiuohDV6L8gY9VHjs74dMKos2pVp74vyHFRiTHwPHFDAEgzYDYDQYEh2yahi4Jga6qQn3q45yzvPcPibUaKNRrkTbsDHkK |
I have completed all remaining tasks now (test and cleanup mostly), the HDAccount class is now complete and fully functional. Isort worked as excepted before and the automated tests found no issues, but since I added some more imports today the automated tests find errors. My local isort does tell me that the imports are fine. I have tried different options, like ignoring types, but I just can't get the automated testing tool to accept the file. Sadly the error report does not give me any hint what is not ok in detail. Do you know what could be the problem? apart from that, are you content with this result and can I submit it to gitcoin? You can inspect one successful outgoing transaction usingf a key in the path "m/1H/1/42": https://rinkeby.etherscan.io/address/0x56fe41bd2f1993a2b460bbfa1eac838188e0c5c3 Final output: Class test outputs - click to expand--- TEST 1: Create HDAccount ---Creating new Account --- TEST2: Init account --- Key: xprv9s21ZrQH143K3jVLNgf8Fui3jCtWPcqiQiRiaAK7ePNNJZ9JtGyGTGgcZ1vTvvupog3fNh1fKX1NUnXktUb7HkHm8RPF3T1HR2fX9azVBoU --- TEST3: Derive children --- Encoded key: xprv9vVBpg3dEWZik1QQVSm8sqnnKeo5yrHJ4LAKy3xMPmdyibFzhycEH39yrC9UGbAZ4CqPFiP8RmfMJHNar9QJvHcDuCbvfJJq18f5ig6DcM1 --- TEST4: Remove private key (only public key derivation possible) --- Encoded key: xpub69NmrBJkLnq5fVt2ye6zJ4vXxwKAbpRAzcALGLjURqfXCagrV5cfbHu9tbGfbHRp1AZ9u4j6ZffDBX4eLykvNhBbGyNKeSac5ErJquFqsFt --- TEST 5: Derive path --- Encoded key: xprv9zJqmMpcSQnyLhJmcANVdrQF6tLNahrRkq6zrhmBxJMooKqnhvrwP84Yv8PPSQn9NJCefbZ5SJLdDUMcAe31ZMWYaMa2B243LH5571bWepY --- TEST 6: Get address from xprv and xpub encoded keys --- 0xB2f88570049b43E901769412A7180e20969cfE5C Success! --- TEST 7: Sign message hash --- signing key : xprv9zJqmMpcSQnyLhJmcANVdrQF6tLNahrRkq6zrhmBxJMooKqnhvrwP84Yv8PPSQn9NJCefbZ5SJLdDUMcAe31ZMWYaMa2B243LH5571bWepY --- TEST 8: Create and sign Transaction --- Encoded key: xprv9y8Gw5q3qFv42CiuohDV6L8gY9VHjs74dMKos2pVp74vyHFRiTHwPHFDAEgzYDYDQYEh2yahi4Jga6qQn3q45yzvPcPibUaKNRrkTbsDHkK --- TEST 9: BIP32 Testvector 1 --- Success! --- TEST 10: BIP32 Testvector 2 --- Success! --- TEST 11: BIP32 Testvector 3 --- All tests were successful! |
Closed in favor of #33 |
What was wrong?
Issue #24
How was it fixed?
I have created the hdaccounts.py file containing the class HDAccount(BaseAccount). I have defined the functions I will need and commented their meaning, usage and further steps. I have left TODOs which I will work on.
Question: Is it okay if I import the files "mnemonic.py" and "deterministic.py" from pybitcointools and if yes, do you want me to adapt them to reduce the overhead of the required libraries or do you want me to write them completely from scratch?
Note: I have an unusually high amount of work last week and in the coming week. I will spend just a couple of hours in the coming week, but continuous progress will be observable. Afterwards the progress will be significantly accelerated.