Skip to content

Commit

Permalink
Fix verify error when use sha256 hash
Browse files Browse the repository at this point in the history
  • Loading branch information
weiqiushi committed Jan 31, 2024
1 parent c4ba898 commit c79e589
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
3 changes: 2 additions & 1 deletion contracts/PublicDataProof.sol
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ library PublicDataProof {
computedHash = sha256(bytes.concat(proof[i], currentHash));
}
currentHash = _bytes32To16(computedHash);
leaf_index = leaf_index / 2;
}

leaf_index = leaf_index / 2;
}

return computedHash;
Expand Down
21 changes: 17 additions & 4 deletions contracts/public_data_storage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,17 @@ contract PublicDataStorage is Initializable, UUPSUpgradeable, OwnableUpgradeable

}

function allowPublicDataContract(address contractAddr) public onlyOwner {
_allowedPublicDataContract[contractAddr] = true;
function allowPublicDataContract(address[] calldata contractAddrs) public onlyOwner {
for (uint i = 0; i < contractAddrs.length; i++) {
_allowedPublicDataContract[contractAddrs[i]] = true;
}

}

function denyPublicDataContract(address contractAddr) public onlyOwner {
_allowedPublicDataContract[contractAddr] = false;
function denyPublicDataContract(address[] calldata contractAddrs) public onlyOwner {
for (uint i = 0; i < contractAddrs.length; i++) {
_allowedPublicDataContract[contractAddrs[i]] = false;
}
}

function setSysConfig(SysConfig calldata config) public onlyOwner {
Expand Down Expand Up @@ -286,6 +291,14 @@ contract PublicDataStorage is Initializable, UUPSUpgradeable, OwnableUpgradeable
return CycleOutputInfo(_cycleInfos[cycleNumber].totalAward, _cycleInfos[cycleNumber].scoreList.getSortedList());
}

function getPledgeInfo(address supplier) public view returns(SupplierInfo memory) {
return _supplierInfos[supplier];
}

function isDataContractAllowed(address contractAddr) public view returns(bool) {
return _allowedPublicDataContract[contractAddr];
}

function getOwner(bytes32 dataMixedHash) public view returns(address) {
PublicData memory info = _publicDatas[dataMixedHash];
return _getDataOwner(dataMixedHash, info);
Expand Down
4 changes: 2 additions & 2 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ export async function main() {

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
/*

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});*/
});

0 comments on commit c79e589

Please sign in to comment.