Search in sources :

Example 1 with RevealedVote

use of bisq.core.dao.vote.RevealedVote 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());
}
Also used : SecretKey(javax.crypto.SecretKey) PB(io.bisq.generated.protobuffer.PB) RevealedVote(bisq.core.dao.vote.RevealedVote) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) CryptoException(bisq.common.crypto.CryptoException) BlindVote(bisq.core.dao.vote.BlindVote) ProposalList(bisq.core.dao.proposal.ProposalList)

Aggregations

CryptoException (bisq.common.crypto.CryptoException)1 ProposalList (bisq.core.dao.proposal.ProposalList)1 BlindVote (bisq.core.dao.vote.BlindVote)1 RevealedVote (bisq.core.dao.vote.RevealedVote)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 PB (io.bisq.generated.protobuffer.PB)1 SecretKey (javax.crypto.SecretKey)1