Skip to content

Commit

Permalink
dedup challenges, squeeze range eq num of leaves in mt
Browse files Browse the repository at this point in the history
  • Loading branch information
z-tech committed Jul 25, 2024
1 parent 775f096 commit 4e74c11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/direct/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use ark_ff::FftField;
#[cfg(not(feature = "std"))]
use ark_std::vec::Vec;

use crate::utils::squeeze_integer;
use crate::utils::{dedup, squeeze_integer};

pub struct DirectProof<F, M, S>
where
Expand Down Expand Up @@ -57,13 +57,13 @@ where
for _ in 0..num_challenges {
challenges.push(squeeze_integer(&mut sponge, 32));
}
challenges
dedup(challenges)
}
pub fn num_committed_values(&self) -> usize {
self.committed_values.len()
}
pub fn verify(&self, commitment_digest: M::InnerDigest, challenges: Vec<usize>) -> bool {
if self.challenge_answers.leaf_indexes
!= challenges.iter().rev().cloned().collect::<Vec<usize>>()
{
// TODO: IDK why self.challenge_answers.leaf_indexes comes back in reverse
if self.challenge_answers.leaf_indexes != challenges {
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions src/direct/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
direct::{config::DirectConfig, proof::DirectProof},
ldt::Verifier,
statement::single::SingleStatement,
utils::squeeze_integer,
utils::{dedup, squeeze_integer},
witness::Witness,
};

Expand Down Expand Up @@ -58,8 +58,9 @@ where
// squeeze out the challenges as indices
let mut challenges = Vec::with_capacity(self.config.num_challenges);
for _ in 0..self.config.num_challenges {
challenges.push(squeeze_integer(&mut sponge, 32));
challenges.push(squeeze_integer(&mut sponge, proof.num_committed_values()));
}
challenges = dedup(challenges);
// verifiy the proof against the claim
proof.verify(claim.commitment_digest(), challenges)
}
Expand Down

0 comments on commit 4e74c11

Please sign in to comment.