Esempio n. 1
0
void convert(NTL::ZZX& out, const NTL::Vec<long>& in)
{
  out.SetLength(in.length());
  for (long i=0; i<in.length(); i++)
    out[i] = conv<ZZ>(in[i]);
  out.normalize();
}
Esempio n. 2
0
/*!
 * @param n : phi(m)
 */
void pack_into_coeff(NTL::ZZX& plain, const std::vector<long>& input,
                     long n, bool reverse) {
    long sze = static_cast<long>(input.size());

    assert(sze > 0);
    assert(sze <= n);

    plain.SetLength(sze);

    if (reverse) {
        NTL::SetCoeff(plain, 0, input.back());

        for (long i = 0; i < sze - 1; i++) {
            NTL::SetCoeff(plain, n - i - 1, -input[i]);
        }
    } else {
        for (long i = 0; i < sze; i++) {
            NTL::SetCoeff(plain, i, input[i]);
        }
    }
}