Use one function for verifying negative reports

This commit is contained in:
Vecna 2024-02-28 14:10:45 -05:00
parent 9412817a66
commit 495f196107
1 changed files with 17 additions and 18 deletions

View File

@ -85,25 +85,24 @@ impl NegativeReport {
}
}
/// Verify report if proof of bridge knowledge is bridge line hash
pub fn verify_with_hash_of_bridge_line(self, bl: &BridgeLine) -> bool {
/// Verify report. Caller must pass Some of the bridge knowledge proof type
/// in the report.
pub fn verify(self, bl: Option<&BridgeLine>, bucket: Option<&Scalar>) -> bool {
match self.bridge_pok {
ProofOfBridgeKnowledge::HashOfBridgeLine(pok) => {
let hash = HashOfBridgeLine::new(bl);
ProofOfBridgeKnowledge::HashOfBridgeLine(pok) => match bl {
Some(b) => {
let hash = HashOfBridgeLine::new(b);
hash == pok
}
_ => false,
}
}
/// Verify report if proof of bridge knowledge is bucket hash
pub fn verify_with_hash_of_bucket(self, bucket: &Scalar) -> bool {
match self.bridge_pok {
ProofOfBridgeKnowledge::HashOfBucket(pok) => {
let hash = HashOfBucket::new(bucket);
None => false,
},
ProofOfBridgeKnowledge::HashOfBucket(pok) => match bucket {
Some(b) => {
let hash = HashOfBucket::new(b);
hash == pok
}
_ => false,
None => false,
},
}
}
}