I know that contract storage on the Ethereum blockchain is not encrypted or private in any way. All data on the blockchain is publicly viewable. Even the value of a variable declared as private
can be known by sync'ing with the blockchain and reading the contract storage. My question is - how simple or complex is it to read a contract's storage data and extract some information from it, without knowing the data structures, i.e. how the data is organized?
For example, in the following partial code, (just made up some arbitrary data structure), assume there is an internal function that determines whether a particular msg.sender is allowed to access the data:
contract DataStore {
struct Datum {
uint8 id;
bytes32 serialNum;
string name;
uint256 createdAt;
}
mapping (address => Datum) private entityData;
function getName(address entity) public constant returns (string) {
if (isAllowed(msg.sender) {
return name;
}
else {
return "";
}
}
...
...
Would someone whose account does not have permission to access the data as per the isAllowed
function, be able to extract the name that a specific address is mapped to, even if they did not know what the contract's internal data structures are? If so, how could that be done? In other words, just by looking at a contract's storage bytes, what information can be obtained and how?
I just want to get an idea of how complex this is. I know that "security by obscurity" is not a good idea, so I do not intend to rely on it in my code. Just curious.