Skip to content

Commit

Permalink
feat(protocol): introduce SgxOrZkVerifier to allow any valid proof (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
YoGhurt111 authored Jan 20, 2025
1 parent c0ab98f commit 46b8ac3
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
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 packages/protocol/contracts/layer1/devnet/verifiers/OpVerifier.sol
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)
{ }
}
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;
}
}

0 comments on commit 46b8ac3

Please sign in to comment.