Skip to content

Commit 88b0f2a

Browse files
committed
wip
1 parent 22ae80d commit 88b0f2a

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/sign/src/main.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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
7574
const 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

Comments
 (0)