Is there a way to sign message by the Smart Contract?

I have a public view function that performs some calculations on the given input and returns the result. Although smart contracts don’t have a private key Is there any way to add a signature as proof that output is generated by the smart contract?

Can a function in smart contract return output along with digital signature so the client can verify that output was generated by smart contract ?

1 Like

The smart contract can’t sign but ERC1271 defines a way to simulate that. Our SignatureChecker library implements the ERC.

1 Like

Going through SignatureChecker & ERC1271 what I understood is, isValidSignatureNow(signer, hash, signature) can be used to check the signature. But in firstplace, how can the contract generate the signature?

The contract doesn’t generate the signature. The contract will have one or more addresses that it considers valid signers, and when it receives a signature through isValidSignature it will verify that it was signed by one of those signers.

1 Like