NoteGio / openrelay

OpenRelay is an open source relay for the 0x protocol. OpenRelay provides an open, scalable orderbook. Users can post offers for any ERC20 or ERC721 token, or search for trades with other users
Other
159 stars 56 forks source link

Fix destructive signature checks #117

Closed AusIV closed 6 years ago

AusIV commented 6 years ago

We were encountering a strange issue where signatures were coming up as invalid. Checks would pass in the ingest service, and fail in subsequent services.

It turns out that signature checks with crypto.Ecrecover are destructive. I think I've encountered this before, as in verifyEthSign I had already made a copy of the signature for verification, but in verifyEIP712 we were using the signature directly. I'm not sure why this manipulates the signature (especially the sigtype byte, which isn't even part of what we pass to Ecrecover), but passing a copy resolves the issue.