|
3 | 3 | //! ```rust |
4 | 4 | //! use catalyst_voting::{ |
5 | 5 | //! decrypt_tally, encrypt_vote, generate_tally_proof, tally, verify_tally_proof, |
6 | | -//! DecryptionTallySetup, EncryptionRandomness, SecretKey, Vote, |
| 6 | +//! DecryptionTallySetup, SecretKey, Vote, |
7 | 7 | //! }; |
8 | 8 | //! |
9 | 9 | //! struct Voter { |
|
13 | 13 | //! |
14 | 14 | //! let mut rng = rand_core::OsRng; |
15 | 15 | //! let voting_options = 3; |
16 | | -//! let election_secret_key = SecretKey::generate(&mut rng); |
| 16 | +//! let election_secret_key = SecretKey::random(&mut rng); |
17 | 17 | //! let election_public_key = election_secret_key.public_key(); |
18 | 18 | //! |
19 | 19 | //! let voter_1 = Voter { |
|
35 | 35 | //! let vote_2 = Vote::new(voter_2.choice, voting_options).unwrap(); |
36 | 36 | //! let vote_3 = Vote::new(voter_3.choice, voting_options).unwrap(); |
37 | 37 | //! |
38 | | -//! let voter_1_randomness = EncryptionRandomness::generate(&mut rng, voting_options); |
39 | | -//! let voter_2_randomness = EncryptionRandomness::generate(&mut rng, voting_options); |
40 | | -//! let voter_3_randomness = EncryptionRandomness::generate(&mut rng, voting_options); |
41 | | -//! |
42 | | -//! let encrypted_vote_1 = |
43 | | -//! encrypt_vote(&vote_1, &election_public_key, &voter_1_randomness).unwrap(); |
44 | | -//! let encrypted_vote_2 = |
45 | | -//! encrypt_vote(&vote_2, &election_public_key, &voter_2_randomness).unwrap(); |
46 | | -//! let encrypted_vote_3 = |
47 | | -//! encrypt_vote(&vote_3, &election_public_key, &voter_3_randomness).unwrap(); |
| 38 | +//! let (encrypted_vote_1, voter_randomness_1) = |
| 39 | +//! encrypt_vote(&vote_1, &election_public_key, &mut rng); |
| 40 | +//! let (encrypted_vote_2, voter_randomness_2) = |
| 41 | +//! encrypt_vote(&vote_2, &election_public_key, &mut rng); |
| 42 | +//! let (encrypted_vote_3, voter_randomness_3) = |
| 43 | +//! encrypt_vote(&vote_3, &election_public_key, &mut rng); |
48 | 44 | //! let encrypted_votes = vec![encrypted_vote_1, encrypted_vote_2, encrypted_vote_3]; |
49 | 45 | //! |
50 | 46 | //! let encrypted_tallies: Vec<_> = (0..voting_options) |
|
0 commit comments