From c73230e9376b7ddf1d06e73b6bf0f5e100f9258b Mon Sep 17 00:00:00 2001 From: onyinyang Date: Tue, 18 May 2021 12:04:21 -0400 Subject: [PATCH] Added Bridgeline to open-entry --- crates/lox-library/src/proto/open_invite.rs | 14 ++++++++++---- crates/lox-library/src/tests.rs | 16 ++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/crates/lox-library/src/proto/open_invite.rs b/crates/lox-library/src/proto/open_invite.rs index 3d7b20c..a818376 100644 --- a/crates/lox-library/src/proto/open_invite.rs +++ b/crates/lox-library/src/proto/open_invite.rs @@ -22,7 +22,7 @@ use zkp::CompactProof; use zkp::ProofError; use zkp::Transcript; -use super::super::bridge_table; +use super::super::{{bridge_table, BridgeLine}}; use super::super::cred; use super::super::dup_filter::SeenType; use super::super::OPENINV_LENGTH; @@ -55,6 +55,7 @@ pub struct Response { bucket: Scalar, level_since: Scalar, piBlindIssue: CompactProof, + bridge_line: BridgeLine, } // The userblinding ZKP @@ -189,6 +190,8 @@ impl BridgeAuth { // of the bucket id (u32) and the bucket's decryption key ([u8; 16]) let bucket_key = self.bridge_table.keys[bucket_id]; let bucket: Scalar = bridge_table::to_scalar(bucket_id_u32, &bucket_key); + let pre_line = self.bridge_table.decrypt_bucket_id(bucket_id_u32, &bucket_key).unwrap().0; + let bridge_line: BridgeLine = pre_line[0]; // Create the level_since attribute (Scalar), which is today's // Julian date @@ -253,6 +256,7 @@ impl BridgeAuth { bucket, level_since, piBlindIssue, + bridge_line, }) } } @@ -263,7 +267,7 @@ pub fn handle_response( state: State, resp: Response, lox_pub: &IssuerPubKey, -) -> Result { +) -> Result<(cred::Lox, bridge_table::BridgeLine), ProofError> { let A: &RistrettoPoint = &CMZ_A; let B: &RistrettoPoint = &CMZ_B; let Btable: &RistrettoBasepointTable = &CMZ_B_TABLE; @@ -307,7 +311,7 @@ pub fn handle_response( // Decrypt EncQ let Q = resp.EncQ.1 - (state.d * resp.EncQ.0); - Ok(cred::Lox { + Ok((cred::Lox { P: resp.P, Q, id, @@ -316,5 +320,7 @@ pub fn handle_response( level_since: resp.level_since, invites_remaining: Scalar::zero(), blockages: Scalar::zero(), - }) + }, + resp.bridge_line, + )) } diff --git a/crates/lox-library/src/tests.rs b/crates/lox-library/src/tests.rs index af7ddcd..e681d5e 100644 --- a/crates/lox-library/src/tests.rs +++ b/crates/lox-library/src/tests.rs @@ -45,7 +45,7 @@ impl TestHarness { self.ba.advance_days(days); } - fn open_invite(&mut self) -> cred::Lox { + fn open_invite(&mut self) -> (cred::Lox, bridge_table::BridgeLine) { // Issue an open invitation let inv = self.bdb.invite(); @@ -141,7 +141,7 @@ fn test_open_invite() { let mut th = TestHarness::new(); // Join an untrusted user - let cred = th.open_invite(); + let cred = th.open_invite().0; // Check that we can use the credential to read a bucket let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap(); @@ -158,7 +158,7 @@ fn test_open_invite() { fn test_trust_promotion() { let mut th = TestHarness::new(); - let cred = th.open_invite(); + let cred = th.open_invite().0; assert!(th.ba.verify_lox(&cred)); // Time passes @@ -181,7 +181,7 @@ fn test_trust_promotion() { fn test_level0_migration() { let mut th = TestHarness::new(); - let cred = th.open_invite(); + let cred = th.open_invite().0; assert!(th.ba.verify_lox(&cred)); // Time passes @@ -208,7 +208,7 @@ fn test_level_up() { let mut th = TestHarness::new(); // Join an untrusted user - let cred = th.open_invite(); + let cred = th.open_invite().0; // Time passes th.advance_days(47); @@ -248,7 +248,7 @@ fn test_issue_invite() { let mut th = TestHarness::new(); // Join an untrusted user - let cred = th.open_invite(); + let cred = th.open_invite().0; // Time passes th.advance_days(47); @@ -280,7 +280,7 @@ fn test_redeem_invite() { let mut th = TestHarness::new(); // Join an untrusted user - let cred = th.open_invite(); + let cred = th.open_invite().0; // Time passes th.advance_days(47); @@ -370,7 +370,7 @@ fn test_blockage_migration() { let mut th = TestHarness::new(); // Join an untrusted user - let cred = th.open_invite(); + let cred = th.open_invite().0; // Time passes th.advance_days(47);