Skip to content
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

back-ports privateKey validation of the 2.x Accounts module to 1.x #3323

Merged
merged 6 commits into from
Jan 24, 2020

Conversation

nivida
Copy link
Contributor

@nivida nivida commented Jan 21, 2020

Description

Thanks to @DalderupMaurice to give me a hint about the more advanced solution in the 2.x branch.

Type of change

  • Enhancement

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run dtslint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success and extended the tests if necessary.
  • I ran npm run build-all and tested the resulting file/'s from dist folder in a browser.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have tested my code on the live network.

@nivida nivida added Enhancement Includes improvements or optimizations 1.x 1.0 related issues labels Jan 21, 2020
@nivida nivida requested a review from cgewecke January 21, 2020 10:04
@nivida nivida added the Review Needed Maintainer(s) need to review label Jan 21, 2020
@nivida nivida marked this pull request as ready for review January 21, 2020 10:04
@nivida nivida changed the title back-ports privateKey handling of the 2.x Accounts module to 1.x back-ports privateKey validation of the 2.x Accounts module to 1.x Jan 21, 2020
Copy link
Collaborator

@cgewecke cgewecke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes! This is nicer - LGTM.

Left some reformatting suggestions (sorry)

test/eth.accounts.sign.js Outdated Show resolved Hide resolved
test/eth.accounts.sign.js Outdated Show resolved Hide resolved
test/eth.accounts.sign.js Outdated Show resolved Hide resolved
test/eth.accounts.sign.js Outdated Show resolved Hide resolved
test/eth.accounts.sign.js Outdated Show resolved Hide resolved
test/eth.accounts.sign.js Outdated Show resolved Hide resolved
test/eth.accounts.sign.js Outdated Show resolved Hide resolved
test/eth.accounts.sign.js Outdated Show resolved Hide resolved
test/eth.accounts.sign.js Outdated Show resolved Hide resolved
@cgewecke cgewecke self-requested a review January 21, 2020 18:38
Copy link
Collaborator

@cgewecke cgewecke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Just realized this change if causing a couple tests to fail in CI...those probably need to pass or be investigated :)

Otherwise LGTM - this is a nice solution.

Left a few reformatting suggestions (sorry)

@nivida nivida requested a review from cgewecke January 22, 2020 11:16
@nivida
Copy link
Contributor Author

nivida commented Jan 22, 2020

@cgewecke I've removed the test vectors with 30 or 31bytes long private keys stored in the keystore v3 JSON file because web3.js does not left-pad the PK to 32bytes as go-ethereum is doing. I think the path of keeping the PK untouched is the right one. WDYT?

@coveralls
Copy link

coveralls commented Jan 22, 2020

Coverage Status

Coverage increased (+0.02%) to 85.466% when pulling 4ca9d41 on back-port/pk-handling-accounts into 5a53ae9 on 1.x.

Copy link
Collaborator

@cgewecke cgewecke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you have encrypted with 1.2.4 using a non-standard length, stored the result somewhere and want to decrypt with a later version? The test case suggests the non-standard length should work for this purpose.

Not completely certain what's correct here - have opened #3328 as a possible alternative.

…dded to eth.accounts.encrypt-decrypt test file
@nivida
Copy link
Contributor Author

nivida commented Jan 23, 2020

@cgewecke I've applied the requested changes and re-added the 30/31 byte test vectors.
Thanks for your review! I have totally missed that case.

@nivida nivida requested a review from cgewecke January 23, 2020 09:57
Copy link
Collaborator

@cgewecke cgewecke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great and improves on the suggestion in #3328.

The test file changes should really come out though, sorry. I think those files should only be changed for logic so the implications of the new code are crystal clear. They don't require "helpful reformatting" - unless done as a separate initiative.

docs/web3-eth-accounts.rst Show resolved Hide resolved
test/eth.accounts.encrypt-decrypt.js Show resolved Hide resolved
@nivida nivida removed the Review Needed Maintainer(s) need to review label Jan 24, 2020
@nivida nivida merged commit 0b657c2 into 1.x Jan 24, 2020
@cgewecke
Copy link
Collaborator

@nivida This was merged over a requested change?

@nivida nivida deleted the back-port/pk-handling-accounts branch January 27, 2020 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Enhancement Includes improvements or optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants