From 51c593e49613944c66e6cd82cde74c8628a5f1be Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 7 Dec 2023 20:26:45 +0000 Subject: [PATCH 1/3] fix: broken uint256_t --- barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp index d8cd9ef2f18..5ddaa9713ae 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint256/uint256.hpp @@ -14,6 +14,7 @@ #include "../uint128/uint128.hpp" #include "barretenberg/common/serialize.hpp" #include "barretenberg/common/throw_or_abort.hpp" +#include #include #include #include @@ -91,7 +92,7 @@ class alignas(32) uint256_t { explicit constexpr operator bool() const { return static_cast(data[0]); }; - template explicit constexpr operator T() const { return static_cast(data[0]); }; + template explicit constexpr operator T() const { return static_cast(data[0]); }; [[nodiscard]] constexpr bool get_bit(uint64_t bit_index) const; [[nodiscard]] constexpr uint64_t get_msb() const; From 01cdc163e5ca6b5d70e046685aa28200820d62a4 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 7 Dec 2023 20:33:32 +0000 Subject: [PATCH 2/3] Compile fix --- .../barretenberg/stdlib/primitives/bigfield/bigfield.fuzzer.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.fuzzer.hpp b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.fuzzer.hpp index 18e2cbe129e..5111ea71a54 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.fuzzer.hpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/primitives/bigfield/bigfield.fuzzer.hpp @@ -266,7 +266,7 @@ template class BigFieldBase { mask = (uint256_t(1) << mask_size) - 1; // Choose the bit range // Return instruction - return { .id = instruction_opcode, .arguments.element = Element(temp & mask) }; + return { .id = instruction_opcode, .arguments.element = Element(static_cast(temp & mask)) }; break; case OPCODE::RANDOMSEED: From 55678c80fc972f9cc7ac478282ea9b9e17444b16 Mon Sep 17 00:00:00 2001 From: ludamad Date: Thu, 7 Dec 2023 21:09:00 +0000 Subject: [PATCH 3/3] Also constrain u128 --- barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp index 3dc320abe2d..e229f9b7d23 100644 --- a/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp +++ b/barretenberg/cpp/src/barretenberg/numeric/uint128/uint128.hpp @@ -5,6 +5,7 @@ #ifdef __i386__ #include "barretenberg/common/serialize.hpp" +#include namespace numeric { @@ -37,7 +38,7 @@ class alignas(32) uint128_t { constexpr ~uint128_t() = default; explicit constexpr operator bool() const { return static_cast(data[0]); }; - template explicit constexpr operator T() const { return static_cast(data[0]); }; + template explicit constexpr operator T() const { return static_cast(data[0]); }; [[nodiscard]] constexpr bool get_bit(uint64_t bit_index) const; [[nodiscard]] constexpr uint64_t get_msb() const;