Skip to content

Commit c3efd60

Browse files
notnotrajunotnotraju
andauthored
chore: fix asm_self_* field arithmetic signatures (#22353)
## Summary - Remove incorrect `const` from the first parameter of the 5 `asm_self_*` field functions (mul, sqr, add, sub, reduce_once). These functions modify the parameter in-place via inline assembly but declared it `const field&`. ## Test plan - [x] `ecc_tests` — 836/836 passed Co-authored-by: notnotraju <raju@aztec-labs.com>
1 parent 48e9df0 commit c3efd60

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

barretenberg/cpp/src/barretenberg/ecc/fields/field_declarations.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -629,14 +629,14 @@ template <class Params_> struct alignas(32) field {
629629
BB_INLINE static field asm_sqr_with_coarse_reduction(const field& a) noexcept;
630630
BB_INLINE static field asm_add_with_coarse_reduction(const field& a, const field& b) noexcept;
631631
BB_INLINE static field asm_sub_with_coarse_reduction(const field& a, const field& b) noexcept;
632-
BB_INLINE static void asm_self_mul_with_coarse_reduction(const field& a, const field& b) noexcept;
633-
BB_INLINE static void asm_self_sqr_with_coarse_reduction(const field& a) noexcept;
634-
BB_INLINE static void asm_self_add_with_coarse_reduction(const field& a, const field& b) noexcept;
635-
BB_INLINE static void asm_self_sub_with_coarse_reduction(const field& a, const field& b) noexcept;
632+
BB_INLINE static void asm_self_mul_with_coarse_reduction(field& a, const field& b) noexcept;
633+
BB_INLINE static void asm_self_sqr_with_coarse_reduction(field& a) noexcept;
634+
BB_INLINE static void asm_self_add_with_coarse_reduction(field& a, const field& b) noexcept;
635+
BB_INLINE static void asm_self_sub_with_coarse_reduction(field& a, const field& b) noexcept;
636636

637637
BB_INLINE static void asm_conditional_negate(field& r, uint64_t predicate) noexcept;
638638
BB_INLINE static field asm_reduce_once(const field& a) noexcept;
639-
BB_INLINE static void asm_self_reduce_once(const field& a) noexcept;
639+
BB_INLINE static void asm_self_reduce_once(field& a) noexcept;
640640
static constexpr uint64_t zero_reference = 0x00ULL;
641641
#endif
642642
constexpr field tonelli_shanks_sqrt() const noexcept;

barretenberg/cpp/src/barretenberg/ecc/fields/field_impl_x64.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ template <class T> field<T> field<T>::asm_mul_with_coarse_reduction(const field&
4646
return r;
4747
}
4848

49-
template <class T> void field<T>::asm_self_mul_with_coarse_reduction(const field& a, const field& b) noexcept
49+
template <class T> void field<T>::asm_self_mul_with_coarse_reduction(field& a, const field& b) noexcept
5050
{
5151
constexpr uint64_t r_inv = T::r_inv;
5252
constexpr uint64_t modulus_0 = modulus.data[0];
@@ -141,7 +141,7 @@ template <class T> field<T> field<T>::asm_sqr_with_coarse_reduction(const field&
141141
return r;
142142
}
143143

144-
template <class T> void field<T>::asm_self_sqr_with_coarse_reduction(const field& a) noexcept
144+
template <class T> void field<T>::asm_self_sqr_with_coarse_reduction(field& a) noexcept
145145
{
146146
constexpr uint64_t r_inv = T::r_inv;
147147
constexpr uint64_t modulus_0 = modulus.data[0];
@@ -227,7 +227,7 @@ template <class T> field<T> field<T>::asm_add_with_coarse_reduction(const field&
227227
return r;
228228
}
229229

230-
template <class T> void field<T>::asm_self_add_with_coarse_reduction(const field& a, const field& b) noexcept
230+
template <class T> void field<T>::asm_self_add_with_coarse_reduction(field& a, const field& b) noexcept
231231
{
232232
constexpr uint64_t twice_not_modulus_0 = twice_not_modulus.data[0];
233233
constexpr uint64_t twice_not_modulus_1 = twice_not_modulus.data[1];
@@ -277,7 +277,7 @@ template <class T> field<T> field<T>::asm_sub_with_coarse_reduction(const field&
277277
return r;
278278
}
279279

280-
template <class T> void field<T>::asm_self_sub_with_coarse_reduction(const field& a, const field& b) noexcept
280+
template <class T> void field<T>::asm_self_sub_with_coarse_reduction(field& a, const field& b) noexcept
281281
{
282282
constexpr uint64_t twice_modulus_0 = twice_modulus.data[0];
283283
constexpr uint64_t twice_modulus_1 = twice_modulus.data[1];
@@ -353,7 +353,7 @@ template <class T> field<T> field<T>::asm_reduce_once(const field& a) noexcept
353353
return r;
354354
}
355355

356-
template <class T> void field<T>::asm_self_reduce_once(const field& a) noexcept
356+
template <class T> void field<T>::asm_self_reduce_once(field& a) noexcept
357357
{
358358
constexpr uint64_t not_modulus_0 = not_modulus.data[0];
359359
constexpr uint64_t not_modulus_1 = not_modulus.data[1];

0 commit comments

Comments
 (0)