@@ -64,17 +64,17 @@ fn main() -> Result<(), Box<dyn Error>> {
6464
6565 let cli = Cli :: parse ( ) ;
6666
67- let mut rng = ChaCha20Rng :: from_entropy ( ) ;
6867 match cli {
69- Cli :: V1 ( args) => v1_exec ( args, & mut rng ) ,
70- Cli :: V2 ( args) => v2_exec ( args, & mut rng ) ,
68+ Cli :: V1 ( args) => v1_exec ( args) ,
69+ Cli :: V2 ( args) => v2_exec ( args) ,
7170 }
7271}
7372
7473/// Number of voting options
7574const VOTING_OPTIONS : u8 = 2 ;
7675
77- fn v1_exec ( args : CliArgs , rng : & mut ChaCha20Rng ) -> Result < ( ) , Box < dyn Error > > {
76+ fn v1_exec ( args : CliArgs ) -> Result < ( ) , Box < dyn Error > > {
77+ let mut rng = ChaCha20Rng :: from_entropy ( ) ;
7878 let pk = hex:: decode ( args. public_key ) ?;
7979 let mut sk = hex:: decode ( args. private_key ) ?;
8080
@@ -99,7 +99,7 @@ fn v1_exec(args: CliArgs, rng: &mut ChaCha20Rng) -> Result<(), Box<dyn Error>> {
9999 let ek = ElectionPublicKey :: from_bytes ( & election_pk)
100100 . ok_or ( "unable to parse election pub key" . to_string ( ) ) ?;
101101
102- let ( ciphertexts, proof) = ek. encrypt_and_prove_vote ( rng, & crs, vote) ;
102+ let ( ciphertexts, proof) = ek. encrypt_and_prove_vote ( & mut rng, & crs, vote) ;
103103 let ( proof, encrypted_vote) = compose_encrypted_vote_part ( ciphertexts. clone ( ) , proof) ?;
104104
105105 let fragment_bytes = generate_vote_fragment (
@@ -118,7 +118,7 @@ fn v1_exec(args: CliArgs, rng: &mut ChaCha20Rng) -> Result<(), Box<dyn Error>> {
118118 Ok ( ( ) )
119119}
120120
121- fn v2_exec ( args : CliArgs , rng : & mut ChaCha20Rng ) -> Result < ( ) , Box < dyn Error > > {
121+ fn v2_exec ( args : CliArgs ) -> Result < ( ) , Box < dyn Error > > {
122122 let sk_bytes = hex:: decode ( args. private_key ) ?;
123123
124124 // Election pub key published as a Bech32_encoded address
@@ -146,14 +146,13 @@ fn v2_exec(args: CliArgs, rng: &mut ChaCha20Rng) -> Result<(), Box<dyn Error>> {
146146 let proposal_index = args. proposal ;
147147 let choice = args. choice ;
148148
149- let tx = catalyst_voting:: txs:: v1:: Tx :: new_private (
149+ let tx = catalyst_voting:: txs:: v1:: Tx :: new_private_with_default_rng (
150150 vote_plan_id,
151151 proposal_index,
152152 VOTING_OPTIONS ,
153153 choice,
154154 & election_public_key,
155155 & private_key,
156- rng,
157156 ) ?;
158157
159158 // fragment in hex: output consumed as input to another program
0 commit comments