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

Keystore V4 support #18

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Keystore V4 support #18

wants to merge 2 commits into from

Conversation

naps62
Copy link

@naps62 naps62 commented Jul 4, 2023

This is a follow-up to #17 that attempts to preserve v3 functionality.
I'm not sure about some of the decisions made here, so I'm asking for some feedback before finishing the work

Summary of changes:

  • EthKeystore becomes an enum, with both V3 and V4 variants
  • Both versions have their internal structs and logic in a separate module (still WIP)
  • A feature flag will be added to control v4 support
  • These are breaking changes, but they preserve support for v3. as far as I could tell, there is no non-breaking way of adding v4 support (since e.g. we no longer have a crypto.mac field in v4)

questions:

  1. does this structure make sense? am I over-engineering in some way?
  2. the spec for EIP-2335 is very relaxed about the contents of the kdf / checksum / cipher fields. They all only need to conform to the same generic Module spec. However, the approach in Bump to version 4 following test vecs here: https://eips.ethereum.org/EIPS/eip-2335 #17 used more fine-grained structs for each one. I've got no clue which approach should be followed here
  3. should the feature flag be opt-in or opt-out?

Still a bit left to do, but I'd like some feedback on the structure and
some of the pending changes
match v["version"].as_i64() {
// TODO tests/test-key/my_keystore has no version field
// should we default to v3 to preserve compatibility, or raise an error?
Some(3) | None => {
Copy link
Author

Choose a reason for hiding this comment

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

this here was one of my main questions. Without Nnoe, some of the existing tests fail

@naps62 naps62 changed the title V4 support: initial setup Keystore V4 support Jul 4, 2023
@roynalnaruto roynalnaruto self-requested a review July 5, 2023 21:46
Copy link
Owner

@roynalnaruto roynalnaruto left a comment

Choose a reason for hiding this comment

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

How about we keep the current structure of the project, while introducing a new feature-gated module v4 that has a separate EthKeystoreV4 struct.

Essentially, we don't make use of an Enum with the V3/V4 variants, but a separate struct altogether, which will also make serde issues less complicated?

@naps62
Copy link
Author

naps62 commented Jul 5, 2023

@roynalnaruto does that mean we also have separate decrypt/encrypt functions for v4?

I was assuming that was not desirable, beucase it forces the caller to have knowledge of the type of keystore being used.

Or maybe I'm missing something obvious here

@roynalnaruto
Copy link
Owner

@naps62

does that mean we also have separate decrypt/encrypt functions for v4?

I am still thinking about the design. I will get back to you on this.

@naps62
Copy link
Author

naps62 commented Aug 22, 2023

@roynalnaruto any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants