|
@@ -54,16 +54,17 @@ pub const MIN_TRUST_LEVEL: u32 = 3;
|
|
|
const SESSION_ID: &[u8] = b"check_blockage";
|
|
|
|
|
|
muCMZProtocol! { check_blockage,
|
|
|
- L: Lox { id: R, bucket: H, trust_level: R, level_since: H, invites_remaining: R, blockages: R },
|
|
|
- M: MigrationKey { lox_id: J, from_bucket: H} ,
|
|
|
- L.bucket = M.from_bucket,
|
|
|
+ L: Lox { id: R, bucket: H, trust_level: R, level_since: H, invites_remaining: H, blockages: H },
|
|
|
+ M: MigrationKey { lox_id: R, from_bucket: H},
|
|
|
+ M.lox_id = L.id,
|
|
|
+ M.from_bucket = L.bucket,
|
|
|
}
|
|
|
|
|
|
pub fn request(
|
|
|
+ rng: &mut (impl CryptoRng + RngCore),
|
|
|
L: Lox,
|
|
|
- mig_pubkeys: CMZPubkey<G>,
|
|
|
+ migkey_pubkeys: CMZPubkey<G>,
|
|
|
) -> Result<(check_blockage::Request, check_blockage::ClientState), CredentialError> {
|
|
|
- let mut rng = rand::thread_rng();
|
|
|
cmz_group_init(G::hash_from_bytes::<Sha512>(b"CMZ Generator A"));
|
|
|
|
|
|
// Ensure that the credenials can be correctly shown; that is, the
|
|
@@ -91,13 +92,11 @@ pub fn request(
|
|
|
));
|
|
|
}
|
|
|
}
|
|
|
+ let mut M = MigrationKey::using_pubkey(&migkey_pubkeys);
|
|
|
+ M.lox_id = L.id;
|
|
|
+ M.from_bucket = L.bucket;
|
|
|
|
|
|
- match check_blockage::prepare(
|
|
|
- &mut rng,
|
|
|
- SESSION_ID,
|
|
|
- &L,
|
|
|
- MigrationKey::using_pubkey(&mig_pubkeys),
|
|
|
- ) {
|
|
|
+ match check_blockage::prepare(rng, SESSION_ID, &L, M) {
|
|
|
Ok(req_state) => Ok(req_state),
|
|
|
Err(e) => Err(CredentialError::CMZError(e)),
|
|
|
}
|
|
@@ -195,3 +194,26 @@ pub fn handle_response(
|
|
|
None => Err(CMZError::Unknown),
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+#[cfg(all(test, feature = "bridgeauth"))]
|
|
|
+mod tests {
|
|
|
+ use super::*;
|
|
|
+ use crate::mock_auth::TestHarness;
|
|
|
+
|
|
|
+ #[test]
|
|
|
+ fn test_check_blockage() {
|
|
|
+ let mut th = TestHarness::new();
|
|
|
+ let rng = &mut rand::thread_rng();
|
|
|
+ let invite = th.bdb.invite().unwrap();
|
|
|
+ let mut lox_cred = th.open_invite(rng, &invite);
|
|
|
+ let mut mig_cred = th.trust_promotion(rng, lox_cred.clone());
|
|
|
+ lox_cred = th.migration(rng, lox_cred.clone(), mig_cred.clone());
|
|
|
+ let lox_cred_1 = th.level_up(rng, lox_cred.clone());
|
|
|
+ let lox_cred_2 = th.level_up(rng, lox_cred_1.clone());
|
|
|
+ let lox_cred_3 = th.level_up(rng, lox_cred_2.clone());
|
|
|
+ th.block_bridges(lox_cred_3.clone());
|
|
|
+ mig_cred = th.check_blockage(rng, lox_cred_3.clone());
|
|
|
+ println!("Mig Cred: {:?}", mig_cred);
|
|
|
+ th.verify_migration(&mig_cred);
|
|
|
+ }
|
|
|
+}
|