From ac87db554a96e21e658974ba51deccdbfa7ebeed Mon Sep 17 00:00:00 2001 From: Martin Ivanov Date: Mon, 24 Jun 2024 12:05:51 +0300 Subject: [PATCH] refactor(): Miscellaneous improvements from the Veridise audit --- .../inner_level.rs | 4 ++-- .../deposits_accumulator_balance_aggregator/first_level.rs | 2 +- .../circuits/src/utils/circuit/hashing/merkle/sha256.rs | 3 +-- .../solidity/contracts/balance_verifier/BalanceVerifier.sol | 1 - 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/beacon-light-client/plonky2/crates/circuits/src/deposit_accumulator_balance_aggregator_diva/inner_level.rs b/beacon-light-client/plonky2/crates/circuits/src/deposit_accumulator_balance_aggregator_diva/inner_level.rs index 15b995a0d..0b16f388b 100644 --- a/beacon-light-client/plonky2/crates/circuits/src/deposit_accumulator_balance_aggregator_diva/inner_level.rs +++ b/beacon-light-client/plonky2/crates/circuits/src/deposit_accumulator_balance_aggregator_diva/inner_level.rs @@ -18,7 +18,7 @@ use plonky2::{ use plonky2_crypto::biguint::CircuitBuilderBiguint; use super::first_level::{ - DivaAccumulatedDataTarget, DepositAccumulatorBalanceAggregatorDivaFirstLevel, + DepositAccumulatorBalanceAggregatorDivaFirstLevel, DivaAccumulatedDataTarget, }; pub struct DepositAccumulatorBalanceAggregatorDivaInnerLevel; @@ -38,7 +38,7 @@ impl Circuit for DepositAccumulatorBalanceAggregatorDivaInnerLevel { fn define( builder: &mut CircuitBuilder, circuit_data: &Self::Params, - ) -> Self::Target where { + ) -> Self::Target { let proof1 = verify_proof(builder, &circuit_data); let proof2 = verify_proof(builder, &circuit_data); diff --git a/beacon-light-client/plonky2/crates/circuits/src/deposits_accumulator_balance_aggregator/first_level.rs b/beacon-light-client/plonky2/crates/circuits/src/deposits_accumulator_balance_aggregator/first_level.rs index 8a0c403a4..0c74e9e66 100644 --- a/beacon-light-client/plonky2/crates/circuits/src/deposits_accumulator_balance_aggregator/first_level.rs +++ b/beacon-light-client/plonky2/crates/circuits/src/deposits_accumulator_balance_aggregator/first_level.rs @@ -896,7 +896,7 @@ mod test { pw.set_proof_with_pis_target(&targets.bls_verification_proof, &bls_proof); let s = Instant::now(); - let proof = circuit.prove(pw).unwrap(); + let _proof = circuit.prove(pw).unwrap(); println!("Proof generated in {:?}", s.elapsed()); } } diff --git a/beacon-light-client/plonky2/crates/circuits/src/utils/circuit/hashing/merkle/sha256.rs b/beacon-light-client/plonky2/crates/circuits/src/utils/circuit/hashing/merkle/sha256.rs index b02b69b97..03737a83d 100644 --- a/beacon-light-client/plonky2/crates/circuits/src/utils/circuit/hashing/merkle/sha256.rs +++ b/beacon-light-client/plonky2/crates/circuits/src/utils/circuit/hashing/merkle/sha256.rs @@ -102,8 +102,7 @@ pub fn assert_merkle_proof_is_valid_const_sha256< gindex: u64, ) { let is_valid = validate_merkle_proof_const_sha256(builder, leaf, root, branch, gindex); - let _true = builder._true(); - builder.connect(is_valid.target, _true.target); + builder.assert_true(is_valid); } pub fn hash_tree_root_sha256, const D: usize>( diff --git a/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifier.sol b/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifier.sol index 2a04fd410..ecc8b9bd0 100644 --- a/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifier.sol +++ b/beacon-light-client/solidity/contracts/balance_verifier/BalanceVerifier.sol @@ -44,7 +44,6 @@ abstract contract BalanceVerifier is Ownable, IBalanceVerifier { bytes calldata proof, uint256[] memory publicInputs ) internal { - // Make the call using `address(this).call` (bool success, bytes memory returnData) = verifier.call( // Encode the call to the `verify` function with the public inputs abi.encodeWithSelector(PlonkVerifier.Verify.selector, proof, publicInputs)