Skip to content

Commit

Permalink
Merge pull request #585 from Zeegomo/add-ballot
Browse files Browse the repository at this point in the history
Support early verification of ballots at the typesystem level
  • Loading branch information
Mikhail Zabaluev authored Jul 2, 2021
2 parents 740a162 + 7ae8b01 commit 271e6f0
Show file tree
Hide file tree
Showing 9 changed files with 482 additions and 208 deletions.
2 changes: 1 addition & 1 deletion chain-impl-mockchain/src/certificate/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Arbitrary for VotePlan {

let mut keys = Vec::new();
// it should have been 256 but is limited for the sake of adequate test times
let keys_n = g.next_u32() % 16;
let keys_n = g.next_u32() % 15 + 1;
let mut seed = [0u8; 32];
g.fill_bytes(&mut seed);
let mut rng = rand_chacha::ChaCha20Rng::from_seed(seed);
Expand Down
6 changes: 3 additions & 3 deletions chain-impl-mockchain/src/testing/gen/vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
};
use chain_core::property::BlockDate as BlockDateProp;
use chain_crypto::digest::DigestOf;
use chain_vote::Crs;
use chain_vote::{Crs, ElectionPublicKey, Vote};
use rand_core::{CryptoRng, RngCore};
use typed_bytes::ByteBuilder;

Expand Down Expand Up @@ -105,13 +105,13 @@ impl VoteTestGen {
rng: &mut R,
) -> Payload {
let encrypting_key =
chain_vote::ElectionPublicKey::from_participants(vote_plan.committee_public_keys());
ElectionPublicKey::from_participants(vote_plan.committee_public_keys());

let crs = Crs::from_hash(&vote_plan.to_id().as_ref());
let (encrypted_vote, proof) = encrypting_key.encrypt_and_prove_vote(
rng,
&crs,
chain_vote::Vote::new(
Vote::new(
proposal.options().choice_range().clone().max().unwrap() as usize + 1,
choice.as_byte() as usize,
),
Expand Down
Loading

0 comments on commit 271e6f0

Please sign in to comment.