-
Notifications
You must be signed in to change notification settings - Fork 10
Anonymous voting with homomorphic encryption #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for tansu canceled.
|
✅ Deploy Preview for testnet-tansu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
For now I pushed some code which only handles a single tally. I will add some tests and the full flow first and then add the other tallies once I am sure this is the way. |
Rebased and everything. Now I need to fix the public voting and could get this merged. |
Ok giving this a go for v1 🚀 I will iterate now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
dao
enhancement
New feature or request
Non-Rewarded
ODHack12
rust
Rust stuff
soroban
Stellar smart contract
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #128
Add an anonymous voting feature to the smart contract.
This PR also refactor the existing public voting logic as to accommodate for the private voting part. There is a new enum to specify a vote and its type can either be public or private. The respective enum/struct are specific to the vote type.
To maintain the privacy of votes, a commitment using the BLS12-381 is created. This requires that we keep the voting tally in a scalar field. As going back and forth the scalar field is possible, a seed is used to obfuscate the vote. This value encrypted using an asymmetric key and is stored on-chain (handling of the private key is out of scope for this PR as it has to be done on the frontend. We just store the public key on-chain so that anyone can vote.)
At the end of the voting process, we use the private key to decrypt all seeds and with the running tally of the votes we can recover the voting result.
For convenience, we store three tallies to represent the three possible voting states. The alternative was to use a middle point and do some +- but that's not straightforward and leads to some overflows, etc. TLDR; I think the 3 tally solution is a good alternative and actually does not restrict to 2 states. Imaging going with 4 states just with a single integer field. That would get quite messy, if even doable.
Since we have commitments for all votes, we can sum up the commitments and prove that we correctly decrypted the seeds and have the correct voting seed and voting tallies.