ERC-1271
Allow smart contracts signage
ERC-1271, which allows for on-chain signature verification for Smart Contracts (since contracts do no have private keys).
The verifying contract would get passed in the 32-byte hash that it wants to verify along with an implementation dependant byte array - domain seperator.
We expect a return of the bytes4 magic value
0x1626ba7e
when function passes.signer contract(multi-sig) must implement
isValidSignature
and return themagicValue
up to the contract to implement the logic of what determines a valid signature
if its multi-sig: could be concatentation of the various users' signatures
IMplementation example:

For example we would have to incorporate the following:
{...}
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
{...}
if (Address.isContract(sellOrder.signer)) {
(bool success, bytes memory data) = sellOrder.signer.staticcall(abi.encodeWithSelector(IERC1271.isValidSignature.selector, digest, abi.encodePacked(r, s, v));
if (!success) revert MISSING_VALID_SIGNATURE_FUNCTION_EIP1271;
bytes4 magicValue = abi.decode(data, (bytes4));
// must return the bytes4 magic value 0x1626ba7e when function passes
if (magicValue != 0x1626ba7e) revert SIGNATURE_INVALID_EIP1271;
It is established in the standard that in case of success, the function must return the value
0x1626ba7e
This is not a random value. It is the signature of the function
isValidSignature(bytes32,bytes)
Links
Last updated