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
What happened?
I expect that:
would lead to my custom ECC implementation being used.
However,
sign_transactioncreates a new LocalAccount, and calls to methods likesign_transactionpass the bytes private key - which means the default Backend will get used for signing.I assume this is a bug since
set_key_backenddoes not have any effect.Our workaround is to pass the backend to the PrivateKey:
PrivateKey(bytes([0]*32), MyECCBackend()). When using LocalAccount objects we setacc._private_key = PrivateKey(..., MyECCBackend())PS: It would also be nice to have a clean interface like
set_key_backendfor 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:
self._key_obj(PrivateKey) instead ofself.key(bytes) when making calls to_publicapieth-account Version
0.8.0
Python Version
3.10.13
Operating System
macos