LowGear with higher statistical security.

This commit is contained in:
Marcel Keller
2021-04-16 11:10:49 +10:00
parent 8c9a7431b8
commit 6c89808733

View File

@@ -11,6 +11,8 @@
template<int L>
class fixint : public SignedZ2<64 * (L + 1)>
{
static const int OVERFLOW = 60;
public:
typedef SignedZ2<64 * (L + 1)> super;
@@ -22,7 +24,7 @@ public:
fixint(const T& other) :
super(other)
{
char check = this->a[this->N_WORDS - 1] >> 56;
auto check = mp_limb_signed_t(this->a[this->N_WORDS - 1]) >> OVERFLOW;
assert(check == 0 or check == -1);
}
@@ -68,7 +70,7 @@ public:
void allocate_slots(const T& limit)
{
int n_bits = this->size_in_bits();
if (numBits(limit) - 56 > n_bits)
if (numBits(limit) - OVERFLOW > n_bits)
{
cerr << "cannot hold " << numBits(limit) << " bits, " << n_bits
<< " available" << endl;