cardano-foundation / cf-cardano-ballot

Cardano Ballot is a user-friendly, hybrid on- and off-chain voting system developed by the Cardano Foundation. Cardano Ballot leverages a set of backend services combined with frontend applications to facilitate voting within the Cardano Ecosystem.
Mozilla Public License 2.0
16 stars 1 forks source link

DESIGN: 1 or 2 Hydra Networks with Hydra Results Tally Idea. #226

Open matiwinnetou opened 1 year ago

matiwinnetou commented 1 year ago

Instead of doing hydra-tally like we are doing in https://github.com/cardano-foundation/hydra-voting-poc, we could actually do this differently which would support more requirements we have.

The way we did this so far is that we cannot really encrypt the votes and in many cases we can only publish the votes after proposalsRevealSlot | Epoch passes. Instead, what we could do is we could create not 1 but 2 Hydra networks shared with participants. On the first Hydra network we would publish Cardano metadata transactions where each transaction is encrypted vote. When we create a voting event, we generate public and private key and store private key in a secure db. Once event finishes and proposalsRevealSlot | Epoch passes we can actually send to L1 or L2 (or both) the private key for the event, meaning that all hydra head participants (a Tally Committee) would be able to decode those votes. Once decoded they would actually run a piece of off-chain code that would count those votes. Here we could use normal encryption. In case votes need to be private we could use Partial Homomorphic Encryption / Decryption, which effectively would mean that the Hydra Head Operators CAN do the tally but they won't be able to decrypt the individual votes.

In addition each of our vote that we send to L2 could have a last merkle proof for this and of course last L1 transaction hash along with merkle root hash for the last tree we committed to L1.

Partial Homomorphic Encryption / Decryption can be only used if it is possible to share vote results during voting session (which is rarely the case). It protect voter's privacy but it leaks the results of the voting.

Once results are known by each operator they could post this to another Hydra L2 network. Each operator posts one result along with 1 NFT from L1 which previously organiser hands out to the operator (1 NFT means they won't be able to post two results per one operator). Smart contract takes all results, burns all NFTs and applying 51% rule selects the winning result based on majority.

Once final result is known (we call this -> the tally of the tallies) it fan-out could be called by one of the operators resulting in closing first and second Hydra network and in case of the second Hydra network posting final winning results to L1.

@MicroProofs is this something that is feasible to be done in smart contract as described above?

matiwinnetou commented 1 year ago

As @Ryun1 pointed out, for second network Hydra is not even needed, one could post results to L1 directly and let the tally process be run via contracts.