-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rust/catalyst-voting): Vote proof (#54)
* initialize a new crate * add intentionally failed test * fix CI * fix * fix * update vscode setting.recommended.json * add a basic interfaces for the vote part * add basic elgamal encryption based on the ristretto255 group * add arithmetic tests for ristretto255 * fix tests * wip * add decryption algorithm, add tests * fix CI * remove unused std_ops_gen * add new voter module * add EncryptionRandomness random generation * add a tally function * fix * wip * add a babystep implementation * wip * refactor, add decrypt_tally_result * wip * wip * add voting test * remove rayon dependency for now * fix spelling, remove rayon * fix * remove unused anyhow dep * intentionally break the test * try * wip * update DecryptionTallySetup interface * add doctest example * refactor, make voting_test as integration test * fix baby_step_giant_step_test * move tally module into the seprate dir * add new proof.rs * refactor * add to_bytes, from_bytes functions for Scalar and GroupElement * add zk_dl_equality.rs * add hash module * update hash implementation * add dleq verify function, add tests * implement tally proof generation and tally proof verification * update voting_test with the tally proofs, fix verify_tally_proof * remove uneeded comment * fix * fix * fix spelling * fix comment * update rust docs * fix rustdoc tests * refactor * refactor * add zk_unit_vector_proof module * refactor * add polynomial generation * fix * wip * wip * finish proof generation * refactor * add new get_bit function * refactor bit calculation * wip * fix calculation * refactor imports * refactor * refactor * update tests * update comment * update test * refactor * fix doc tests * remove redundant polynomial test * refactor imports, add voter proof module * fix doc test * update * add error handling for `generate_voter_proof` * update voting_test * update test * fix spelling
- Loading branch information
Showing
15 changed files
with
831 additions
and
91 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
42 changes: 42 additions & 0 deletions
42
rust/catalyst-voting/src/crypto/zk_unit_vector/challenges.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//! ZK unit vector challenges calculation functionality | ||
use curve25519_dalek::digest::Digest; | ||
|
||
use crate::{ | ||
crypto::{ | ||
elgamal::Ciphertext, group::GroupElement, hash::Blake2b512Hasher, | ||
zk_unit_vector::randomness_announcements::Announcement, | ||
}, | ||
PublicKey, | ||
}; | ||
|
||
/// Calculates the first challenge hash. | ||
pub(crate) fn calculate_first_challenge_hash( | ||
commitment_key: &GroupElement, public_key: &PublicKey, ciphertexts: &[Ciphertext], | ||
announcements: &[Announcement], | ||
) -> Blake2b512Hasher { | ||
let mut hash = Blake2b512Hasher::new() | ||
.chain_update(commitment_key.to_bytes()) | ||
.chain_update(public_key.to_bytes()); | ||
for c in ciphertexts { | ||
hash.update(c.first().to_bytes()); | ||
hash.update(c.second().to_bytes()); | ||
} | ||
for announcement in announcements { | ||
hash.update(announcement.i.to_bytes()); | ||
hash.update(announcement.b.to_bytes()); | ||
hash.update(announcement.a.to_bytes()); | ||
} | ||
hash | ||
} | ||
|
||
/// Calculates the second challenge hash. | ||
pub(crate) fn calculate_second_challenge_hash( | ||
mut com_1_hash: Blake2b512Hasher, ciphertexts: &[Ciphertext], | ||
) -> Blake2b512Hasher { | ||
for c in ciphertexts { | ||
com_1_hash.update(c.first().to_bytes()); | ||
com_1_hash.update(c.second().to_bytes()); | ||
} | ||
com_1_hash | ||
} |
Oops, something went wrong.