Skip to content

Instantly share code, notes, and snippets.

@johnson86tw
Created June 14, 2021 05:47
Show Gist options
  • Save johnson86tw/ea1d60a3509d6f760a4145aac4e5274c to your computer and use it in GitHub Desktop.
Save johnson86tw/ea1d60a3509d6f760a4145aac4e5274c to your computer and use it in GitHub Desktop.
contract WithoutZK {
string greeting = "hello world";
uint256 answer = 1770;
function greet() public view returns (string memory) {
return greeting;
}
function _setGreeting(string memory _greeting) internal {
greeting = _greeting;
}
function process(uint256 _secret) public {
require(verify(_secret), "invalid");
_setGreeting("answer to the ultimate question of life, the universe, and everything");
}
function verify(uint256 _secret) public view returns(bool){
return calculate(_secret) == answer;
}
function calculate(uint256 _secret) public pure returns(uint256) {
return _secret*_secret + 6;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment