Skip to content

Instantly share code, notes, and snippets.

@codebuster22
Created June 9, 2021 12:23
Show Gist options
  • Save codebuster22/8dfa8c32804a598192cb7aa5fa93642d to your computer and use it in GitHub Desktop.
Save codebuster22/8dfa8c32804a598192cb7aa5fa93642d to your computer and use it in GitHub Desktop.
SeedSignature Contract Deployed on Rinkeby
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC1271 standard signature validation method for
* contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
*
* _Available since v4.1._
*/
interface IERC1271 {
/**
* @dev Should return whether the signature provided is valid for the provided data
* @param hash Hash of the data to be signed
* @param signature Signature byte array associated with _data
*/
function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}
contract SeedSignature{
function isValidSignature(bytes32 _hash, bytes calldata _signature) external pure returns(bytes4) {
bytes32 s = _readBytes32(_signature, 97);
require(_hash == s, "Invalid Hash");
return bytes4(keccak256("isValidSignature(bytes,bytes)"));
}
function _readBytes32(bytes memory b, uint256 index) private pure returns (bytes32 result) {
require(
b.length >= index + 32,
"META_TX: Invalid index for given bytes"
);
index += 32;
assembly {
result := mload(add(b, index))
}
return result;
}
function generateSignature() external view returns(bytes32 hash,bytes memory signature){
hash = keccak256(abi.encodePacked("Gnosis Safe Transaction"));
bytes1 v;
bytes12 a;
bytes memory paddedAddress = bytes.concat(a, bytes20(address(this)));
signature = bytes.concat(paddedAddress, bytes32(uint256(97)), v, bytes32(uint256(hash.length)), hash);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment