ChainProof SmartContract
ChainProof SmartContract
code:ChainProof.sol
pragma solidity ^0.5.7;
contract ChainProof {
struct Proof {
bytes32 messageHash;
uint256 timestamp;
}
mapping (address => Proof) public proofs;
event ProofCreated(address signer);
constructor () public {
}
function registerProof(bytes32 messageHash, bytes memory signature)
public
returns (bool)
{
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(signature, 32))
s := mload(add(signature, 64))
v := byte(0, mload(add(signature, 96)))
}
address signer = ecrecover(messageHash, v, r, s);
require(signer != address(0));
require(proofssigner.timestamp == 0); Proof storage proof = proofssigner; proof.messageHash = messageHash;
proof.timestamp = now;
emit ProofCreated(signer);
return true;
}
function getProof(address _address)
public
view
returns (bytes32, uint256) {
return (proof.messageHash, proof.timestamp);
}
}