Skip to content

Commit

Permalink
fix(contracts) Verifier digest mutability
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimo99 authored and PetarKirov committed Aug 28, 2024
1 parent 775a9bd commit 6538d38
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import {IBalanceVerifier} from './interfaces/IBalanceVerifierDiva.sol';
import '@openzeppelin/contracts/access/Ownable.sol';

abstract contract BalanceVerifier is Ownable, IBalanceVerifier {
/// @notice the verifierDigest of the plonky2 circuit
uint256 public immutable VERIFIER_DIGEST;

/// @notice The genesis block timestamp.
uint256 public immutable GENESIS_BLOCK_TIMESTAMP;

Expand All @@ -22,19 +19,26 @@ abstract contract BalanceVerifier is Ownable, IBalanceVerifier {

address internal verifier;

/// @notice the verifierDigest of the plonky2 circuit
uint256 public verifierDigest;

constructor(
uint256 verifierDigest,
uint256 _verifierDigest,
uint256 genesisBlockTimestamp,
address _verifier,
address _owner
) Ownable(_owner) {
VERIFIER_DIGEST = verifierDigest;
verifierDigest = _verifierDigest;
GENESIS_BLOCK_TIMESTAMP = genesisBlockTimestamp;
verifier = _verifier;
}

function setVerifier(address _verifier) external override onlyOwner {
function setVerifier(
address _verifier,
uint256 newVerifierDigest
) external override onlyOwner {
verifier = _verifier;
verifierDigest = newVerifierDigest;
}

/// @notice Verifies the proof and writes the data for given slot if valid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract BalanceVerifierDiva is BalanceVerifier, IBalanceVerifierDiva {
uint64 _numberOfSlashedValidators
) external override {
uint256[] memory publicInputs = new uint256[](2);
publicInputs[0] = VERIFIER_DIGEST;
publicInputs[0] = verifierDigest;
publicInputs[1] = (uint256(
sha256(
abi.encodePacked(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ contract BalanceVerifierLido is BalanceVerifier, IBalanceVerifierLido {
uint64 _numberOfSlashedValidators
) external override {
uint256[] memory publicInputs = new uint256[](2);
publicInputs[0] = VERIFIER_DIGEST;
publicInputs[0] = verifierDigest;
publicInputs[1] = (uint256(
sha256(
abi.encodePacked(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ interface IBalanceVerifier {
/// @dev Verification failed
error VerificationFailed();

function setVerifier(address newVerifier) external;
function setVerifier(address newVerifier, uint256 newVerifierDigest) external;
}

0 comments on commit 6538d38

Please sign in to comment.