Fix: verifying identity instance signature

This commit is contained in:
Richard Ramos 2018-11-07 07:54:05 -04:00
parent 2f11d19c60
commit a94f810382
8 changed files with 24 additions and 19 deletions

View File

@ -103,7 +103,7 @@ class ContractSettings {
this.pendingToLoad++; this.pendingToLoad++;
try { try {
const code = await this.web3.eth.getCode(this.contracts[topicName].address) const code = await this.web3.eth.getCode(this.contracts[topicName].address);
this.contracts[topicName].code = this.web3.utils.soliditySha3(code); this.contracts[topicName].code = this.web3.utils.soliditySha3(code);
this.pendingToLoad--; this.pendingToLoad--;
if(this.pendingToLoad == 0) this.events.emit("setup:complete", this); if(this.pendingToLoad == 0) this.events.emit("setup:complete", this);

View File

@ -18,6 +18,7 @@ class IdentityStrategy extends Strategy {
async _validateInstance(input){ async _validateInstance(input){
const instanceCodeHash = this.web3.utils.soliditySha3(await this.web3.eth.getCode(input.contract)); const instanceCodeHash = this.web3.utils.soliditySha3(await this.web3.eth.getCode(input.contract));
const kernelVerifSignature = this.web3.utils.soliditySha3(this.contract.kernelVerification).slice(0, 10); const kernelVerifSignature = this.web3.utils.soliditySha3(this.contract.kernelVerification).slice(0, 10);
if(instanceCodeHash === null) return false; if(instanceCodeHash === null) return false;
let verificationResult = await this.web3.eth.call({ let verificationResult = await this.web3.eth.call({

View File

@ -15,6 +15,7 @@ import Web3 from 'web3';
import config from '../config'; import config from '../config';
import {withStyles} from '@material-ui/core/styles'; import {withStyles} from '@material-ui/core/styles';
window.IdentityFactory = IdentityFactory;
const styles = {}; const styles = {};
@ -24,7 +25,7 @@ class Body extends Component {
super(props); super(props);
this.state = { this.state = {
tab: 0, tab: 0,
identityAddress: null, identityAddress: "0x0000000000000000000000000000000000000000",
nonce: '0', nonce: '0',
kid: null, kid: null,
skid: null, skid: null,
@ -87,8 +88,7 @@ class Body extends Component {
}); });
this.setState({ this.setState({
web3js, web3js
identityAddress: IdentityGasRelay.options.address
}); });
}); });
} }

View File

@ -93,7 +93,7 @@ class Status extends Component {
web3.eth.getBlock('latest').then(block => { web3.eth.getBlock('latest').then(block => {
this.setState({block: block.number}); this.setState({block: block.number});
this.readChain(); this.readChain();
setTimeout(this.web3BlockRead, 10000); setTimeout(this.web3BlockRead, 5000);
return true; return true;
}); });
} }

View File

@ -91,7 +91,7 @@ class Status extends Component {
web3.eth.getBlock('latest').then(block => { web3.eth.getBlock('latest').then(block => {
this.setState({block: block.number}); this.setState({block: block.number});
this.readChain(); this.readChain();
setTimeout(this.web3BlockRead, 10000); setTimeout(this.web3BlockRead, 5000);
return true; return true;
}); });
} }

View File

@ -123,6 +123,8 @@ class StatusGasRelayer {
sendOptions.symKeyID = skid; sendOptions.symKeyID = skid;
} }
console.log(sendOptions);
const msgId = await this.web3.shh.post(sendOptions); const msgId = await this.web3.shh.post(sendOptions);
return msgId; return msgId;
} }

View File

@ -10,15 +10,14 @@ contract Factory is Controlled {
uint256 blockNumber; uint256 blockNumber;
uint256 timestamp; uint256 timestamp;
address kernel; address kernel;
bytes32 codeHash;
} }
mapping(bytes32 => uint256) hashToVersion; mapping(bytes32 => uint256) public hashToVersion;
mapping(address => uint256) versionMap; mapping(address => uint256) public versionMap;
Version[] versionLog; Version[] public versionLog;
uint256 latestUpdate; uint256 public latestUpdate;
address latestKernel; address public latestKernel;
constructor(address _kernel) constructor(address _kernel)
public public
@ -39,15 +38,13 @@ contract Factory is Controlled {
returns( returns(
uint256 blockNumber, uint256 blockNumber,
uint256 timestamp, uint256 timestamp,
address kernel, address kernel
bytes32 codeHash
) )
{ {
return ( return (
versionLog[index].blockNumber, versionLog[index].blockNumber,
versionLog[index].timestamp, versionLog[index].timestamp,
versionLog[index].kernel, versionLog[index].kernel
versionLog[index].codeHash
); );
} }
@ -91,8 +88,7 @@ contract Factory is Controlled {
require(_kernel != latestKernel); require(_kernel != latestKernel);
bytes32 _codeHash = getCodeHash(_kernel); bytes32 _codeHash = getCodeHash(_kernel);
versionMap[_kernel] = versionLog.length; versionMap[_kernel] = versionLog.length;
hashToVersion[_codeHash] = versionLog.length; versionLog.push(Version({blockNumber: block.number, timestamp: block.timestamp, kernel: _kernel}));
versionLog.push(Version({blockNumber: block.number, timestamp: block.timestamp, kernel: _kernel, codeHash: _codeHash}));
latestUpdate = block.timestamp; latestUpdate = block.timestamp;
latestKernel = _kernel; latestKernel = _kernel;
emit NewKernel(_kernel, _codeHash); emit NewKernel(_kernel, _codeHash);

View File

@ -51,6 +51,12 @@ contract IdentityFactory is Factory {
returns (address) returns (address)
{ {
IdentityKernel instance = IdentityKernel(new DelayedUpdatableInstance(address(latestKernel))); IdentityKernel instance = IdentityKernel(new DelayedUpdatableInstance(address(latestKernel)));
bytes32 codeHash = getCodeHash(address(instance));
if(hashToVersion[codeHash] == 0){
hashToVersion[codeHash] = versionLog.length;
}
instance.initIdentity(_keys,_purposes,_types,_managerThreshold,_actorThreshold,_recoveryContract); instance.initIdentity(_keys,_purposes,_types,_managerThreshold,_actorThreshold,_recoveryContract);
emit IdentityCreated(address(instance)); emit IdentityCreated(address(instance));
return instance; return instance;