-
Notifications
You must be signed in to change notification settings - Fork 29
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
contracts: submit pre-signed transaction #175
Conversation
The And if you CBOR encode the envelope you end up with the contract receiving CBOR encoded data, rather than the calldata... |
This will fix #179 |
There are a few scenarios we want to handle with
However, currently the wrapper will raise an error if you submit a transaction signed by somebody else. This matches Ethers behavior. If you submit a pre-signed but unencrypted transaction to a provider, it won't be able to encrypt it because no signer exists. ( The Ethers API doesn't let you submit pre-signed transactions to a signer, it requires you decode it and re-submit it in the Realistically, this means the sapphire wrapper, with Ethers, cannot re-encrypt pre-signed transactions even when the tx signer matches the address of the Ethers signer. And the contract is unable to get the calldata public key, so it can't trust that if it encrypts something with a key provided by the user that they won't be able to intercept it. |
35e7a90
to
20282fa
Compare
So... looks like the error I want to fix is fundamentally unfixable. But, instead I added a test to make sure the EIP155 module can sign and submit transactions, and that transactions submitted by the wrapped provider are encrypted. |
So I can fix this error where we submit pre-signed transactions through the provider which is attached to a signer with a different address. But we can't automatically encrypt pre-signed transactions. |
Why not? Encryption with an ephemeral key derived from the runtime and the client key has nothing to do with who signed the tx. |
The calldata is signed, modifying the calldata by wrapping it in an encrypted envelope would invalidate the existing signature. When I use:
The
If I wrap the
And only via creating a new If this happens via MetaMask and the dApp signs a transaction without encrypting it then sends it through a wrapped signer it will try to encrypt it before submission. I have slightly modified the behavior and added test cases so it you pass a transaction not signed by the signers address it will not attempt to encrypt it and pass it on. This makes submitting the gasless transactions easier because you don't need to setup a different unwrapped provider to submit it. |
This may be relevant: #106 |
3e801d7
to
bc36df9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking comments.
f2e2b6c
to
50bb8e1
Compare
Co-authored-by: Xi Zhang <[email protected]>
Co-authored-by: Xi Zhang <[email protected]>
Co-authored-by: Xi Zhang <[email protected]>
Co-authored-by: Xi Zhang <[email protected]>
Co-authored-by: Xi Zhang <[email protected]>
Co-authored-by: Xi Zhang <[email protected]>
Co-authored-by: Xi Zhang <[email protected]>
2c01068
to
988e06f
Compare
Co-authored-by: Xi Zhang <[email protected]> efc9ce0
Co-authored-by: Xi Zhang <[email protected]> efc9ce0
Fixes #179:
I have added tests transaction envelope tests:
This slightly modifies sapphire.wrap behavior so if it receives a signed but unencrypted transaction from an address which it can't sign for the transaction will pass through as-is.