Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): deploy the generated Yul plonk verifier #13016

Merged
merged 15 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 10 additions & 4 deletions packages/protocol/contracts/L1/ProofVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

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 {
Expand All @@ -17,7 +18,7 @@ interface IProofVerifier {
bytes32 blockHash,
address prover,
bytes32 txListHash
) external pure returns (bool verified);
) external view returns (bool verified);

function verifyMKP(
bytes memory key,
Expand All @@ -27,16 +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,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
) external pure returns (bool) {
) external view returns (bool) {
return
LibZKP.verify({
plonkVerifier: resolve("plonk_verifier", false),
dantaik marked this conversation as resolved.
Show resolved Hide resolved
verificationKey: verificationKey,
zkproof: zkproof,
blockHash: blockHash,
Expand Down
10 changes: 7 additions & 3 deletions packages/protocol/contracts/libs/LibZKP.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ library LibZKP {
*********************/

function verify(
address plonkVerifier,
bytes memory verificationKey,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
) internal pure returns (bool verified) {
// TODO
return true;
) internal view returns (bool verified) {
// TODO(david):
// 1) verificationKey is hard-coded in the generated PlonkVerifier, make it as a configurable parameter.
// 2) public input is assembled in client software for testing purposes right now, move this part of logic
// to here.
(verified, ) = plonkVerifier.staticcall(zkproof);
}
}
Loading