Skip to content

Commit

Permalink
feat(protocol): deploy the generated Yul plonk verifier (#13016)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored Jan 26, 2023
1 parent 1bfa69b commit eb5d564
Show file tree
Hide file tree
Showing 18 changed files with 1,839 additions and 165 deletions.
2 changes: 1 addition & 1 deletion packages/protocol/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ typechain
abis
abi
deployments/*.json

bin
yarn.lock
yarn-debug.log*
yarn-error.log*
Expand Down
19 changes: 12 additions & 7 deletions packages/protocol/contracts/L1/ProofVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@

pragma solidity ^0.8.9;

import "../thirdparty/LibMerkleTrie.sol";
import "../common/EssentialContract.sol";
import "../libs/LibZKP.sol";
import "../thirdparty/LibMerkleTrie.sol";

/// @author dantaik <dan@taiko.xyz>
interface IProofVerifier {
function verifyZKP(
bytes memory verificationKey,
string memory verifierId,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
) external pure returns (bool verified);
) external view returns (bool verified);

function verifyMKP(
bytes memory key,
Expand All @@ -27,17 +28,21 @@ interface IProofVerifier {
) external pure returns (bool verified);
}

contract ProofVerifier is IProofVerifier {
contract ProofVerifier is IProofVerifier, EssentialContract {
function init(address addressManager) external initializer {
EssentialContract._init(addressManager);
}

function verifyZKP(
bytes memory verificationKey,
string memory verifierId,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
) external pure returns (bool) {
) external view returns (bool) {
return
LibZKP.verify({
verificationKey: verificationKey,
plonkVerifier: resolve(verifierId, false),
zkproof: zkproof,
blockHash: blockHash,
prover: prover,
Expand Down
1 change: 0 additions & 1 deletion packages/protocol/contracts/L1/libs/LibProposing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

pragma solidity ^0.8.9;

import "../../common/ConfigManager.sol";
import "../../libs/LibTxDecoder.sol";
import "../TkoToken.sol";
import "./LibUtils.sol";
Expand Down
7 changes: 3 additions & 4 deletions packages/protocol/contracts/L1/libs/LibProving.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pragma solidity ^0.8.9;

import {IProofVerifier} from "../ProofVerifier.sol";
import "../../common/AddressResolver.sol";
import "../../common/ConfigManager.sol";
import "../../libs/LibAnchorSignature.sol";
import "../../libs/LibBlockHeader.sol";
import "../../libs/LibReceiptDecoder.sol";
Expand Down Expand Up @@ -256,9 +255,9 @@ library LibProving {
} else {
require(
proofVerifier.verifyZKP({
verificationKey: ConfigManager(
resolver.resolve("config_manager", false)
).getValue(string(abi.encodePacked("zk_vkey_", i))),
verifierId: string(
abi.encodePacked("plonk_verifier_", i)
),
zkproof: evidence.proofs[i],
blockHash: blockHash,
prover: evidence.prover,
Expand Down
35 changes: 0 additions & 35 deletions packages/protocol/contracts/common/ConfigManager.sol

This file was deleted.

9 changes: 5 additions & 4 deletions packages/protocol/contracts/libs/LibZKP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ library LibZKP {
*********************/

function verify(
bytes memory verificationKey,
address plonkVerifier,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
) internal pure returns (bool verified) {
// TODO
return true;
) internal view returns (bool verified) {
// TODO(david):public input is assembled in client software for testing purposes right now, move this part of logic
// to here.
(verified, ) = plonkVerifier.staticcall(zkproof);
}
}
Loading

0 comments on commit eb5d564

Please sign in to comment.