Skip to content

set_key_backend method does not influence backend selection #322

@laurenz-k

Description

@laurenz-k

What happened?

I expect that:

acc = Account()
acc.set_key_backend(MyECCBackend())
acc.sign_transaction({...}, PrivateKey(...))

would lead to my custom ECC implementation being used.

However, sign_transaction creates a new LocalAccount, and calls to methods like sign_transaction pass the bytes private key - which means the default Backend will get used for signing.

I assume this is a bug since set_key_backend does not have any effect.

Our workaround is to pass the backend to the PrivateKey: PrivateKey(bytes([0]*32), MyECCBackend()). When using LocalAccount objects we set acc._private_key = PrivateKey(..., MyECCBackend())

PS: It would also be nice to have a clean interface like set_key_backend for LocalAccount objects.

Fill this section in if you know how this could or should be fixed

Not sure about which design would be nicest, but either:

  • pass in the backend when creating PrivateKey objects in Account
  • make LocalAccount pass self._key_obj (PrivateKey) instead of self.key (bytes) when making calls to _publicapi

eth-account Version

0.8.0

Python Version

3.10.13

Operating System

macos

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions