How does a smart contract like a Safe Multisig create a signature?

146 Views Asked by At

With EIP 1271 it seems relatively straightforward, have a read only method that returns a magic value, but in the Safe contracts, it allows a signer to be an EOA, as long as the r and s values of the ecrecover function are provided.

How does this actually work?

Looked through the Safe docs, Discord, and EIP 1271 documentation.

1

There are 1 best solutions below

0
On

From your added comment i think i can put 1 and 2 together and give you what i feel is the answer you're looking for.

When using safe, if you want to have a contract be a signer in a tx (providing the e and s values) you use a contract-based signature. The contract generates a message that it wants to sign, then calls the signMessage function of the safe contract passing the message as a parameter.

The Safe contract verifies the calling contract as an authorized signer by checking the list of authorized signers then it generates a hash of the message and sends it back to the calling contract.

It (the calling contract) then signs the hash using its private key and returns the r and s values to the Safe contract which verifies the signature and adds the calling contract as a signer to the transaction.

I don't know how well this answers your question but i hope it was clear enough for know if it wasn't. Give me your feedback.