Skip to content

Commit

Permalink
CI fix:
Browse files Browse the repository at this point in the history
Compatibility with 32-bit systems
  • Loading branch information
FAlbertDev committed Mar 8, 2024
1 parent 50fae0b commit 9e6afc7
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/lib/pubkey/curve448/curve448_utils/curve448_gf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,6 @@ void reduce_after_mul(std::span<uint64_t, 7> out, std::span<const uint64_t, 14>
}

constexpr size_t words_per_uint64 = 8 / sizeof(word);
constexpr size_t bytes_per_uint64 = 8;

template <size_t S>
std::array<word, S * words_per_uint64> span64_to_word_arr(std::span<const uint64_t, S> a) {
std::array<uint8_t, S * bytes_per_uint64> bytes;
copy_out_le(bytes.data(), bytes.size(), a.data());
std::array<word, S * words_per_uint64> out;
load_le<word>(out.data(), bytes.data(), out.size());
return out;
}

template <size_t S>
void word_arr_to_span64(std::span<uint64_t, S> out, std::span<const word, S * words_per_uint64> in) {
std::array<uint8_t, S * bytes_per_uint64> bytes;
copy_out_le(bytes.data(), bytes.size(), in.data());
load_le<uint64_t>(out.data(), bytes.data(), out.size());
}

void gf_mul(std::span<uint64_t, 7> out, std::span<const uint64_t, 7> a, std::span<const uint64_t, 7> b) {
std::array<uint64_t, 14> ws;
Expand All @@ -175,8 +158,8 @@ void gf_mul(std::span<uint64_t, 7> out, std::span<const uint64_t, 7> a, std::spa
reinterpret_cast<const word*>(a.data()),
reinterpret_cast<const word*>(b.data()));
} else {
const auto a_arr = load_le<std::array<uint64_t, 7>>(store_le(a));
const auto b_arr = load_le<std::array<uint64_t, 7>>(store_le(b));
const auto a_arr = load_le<std::array<word, words_per_uint64 * 7>>(store_le(a));
const auto b_arr = load_le<std::array<word, words_per_uint64 * 7>>(store_le(b));
auto ws_arr = std::array<word, words_per_uint64 * 14>{};

bigint_mul(ws_arr.data(),
Expand All @@ -202,7 +185,7 @@ void gf_square(std::span<uint64_t, 7> out, std::span<const uint64_t, 7> a) {
// Reinterpret cast to itself to prevent compiler errors on non 64-bit systems
bigint_comba_sqr7(reinterpret_cast<word*>(ws.data()), reinterpret_cast<const word*>(a.data()));
} else {
const auto a_arr = load_le<std::array<uint64_t, 7>>(store_le(a));
const auto a_arr = load_le<std::array<word, words_per_uint64 * 7>>(store_le(a));
auto ws_arr = std::array<word, words_per_uint64 * 14>{};
bigint_sqr(ws_arr.data(), ws_arr.size(), a_arr.data(), a_arr.size(), a_arr.size(), nullptr, 0);
load_le(ws, store_le(ws_arr));
Expand Down

0 comments on commit 9e6afc7

Please sign in to comment.