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