Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminsavage committed Mar 28, 2024
1 parent 3f82ce9 commit 73ef0f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
14 changes: 12 additions & 2 deletions ipa-core/src/protocol/ipa_prf/malicious_security/hashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,18 @@ mod test {
);

// swapping two elements should change the hash
let index_1 = rng.gen_range(0..LIST_LENGTH);
let index_2 = (index_1 + rng.gen_range(1..LIST_LENGTH)) % LIST_LENGTH;
let mut index_1 = 0;
let mut index_2 = 0;
// There is a 1 in 31 chance that these two elements are the exact same value.
// To make sure this doesn't become a flaky test, let's just pick two different
// elements to swap when that happens.
// This will be an infinite loop if all elements are the same. The chances of that
// are (1 / 31) ^ (LIST_LENGTH - 1)
// which is 1 in 923,521 when LIST_LENGTH is 5. I'm OK with that.
while list[index_1] == list[index_2] {
index_1 = rng.gen_range(0..LIST_LENGTH);
index_2 = (index_1 + rng.gen_range(1..LIST_LENGTH)) % LIST_LENGTH;
}
list.swap(index_1, index_2);

let hash_3 = compute_hash(&list);
Expand Down
16 changes: 8 additions & 8 deletions ipa-core/src/protocol/ipa_prf/malicious_security/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub type TwoNPlusOne<N> = Sum<Sum<N, N>, U1>;
/// Distributed Zero Knowledge Proofs algorithm drawn from
/// `https://eprint.iacr.org/2023/909.pdf`
///
#[allow(non_camel_case_types)]
#[allow(non_camel_case_types, clippy::many_single_char_names)]
impl<F> ProofGenerator<F>
where
F: PrimeField,
Expand All @@ -57,8 +57,8 @@ where
}

pub fn gen_challenge_and_recurse<λ: ArrayLength, I, J>(
proof_left: GenericArray<F, TwoNMinusOne<λ>>,
proof_right: GenericArray<F, TwoNMinusOne<λ>>,
proof_left: &GenericArray<F, TwoNMinusOne<λ>>,
proof_right: &GenericArray<F, TwoNMinusOne<λ>>,
u: I,
v: J,
) -> ProofGenerator<F>
Expand All @@ -84,7 +84,7 @@ where
"When the output is this small, you should validate the proof with a more straightforward reveal"

Check warning on line 84 in ipa-core/src/protocol/ipa_prf/malicious_security/prover.rs

View check run for this annotation

Codecov / codecov/patch

ipa-core/src/protocol/ipa_prf/malicious_security/prover.rs#L84

Added line #L84 was not covered by tests
);

let r: F = hash_to_field(&compute_hash(&proof_left), &compute_hash(&proof_right));
let r: F = hash_to_field(&compute_hash(proof_left), &compute_hash(proof_right));
let mut p = GenericArray::<F, λ>::generate(|_| F::ZERO);
let mut q = GenericArray::<F, λ>::generate(|_| F::ZERO);
let denominator = CanonicalLagrangeDenominator::<F, λ>::new();
Expand Down Expand Up @@ -277,8 +277,8 @@ mod test {

// fiat-shamir
let pg_2 = ProofGenerator::gen_challenge_and_recurse::<U4, _, _>(
proof_left_1,
proof_right_1,
&proof_left_1,
&proof_right_1,
U_1.into_iter().map(|x| Fp31::try_from(x).unwrap()),
V_1.into_iter().map(|x| Fp31::try_from(x).unwrap()),
);
Expand All @@ -302,8 +302,8 @@ mod test {

// fiat-shamir
let pg_3 = ProofGenerator::gen_challenge_and_recurse::<U4, _, _>(
proof_left_2,
proof_right_2,
&proof_left_2,
&proof_right_2,
pg_2.u,
pg_2.v,
);
Expand Down

0 comments on commit 73ef0f8

Please sign in to comment.