If I use private variable, can attacker or anyone be able to know what the variable is?
For example.
I declare a private variable named "secret" without initialize its value.
Later after I created the contract, I then interacted with my contract by set the "secret" variable to "hello". Suppose I did this using ether wallet with metamask.
setSecret("hello")
In theory, I know that anyone can't get my private secret by interacting with my Secret contract. But since I set the secret to "hello" in the previous transaction. Will the word "hello" get record in a log file, transaction, or somewhere which can be dig up?
I'm just trying to understand how to keep a secret inside my contract.
This is my example contract
pragma solidity ^0.4.15;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permission"
*/
contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original 'owner' of the contract to the sender
* account.
*/
function Ownable() internal {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
}
contract Secret is Ownable {
string private secret;
function Secret() public {
secret = "";
}
function setSecret(string _secret) public onlyOwner {
secret = _secret;
}
}