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 Sep 26, 2024
1 parent 56c80f5 commit 968855c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import {ZeroAddressError} from '../Errors.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 @@ -23,8 +20,11 @@ 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
Expand All @@ -33,16 +33,19 @@ abstract contract BalanceVerifier is Ownable, IBalanceVerifier {
revert ZeroAddressError();
}
verifier = _verifier;

VERIFIER_DIGEST = verifierDigest;
verifierDigest = _verifierDigest;
GENESIS_BLOCK_TIMESTAMP = genesisBlockTimestamp;
}

function setVerifier(address _verifier) external override onlyOwner {
function setVerifier(
address _verifier,
uint256 newVerifierDigest
) external override onlyOwner {
if (_verifier == address(0)) {
revert ZeroAddressError();
}
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 @@ -43,7 +43,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 968855c

Please sign in to comment.