Added Bridgeline to open-entry

This commit is contained in:
onyinyang 2021-05-18 12:04:21 -04:00
parent a56ac87868
commit c73230e937
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
2 changed files with 18 additions and 12 deletions

View File

@ -22,7 +22,7 @@ use zkp::CompactProof;
use zkp::ProofError; use zkp::ProofError;
use zkp::Transcript; use zkp::Transcript;
use super::super::bridge_table; use super::super::{{bridge_table, BridgeLine}};
use super::super::cred; use super::super::cred;
use super::super::dup_filter::SeenType; use super::super::dup_filter::SeenType;
use super::super::OPENINV_LENGTH; use super::super::OPENINV_LENGTH;
@ -55,6 +55,7 @@ pub struct Response {
bucket: Scalar, bucket: Scalar,
level_since: Scalar, level_since: Scalar,
piBlindIssue: CompactProof, piBlindIssue: CompactProof,
bridge_line: BridgeLine,
} }
// The userblinding ZKP // The userblinding ZKP
@ -189,6 +190,8 @@ impl BridgeAuth {
// of the bucket id (u32) and the bucket's decryption key ([u8; 16]) // of the bucket id (u32) and the bucket's decryption key ([u8; 16])
let bucket_key = self.bridge_table.keys[bucket_id]; let bucket_key = self.bridge_table.keys[bucket_id];
let bucket: Scalar = bridge_table::to_scalar(bucket_id_u32, &bucket_key); 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 // Create the level_since attribute (Scalar), which is today's
// Julian date // Julian date
@ -253,6 +256,7 @@ impl BridgeAuth {
bucket, bucket,
level_since, level_since,
piBlindIssue, piBlindIssue,
bridge_line,
}) })
} }
} }
@ -263,7 +267,7 @@ pub fn handle_response(
state: State, state: State,
resp: Response, resp: Response,
lox_pub: &IssuerPubKey, lox_pub: &IssuerPubKey,
) -> Result<cred::Lox, ProofError> { ) -> Result<(cred::Lox, bridge_table::BridgeLine), ProofError> {
let A: &RistrettoPoint = &CMZ_A; let A: &RistrettoPoint = &CMZ_A;
let B: &RistrettoPoint = &CMZ_B; let B: &RistrettoPoint = &CMZ_B;
let Btable: &RistrettoBasepointTable = &CMZ_B_TABLE; let Btable: &RistrettoBasepointTable = &CMZ_B_TABLE;
@ -307,7 +311,7 @@ pub fn handle_response(
// Decrypt EncQ // Decrypt EncQ
let Q = resp.EncQ.1 - (state.d * resp.EncQ.0); let Q = resp.EncQ.1 - (state.d * resp.EncQ.0);
Ok(cred::Lox { Ok((cred::Lox {
P: resp.P, P: resp.P,
Q, Q,
id, id,
@ -316,5 +320,7 @@ pub fn handle_response(
level_since: resp.level_since, level_since: resp.level_since,
invites_remaining: Scalar::zero(), invites_remaining: Scalar::zero(),
blockages: Scalar::zero(), blockages: Scalar::zero(),
}) },
resp.bridge_line,
))
} }

View File

@ -45,7 +45,7 @@ impl TestHarness {
self.ba.advance_days(days); 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 // Issue an open invitation
let inv = self.bdb.invite(); let inv = self.bdb.invite();
@ -141,7 +141,7 @@ fn test_open_invite() {
let mut th = TestHarness::new(); let mut th = TestHarness::new();
// Join an untrusted user // 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 // Check that we can use the credential to read a bucket
let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap(); let (id, key) = bridge_table::from_scalar(cred.bucket).unwrap();
@ -158,7 +158,7 @@ fn test_open_invite() {
fn test_trust_promotion() { fn test_trust_promotion() {
let mut th = TestHarness::new(); let mut th = TestHarness::new();
let cred = th.open_invite(); let cred = th.open_invite().0;
assert!(th.ba.verify_lox(&cred)); assert!(th.ba.verify_lox(&cred));
// Time passes // Time passes
@ -181,7 +181,7 @@ fn test_trust_promotion() {
fn test_level0_migration() { fn test_level0_migration() {
let mut th = TestHarness::new(); let mut th = TestHarness::new();
let cred = th.open_invite(); let cred = th.open_invite().0;
assert!(th.ba.verify_lox(&cred)); assert!(th.ba.verify_lox(&cred));
// Time passes // Time passes
@ -208,7 +208,7 @@ fn test_level_up() {
let mut th = TestHarness::new(); let mut th = TestHarness::new();
// Join an untrusted user // Join an untrusted user
let cred = th.open_invite(); let cred = th.open_invite().0;
// Time passes // Time passes
th.advance_days(47); th.advance_days(47);
@ -248,7 +248,7 @@ fn test_issue_invite() {
let mut th = TestHarness::new(); let mut th = TestHarness::new();
// Join an untrusted user // Join an untrusted user
let cred = th.open_invite(); let cred = th.open_invite().0;
// Time passes // Time passes
th.advance_days(47); th.advance_days(47);
@ -280,7 +280,7 @@ fn test_redeem_invite() {
let mut th = TestHarness::new(); let mut th = TestHarness::new();
// Join an untrusted user // Join an untrusted user
let cred = th.open_invite(); let cred = th.open_invite().0;
// Time passes // Time passes
th.advance_days(47); th.advance_days(47);
@ -370,7 +370,7 @@ fn test_blockage_migration() {
let mut th = TestHarness::new(); let mut th = TestHarness::new();
// Join an untrusted user // Join an untrusted user
let cred = th.open_invite(); let cred = th.open_invite().0;
// Time passes // Time passes
th.advance_days(47); th.advance_days(47);