Skip to content

Commit

Permalink
fix: fix decompose_generators_fold (PROOF-620) (#16)
Browse files Browse the repository at this point in the history
* work around

* reference bug

* fix bug
  • Loading branch information
rnburn authored Sep 16, 2023
1 parent c203823 commit dd159f8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sxt/proof/inner_product/generator_fold.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ void decompose_generator_fold(basct::span<unsigned>& res, const s25t::element& m
const s25t::element& m_high) noexcept {
SXT_DEBUG_ASSERT(res.size() == s25cn::max_bits_v);
size_t bit_index = 0;

for (size_t i = 0; i < 4; ++i) {
uint64_t x, y;
std::memcpy(&x, reinterpret_cast<const char*>(&m_low) + sizeof(uint64_t) * i, sizeof(uint64_t));
std::memcpy(&y, reinterpret_cast<const char*>(&m_high) + sizeof(uint64_t) * i,
sizeof(uint64_t));
auto m = std::min(s25cn::max_bits_v - bit_index, 64ul);
for (size_t bit_offset = 0; bit_offset < m; ++bit_offset) {
auto mask = 1ull << bit_index;
auto mask = 1ull << (bit_index - i * 64);
res[bit_index++] =
static_cast<unsigned>((x & mask) != 0) + 2u * static_cast<unsigned>((y & mask) != 0);
}
Expand All @@ -58,9 +59,9 @@ void decompose_generator_fold(basct::span<unsigned>& res, const s25t::element& m
//--------------------------------------------------------------------------------------------------
// fold_generators
//--------------------------------------------------------------------------------------------------
CUDA_CALLABLE void fold_generators(c21t::element_p3& res, basct::cspan<unsigned> decomposition,
const c21t::element_p3& g_low,
const c21t::element_p3& g_high) noexcept {
CUDA_CALLABLE
void fold_generators(c21t::element_p3& res, basct::cspan<unsigned> decomposition,
const c21t::element_p3& g_low, const c21t::element_p3& g_high) noexcept {
if (decomposition.empty()) {
// this should never happen
res = c21t::element_p3::identity();
Expand Down

0 comments on commit dd159f8

Please sign in to comment.