-
Notifications
You must be signed in to change notification settings - Fork 0
Creating & Issuing
David Michael Akers edited this page Oct 17, 2017
·
6 revisions
Keys are identified by the keccak256 hash of: the service id, the time the key is created, the address the key is issued to. This makes them impractical to regenerate so the key should be stored.
A service owner can create a key by passing a service to the createKey function. This creates a new key for that service and issues it to the service owner's account. A transaction will be returned with a log containing a KeyCreated event denoting the _owner, and the new _key.
Alternatively you can pass an account address and service to the issueKey function to directly issue a key to any account address.
event KeyCreated(address indexed _owner, bytes32 indexed _key);
function createKey(bytes32 service)
public
ownsService(service)
{
issueKey(service, msg.sender);
}
function issueKey(bytes32 service, address issueTo)
public
ownsService(service)
{
bytes32 id = keccak256(service, now, issueTo);
require(keys[id].owner == address(0));
keys[id].owner = issueTo;
keys[id].service = service;
keyList.push(id);
KeyCreated(issueTo, id);
}