From 1dbc14d5f19adb4cc59471dfe84fb98f7d3c861c Mon Sep 17 00:00:00 2001 From: Vecna Date: Wed, 17 Jan 2024 17:41:53 -0500 Subject: [PATCH] Uncomment level and bucket checks --- .../lox-library/src/proto/positive_report.rs | 70 +++++++------------ 1 file changed, 26 insertions(+), 44 deletions(-) diff --git a/crates/lox-library/src/proto/positive_report.rs b/crates/lox-library/src/proto/positive_report.rs index 7e1d4f5..b43841a 100644 --- a/crates/lox-library/src/proto/positive_report.rs +++ b/crates/lox-library/src/proto/positive_report.rs @@ -43,7 +43,6 @@ pub struct Request { CBlockages: RistrettoPoint, CQ: RistrettoPoint, -/* // Fields for proving which bucket we have H: RistrettoPoint, BP: RistrettoPoint, @@ -51,7 +50,6 @@ pub struct Request { // Fields for proving 3 <= trust_level <= 4 // CG can be computed by verifier CGsq: RistrettoPoint, -*/ // The combined lox_zkp piUser: CompactProof, @@ -61,11 +59,11 @@ define_proof! { requestproof, "Positive Report Request", (id, bucket, level, since, invremain, blockages, - zid, zbucket, zlevel, zsince, zinvremain, zblockages, negzQ), -// g, zg, wg, yg), + zid, zbucket, zlevel, zsince, zinvremain, zblockages, negzQ, + g, zg, wg, yg), (P, CId, CBucket, CLevel, CSince, CInvRemain, CBlockages, - V, Xid, Xbucket, Xlevel, Xsince, Xinvremain, Xblockages), -// H, BP, CG, CGsq), + V, Xid, Xbucket, Xlevel, Xsince, Xinvremain, Xblockages, + H, BP, CG, CGsq), (A): // Blind showing of the Lox credential CId = (id*P + zid*A), @@ -74,33 +72,29 @@ define_proof! { CSince = (since*P + zsince*A), CInvRemain = (invremain*P + zinvremain*A), CBlockages = (blockages*P + zblockages*A), - V = (zid*Xid + zbucket*Xbucket + zlevel*Xlevel + zsince*Xsince + zinvremain*Xinvremain + zblockages*Xblockages + negzQ*A) -/* + V = (zid*Xid + zbucket*Xbucket + zlevel*Xlevel + zsince*Xsince + zinvremain*Xinvremain + zblockages*Xblockages + negzQ*A), // Prove bucket is same bucket used in BP BP = (bucket*H), // Prove CLevel encodes a value of 3 or 4 // First prove g is a bit by proving that g = g^2 CG = (g*P + zg*A), CGsq = (g*CG + wg*A), CGsq = (g*P + yg*A) // The verifier will compute CG = CLevel - 3P -*/ } -pub fn request( - lox_cred: &cred::Lox, - lox_pub: &IssuerPubKey, -) -> Result { +pub fn request(lox_cred: &cred::Lox, lox_pub: &IssuerPubKey) -> Result { let A: &RistrettoPoint = &CMZ_A; let Atable: &RistrettoBasepointTable = &CMZ_A_TABLE; -/* // TODO: Where should this go? For efficiency, this should probably be global - let today: u32 = time::OffsetDateTime::now_utc().date() + let today: u32 = time::OffsetDateTime::now_utc() + .date() .to_julian_day() .try_into() .unwrap(); - let H: RistrettoPoint = RistrettoPoint::hash_from_bytes::(format!("PR Generator H for {}",today).as_bytes()); + let H: RistrettoPoint = RistrettoPoint::hash_from_bytes::( + format!("PR Generator H for {}", today).as_bytes(), + ); let Htable: RistrettoBasepointTable = RistrettoBasepointTable::create(&H); -*/ // Ensure that the credential can be correctly shown: it must be the case // that trust_level is 3 or 4 @@ -151,7 +145,6 @@ pub fn request( + zblockages * lox_pub.X[6] + &negzQ * Atable; -/* // Compute BP for proving knowledge of bucket let BP = &lox_cred.bucket * &Htable; @@ -175,7 +168,6 @@ pub fn request( let CG = g * P + &zg * Atable; let CGsq = g * P + &yg * Atable; -*/ // Construct the proof let mut transcript = Transcript::new(b"positive report request"); @@ -197,12 +189,10 @@ pub fn request( Xsince: &lox_pub.X[4], Xinvremain: &lox_pub.X[5], Xblockages: &lox_pub.X[6], -/* H: &H, BP: &BP, CG: &CG, CGsq: &CGsq, -*/ id: &lox_cred.id, bucket: &lox_cred.bucket, level: &lox_cred.trust_level, @@ -216,34 +206,28 @@ pub fn request( zinvremain: &zinvremain, zblockages: &zblockages, negzQ: &negzQ, -/* g: &g, zg: &zg, wg: &wg, yg: &yg, -*/ }, ) .0; - Ok( - Request { - P, - CId, - CBucket, - CLevel, - CSince, - CInvRemain, - CBlockages, - CQ, -/* - H, - BP, - CGsq, -*/ - piUser, - } - ) + Ok(Request { + P, + CId, + CBucket, + CLevel, + CSince, + CInvRemain, + CBlockages, + CQ, + H, + BP, + CGsq, + piUser, + }) } impl BridgeAuth { @@ -268,7 +252,7 @@ impl BridgeAuth { - req.CQ; // Recompute CG -// let CG = req.CLevel - Scalar::from(3 as u8) * req.P; + let CG = req.CLevel - Scalar::from(3 as u8) * req.P; // Verify the zkp let mut transcript = Transcript::new(b"positive report request"); @@ -291,12 +275,10 @@ impl BridgeAuth { Xsince: &self.lox_pub.X[4].compress(), Xinvremain: &self.lox_pub.X[5].compress(), Xblockages: &self.lox_pub.X[6].compress(), -/* H: &req.H.compress(), BP: &req.BP.compress(), CG: &CG.compress(), CGsq: &req.CGsq.compress(), -*/ }, )?;