wyvernprotocol / wyvern-v3

Wyvern Protocol v3.1, Ethereum implementation
https://wyvernprotocol.com
MIT License
298 stars 121 forks source link

Add support for signing orders with personal_sign, mimicking 0xProtocol #46

Closed MarvinJanssen closed 3 years ago

MarvinJanssen commented 3 years ago

This PR makes it possible to sign orders with personal_sign and have them validate (i.e. keccak256("\x19Ethereum Signed Message:\n32ORDER_HASH_HERE")). When calling a function that takes signatures, one has to signal personal_sign was used by appending the byte 0x03 to the signature. It mimics the way 0xProtocol does it. However, if the extra byte is absent, validateOrderAuthorization() assumes EIP712/sign_typed_data was used. (Which is unlike 0xProtocol, as it requires the extra byte at the end.) The choice was made to ensure backwards compatibility. The personal_sign prefix can be set via the constructor of the WyvernExchange contract, so that it can be easily deployed on EVM-compatible chains that have a different prefix (like Klaytn). The prefix defaults to "\x19Ethereum Signed Message:\n".

Tests have been added/updated where needed.

There are also some miscellaneous fixes, and the StaticMarket contract now no longer inherits from StaticUtil nor depends on the atomicizer.