I have a citizenship persona contract which acts as a personal identity file which is under the control of the user. Personas can make other personas in the system into trustees or allies. As part of the persona contract I'd like to implement a feature called publicity
, which has three settings, denoted by -1, 0, 1
. publicity
controls who can access the persona's general information.
-1
= only trustees can access info.
0
= trustees and allies can access info.
1
= full publicity to anyone who requests it.
There are two lines of security I'm concerned about: interacting with functions themselves and viewing the state on the blockchain.
The first issue can be solved against with modifiers, although I'm not exactly sure the following attempt works (persona
is a struct containing all the relevant details about the human being which can be queried):
mapping(address => int) allies;
mapping(address => int) trustees; //
modifier Security {
if(persona.publicity = -1) {
if(trustees[msg.sender] = -1) {
_ } else throw;
}
else if(persona.publicity = 0) {
if(allies[msg.sender] = 0 || trustees[msg.sender] = -1) {
_ } else throw;
}
else _
}
I'm not sure if this is valid. Would appreciate if this syntax could be verified.
The second line of attack is reading state directly on the blockchain. This is a little more complicated. I know many of the state variables that hold data can be encrypted using the sha3(x,y,z)
approach. But how would you implement this?
This is the struct which holds persona information:
struct Persona {
bytes16[] name;
bytes16[][] residency;
bytes32 id;
string origin;
uint created;
uint access;
int birth;
int exit;
int publicity;
int status;
Sex assigned;
}
Persona public persona;
How could these state variables be encrypted so that they can't be read on the blockchain? What sort of scheme could you implement so that people in the trustees or allies permission group would be able to decrypt the data on their end? Apologies if this is too much for one question but I think it might be useful for others with permission group/access restriction questions.