Skip to content

Conversation

peterbroadhurst
Copy link
Contributor

@peterbroadhurst peterbroadhurst commented Sep 2, 2025

The FS Wallet feature is very useful for managing on-disk wallets, but you currently have to use the Ethereum Address to reference the KeystoreV3 files.

This is odd in cases where using this library for signing with different Web3 ecosystems, such as when building connectors for FireFly to those ecosystems.

So this PR decouples the Eth specific layer (no change to API) from the generic underlying layer (new direct API for this).

@peterbroadhurst peterbroadhurst marked this pull request as ready for review September 2, 2025 02:06
Copy link
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

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

Thanks @peterbroadhurst - looks good, a comment about the underlying API

Close() error

GetAccounts(ctx context.Context) ([]string, error)
GetWalletFile(ctx context.Context, addr string) (keystorev3.WalletFile, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to update the WalletFile as it has a KeyPair function that returns a *secp256k1.KeyPair as other Web3 protocols might not use that signing algo/curve

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand users of keystorev3.WalletFile might choose to ignore the existence of the KeyPair() function as irrelevant to them (and use PrivateKey() instead).

However, I don't see a need to remove this function or modify that other package to have an interface that excludes it.

Do you have a strong reason for removing it?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see they could reconstruct their own representation using the private key expose

Comment on lines +55 to +58
if err == nil {
keypair := kv3.KeyPair()
if keypair.Address != *addr {
err = i18n.NewError(ctx, signermsgs.MsgAddressMismatch, keypair.Address, addr)
Copy link
Contributor

Choose a reason for hiding this comment

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

The reason I mentioned the comment above is because you are using that KeyPair() API to validate the address here - I think as part of this PR there should be a KeyPairGeneric construct interface which has three methods GetPubKey , GetPrivKey and GetAddr

Copy link
Contributor

Choose a reason for hiding this comment

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

Specially the GetAddr should be a string inside of the ethaddress for the new Generic flow

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the code a bit closer, this will result in a lot of changes but is needed to plugin a new type of signing curve in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed that plugging into the other package keystorev3 a new form of cryptography would be a lot of work. I haven't proposed that here. Instead (per my comment above) users of this just access the private key from the wallet file using .PrivateKey() and can consider the KeyPair() function as "historical cruft".

@EnriqueL8
Copy link
Contributor

What if instead of an AddressValidator it's actually an address creator, you want all your keys inside one FS Wallet to you the same address semantics so allow that to be provided and inside the KeyPair it's just an opaque string to the system?

@peterbroadhurst
Copy link
Contributor Author

What if instead of an AddressValidator it's actually an address creator, you want all your keys inside one FS Wallet to you the same address semantics so allow that to be provided and inside the KeyPair it's just an opaque string to the system?

I'm trying to relate this question to the PR @EnriqueL8 sorry.

Certainly interesting if someone wanted to contribute a (quite large) extensions to this simple FS wallet to support more advanced use cases like this. But it's not my proposal.

I simply want to:

  1. Preserve the old Ethereum Address specific function that you mention above (with no opinion on good/bad - just don't want to change it and break any users of this library)
  2. Add a way to use the 90% of this fswallet code that's got nothing to do with Ethereum addresses, with simple string naming of the things inside of it

Copy link
Contributor

@EnriqueL8 EnriqueL8 left a comment

Choose a reason for hiding this comment

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

Agree with the above, my concerns over the API are not completely valid as there are other paths to get the priv/pub key pair

Close() error

GetAccounts(ctx context.Context) ([]string, error)
GetWalletFile(ctx context.Context, addr string) (keystorev3.WalletFile, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

I see they could reconstruct their own representation using the private key expose

@EnriqueL8 EnriqueL8 merged commit acc10bd into main Sep 8, 2025
5 checks passed
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