Have LA recompute H rather than accepting it from user

This commit is contained in:
Vecna 2024-02-26 17:37:56 -05:00
parent e2e59e50a6
commit af68c8818d
1 changed files with 9 additions and 6 deletions

View File

@ -44,7 +44,7 @@ pub struct Request {
CQ: RistrettoPoint, CQ: RistrettoPoint,
// Fields for proving which bucket we have // Fields for proving which bucket we have
pub H: RistrettoPoint, pub date: u32, // date is used to compute H
pub BP: RistrettoPoint, pub BP: RistrettoPoint,
// Fields for proving 3 <= trust_level <= 4 // Fields for proving 3 <= trust_level <= 4
@ -86,13 +86,13 @@ pub fn request(lox_cred: &cred::Lox, lox_pub: &IssuerPubKey) -> Result<Request,
let Atable: &RistrettoBasepointTable = &CMZ_A_TABLE; let Atable: &RistrettoBasepointTable = &CMZ_A_TABLE;
// TODO: Where should this go? For efficiency, this should probably be global // TODO: Where should this go? For efficiency, this should probably be global
let today: u32 = time::OffsetDateTime::now_utc() let date: u32 = time::OffsetDateTime::now_utc()
.date() .date()
.to_julian_day() .to_julian_day()
.try_into() .try_into()
.unwrap(); .unwrap();
let H: RistrettoPoint = RistrettoPoint::hash_from_bytes::<Sha512>( let H: RistrettoPoint = RistrettoPoint::hash_from_bytes::<Sha512>(
format!("PR Generator H for {}", today).as_bytes(), format!("PR Generator H for {}", date).as_bytes(),
); );
let Htable: RistrettoBasepointTable = RistrettoBasepointTable::create(&H); let Htable: RistrettoBasepointTable = RistrettoBasepointTable::create(&H);
@ -223,7 +223,7 @@ pub fn request(lox_cred: &cred::Lox, lox_pub: &IssuerPubKey) -> Result<Request,
CInvRemain, CInvRemain,
CBlockages, CBlockages,
CQ, CQ,
H, date,
BP, BP,
CGsq, CGsq,
piUser, piUser,
@ -234,8 +234,11 @@ impl BridgeAuth {
/// Receive a positive report request /// 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) -> Result<(), ProofError> {
let A: &RistrettoPoint = &CMZ_A; let A: &RistrettoPoint = &CMZ_A;
let H: RistrettoPoint = RistrettoPoint::hash_from_bytes::<Sha512>(
format!("PR Generator H for {}", req.date).as_bytes(),
);
if req.P.is_identity() || req.H.is_identity() { if req.P.is_identity() {
return Err(ProofError::VerificationFailure); return Err(ProofError::VerificationFailure);
} }
@ -275,7 +278,7 @@ impl BridgeAuth {
Xsince: &self.lox_pub.X[4].compress(), Xsince: &self.lox_pub.X[4].compress(),
Xinvremain: &self.lox_pub.X[5].compress(), Xinvremain: &self.lox_pub.X[5].compress(),
Xblockages: &self.lox_pub.X[6].compress(), Xblockages: &self.lox_pub.X[6].compress(),
H: &req.H.compress(), H: &H.compress(),
BP: &req.BP.compress(), BP: &req.BP.compress(),
CG: &CG.compress(), CG: &CG.compress(),
CGsq: &req.CGsq.compress(), CGsq: &req.CGsq.compress(),