Skip to content

Instantly share code, notes, and snippets.

@d11e9
Created November 20, 2015 17:00
Show Gist options
  • Save d11e9/d4912abc803e1c4ce133 to your computer and use it in GitHub Desktop.
Save d11e9/d4912abc803e1c4ce133 to your computer and use it in GitHub Desktop.
import "owned";
contract RevokableOwned is owned {
address previousOwner;
uint8 revokableV;
bytes32 revokableR;
bytes32 revokableS;
// In order to make a contracts ownership revokeable you must
// provide a signature VRS of a master passphrase which has been
// hashed using SHA3 twice. This can only be done by the current owner.
function makeRevokable(uint8 _v, bytes32 _r, bytes32 _s) onlyowner {
revokableV = _v;
revokableR = _r;
revokableS = _s;
}
// All that is needed to revoke ownership of the contract is the twice
// hashed passphrase, which can be submitted by any sender.
function revoke(bytes32 twiceHashedPassphrase) returns (bool success) {
if (revokableV != uint8(0)
&& owner != address(0)
&& ecrecover(twiceHashedPassphrase, revokableV, revokableR, revokableS) == owner) {
previousOwner = owner;
owner = address(0);
return true;
}
}
// In order to reclaim ownership of a contract who's ownership has been revoked
// You need to be able to provide a once hashed version of the passphrase.
function reclaim(bytes32 onceHashedPassphrase) {
bytes32 data = sha3(onceHashedPassphrase);
address signer = ecrecover(data, revokableV, revokableR, revokableS);
if (signer == previousOwner) owner = msg.sender;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment