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; }
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; }