use of bisq.core.dao.vote.BlindVote in project bisq-core by bisq-network.
the class IssuanceService method getRevealedVotes.
private Set<RevealedVote> getRevealedVotes(Map<String, SecretKey> secretKeysByTxIdMap, Set<BlindVoteWithRevealTxId> blindVoteWithRevealTxIdSet) {
return blindVoteWithRevealTxIdSet.stream().map(blindVoteWithRevealTxId -> {
try {
// TODO check if cloning here is needed (we might want to keep the blindVote separated from the
// blindVoteList to the RevealedVote...)
final BlindVote blindVote = BlindVote.clone(blindVoteWithRevealTxId.getBlindVote());
final byte[] encryptedProposalList = blindVote.getEncryptedProposalList();
final SecretKey secretKey = secretKeysByTxIdMap.get(blindVoteWithRevealTxId.getTxId());
final byte[] decrypted = Encryption.decrypt(encryptedProposalList, secretKey);
// TODO move to ProposalList
final PB.PersistableEnvelope envelope = PB.PersistableEnvelope.parseFrom(decrypted);
ProposalList proposalList = ProposalList.fromProto(envelope.getProposalList());
return new RevealedVote(proposalList, blindVote);
} catch (CryptoException e) {
e.printStackTrace();
return null;
} catch (InvalidProtocolBufferException e) {
e.printStackTrace();
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toSet());
}
Aggregations