Skip to content

Commit 7026535

Browse files
committed
add acv demo
1 parent 8257439 commit 7026535

File tree

6 files changed

+391
-15
lines changed

6 files changed

+391
-15
lines changed

solution/anonymous_ciphertext_voting/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ wedpr_l_macros = "1.0.0"
2020
wedpr_l_protos = { git = "https://github.com/WeBankBlockchain/WeDPR-Lab-Crypto.git", branch = "release-1.2.0" }
2121
wedpr_l_utils = "1.1.0"
2222
wedpr_s_protos = { path = "../../protos" }
23+
colored = "1.8"

solution/anonymous_ciphertext_voting/src/coordinator.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn make_system_parameters(
3636

3737
/// Certifies voter's weight which indicates the maximum value that the voter
3838
/// can vote in total.
39-
pub fn certify_bounded_voter(
39+
pub fn certify_voter(
4040
secret_key: &[u8],
4141
value: u32,
4242
registration_request: &RegistrationRequest,
@@ -74,6 +74,7 @@ pub fn aggregate_vote_sum_response(
7474
vote_storage_part: &VoteStorage,
7575
vote_sum: &mut VoteStorage,
7676
) -> Result<bool, WedprError> {
77+
// Init storage when first part upload
7778
if !vote_sum.has_blank_ballot() {
7879
vote_sum
7980
.mut_blank_ballot()
@@ -91,7 +92,6 @@ pub fn aggregate_vote_sum_response(
9192
vote_sum.mut_voted_ballot().push(ballot_pair);
9293
}
9394
}
94-
9595
let mut tmp_vote_storage_sum = VoteStorage::new();
9696
let mut blank_c1_sum =
9797
bytes_to_point(&vote_sum.get_blank_ballot().get_ciphertext1())?;
@@ -157,6 +157,7 @@ pub fn aggregate_decrypted_part_sum(
157157
decrypted_result_part_storage: &DecryptedResultPartStorage,
158158
counting_result_sum: &mut DecryptedResultPartStorage,
159159
) -> Result<bool, WedprError> {
160+
// Init storage when first part upload
160161
if !counting_result_sum.has_blank_part() {
161162
counting_result_sum
162163
.mut_blank_part()

solution/anonymous_ciphertext_voting/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ extern crate lazy_static;
88
#[macro_use]
99
extern crate wedpr_l_macros;
1010

11-
mod config;
11+
pub mod config;
1212
pub mod coordinator;
1313
pub mod counter;
1414
pub mod verifier;
@@ -30,7 +30,7 @@ mod tests {
3030
use super::*;
3131

3232
#[test]
33-
fn test_bounded_voting() {
33+
fn test_anonymous_ciphertext_voting() {
3434
// Generate coordinator's key pair
3535
let max_vote_number = 20000;
3636
let (public_key, secret_key) = SIGNATURE_SECP256K1.generate_keypair();
@@ -72,12 +72,12 @@ mod tests {
7272
voter_secret_list.push(vote_secret.clone());
7373

7474
// voter -> coordinator generate blank ballot
75-
let vote_request = voter::make_bounded_registration_request(
75+
let vote_request = voter::make_registration_request(
7676
&vote_secret,
7777
&system_parameters,
7878
)
7979
.unwrap();
80-
let response = coordinator::certify_bounded_voter(
80+
let response = coordinator::certify_voter(
8181
&secret_key,
8282
blank_ballot,
8383
&vote_request,
@@ -110,7 +110,7 @@ mod tests {
110110
let mut encrypted_vote_sum = VoteStorage::new();
111111
for index in 0..voting_ballot_count.len() {
112112
let ballot_choice = make_choice(&voting_ballot_count[index]);
113-
let vote_request = voter::vote_bounded(
113+
let vote_request = voter::vote(
114114
&voter_secret_list[index],
115115
&ballot_choice,
116116
&response_list[index],
@@ -119,7 +119,7 @@ mod tests {
119119
.unwrap();
120120
assert_eq!(
121121
true,
122-
verifier::verify_bounded_vote_request(
122+
verifier::verify_vote_request(
123123
&system_parameters,
124124
&vote_request,
125125
&public_key

0 commit comments

Comments
 (0)