Skip to content

Commit d9d7b72

Browse files
cyjseagullHaoXuan40404
authored andcommitted
remove POLL_RESULT_KEY_TOTAL_BALLOTS
1 parent cc08df1 commit d9d7b72

File tree

3 files changed

+2
-40
lines changed

3 files changed

+2
-40
lines changed

solution/anonymous_ciphertext_voting/src/coordinator.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -354,28 +354,6 @@ pub fn finalize_vote_result(
354354
max_vote_limit: i64,
355355
) -> Result<VoteResultStorage, WedprError> {
356356
let mut result = VoteResultStorage::new();
357-
let blank_c1_sum =
358-
bytes_to_point(vote_sum.get_blank_ballot().get_ciphertext1())?;
359-
let blank_c2_r_sum = bytes_to_point(
360-
aggregated_decrypted_result
361-
.get_blank_part()
362-
.get_blinding_c2(),
363-
)?;
364-
365-
// Compute the total votes.
366-
let target_total = blank_c1_sum - blank_c2_r_sum;
367-
let mut calculate_total_iter = 0;
368-
for i in 0..=max_vote_limit {
369-
calculate_total_iter = &calculate_total_iter + 1;
370-
if target_total.eq(&(*BASEPOINT_G1 * Scalar::from(i as u64))) {
371-
let mut new_pair = StringToInt64Pair::new();
372-
new_pair.set_key(POLL_RESULT_KEY_TOTAL_BALLOTS.to_string());
373-
new_pair.set_value(i);
374-
result.mut_result().push(new_pair);
375-
break;
376-
}
377-
}
378-
379357
// Compute the votes for each candidate.
380358
let mut iter = 0;
381359
for candidate in poll_parameters.get_candidates().get_candidate() {
@@ -401,9 +379,7 @@ pub fn finalize_vote_result(
401379
}
402380
}
403381
wedpr_println!(
404-
"** finalize_vote_result calculate_total_iter: {:?}, decrypt \
405-
candidate iter: {:?}, result: {:?}",
406-
calculate_total_iter,
382+
"** finalize_vote_result: decrypt candidate iter: {:?}, result: {:?}",
407383
iter,
408384
result.get_result()
409385
);

solution/anonymous_ciphertext_voting/src/lib.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -922,13 +922,8 @@ mod tests {
922922
.unwrap();
923923
assert!(result);
924924
// check the candidate result(with Wedpr_voting_total_ballots)
925-
assert!(final_result_request_unlisted.get_result().len() == 4);
925+
assert!(final_result_request_unlisted.get_result().len() == 3);
926926
for candidate_result in final_result_request_unlisted.get_result() {
927-
if candidate_result.get_key()
928-
== POLL_RESULT_KEY_TOTAL_BALLOTS.to_string()
929-
{
930-
assert!(candidate_result.get_value() == 60);
931-
}
932927
if candidate_result.get_key() == "Alice" {
933928
assert!(candidate_result.get_value() == 40);
934929
}

solution/anonymous_ciphertext_voting/src/verifier.rs

-9
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,6 @@ pub fn verify_vote_result(
174174
.get_blinding_c2(),
175175
)?;
176176

177-
let blank_result =
178-
get_int64_by_candidate(vote_result, POLL_RESULT_KEY_TOTAL_BALLOTS)?;
179-
let expected_blank_ballot_result = blank_c1_sum - (blank_c2_r_sum);
180-
if expected_blank_ballot_result
181-
.ne(&(*BASEPOINT_G1 * (Scalar::from(blank_result as u64))))
182-
{
183-
return Ok(false);
184-
}
185-
186177
for candidate in poll_parameters.get_candidates().get_candidate() {
187178
let ballot = get_ballot_by_candidate(vote_sum, candidate)?;
188179
let candidate_counting_part = get_counting_part_by_candidate(

0 commit comments

Comments
 (0)