iden3/contracts

Update from Roots to Identity States

Closed this issue · 4 comments

Update from Roots to Identity States
ed255 commented

The new methods to init and set state should be the following (with pseudocode):

initState(bytes32 newState, bytes32 genesisState, bytes31 id, bytes memory kOpProof, bytes memory itp, bytes32 sig) public {
  require(identities[id].length == 0);
  require(genesisIdFromState(genesisState) == id);
  
  _setState(newState, genesisState, id, kOpProof, itp, sig);
}

setState(bytes32 newState, bytes31 id, bytes memory kOpProof, bytes memory itp, bytes32 sig) public {
  require(identities[id].length>0);
  lastEvent = identities[id][identities[id].length - 1];
  require(lastEvent.BlockN != block.number, "no multiple set in the same block");

  _setState(newState, lastEvent.State, id, kOpProof, itp, sig);
}

_setState(bytes32 newState, byte32 oldState, bytes31 id, bytes memory kOpProof, bytes memory itp, bytes32 sig) private {
  require(verifyProof(newState, kOpProof) == true);
  kOp = KeyFromKOpProof(kOpProof);
  require(verifySignature("minorTransition:" + oldState + newState, kOp);
  require(verifyTransitionProof(oldState, newState, itp) == true);

  identities[id].push(IDState(uint64(block.number), uint64(block.timestamp), newState));
  emit StateUpdated(id, uint64(block.number), uint64(block.timestamp), newState);
}

Done the interfices ab460b3

Done