-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(protocol): extract IProofVerifier interface (#6800)
- Loading branch information
Showing
8 changed files
with
154 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: MIT | ||
// | ||
// ╭━━━━╮╱╱╭╮╱╱╱╱╱╭╮╱╱╱╱╱╭╮ | ||
// ┃╭╮╭╮┃╱╱┃┃╱╱╱╱╱┃┃╱╱╱╱╱┃┃ | ||
// ╰╯┃┃┣┻━┳┫┃╭┳━━╮┃┃╱╱╭━━┫╰━┳━━╮ | ||
// ╱╱┃┃┃╭╮┣┫╰╯┫╭╮┃┃┃╱╭┫╭╮┃╭╮┃━━┫ | ||
// ╱╱┃┃┃╭╮┃┃╭╮┫╰╯┃┃╰━╯┃╭╮┃╰╯┣━━┃ | ||
// ╱╱╰╯╰╯╰┻┻╯╰┻━━╯╰━━━┻╯╰┻━━┻━━╯ | ||
pragma solidity ^0.8.9; | ||
|
||
import "../thirdparty/LibMerkleTrie.sol"; | ||
import "../libs/LibZKP.sol"; | ||
|
||
/// @author dantaik <[email protected]> | ||
interface IProofVerifier { | ||
function verifyZKP( | ||
bytes memory verificationKey, | ||
bytes calldata zkproof, | ||
bytes32 blockHash, | ||
address prover, | ||
bytes32 txListHash | ||
) external pure returns (bool verified); | ||
|
||
function verifyMKP( | ||
bytes memory key, | ||
bytes memory value, | ||
bytes memory proof, | ||
bytes32 root | ||
) external pure returns (bool verified); | ||
} | ||
|
||
contract ProofVerifier is IProofVerifier { | ||
function verifyZKP( | ||
bytes memory verificationKey, | ||
bytes calldata zkproof, | ||
bytes32 blockHash, | ||
address prover, | ||
bytes32 txListHash | ||
) external pure returns (bool) { | ||
return | ||
LibZKP.verify({ | ||
verificationKey: verificationKey, | ||
zkproof: zkproof, | ||
blockHash: blockHash, | ||
prover: prover, | ||
txListHash: txListHash | ||
}); | ||
} | ||
|
||
function verifyMKP( | ||
bytes memory key, | ||
bytes memory value, | ||
bytes memory proof, | ||
bytes32 root | ||
) external pure returns (bool) { | ||
return | ||
LibMerkleTrie.verifyInclusionProof({ | ||
_key: key, | ||
_value: value, | ||
_proof: proof, | ||
_root: root | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters