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++;
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.pendingToLoad--;
if(this.pendingToLoad == 0) this.events.emit("setup:complete", this);

View File

@ -18,6 +18,7 @@ class IdentityStrategy extends Strategy {
async _validateInstance(input){
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);
if(instanceCodeHash === null) return false;
let verificationResult = await this.web3.eth.call({
@ -39,7 +40,7 @@ class IdentityStrategy extends Strategy {
return {success: false, message: "Invalid identity instance"};
}
}
const params = this._obtainParametersFunc(input);
// Verifying if token is allowed

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -51,6 +51,12 @@ contract IdentityFactory is Factory {
returns (address)
{
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);
emit IdentityCreated(address(instance));
return instance;