From 6448537c4bae4966fc53645c776ea2eb45eb7d40 Mon Sep 17 00:00:00 2001 From: Vecna Date: Wed, 28 Feb 2024 16:06:58 -0500 Subject: [PATCH] One verify function for positive reports --- src/negative_report.rs | 3 +-- src/positive_report.rs | 16 ++++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/negative_report.rs b/src/negative_report.rs index 2058969..353b54f 100644 --- a/src/negative_report.rs +++ b/src/negative_report.rs @@ -85,8 +85,7 @@ impl NegativeReport { } } - /// Verify report. Caller must pass Some of the bridge knowledge proof type - /// in the report. + /// Verify the report pub fn verify(self, bridge_info: &BridgeInfo) -> bool { match self.bridge_pok { ProofOfBridgeKnowledge::HashOfBridgeLine(pok) => { diff --git a/src/positive_report.rs b/src/positive_report.rs index bcfc470..0d915ae 100644 --- a/src/positive_report.rs +++ b/src/positive_report.rs @@ -5,7 +5,7 @@ use crate::{bridge_info::BridgeInfo, get_date, CONFIG, COUNTRY_CODES}; use curve25519_dalek::ristretto::RistrettoBasepointTable; use ed25519_dalek::{Signature, Signer, SigningKey, Verifier}; -use lox_library::{cred::Lox, proto::positive_report as lox_pr, IssuerPubKey}; +use lox_library::{cred::Lox, proto::positive_report as lox_pr, BridgeAuth, IssuerPubKey}; use serde::{Deserialize, Serialize}; use sha1::{Digest, Sha1}; use std::option::Option; @@ -102,15 +102,10 @@ impl PositiveReport { } } - /// Verify everything except the Lox proof. - /// Parameters: - /// - The bucket ID for the bucket containing this bridge - /// - A basepoint table for computing multiples of H - /// - The bridge verifying key for this bridge (if bridge token is required) - /// These parameters are assumed to be correct and are NOT checked against - /// the fingerprint listed in the report. - pub fn verify_excluding_lox_proof( + /// Verify report + pub fn verify( self, + la: &mut BridgeAuth, bridge_info: &BridgeInfo, Htable: &RistrettoBasepointTable, ) -> bool { @@ -138,7 +133,8 @@ impl PositiveReport { if &bucket * Htable != BP { return false; } - true + // Verify Lox proof + la.handle_positive_report(self.lox_proof, &Htable).is_ok() } }