Files
MP-SPDZ/Math/Setup.hpp
Marcel Keller 4ef6b6d873 Maintenance.
2020-05-08 21:43:05 +10:00

44 lines
831 B
C++

/*
* Setup.hpp
*
*/
#ifndef MATH_SETUP_HPP_
#define MATH_SETUP_HPP_
#include "gfp.h"
template<class T>
void read_setup(const string& dir_prefix, int lgp)
{
bigint p;
string filename = dir_prefix + "Params-Data";
if (dir_prefix.compare("") == 0)
filename = string(PREP_DIR "Params-Data");
#ifdef DEBUG_FILES
cerr << "loading params from: " << filename << endl;
#endif
ifstream inpf(filename.c_str());
inpf >> p;
if (inpf.fail())
{
if (lgp > 0)
{
cerr << "No modulus found in " << filename << ", generating " << lgp
<< "-bit prime" << endl;
T::init_default(lgp);
}
else
throw file_error(filename.c_str());
}
else
T::init_field(p);
inpf.close();
}
#endif /* MATH_SETUP_HPP_ */