Moved protocol modules into submodules of "proto" module instead of all being at the top level

This commit is contained in:
Ian Goldberg 2021-05-01 15:21:50 -04:00
parent ab864fae45
commit 8a19376edc
5 changed files with 38 additions and 26 deletions

View File

@ -318,10 +318,21 @@ pub fn pt_dbl(P: &RistrettoPoint) -> RistrettoPoint {
P + P P + P
} }
// The protocol modules /// The protocol modules.
pub mod migration; ///
pub mod open_invite; /// Each protocol lives in a submodule. Each submodule defines structs
pub mod trust_promotion; /// for Request (the message from the client to the bridge authority),
/// State (the state held by the client while waiting for the reply),
/// and Response (the message from the bridge authority to the client).
/// Each submodule defines functions request, which produces a (Request,
/// State) pair, and handle_response, which consumes a State and a
/// Response. It also adds a handle_* function to the BridgeAuth struct
/// that consumes a Request and produces a Result<Response, ProofError>.
pub mod proto {
pub mod migration;
pub mod open_invite;
pub mod trust_promotion;
}
// Unit tests // Unit tests
#[cfg(test)] #[cfg(test)]

View File

@ -40,10 +40,10 @@ use zkp::CompactProof;
use zkp::ProofError; use zkp::ProofError;
use zkp::Transcript; use zkp::Transcript;
use super::cred; use super::super::cred;
use super::dup_filter::SeenType; use super::super::dup_filter::SeenType;
use super::{BridgeAuth, IssuerPubKey}; use super::super::{BridgeAuth, IssuerPubKey};
use super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE}; use super::super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE};
pub struct Request { pub struct Request {
// Fields for blind showing the Lox credential // Fields for blind showing the Lox credential

View File

@ -22,15 +22,16 @@ use zkp::CompactProof;
use zkp::ProofError; use zkp::ProofError;
use zkp::Transcript; use zkp::Transcript;
use super::bridge_table; use super::super::bridge_table;
use super::cred; use super::super::cred;
use super::dup_filter::SeenType; use super::super::dup_filter::SeenType;
use super::{BridgeAuth, IssuerPubKey}; use super::super::OPENINV_LENGTH;
use super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE}; use super::super::{BridgeAuth, BridgeDb, IssuerPubKey};
use super::super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE};
/// The request message for this protocol /// The request message for this protocol
pub struct Request { pub struct Request {
invite: [u8; super::OPENINV_LENGTH], invite: [u8; OPENINV_LENGTH],
D: RistrettoPoint, D: RistrettoPoint,
EncIdClient: (RistrettoPoint, RistrettoPoint), EncIdClient: (RistrettoPoint, RistrettoPoint),
piUserBlinding: CompactProof, piUserBlinding: CompactProof,
@ -104,7 +105,7 @@ define_proof! {
/// Submit an open invitation issued by the BridgeDb to receive your /// Submit an open invitation issued by the BridgeDb to receive your
/// first Lox credential /// first Lox credential
pub fn request(invite: &[u8; super::OPENINV_LENGTH]) -> (Request, State) { pub fn request(invite: &[u8; OPENINV_LENGTH]) -> (Request, State) {
let B: &RistrettoPoint = &CMZ_B; let B: &RistrettoPoint = &CMZ_B;
let Btable: &RistrettoBasepointTable = &CMZ_B_TABLE; let Btable: &RistrettoBasepointTable = &CMZ_B_TABLE;
@ -159,8 +160,7 @@ impl BridgeAuth {
// Check the signature on the open_invite. We manually match // Check the signature on the open_invite. We manually match
// here because we're changing the Err type from SignatureError // here because we're changing the Err type from SignatureError
// to ProofError // to ProofError
let (invite_id, bucket_id_u32) = let (invite_id, bucket_id_u32) = match BridgeDb::verify(req.invite, self.bridgedb_pub) {
match super::BridgeDb::verify(req.invite, self.bridgedb_pub) {
Ok(res) => res, Ok(res) => res,
Err(_) => return Err(ProofError::VerificationFailure), Err(_) => return Err(ProofError::VerificationFailure),
}; };

View File

@ -38,12 +38,12 @@ use zkp::Transcript;
use std::collections::HashMap; use std::collections::HashMap;
use super::cred; use super::super::cred;
use super::dup_filter::SeenType; use super::super::dup_filter::SeenType;
use super::migration_table; use super::super::migration_table;
use super::{pt_dbl, scalar_dbl, scalar_u64}; use super::super::{pt_dbl, scalar_dbl, scalar_u64};
use super::{BridgeAuth, IssuerPubKey}; use super::super::{BridgeAuth, IssuerPubKey};
use super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE}; use super::super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE};
/// The minimum number of days a user has to be at trust level 0 /// The minimum number of days a user has to be at trust level 0
/// (untrusted) with their (single) bridge unblocked before they can /// (untrusted) with their (single) bridge unblocked before they can

View File

@ -2,6 +2,7 @@
BridgeLine::random() or private fields */ BridgeLine::random() or private fields */
use super::bridge_table::BridgeLine; use super::bridge_table::BridgeLine;
use super::proto::*;
use super::*; use super::*;
#[test] #[test]