Skip to content

Commit

Permalink
Check proof semantics during verification (#7)
Browse files Browse the repository at this point in the history
Ensures that proof semantics are valid for the given statement during verification.
  • Loading branch information
AaronFeickert authored Jan 5, 2024
1 parent 6ec58d1 commit 72e0134
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,29 @@ impl Proof {
/// proof was generated.
///
/// Returns a boolean that is `true` if and only if the proof is valid.
#[allow(non_snake_case)]
#[allow(clippy::too_many_lines, non_snake_case)]
pub fn verify(&self, statement: &Statement, message: Option<&[u8]>) -> bool {
// Extract statement values for convenience
let M = statement.get_input_set().get_keys();
let params = statement.get_params();
let J = statement.get_J();

// Check that the proof semantics are valid for the statement
if self.X.len() != params.get_m() as usize {
return false;
}
if self.Y.len() != params.get_m() as usize {
return false;
}
if self.f.len() != params.get_m() as usize {
return false;
}
for f_row in &self.f {
if f_row.len() != (params.get_n() - 1) as usize {
return false;
}
}

// Generate the verifier challenge
let mut transcript = Transcript::new("Triptych proof".as_bytes());
transcript.append_u64("version".as_bytes(), VERSION);
Expand Down

0 comments on commit 72e0134

Please sign in to comment.