// (C) 2018 University of Bristol. See License.txt #include "Math/Subroutines.h" #include "FHE/PPData.h" #include "FHE/FFT.h" #include "FHE/Matrix.h" void PPData::assign(const PPData& PPD) { R=PPD.R; prData=PPD.prData; root=PPD.root; } void PPData::init(const Ring& Rg,const Zp_Data& PrD) { R=Rg; prData=PrD; root=Find_Primitive_Root_m(Rg.m(),Rg.Phi(),PrD); } ostream& operator<<(ostream& s,const PPData& PPD) { bigint ans; s << PPD.prData << endl; s << PPD.R << endl; to_bigint(ans,PPD.root,PPD.prData); s << ans << " "; return s; } istream& operator>>(istream& s,PPData& PPD) { bigint ans; s >> PPD.prData >> PPD.R; s >> ans; to_modp(PPD.root,ans,PPD.prData); return s; } void PPData::to_eval(vector& elem) const { if (elem.size()!= (unsigned) R.phi_m()) { throw params_mismatch(); } throw not_implemented(); /* vector ans; ans.resize(R.phi_m()); modp x=root; for (int i=0; i& elem) const { // avoid warning elem.empty(); throw not_implemented(); /* modp_matrix A; int n=phi_m(); A.resize(n, vector(n+1) ); modp x=root; for (int i=0; i& mess) const { // Uses Horner's rule gfp ans; to_gfp(ans,mess[mess.size()-1]); gfp coeff; for (int j=mess.size()-2; j>=0; j--) { ans.mul(thetaPow); to_gfp(coeff,mess[j]); ans.add(coeff); } return ans; }