Skip to content

Commit

Permalink
Merge branch 'main' into random_proof_reward
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Feb 22, 2023
2 parents ca4e281 + 3e43c0c commit 1093ba7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
12 changes: 3 additions & 9 deletions packages/protocol/contracts/L1/ProofVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ interface IProofVerifier {
function verifyZKP(
string memory verifierId,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
bytes32 instance
) external view returns (bool verified);

function verifyMKP(
Expand All @@ -36,17 +34,13 @@ contract ProofVerifier is IProofVerifier, EssentialContract {
function verifyZKP(
string memory verifierId,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
bytes32 instance
) external view returns (bool) {
return
LibZKP.verify({
plonkVerifier: resolve(verifierId, false),
zkproof: zkproof,
blockHash: blockHash,
prover: prover,
txListHash: txListHash
instance: instance
});
}

Expand Down
12 changes: 9 additions & 3 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ library LibProving {

if (!skipZKPVerification) {
for (uint256 i; i < config.zkProofsPerBlock; ++i) {
bytes32 instance = keccak256(
abi.encode(
blockHash,
evidence.prover,
evidence.meta.txListHash
)
);

if (
!proofVerifier.verifyZKP({
verifierId: string(
Expand All @@ -296,9 +304,7 @@ library LibProving {
)
),
zkproof: evidence.proofs[i],
blockHash: blockHash,
prover: evidence.prover,
txListHash: evidence.meta.txListHash
instance: instance
})
) revert L1_ZKP();
}
Expand Down
4 changes: 1 addition & 3 deletions packages/protocol/contracts/libs/LibZKP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ library LibZKP {
function verify(
address plonkVerifier,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
bytes32 instance
) internal view returns (bool verified) {
// TODO(david):public input is assembled in client software
// for testing purposes right now, move this part of logic
Expand Down
4 changes: 1 addition & 3 deletions packages/protocol/contracts/test/L1/TestTaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ contract TestTaikoL1 is TaikoL1, IProofVerifier {
function verifyZKP(
string memory /*verifierId*/,
bytes calldata /*zkproof*/,
bytes32 /*blockHash*/,
address /*prover*/,
bytes32 /*txListHash*/
bytes32 /*instance*/
) public pure override returns (bool) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ contract TestTaikoL1EnableTokenomics is TaikoL1, IProofVerifier {
function verifyZKP(
string memory /*verifierId*/,
bytes calldata /*zkproof*/,
bytes32 /*blockHash*/,
address /*prover*/,
bytes32 /*txListHash*/
bytes32 /*instance*/
) public pure override returns (bool) {
return true;
}
Expand Down
12 changes: 9 additions & 3 deletions packages/protocol/contracts/test/libs/TestLibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ library TestLibProving {

if (!skipZKPVerification) {
for (uint256 i; i < config.zkProofsPerBlock; ++i) {
bytes32 instance = keccak256(
abi.encode(
blockHash,
evidence.prover,
evidence.meta.txListHash
)
);

if (
!proofVerifier.verifyZKP({
verifierId: string(
Expand All @@ -302,9 +310,7 @@ library TestLibProving {
)
),
zkproof: evidence.proofs[i],
blockHash: blockHash,
prover: evidence.prover,
txListHash: evidence.meta.txListHash
instance: instance
})
) revert L1_ZKP();
}
Expand Down

0 comments on commit 1093ba7

Please sign in to comment.