Exemple #1
0
vector<Ctxt> encryptVotes(vector<PlaintextArray> votes, EncryptedArray ea, const FHEPubKey& publicKey) {
  vector<Ctxt> ret;
  for(int i = 0; i < votes.size(); i++) {
    Ctxt c(publicKey);
    ea.encrypt(c, publicKey, votes[i]);
    ret.push_back(c);
  }

  return ret;
}
Exemple #2
0
Ctxt select(Ctxt ctxt, int value, EncryptedArray ea, const FHEPubKey& publicKey) {
  PlaintextArray mask(ea);
  mask.encode(getVote(value, ea.size()));

  Ctxt maskCtxt(publicKey);
  ea.encrypt(maskCtxt, publicKey, mask);

  Ctxt ret(ctxt);
  ret.multiplyBy(maskCtxt);

  return ret;
}