Created
September 27, 2017 14:06
-
-
Save gauravsaini03-zz/ba7facff689720093493119c192d394c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.4; | |
contract Certification { | |
address public certificateAuthority; | |
string public certificateAuthorityName; | |
mapping (bytes32 => bytes32) certificate; //sha3(register-number) => sha3(other info) | |
event Issued(bytes32 key); | |
function Certification(string _certificateAuthorityName) { | |
certificateAuthority = msg.sender; | |
certificateAuthorityName = _certificateAuthorityName; | |
} | |
//transactional functions | |
function issue(bytes32 _regNo, bytes32 _name) external { | |
require(msg.sender == certificateAuthority); //check authority | |
require(certificate[sha3(_regNo)] == 0 ); //check if already exists | |
bytes32 key = sha3(_regNo); | |
certificate[ key ] = sha3(_regNo, _name); //storage | |
Issued(key); //fire issued event | |
} | |
//constant functions | |
function verify(bytes32 _regNo, bytes32 _name) constant returns (bool) { | |
if( certificate[sha3(_regNo)] == sha3(_regNo, _name) ) { | |
return true; | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment