From 2059e32b62d405a6af8ead34175868b421833bf8 Mon Sep 17 00:00:00 2001 From: ludamad Date: Wed, 12 Apr 2023 20:24:36 -0400 Subject: [PATCH] doc: Document more thoroughly why fields don't 0-init (https://github.com/AztecProtocol/barretenberg/pull/349) * Update field.hpp * Update field.hpp * Update field.hpp --- barretenberg/cpp/src/barretenberg/ecc/fields/field.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/ecc/fields/field.hpp b/barretenberg/cpp/src/barretenberg/ecc/fields/field.hpp index 66c59ea0d2e..80a87f46aff 100644 --- a/barretenberg/cpp/src/barretenberg/ecc/fields/field.hpp +++ b/barretenberg/cpp/src/barretenberg/ecc/fields/field.hpp @@ -25,6 +25,10 @@ namespace barretenberg { template struct alignas(32) field { public: // We don't initialize data by default since we'd lose a lot of time on pointless initializations. + // Other alternatives have been noted, such as casting to get around constructors where they matter, + // however it is felt that sanitizer tools (e.g. MSAN) can detect garbage well, whereas doing + // hacky casts where needed would require rework to critical algos like MSM, FFT, Sumcheck. + // Instead, the recommended solution is use an explicit = 0 where initialization is important. field() noexcept {} constexpr field(const uint256_t& input) noexcept