in pir_client.cpp [25:62]
PirQuery PIRClient::generate_query(uint64_t desiredIndex) {
indices_ = compute_indices(desiredIndex, pir_params_.nvec);
compute_inverse_scales();
vector<vector<Ciphertext> > result(pir_params_.d);
int N = params_.poly_modulus_degree();
Plaintext pt(params_.poly_modulus_degree());
for (uint32_t i = 0; i < indices_.size(); i++) {
uint32_t num_ptxts = ceil( (pir_params_.nvec[i] + 0.0) / N);
// initialize result.
cout << "Client: index " << i + 1 << "/ " << indices_.size() << " = " << indices_[i] << endl;
cout << "Client: number of ctxts needed for query = " << num_ptxts << endl;
for (uint32_t j =0; j < num_ptxts; j++){
pt.set_zero();
if (indices_[i] > N*(j+1) || indices_[i] < N*j){
#ifdef DEBUG
cout << "Client: coming here: so just encrypt zero." << endl;
#endif
// just encrypt zero
} else{
#ifdef DEBUG
cout << "Client: encrypting a real thing " << endl;
#endif
uint64_t real_index = indices_[i] - N*j;
pt[real_index] = 1;
}
Ciphertext dest;
encryptor_->encrypt(pt, dest);
dest.parms_id() = params_.parms_id();
result[i].push_back(dest);
}
}
return result;
}