allow the password to be choosable
parent
92fb1016d8
commit
bb84619a9a
|
@ -47,6 +47,7 @@ contract CryptoCTF10 {
|
|||
bool submissionsOpen;
|
||||
mapping (address => mapping (uint => bool)) solves; // address -> challengeID -> solved/not
|
||||
mapping (uint => bool) anySolves; // challengeID -> solved/not
|
||||
string password;
|
||||
}
|
||||
|
||||
mapping (uint => Contest) public contests;
|
||||
|
@ -54,10 +55,11 @@ contract CryptoCTF10 {
|
|||
event ChallengeAddedOrUpdated(uint contestID, uint indexed challengeID);
|
||||
event ChallengeSolved(uint contestID, uint indexed challengeID, address indexed solver);
|
||||
|
||||
function createContest(uint contestID) external {
|
||||
function createContest(uint contestID, string memory password) external {
|
||||
require(contests[contestID].admin == address(0), "This contest ID has already been registered");
|
||||
contests[contestID].admin = msg.sender;
|
||||
contests[contestID].submissionsOpen = false;
|
||||
contests[contestID].password = password;
|
||||
}
|
||||
|
||||
function setAdmin(uint contestID, address newAdmin) external onlyExistingContest(contestID) onlyAdmin(contestID) {
|
||||
|
@ -77,7 +79,7 @@ contract CryptoCTF10 {
|
|||
|
||||
function register(uint contestID, string memory password) external onlyExistingContest(contestID) {
|
||||
require(contests[contestID].players[msg.sender].status == PlayerStatus.Unverified, "You are already registered or banned in this contest");
|
||||
require(keccak256(abi.encodePacked("I_read_it")) == keccak256(abi.encodePacked(password)));
|
||||
require(keccak256(abi.encodePacked(password)) == keccak256(abi.encodePacked(contests[contestID].password)), "Wrong password");
|
||||
contests[contestID].players[msg.sender].status = PlayerStatus.Verified;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue