Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to perform polyEval() ? #469

Open
pandasamanvaya opened this issue Feb 21, 2022 · 0 comments
Open

How to perform polyEval() ? #469

pandasamanvaya opened this issue Feb 21, 2022 · 0 comments

Comments

@pandasamanvaya
Copy link

Hi, everyone. I am new to HElib and recently tried to use the polyEval() function provided in the helib/polyEval.h header file. I tried to evaluate a simple polynomial x+x^2. But I am getting random values as output. Is there any documentation on how to use the polyEval()? Here is the code snippet -

#include<helib/helib.h>
#include<helib/polyEval.h>

using namespace std;
using namespace helib;

int main()
{
	//Defining CKKS scheme parameters
	Context context = ContextBuilder<CKKS>().m(16384).bits(119).precision(20).c(2).build();
	long n = context.getNSlots();

	//Generating keys
	SecKey secretKey(context);
	secretKey.GenSecKey();
	const PubKey& publicKey = secretKey;
	
	vector<int> x = {1, 2}, coeff={0, 1, 1};
	NTL::ZZX poly;
	for(int i=1; i < coeff.size(); i++){
		SetCoeff(poly, i, coeff[i]);
	}
	PtxtArray x0(context, x);
	Ctxt ct(publicKey);
	x0.encrypt(ct);

	Ctxt ans(publicKey);
	polyEval(ans, poly, ct);
	PtxtArray res(context);
	res.decrypt(ans, secretKey);

	vector<double> y;
	res.store(y);
	cout << y[0] << " " << y[1] << "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant