Files
MP-SPDZ/FHE/Ring.cpp
Marcel Keller 2813c0ef0f Maintenance.
2023-08-14 18:29:46 +10:00

46 lines
774 B
C++

#include "Ring.h"
#include "Tools/Exceptions.h"
Ring::Ring(int m) :
mm(0), phim(0)
{
if (m != 0)
init(*this, m);
}
void Ring::pack(octetStream& o) const
{
o.store(mm);
if (((mm - 1) & mm) != 0)
{
o.store(phim);
o.store(pi);
o.store(pi_inv);
o.store(poly);
}
}
void Ring::unpack(octetStream& o)
{
o.get(mm);
if (((mm - 1) & mm) != 0)
{
o.get(phim);
o.get(pi);
o.get(pi_inv);
o.get(poly);
}
else if (mm != 0)
init(*this, mm);
}
bool Ring::operator !=(const Ring& other) const
{
if (mm != other.mm or phim != other.phim or pi != other.pi
or pi_inv != other.pi_inv or poly != other.poly)
return true;
else
return false;
}