Skip to content

Commit

Permalink
Remove redundant passing of the verifier to Evidence::verify()
Browse files Browse the repository at this point in the history
We already have it saved.
  • Loading branch information
fjarri committed Oct 30, 2024
1 parent 48d9572 commit f2459c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions examples/src/simple_malicious.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ fn serialized_garbage() {
let report1 = reports.remove(&v1).unwrap();
let report2 = reports.remove(&v2).unwrap();

assert!(report1.provable_errors[&v0].verify(&v0).is_ok());
assert!(report2.provable_errors[&v0].verify(&v0).is_ok());
assert!(report1.provable_errors[&v0].verify().is_ok());
assert!(report2.provable_errors[&v0].verify().is_ok());
}

#[test]
Expand Down Expand Up @@ -234,8 +234,8 @@ fn attributable_failure() {
let report1 = reports.remove(&v1).unwrap();
let report2 = reports.remove(&v2).unwrap();

assert!(report1.provable_errors[&v0].verify(&v0).is_ok());
assert!(report2.provable_errors[&v0].verify(&v0).is_ok());
assert!(report1.provable_errors[&v0].verify().is_ok());
assert!(report2.provable_errors[&v0].verify().is_ok());
}

#[test]
Expand Down Expand Up @@ -280,6 +280,6 @@ fn attributable_failure_round2() {
let report1 = reports.remove(&v1).unwrap();
let report2 = reports.remove(&v2).unwrap();

assert!(report1.provable_errors[&v0].verify(&v0).is_ok());
assert!(report2.provable_errors[&v0].verify(&v0).is_ok());
assert!(report1.provable_errors[&v0].verify().is_ok());
assert!(report2.provable_errors[&v0].verify().is_ok());
}
16 changes: 8 additions & 8 deletions manul/src/session/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,18 +250,18 @@ where
}

/// Attempts to verify that the attached data constitutes enough evidence
/// to prove the malicious behavior.
/// to prove the malicious behavior of [`Self::guilty_party`].
///
/// Returns `Ok(())` if it is the case.
pub fn verify(&self, party: &SP::Verifier) -> Result<(), EvidenceError> {
pub fn verify(&self) -> Result<(), EvidenceError> {
let deserializer = Deserializer::new::<SP::WireFormat>();
match &self.evidence {
EvidenceEnum::Protocol(evidence) => evidence.verify::<SP>(party, &deserializer),
EvidenceEnum::InvalidDirectMessage(evidence) => evidence.verify::<SP>(party, &deserializer),
EvidenceEnum::InvalidEchoBroadcast(evidence) => evidence.verify::<SP>(party, &deserializer),
EvidenceEnum::InvalidNormalBroadcast(evidence) => evidence.verify::<SP>(party, &deserializer),
EvidenceEnum::InvalidEchoPack(evidence) => evidence.verify(party, &deserializer),
EvidenceEnum::MismatchedBroadcasts(evidence) => evidence.verify::<SP>(party),
EvidenceEnum::Protocol(evidence) => evidence.verify::<SP>(&self.guilty_party, &deserializer),
EvidenceEnum::InvalidDirectMessage(evidence) => evidence.verify::<SP>(&self.guilty_party, &deserializer),
EvidenceEnum::InvalidEchoBroadcast(evidence) => evidence.verify::<SP>(&self.guilty_party, &deserializer),
EvidenceEnum::InvalidNormalBroadcast(evidence) => evidence.verify::<SP>(&self.guilty_party, &deserializer),
EvidenceEnum::InvalidEchoPack(evidence) => evidence.verify(&self.guilty_party, &deserializer),
EvidenceEnum::MismatchedBroadcasts(evidence) => evidence.verify::<SP>(&self.guilty_party),
}
}
}
Expand Down

0 comments on commit f2459c9

Please sign in to comment.