Skip to content

Commit

Permalink
chore(protocol): improve LibZKP (#13047)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik authored Jan 25, 2023
1 parent 3e2af01 commit bf9807e
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 133 deletions.
7 changes: 3 additions & 4 deletions packages/protocol/contracts/L1/ProofVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ 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,
Expand All @@ -34,16 +34,15 @@ contract ProofVerifier is IProofVerifier, EssentialContract {
}

function verifyZKP(
bytes memory verificationKey,
string memory verifierId,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
) external view returns (bool) {
return
LibZKP.verify({
plonkVerifier: resolve("plonk_verifier", false),
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.

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

function verify(
address plonkVerifier,
bytes memory verificationKey,
bytes calldata zkproof,
bytes32 blockHash,
address prover,
bytes32 txListHash
) 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
// 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);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/test/L1/TestTaikoL1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract TestTaikoL1 is TaikoL1, IProofVerifier {
}

function verifyZKP(
bytes memory /*verificationKey*/,
string memory /*verifierId*/,
bytes calldata /*zkproof*/,
bytes32 /*blockHash*/,
address /*prover*/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ contract TestTaikoL1EnableTokenomics is TaikoL1, IProofVerifier {
}

function verifyZKP(
bytes memory /*verificationKey*/,
string memory /*verifierId*/,
bytes calldata /*zkproof*/,
bytes32 /*blockHash*/,
address /*prover*/,
Expand Down
31 changes: 0 additions & 31 deletions packages/protocol/docs/common/ConfigManager.md

This file was deleted.

11 changes: 0 additions & 11 deletions packages/protocol/tasks/deploy_L1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,6 @@ export async function deployContracts(hre: any) {
)
);

// Config manager
const ConfigManager = await utils.deployContract(hre, "ConfigManager");
await utils.waitTx(hre, await ConfigManager.init());
await utils.waitTx(
hre,
await AddressManager.setAddress(
`${chainId}.config_manager`,
ConfigManager.address
)
);

// TaikoL1
const TaikoL1 = await utils.deployContract(
hre,
Expand Down
41 changes: 0 additions & 41 deletions packages/protocol/test/ConfigManager.test.ts

This file was deleted.

0 comments on commit bf9807e

Please sign in to comment.