From 4a38edfc1580aa1cb5113993ff8a2e5574076226 Mon Sep 17 00:00:00 2001 From: DanielKotov <159419107+DanielKotov@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:44:53 +0300 Subject: [PATCH] fix: witness changes in file sponge.hpp (#10345) Static analyzer found that initial values in cache and state arrays weren't properly constrained. Initially state fill in 0 + iv value, but these values weren't constrained as witnesses. We replaced witness_t constructor with function create_constant_witness from class witness_t in file sponge.hpp. All tests for poseidon2s passed after fix. --- .../barretenberg/stdlib/hash/poseidon2/sponge/sponge.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/sponge/sponge.hpp b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/sponge/sponge.hpp index 6d79834aa95..a812ec7811e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/sponge/sponge.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/hash/poseidon2/sponge/sponge.hpp @@ -53,16 +53,16 @@ template (builder, 0); + state[i] = witness_t::create_constant_witness(builder, 0); } - state[rate] = witness_t(builder, domain_iv.get_value()); + state[rate] = witness_t::create_constant_witness(builder, domain_iv.get_value()); } std::array perform_duplex() { // zero-pad the cache for (size_t i = cache_size; i < rate; ++i) { - cache[i] = witness_t(builder, 0); + cache[i] = witness_t::create_constant_witness(builder, 0); } // add the cache into sponge state for (size_t i = 0; i < rate; ++i) { @@ -122,7 +122,7 @@ template (builder, 0); + cache[cache_size] = witness_t::create_constant_witness(builder, 0); return result; }