-
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.
feat(protocol): introduce
SgxOrZkVerifier
to allow any valid proof (#…
- Loading branch information
1 parent
c0ab98f
commit 46b8ac3
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/protocol/contracts/layer1/devnet/verifiers/DevnetVerifier.sol
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,40 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import "../../verifiers/compose/ComposeVerifier.sol"; | ||
|
||
/// @title DevnetVerifier.sol | ||
/// @notice OP or SGX or SP1 or Risc0 verifier | ||
/// @custom:security-contact [email protected] | ||
contract DevnetVerifier is ComposeVerifier { | ||
uint256[50] private __gap; | ||
|
||
address public immutable opVerifier; | ||
address public immutable sgxVerifier; | ||
address public immutable risc0Verifier; | ||
address public immutable sp1Verifier; | ||
|
||
constructor( | ||
address _opVerifier, | ||
address _sgxVerifier, | ||
address _risc0Verifier, | ||
address _sp1Verifier | ||
) { | ||
opVerifier = _opVerifier; | ||
sgxVerifier = _sgxVerifier; | ||
risc0Verifier = _risc0Verifier; | ||
sp1Verifier = _sp1Verifier; | ||
} | ||
|
||
function areVerifiersSufficient(address[] memory _verifiers) | ||
internal | ||
view | ||
override | ||
returns (bool) | ||
{ | ||
if (_verifiers.length != 1) return false; | ||
|
||
return _verifiers[0] == opVerifier || _verifiers[0] == sgxVerifier | ||
|| _verifiers[0] == risc0Verifier || _verifiers[0] == sp1Verifier; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/protocol/contracts/layer1/devnet/verifiers/OpVerifier.sol
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,37 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; | ||
import "src/shared/common/EssentialContract.sol"; | ||
import "src/shared/libs/LibStrings.sol"; | ||
import "../../verifiers/IVerifier.sol"; | ||
|
||
/// @title OpVerifier | ||
/// @notice This contract is the implementation of verifying optimism signature proofs | ||
/// onchain. | ||
/// @custom:security-contact [email protected] | ||
contract OpVerifier is EssentialContract, IVerifier { | ||
uint64 public immutable taikoChainId; | ||
|
||
uint256[50] private __gap; | ||
|
||
constructor(uint64 _taikoChainId) { | ||
taikoChainId = _taikoChainId; | ||
} | ||
|
||
/// @notice Initializes the contract. | ||
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero. | ||
/// @param _rollupResolver The {IResolver} used by this rollup. | ||
function init(address _owner, address _rollupResolver) external initializer { | ||
__Essential_init(_owner, _rollupResolver); | ||
} | ||
|
||
/// @inheritdoc IVerifier | ||
function verifyProof( | ||
Context[] calldata _ctxs, | ||
bytes calldata _proof | ||
) | ||
external | ||
onlyFromNamedEither(LibStrings.B_TAIKO, LibStrings.B_PROOF_VERIFIER) | ||
{ } | ||
} |
33 changes: 33 additions & 0 deletions
33
packages/protocol/contracts/layer1/verifiers/compose/AnyVerifier.sol
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,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import "./ComposeVerifier.sol"; | ||
|
||
/// @title AnyVerifier.sol | ||
/// @notice SGX or SP1 or Risc0 verifier | ||
/// @custom:security-contact [email protected] | ||
contract AnyVerifier is ComposeVerifier { | ||
uint256[50] private __gap; | ||
|
||
address public immutable sgxVerifier; | ||
address public immutable risc0Verifier; | ||
address public immutable sp1Verifier; | ||
|
||
constructor(address _sgxVerifier, address _risc0Verifier, address _sp1Verifier) { | ||
sgxVerifier = _sgxVerifier; | ||
risc0Verifier = _risc0Verifier; | ||
sp1Verifier = _sp1Verifier; | ||
} | ||
|
||
function areVerifiersSufficient(address[] memory _verifiers) | ||
internal | ||
view | ||
override | ||
returns (bool) | ||
{ | ||
if (_verifiers.length != 1) return false; | ||
|
||
return _verifiers[0] == sgxVerifier || _verifiers[0] == risc0Verifier | ||
|| _verifiers[0] == sp1Verifier; | ||
} | ||
} |