-
Notifications
You must be signed in to change notification settings - Fork 680
eth_sign API out of sync with ethapi #555
Comments
I believe this may also need to prefix |
@yusefnapora good point, I mostly copied over the impl notes from the Parity issue, which omitted that |
Wow, that's a great diagram. If you have it handy, could you give me some messages, a test private key / mnemonic and the signed results of geth/parity for testing? |
Unfortunately accounts differ when testing on the different nodes so an apples to apples comparison isn't really possible. I have some test script output that gives some data but missing is the private key for the account: Using node=EthereumJS TestRPC |
Here's the script that generated the above output (it will run correctly on geth, parity or testrpc because it checks the client and makes adjustments to the input data accordingly) Hope that helps!
|
Note: you'll need to change the 'useContract' variable to point to the deployed contract once it's deployed... the contract source code is in the comment. |
Here's a proposed fix I posted to the Parity team: I'm not particularly vested in one versus the other. The documentation on the ethereum wiki for Web3 gives a format for the signature byte order so I would personally lean toward that format. However, v should probably be returned as 27 or 28 and not 00 or 01 as it states in the documentation. https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethsign I'd be inclined to change the byte ordering for Parity to match TestRPC and Geth, fix TestRPC to accept the hex encoded messages and prepend "Ethereum Signed Message" as the other clients do. Finally, TestRPC should return the correct value for v (27 or 28). |
This just stung me today. provider-framework accepts raw data and hashes it itself (without a prefix), matching the documentation at https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethsign, but testrpc expects you to hash the input yourself. I believe that provider-framework's behaviour is correct; a prefix string should not be used except on the |
Confirmed, the behavior has changed between 3.0 and 4.x. I've been out of
the loop recently so not sure what the differences are between TestRPC
versions or what the correct behavior has been decided to be.
…On Wed, Jul 12, 2017 at 12:39 AM, Chris Hitchcott ***@***.***> wrote:
Has the behaviour changed between ***@***.*** and 4.x ??
ECVerify tests failing on 4.x but passing on 3.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/ethereumjs/testrpc/issues/243#issuecomment-314669025>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AaCIsS-42RODZklxre_-WeGTg9RZOWomks5sNGoSgaJpZM4LobfT>
.
|
I'm looking into this. Either I merged a PR and didn't document it, or a dependency updated that changed behavior. The 0x project noticed this as well. It looks like this comment could be correct:
|
Since I posted, testrpc appears to have been modified to apply the personal prefix and hash its input. The following test passes:
Where This is problematic first because it breaks compatibility, but more importantly because only String concatenation in Solidity is difficult at the best of times (and with the added issue of converting an integer to a string for the length, even harder if you want to verify variable-length signatures), so this especially unusable if you want to verify signatures onchain. |
@Arachnid I assume you'd be happy if TestRPC behaved identically to either geth or parity per the diagram submitted above? |
the change to the behaviour of eth_sign in geth to mimic personal_sign without a password makes sense, except it should have never happened because its caused a terrible mess between different implementations across geth, parity, testrpc, metamask and web3. what a mess. the only solution is for all clients/nodes to update to what is the current spec, the new eth_sign semantics as per geth. what about also supporting personal_sign in ganache-core? |
I have spent hours debugging issues related to signing and recovering signatures due to the fact that Metamask's signature comes out differently than truffle's client. Is there any way for this to be reconciled? How can you set up your contract functions to use ecrecover to take care of both cases? Does anyone have an example? |
@rhlsthrm the script above used to work on geth, parity, testrpc (truffle's old client). it's a starting point but it's almost a year old and it was never tested against MetaMask / Infura. |
@fumecow the problem is I want the contract to work regardless of which client signs the message. When I am in my test environment I am using ganache which includes the prefix, but Metamask does not. This is really bad for me, since I have to use two versions of the contract in each test environment. |
without knowing the details, i think you'll have to make adjustments in the calling code based on the node you're running on, like the script above does. note that the contract then works with all the variations because it adjusts the 'v' parameter internally. other than that, i don't think there's a better solution until the signing is standardized between clients. |
So would metamask's web3.eth.sign(msg) prepend the string "\x19Ethereum Signed Message:\n${msg.length}" before signing? Now we have metamask, testrpc, geth, parity, mew, and what else? |
Not to mention now we are supposed to use personal_sign or even eth_signTypedData instead of eth_sign (see this). Does ganache plan to support these new features anytime soon? |
I recently accepted a PR for When we work this issue we should just leverage that library and call it a day. |
Any news? |
Unfortunately @nachomazzara, there isn't any news on this one. We currently only have one developer working these high-priority issues. We're doing much better now (in the last 23 days) with tracking issues, triaging them, and working them. The other dev (me) is working on some other If you want to know if we're working it, just check out the Assigned field, if it's not assigned yet, then it's still in the backlog. Sorry I couldn't give you better news! Sorry it's taken us so long to get to this too; we're trying to catch up!! |
Looking at this issue, it seems like it has been updated. Can anyone here confirm that this is indeed updated and behaving correctly? |
Closing this because after review, we think it's no longer an issue. Please open a new ticket if you believe this to still be a problem. |
As of ethereum/go-ethereum#2940, eth_sign api has changed. It is now
eth_sign(address, msg)
, accepting arbitrary input and putting it through keccak256.Expected Behavior
Upstream eth_api introduced a breaking change where
eth_sign
now accepts the actual message, rather than a 32 byte hash digest. Signature is noweth_sign(address, msg)
Current Behavior
testrpc currently emulates existing
eth_sign(address, sha3(msg))
behaviorPossible Solution
Change
ethereumjs-util.ecsign
to callkeccak256
before callingsecp256k1.sign
Context
We need to sign statements with web3, which is now incompatible between testrpc and real ethapi.
Your Environment
The text was updated successfully, but these errors were encountered: