Skip to content

Commit 18e9499

Browse files
authored
fix: clippy warnings (#71)
1 parent e78508c commit 18e9499

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

src/composition.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub enum ComposedWitness<G: PrimeGroup> {
106106
type ComposedChallenge<G> = <SchnorrProof<G> as SigmaProtocol>::Challenge;
107107

108108
const fn composed_challenge_size<G: PrimeGroup>() -> usize {
109-
(G::Scalar::NUM_BITS as usize + 7) / 8
109+
(G::Scalar::NUM_BITS as usize).div_ceil(8)
110110
}
111111

112112
impl<G: PrimeGroup + ConstantTimeEq> ComposedRelation<G> {
@@ -209,11 +209,11 @@ impl<G: PrimeGroup + ConstantTimeEq> ComposedRelation<G> {
209209
let mut prover_states = Vec::new();
210210

211211
for (i, w) in witnesses.iter().enumerate() {
212-
let (commitment, prover_state) = instances[i].prover_commit(&w, rng)?;
212+
let (commitment, prover_state) = instances[i].prover_commit(w, rng)?;
213213
let (simulated_commitment, simulated_challenge, simulated_response) =
214214
instances[i].simulate_transcript(rng)?;
215215

216-
let valid_witness = instances[i].is_witness_valid(&w);
216+
let valid_witness = instances[i].is_witness_valid(w);
217217
commitments.push(if valid_witness.unwrap_u8() == 1 {
218218
commitment
219219
} else {
@@ -234,7 +234,7 @@ impl<G: PrimeGroup + ConstantTimeEq> ComposedRelation<G> {
234234
let prover_state = prover_states;
235235

236236
if witnesses_found != 1 {
237-
return Err(Error::InvalidInstanceWitnessPair);
237+
Err(Error::InvalidInstanceWitnessPair)
238238
} else {
239239
Ok((
240240
ComposedCommitment::Or(commitments),
@@ -262,11 +262,11 @@ impl<G: PrimeGroup + ConstantTimeEq> ComposedRelation<G> {
262262
) in &prover_states
263263
{
264264
let c = G::Scalar::conditional_select(
265-
&simulated_challenge,
265+
simulated_challenge,
266266
&G::Scalar::ZERO,
267267
*valid_witness,
268268
);
269-
witness_challenge = witness_challenge - c;
269+
witness_challenge -= c;
270270
}
271271
for (
272272
instance,

src/linear_relation/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ impl<G: PrimeGroup> LinearMap<G> {
139139
}
140140
})
141141
.collect::<Result<Vec<_>, InvalidInstance>>()
142-
.into()
143142
}
144143
}
145144

src/tests/test_relations.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ fn simple_subtractions<G: PrimeGroup, R: RngCore>(
305305
}
306306

307307
fn subtractions_with_shift<G: PrimeGroup, R: RngCore>(
308-
mut rng: &mut R,
308+
rng: &mut R,
309309
) -> (CanonicalLinearRelation<G>, Vec<G::Scalar>) {
310310
let B = G::generator();
311-
let x = G::Scalar::random(&mut rng);
311+
let x = G::Scalar::random(rng);
312312
let X = B * (x - G::Scalar::from(2));
313313

314314
let mut linear_relation = LinearRelation::<G>::new();
@@ -444,11 +444,10 @@ fn test_cmz_wallet_with_fee() {
444444
fn test_relations() {
445445
use group::Group;
446446
type G = bls12_381::G1Projective;
447+
type RelationGenerator<G> =
448+
Box<dyn Fn(&mut OsRng) -> (CanonicalLinearRelation<G>, Vec<<G as Group>::Scalar>)>;
447449

448-
let instance_generators: Vec<(
449-
&str,
450-
Box<dyn Fn(&mut OsRng) -> (CanonicalLinearRelation<G>, Vec<<G as Group>::Scalar>)>,
451-
)> = vec![
450+
let instance_generators: Vec<(&str, RelationGenerator<G>)> = vec![
452451
("dlog", Box::new(discrete_logarithm)),
453452
("shifted_dlog", Box::new(shifted_dlog)),
454453
("dleq", Box::new(dleq)),
@@ -488,12 +487,12 @@ fn test_relations() {
488487
let nizk = Nizk::<SchnorrProof<G>, Shake128DuplexSponge<G>>::new(&domain_sep, protocol);
489488

490489
// Test both proof types
491-
let proof_batchable = nizk.prove_batchable(&witness, &mut OsRng).expect(&format!(
492-
"Failed to create batchable proof for {relation_name}"
493-
));
494-
let proof_compact = nizk.prove_compact(&witness, &mut OsRng).expect(&format!(
495-
"Failed to create compact proof for {relation_name}"
496-
));
490+
let proof_batchable = nizk
491+
.prove_batchable(&witness, &mut OsRng)
492+
.unwrap_or_else(|_| panic!("Failed to create batchable proof for {relation_name}"));
493+
let proof_compact = nizk
494+
.prove_compact(&witness, &mut OsRng)
495+
.unwrap_or_else(|_| panic!("Failed to create compact proof for {relation_name}"));
497496

498497
// Verify both proof types
499498
assert!(

0 commit comments

Comments
 (0)