Created
October 9, 2015 20:08
-
-
Save anonymous/236177b10dcb53e4e14f to your computer and use it in GitHub Desktop.
Created using soleditor: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://chriseth.github.io/browser-solidity#gist=
This file contains hidden or 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
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