@@ -64,17 +64,17 @@ fn main() -> Result<(), Box<dyn Error>> {
64
64
65
65
let cli = Cli :: parse ( ) ;
66
66
67
- let mut rng = ChaCha20Rng :: from_entropy ( ) ;
68
67
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) ,
71
70
}
72
71
}
73
72
74
73
/// Number of voting options
75
74
const VOTING_OPTIONS : u8 = 2 ;
76
75
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 ( ) ;
78
78
let pk = hex:: decode ( args. public_key ) ?;
79
79
let mut sk = hex:: decode ( args. private_key ) ?;
80
80
@@ -99,7 +99,7 @@ fn v1_exec(args: CliArgs, rng: &mut ChaCha20Rng) -> Result<(), Box<dyn Error>> {
99
99
let ek = ElectionPublicKey :: from_bytes ( & election_pk)
100
100
. ok_or ( "unable to parse election pub key" . to_string ( ) ) ?;
101
101
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) ;
103
103
let ( proof, encrypted_vote) = compose_encrypted_vote_part ( ciphertexts. clone ( ) , proof) ?;
104
104
105
105
let fragment_bytes = generate_vote_fragment (
@@ -118,7 +118,7 @@ fn v1_exec(args: CliArgs, rng: &mut ChaCha20Rng) -> Result<(), Box<dyn Error>> {
118
118
Ok ( ( ) )
119
119
}
120
120
121
- fn v2_exec ( args : CliArgs , rng : & mut ChaCha20Rng ) -> Result < ( ) , Box < dyn Error > > {
121
+ fn v2_exec ( args : CliArgs ) -> Result < ( ) , Box < dyn Error > > {
122
122
let sk_bytes = hex:: decode ( args. private_key ) ?;
123
123
124
124
// 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>> {
146
146
let proposal_index = args. proposal ;
147
147
let choice = args. choice ;
148
148
149
- let tx = catalyst_voting:: txs:: v1:: Tx :: new_private (
149
+ let tx = catalyst_voting:: txs:: v1:: Tx :: new_private_with_default_rng (
150
150
vote_plan_id,
151
151
proposal_index,
152
152
VOTING_OPTIONS ,
153
153
choice,
154
154
& election_public_key,
155
155
& private_key,
156
- rng,
157
156
) ?;
158
157
159
158
// fragment in hex: output consumed as input to another program
0 commit comments