Skip to content

Commit

Permalink
Changed type of options to usize
Browse files Browse the repository at this point in the history
There is nothing in the library limiting the size of voting vectors.
Restrictions on option and choice formats are applied in mockchain.
  • Loading branch information
Mikhail Zabaluev committed Oct 20, 2020
1 parent a865b7b commit 4022e62
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions chain-vote/src/lib.rs
Expand Up @@ -98,7 +98,7 @@ pub struct TallyState {
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct TallyResult {
pub votes: Vec<Option<u64>>,
pub options: Range<u8>,
pub options: Range<usize>,
}

impl TallyDecryptShare {
Expand Down Expand Up @@ -214,6 +214,7 @@ fn group_elements_from_bytes(bytes: &[u8]) -> Option<Vec<gang::GroupElement>> {
if bytes.len() % GROUP_ELEMENT_BYTES_LEN != 0 {
return None;
}

let elements = bytes
.chunks(GROUP_ELEMENT_BYTES_LEN)
.map(gang::GroupElement::from_bytes)
Expand All @@ -227,9 +228,10 @@ pub fn result(
tally_state: &TallyState,
decrypt_shares: &[TallyDecryptShare],
) -> TallyResult {
let options = tally_state.r2s.len();
let ris =
(0..options).map(|i| gang::GroupElement::sum(decrypt_shares.iter().map(|ds| &ds.r1s[i])));
let options = 0..tally_state.r2s.len();
let ris = options
.clone()
.map(|i| gang::GroupElement::sum(decrypt_shares.iter().map(|ds| &ds.r1s[i])));

let mut r_results = tally_state
.r2s
Expand Down Expand Up @@ -285,10 +287,7 @@ pub fn result(
}
}
}
TallyResult {
votes,
options: (0..options as u8),
}
TallyResult { votes, options }
}

#[cfg(test)]
Expand Down

0 comments on commit 4022e62

Please sign in to comment.