Skip to content

Commit

Permalink
m31 fix reduce function (#584)
Browse files Browse the repository at this point in the history
## Describe the changes

This PR fixes `reduce` function and sets correct `nonresidue` in
the`fp_config`
  • Loading branch information
nonam3e authored Aug 22, 2024
1 parent 621676b commit d54be39
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions icicle/include/fields/stark_fields/m31.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ namespace m31 {
{
const uint32_t modulus = MersenneField::get_modulus().limbs[0];
uint32_t tmp = (xs.storage >> 31) + (xs.storage & modulus); // max: 1 + 2^31-1 = 2^31
tmp = (xs.storage >> 31) + (xs.storage & modulus); // max: 1 + 0 = 1
tmp = (tmp >> 31) + (tmp & modulus); // max: 1 + 0 = 1
return MersenneField{{tmp == modulus ? 0 : tmp}};
}

Expand Down Expand Up @@ -207,9 +207,9 @@ namespace m31 {
static constexpr storage_array<omegas_count, limbs_count> inv = {{{0x40000000}}};

// nonresidue to generate the extension field
static constexpr uint32_t nonresidue = 11;
static constexpr uint32_t nonresidue = 1;
// true if nonresidue is negative.
static constexpr bool nonresidue_is_negative = false;
static constexpr bool nonresidue_is_negative = true;
};

/**
Expand Down

0 comments on commit d54be39

Please sign in to comment.