Don't have LA recompute H every time to verify positive reports

This commit is contained in:
Vecna 2024-02-28 11:47:49 -05:00
parent 2ca58d8b5a
commit 88a0990243
2 changed files with 13 additions and 10 deletions

View File

@ -30,7 +30,12 @@ use super::super::cred;
use super::super::scalar_u32;
use super::super::{BridgeAuth, IssuerPubKey};
use super::super::{CMZ_A, CMZ_A_TABLE};
pub const H_GENERATOR_STRING: &str = "PR Generator H for ";
pub fn compute_H(date: u32) -> RistrettoPoint {
RistrettoPoint::hash_from_bytes::<Sha512>(
format!("PR Generator H for {}", date).as_bytes(),
)
}
#[derive(Serialize, Deserialize)]
pub struct Request {
@ -92,9 +97,7 @@ pub fn request(lox_cred: &cred::Lox, lox_pub: &IssuerPubKey) -> Result<Request,
.to_julian_day()
.try_into()
.unwrap();
let H: RistrettoPoint = RistrettoPoint::hash_from_bytes::<Sha512>(
format!("{}{}", H_GENERATOR_STRING, date).as_bytes(),
);
let H = compute_H(date);
let Htable: RistrettoBasepointTable = RistrettoBasepointTable::create(&H);
// Ensure that the credential can be correctly shown: it must be the case
@ -233,11 +236,9 @@ pub fn request(lox_cred: &cred::Lox, lox_pub: &IssuerPubKey) -> Result<Request,
impl BridgeAuth {
/// Receive a positive report request
pub fn handle_positive_report(&mut self, req: Request) -> Result<(), ProofError> {
pub fn handle_positive_report(&mut self, req: Request, Htable: &RistrettoBasepointTable) -> Result<(), ProofError> {
let A: &RistrettoPoint = &CMZ_A;
let H: RistrettoPoint = RistrettoPoint::hash_from_bytes::<Sha512>(
format!("{}{}", H_GENERATOR_STRING, req.date).as_bytes(),
);
let H = Htable.basepoint();
if req.P.is_identity() {
return Err(ProofError::VerificationFailure);

View File

@ -380,8 +380,10 @@ impl TestHarness {
let req_len = encoded.len();
let resp_start = Instant::now();
let decoded = bincode::deserialize(&encoded[..]).unwrap();
self.ba.handle_positive_report(decoded).unwrap();
let decoded: positive_report::Request = bincode::deserialize(&encoded[..]).unwrap();
let H = positive_report::compute_H(decoded.date);
let Htable: RistrettoBasepointTable = RistrettoBasepointTable::create(&H);
self.ba.handle_positive_report(decoded, &Htable).unwrap();
let resp_t = resp_start.elapsed();
let resp_len = 0;