Compare commits

...

2 Commits

Author SHA1 Message Date
Vecna 2ca58d8b5a Use const for generating H 2024-02-26 17:50:37 -05:00
Vecna af68c8818d Have LA recompute H rather than accepting it from user 2024-02-26 17:37:56 -05:00
1 changed files with 10 additions and 6 deletions

View File

@ -30,6 +30,7 @@ use super::super::cred;
use super::super::scalar_u32; use super::super::scalar_u32;
use super::super::{BridgeAuth, IssuerPubKey}; use super::super::{BridgeAuth, IssuerPubKey};
use super::super::{CMZ_A, CMZ_A_TABLE}; use super::super::{CMZ_A, CMZ_A_TABLE};
pub const H_GENERATOR_STRING: &str = "PR Generator H for ";
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct Request { pub struct Request {
@ -44,7 +45,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 +87,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!("{}{}", H_GENERATOR_STRING, date).as_bytes(),
); );
let Htable: RistrettoBasepointTable = RistrettoBasepointTable::create(&H); let Htable: RistrettoBasepointTable = RistrettoBasepointTable::create(&H);
@ -223,7 +224,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 +235,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!("{}{}", H_GENERATOR_STRING, 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 +279,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(),