HElib  1.0
Implementing Homomorphic Encryption
 All Classes Files Functions Variables Friends Pages
Public Member Functions | List of all members
PAlgebraModDerived< type > Class Template Reference

A concrete instantiation of the virtual class. More...

#include <PAlgebra.h>

Inheritance diagram for PAlgebraModDerived< type >:
PAlgebraModBase

Public Member Functions

 PAlgebraModDerived (const PAlgebra &zMStar, long r)
 
 PAlgebraModDerived (const PAlgebraModDerived &other)
 
PAlgebraModDerivedoperator= (const PAlgebraModDerived &other)
 
virtual PAlgebraModBaseclone () const
 Returns a pointer to a "clone".
 
virtual PA_tag getTag () const
 Returns the type tag: PA_GF2_tag or PA_zz_p_tag.
 
virtual const PAlgebragetZMStar () const
 Returns reference to underlying PAlgebra object.
 
virtual const vector< ZZX > & getFactorsOverZZ () const
 Returns reference to the factorization of Phi_m(X) mod p^r, but as ZZX's.
 
virtual long getR () const
 The value r.
 
virtual long getPPowR () const
 The value p^r.
 
virtual void restoreContext () const
 Restores the NTL context for p^r.
 
virtual void genMaskTable () const
 Generates the "mask table" that is used to support rotations. More...
 
const RXModulus & getPhimXMod () const
 Returns reference to an RXModulus representing Phi_m(X) (mod p^r)
 
const vec_RX & getFactors () const
 Returns reference to the factors of Phim_m(X) modulo p^r.
 
const vec_RX & getCrtCoeffs () const
 Returns the CRT coefficients: element i contains (prod_{j!=i} F_j)^{-1} mod F_i, where F_0 F_1 ... is the factorization of Phi_m(X) mod p^r.
 
const vector< vector< RX > > & getMaskTable () const
 Returns ref to maskTable, which is used to implement rotations (in the EncryptedArray module). More...
 
Embedding in the plaintext slots and decoding back

In all the functions below, G must be irredicible mod p, and the order of G must divide the order of p modulo m (as returned by zMStar.getOrdP()). In addition, when r > 1, G must be the monomial X (RX(1, 1))

void CRT_decompose (vector< RX > &crt, const RX &H) const
 Returns a vector crt[] such that crt[i] = H mod Ft (with t = T[i])
 
void CRT_reconstruct (RX &H, vector< RX > &crt) const
 Returns H in R[X]/Phi_m(X) s.t. for every i<nSlots and t=T[i], we have H == crt[i] (mod Ft)
 
void mapToSlots (MappingData< type > &mappingData, const RX &G) const
 Compute the maps for all the slots. In the current implementation, we if r > 1, then we must have either deg(G) == 1 or G == factors[0].
 
void embedInAllSlots (RX &H, const RX &alpha, const MappingData< type > &mappingData) const
 Returns H in R[X]/Phi_m(X) s.t. for every t in T, the element Ht = (H mod Ft) in R[X]/Ft(X) represents the same element as alpha in R[X]/G(X). More...
 
void embedInSlots (RX &H, const vector< RX > &alphas, const MappingData< type > &mappingData) const
 Returns H in R[X]/Phi_m(X) s.t. for every t in T, the element Ht = (H mod Ft) in R[X]/Ft(X) represents the same element as alphas[i] in R[X]/G(X). More...
 
void decodePlaintext (vector< RX > &alphas, const RX &ptxt, const MappingData< type > &mappingData) const
 Return an array such that alphas[i] in R[X]/G(X) represent the same element as rt = (H mod Ft) in R[X]/Ft(X) where t=T[i]. More...
 
void buildLinPolyCoeffs (vector< RX > &C, const vector< RX > &L, const MappingData< type > &mappingData) const
 Returns a coefficient vector C for the linearized polynomial representing M. More...
 

Detailed Description

template<class type>
class PAlgebraModDerived< type >

A concrete instantiation of the virtual class.

Member Function Documentation

template<class type >
void PAlgebraModDerived< type >::buildLinPolyCoeffs ( vector< RX > &  C,
const vector< RX > &  L,
const MappingData< type > &  mappingData 
) const

Returns a coefficient vector C for the linearized polynomial representing M.

For h in Z/(p^r)[X] of degree < d,

\[ M(h(X) mod G) = sum_{i=0}^{d-1} (C[j] mod G) * (h(X^{p^j}) mod G).\]

G is assumed to be defined in mappingData, with d = deg(G). L describes a linear map M by describing its action on the standard power basis: M(x^j mod G) = (L[j] mod G), for j = 0..d-1.

template<class type >
void PAlgebraModDerived< type >::decodePlaintext ( vector< RX > &  alphas,
const RX &  ptxt,
const MappingData< type > &  mappingData 
) const

Return an array such that alphas[i] in R[X]/G(X) represent the same element as rt = (H mod Ft) in R[X]/Ft(X) where t=T[i].

The mappingData argument should contain the output of mapToSlots(G).

template<class type >
void PAlgebraModDerived< type >::embedInAllSlots ( RX &  H,
const RX &  alpha,
const MappingData< type > &  mappingData 
) const

Returns H in R[X]/Phi_m(X) s.t. for every t in T, the element Ht = (H mod Ft) in R[X]/Ft(X) represents the same element as alpha in R[X]/G(X).

Must have deg(alpha)<deg(G). The mappingData argument should contain the output of mapToSlots(G).

template<class type >
void PAlgebraModDerived< type >::embedInSlots ( RX &  H,
const vector< RX > &  alphas,
const MappingData< type > &  mappingData 
) const

Returns H in R[X]/Phi_m(X) s.t. for every t in T, the element Ht = (H mod Ft) in R[X]/Ft(X) represents the same element as alphas[i] in R[X]/G(X).

Must have deg(alpha[i])<deg(G). The mappingData argument should contain the output of mapToSlots(G).

template<class type >
void PAlgebraModDerived< type >::genMaskTable ( ) const
virtual

Generates the "mask table" that is used to support rotations.

maskTable[i][j] is a polynomial representation of a mask that is 1 in all slots whose i'th coordinate is at least j, and 0 elsewhere. We have:

  maskTable.size() == zMStar.numOfGens()     // # of generators
  for i = 0..maskTable.size()-1:
    maskTable[i].size() == zMStar.OrderOf(i) // order of generator i

Implements PAlgebraModBase.

template<class type>
const vector< vector< RX > >& PAlgebraModDerived< type >::getMaskTable ( ) const
inline

Returns ref to maskTable, which is used to implement rotations (in the EncryptedArray module).

maskTable[i][j] is a polynomial representation of a mask that is 1 in all slots whose i'th coordinate is at least j, and 0 elsewhere. We have:

  maskTable.size() == zMStar.numOfGens()     // # of generators
  for i = 0..maskTable.size()-1:
    maskTable[i].size() == zMStar.OrderOf(i) // order of generator i

The documentation for this class was generated from the following files: