Skip to content

Commit

Permalink
Remove extra generic params
Browse files Browse the repository at this point in the history
  • Loading branch information
akoshelev committed Oct 30, 2024
1 parent 2c9b38d commit ebd4185
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
12 changes: 6 additions & 6 deletions ipa-core/src/protocol/ipa_prf/malicious_security/lagrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ where
/// that were used to generate this table.
/// It is assumed that the `y_coordinates` provided to this function correspond the values of the _input_ "x coordinates"
/// that were used to generate this table.
pub fn eval<I, J>(&self, y_coordinates: I) -> [F; M]
pub fn eval<I>(&self, y_coordinates: I) -> [F; M]
where
I: IntoIterator<Item = J> + Copy,
I: IntoIterator + Copy,
I::IntoIter: ExactSizeIterator,
J: Borrow<F>,
I::Item: Borrow<F>,
{
debug_assert_eq!(y_coordinates.into_iter().len(), N);

Expand Down Expand Up @@ -208,11 +208,11 @@ mod test {

/// test helper function that evaluates a polynomial in monomial form, i.e. `sum_i c_i x^i` on points `x_output`
/// where `c_0` to `c_N` are stored in `polynomial`
fn eval<const M: usize, I, J>(&self, x_output: I) -> [F; M]
fn eval<const M: usize, I>(&self, x_output: I) -> [F; M]
where
I: IntoIterator<Item = J>,
I: IntoIterator,
I::IntoIter: ExactSizeIterator,
J: Borrow<F>,
I::Item: Borrow<F>,
{
x_output
.into_iter()
Expand Down
37 changes: 18 additions & 19 deletions ipa-core/src/protocol/ipa_prf/malicious_security/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,10 @@ impl<F: PrimeField, const L: usize, const P: usize, const M: usize> ProofGenerat
///
/// Distributed Zero Knowledge Proofs algorithm drawn from
/// `https://eprint.iacr.org/2023/909.pdf`
pub fn compute_proof<J, B>(uv_iterator: J, lagrange_table: &LagrangeTable<F, L, M>) -> [F; P]
pub fn compute_proof<J>(uv_iterator: J, lagrange_table: &LagrangeTable<F, L, M>) -> [F; P]
where
J: Iterator<Item = B>,
B: Borrow<([F; L], [F; L])>,
J: Iterator,
J::Item: Borrow<([F; L], [F; L])>,
{
let mut proof = [F::ZERO; P];
for uv_polynomial in uv_iterator {
Expand All @@ -147,14 +147,14 @@ impl<F: PrimeField, const L: usize, const P: usize, const M: usize> ProofGenerat
proof
}

fn gen_challenge_and_recurse<J, B, const N: usize>(
fn gen_challenge_and_recurse<J, const N: usize>(
proof_left: &[F; P],
proof_right: &[F; P],
uv_iterator: J,
) -> UVValues<F, N>
where
J: Iterator<Item = B>,
B: Borrow<([F; L], [F; L])>,
J: Iterator,
J::Item: Borrow<([F; L], [F; L])>,
{
let r: F = hash_to_field(
&compute_hash(proof_left),
Expand Down Expand Up @@ -213,16 +213,16 @@ impl<F: PrimeField, const L: usize, const P: usize, const M: usize> ProofGenerat
/// where
/// `share_of_proof_from_prover_left` from left has type `Vec<[F; P]>`,
/// `my_proof_left_share` has type `Vec<[F; P]>`,
pub fn gen_artefacts_from_recursive_step<C, J, B, const N: usize>(
pub fn gen_artefacts_from_recursive_step<C, J, const N: usize>(
ctx: &C,
record_ids: &mut RecordIdRange,
lagrange_table: &LagrangeTable<F, L, M>,
uv_iterator: J,
) -> (UVValues<F, N>, [F; P], [F; P])
where
C: Context,
J: Iterator<Item = B> + Clone,
B: Borrow<([F; L], [F; L])>,
J: Iterator + Clone,
J::Item: Borrow<([F; L], [F; L])>,
{
// generate next proof
// from iterator
Expand Down Expand Up @@ -356,7 +356,7 @@ mod test {
.unwrap();

// fiat-shamir
let uv_3 = TestProofGenerator::gen_challenge_and_recurse::<_, _, 4>(
let uv_3 = TestProofGenerator::gen_challenge_and_recurse::<_, 4>(
&proof_left_2,
&proof_right_2,
uv_2.iter(),
Expand Down Expand Up @@ -397,13 +397,12 @@ mod test {
// first iteration
let world = TestWorld::default();
let mut record_ids = RecordIdRange::ALL;
let (uv_values, _, _) =
TestProofGenerator::gen_artefacts_from_recursive_step::<_, _, _, 4>(
&world.contexts()[0],
&mut record_ids,
&lagrange_table,
uv_1.iter(),
);
let (uv_values, _, _) = TestProofGenerator::gen_artefacts_from_recursive_step::<_, _, 4>(
&world.contexts()[0],
&mut record_ids,
&lagrange_table,
uv_1.iter(),
);

assert_eq!(7, uv_values.len());
});
Expand Down Expand Up @@ -441,7 +440,7 @@ mod test {

assert_eq!(proof.len(), SmallProofGenerator::PROOF_LENGTH);

let uv_after = SmallProofGenerator::gen_challenge_and_recurse::<_, _, 8>(
let uv_after = SmallProofGenerator::gen_challenge_and_recurse::<_, 8>(
&proof,
&proof,
uv_before.iter(),
Expand Down Expand Up @@ -477,7 +476,7 @@ mod test {

assert_eq!(proof.len(), LargeProofGenerator::PROOF_LENGTH);

let uv_after = LargeProofGenerator::gen_challenge_and_recurse::<_, _, 8>(
let uv_after = LargeProofGenerator::gen_challenge_and_recurse::<_, 8>(
&proof,
&proof,
uv_before.iter(),
Expand Down

0 comments on commit ebd4185

Please sign in to comment.