Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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