From 495f196107d083cab7044e5fff3256d204cef3d4 Mon Sep 17 00:00:00 2001 From: Vecna Date: Wed, 28 Feb 2024 14:10:45 -0500 Subject: [PATCH] Use one function for verifying negative reports --- src/negative_report.rs | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/negative_report.rs b/src/negative_report.rs index 50f4366..071b100 100644 --- a/src/negative_report.rs +++ b/src/negative_report.rs @@ -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); - 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); - hash == pok - } - _ => false, + ProofOfBridgeKnowledge::HashOfBridgeLine(pok) => match bl { + Some(b) => { + let hash = HashOfBridgeLine::new(b); + hash == pok + } + None => false, + }, + ProofOfBridgeKnowledge::HashOfBucket(pok) => match bucket { + Some(b) => { + let hash = HashOfBucket::new(b); + hash == pok + } + None => false, + }, } } }