You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I am implementing a matrix-vector multiplication as following:
`
Ring ring;
SecretKey sk(ring);
Scheme scheme(sk, ring);
long logq = 800; ///< Ciphertext Modulus. Should be smaller than logQ in "src/Params.h" : 800
long logp = 40; ///Scaling factor.
//Should be smaller than logN in "src/Params.h" : 16 => Max Slots = 65536
long logn = 7; // -> 128
long n = 1<< logn;
for (int j = 0; j < circuitDepth; j ++)
{
std::cout << "Multiplication " << j << std::endl;
//Perform matrix-vector multiplication
scheme.mult(c_multiplicationResult,c_matrix[0],c_fieldVec);
//new cM: logq = logq², logp = logp - logq -> rescale, so that it can be added with c_addIdentity
scheme.reScaleByAndEqual(c_multiplicationResult, logp);
//No multiplication was performed on c_addIdentity, therefore logq still has the initial value. In order to add it with cM the
//logp must match as well.
scheme.modDownByAndEqual(c_addIdentity, logp);
//At the end of the process c_fieldVec will get the value from c_result, which has the same logp and logq as cM now.
//For the next multiplication process they have to match.
scheme.modDownByAndEqual(c_matrix[0],logp);
scheme.add(c_result, c_multiplicationResult, c_addIdentity);
scheme.leftRotateFastAndEqual(c_fieldVec, r);
for(int i = 1; i< n; i++)
{
scheme.mult(c_multiplicationResult,c_matrix[i],c_fieldVec);
scheme.reScaleByAndEqual(c_multiplicationResult, logp);
scheme.modDownByAndEqual(c_matrix[i],logp);
scheme.addAndEqual(c_result, c_multiplicationResult);
scheme.leftRotateFastAndEqual(c_fieldVec, r);
}
}
`
The first multiplication gives me the expected result. But the second result consists of values with 10^187, which I have seen occasionally when the parameter were not correct.
Even though the logp and logq of c_matrix[0] and c_fieldVec matches and I have plenty of bits left (740), the second multiplication does not bring the expected result.
Does someone have an idea what I am doing wrong? Any hint would be much appreciated.
The text was updated successfully, but these errors were encountered:
Hi, I've tested your code, but no such error has occurred. In my experiment, I used random inputs for c_matrix, c_fieldVec, etc, so it would be better if you share your exact code or your input data.
Hello,
I am implementing a matrix-vector multiplication as following:
`
Ring ring;
SecretKey sk(ring);
Scheme scheme(sk, ring);
long logq = 800; ///< Ciphertext Modulus. Should be smaller than logQ in "src/Params.h" : 800
long logp = 40; ///Scaling factor.
`
The first multiplication gives me the expected result. But the second result consists of values with 10^187, which I have seen occasionally when the parameter were not correct.
Even though the logp and logq of c_matrix[0] and c_fieldVec matches and I have plenty of bits left (740), the second multiplication does not bring the expected result.
Does someone have an idea what I am doing wrong? Any hint would be much appreciated.
The text was updated successfully, but these errors were encountered: