Don't recompute H when verifying positive reports
This commit is contained in:
parent
c1b058ce4e
commit
d06542f99c
|
@ -3,12 +3,11 @@
|
|||
|
||||
use crate::{get_date, CONFIG, COUNTRY_CODES};
|
||||
|
||||
use curve25519_dalek::{RistrettoPoint, Scalar};
|
||||
use curve25519_dalek::{ristretto::RistrettoBasepointTable, Scalar};
|
||||
use ed25519_dalek::{Signature, Signer, SigningKey, Verifier, VerifyingKey};
|
||||
use lox_library::{cred::Lox, proto::positive_report as lox_pr, IssuerPubKey};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sha1::{Digest, Sha1};
|
||||
use sha2::Sha512;
|
||||
use std::option::Option;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -106,12 +105,14 @@ 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(
|
||||
self,
|
||||
bucket: Scalar,
|
||||
Htable: &RistrettoBasepointTable,
|
||||
bridge_key: Option<VerifyingKey>,
|
||||
) -> bool {
|
||||
// Verify bridge token
|
||||
|
@ -132,11 +133,8 @@ impl PositiveReport {
|
|||
}
|
||||
}
|
||||
// Verify knowledge of bucket ID
|
||||
let H = RistrettoPoint::hash_from_bytes::<Sha512>(
|
||||
format!("{}{}", lox_pr::H_GENERATOR_STRING, self.lox_proof.date).as_bytes(),
|
||||
);
|
||||
let BP = self.lox_proof.BP;
|
||||
if bucket * H != BP {
|
||||
if &bucket * Htable != BP {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
|
|
Loading…
Reference in New Issue