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 all 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
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 <[email protected]>
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)
dantaik marked this conversation as resolved.
Show resolved Hide resolved
),
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