Skip to content

Commit 727ddce

Browse files
yperbasisValarDragon
authored andcommitted
Fix bit checking when mp_limb_t is different from unsigned long (#59)
1 parent a9fa186 commit 727ddce

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

libff/algebra/fields/fp.tcc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,8 @@ Fp_model<n, modulus> Fp_model<n,modulus>::random_element() /// returns random el
733733
const std::size_t part = bitno/GMP_NUMB_BITS;
734734
const std::size_t bit = bitno - (GMP_NUMB_BITS*part);
735735

736-
r.mont_repr.data[part] &= ~(1ul<<bit);
736+
static const mp_limb_t one = 1;
737+
r.mont_repr.data[part] &= ~(one<<bit);
737738

738739
bitno--;
739740
}

libff/algebra/fields/fp12_2over3over2.tcc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@ Fp12_2over3over2_model<n, modulus> Fp12_2over3over2_model<n,modulus>::cyclotomic
388388
res = res.cyclotomic_squared();
389389
}
390390

391-
if (exponent.data[i] & (1ul<<j))
391+
static const mp_limb_t one = 1;
392+
if (exponent.data[i] & (one<<j))
392393
{
393394
found_one = true;
394395
res = res * (*this);

libff/common/rng.tcc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ FieldT SHA512_rng(const uint64_t idx)
5757
const std::size_t part = bitno/GMP_NUMB_BITS;
5858
const std::size_t bit = bitno - (GMP_NUMB_BITS*part);
5959

60-
rval.data[part] &= ~(1ul<<bit);
60+
static const mp_limb_t one = 1;
61+
rval.data[part] &= ~(one<<bit);
6162

6263
bitno--;
6364
}

0 commit comments

Comments
 (0)