Bläddra i källkod

Add migration_type to migration credential protocols

onyinyang 6 dagar sedan
förälder
incheckning
8c77091a98
3 ändrade filer med 13 tillägg och 5 borttagningar
  1. 6 3
      src/proto/blockage_migration.rs
  2. 1 1
      src/proto/check_blockage.rs
  3. 6 1
      src/proto/migration.rs

+ 6 - 3
src/proto/blockage_migration.rs

@@ -42,7 +42,11 @@ use super::level_up::LEVEL_INVITATIONS;
 #[cfg(feature = "bridgeauth")]
 use super::level_up::MAX_LEVEL;
 pub use crate::lox_creds::{Lox, Migration};
+#[cfg(feature = "bridgeauth")]
+use crate::migration_table::MigrationType;
 use cmz::*;
+#[cfg(feature = "bridgeauth")]
+use ff::PrimeField;
 use group::Group;
 use rand::{CryptoRng, RngCore};
 use sha2::Sha512;
@@ -51,7 +55,7 @@ const SESSION_ID: &[u8] = b"blockage_migration";
 
 muCMZProtocol! { blockage_migration,
     [ L: Lox { id: R, bucket: H, trust_level: R, level_since: H, invites_remaining: H, blockages: H },
-    M: Migration { lox_id: R, from_bucket: H, to_bucket: H } ],
+    M: Migration { lox_id: R, from_bucket: H, to_bucket: H, migration_type: I } ],
     N: Lox {id: J, bucket: H, trust_level: I, level_since: S, invites_remaining: I, blockages: H },
     L.id = M.lox_id,
     L.bucket = M.from_bucket,
@@ -141,6 +145,7 @@ impl BridgeAuth {
                 L.set_privkey(&self.lox_priv);
                 M.set_privkey(&self.migration_priv);
                 N.set_privkey(&self.lox_priv);
+                M.migration_type = Some(Scalar::from_u128(MigrationType::Blockage.into()));
                 N.trust_level = Some((level - 2).into());
                 N.level_since = Some(today.into());
                 N.invites_remaining = Some(LEVEL_INVITATIONS[(level - 3) as usize].into());
@@ -188,8 +193,6 @@ mod tests {
         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());
-        th.verify_migration(&mig_cred.clone());
-        th.verify_lox(&lox_cred_3.clone());
         lox_cred = th.blockage_migration(rng, lox_cred_3.clone(), mig_cred.clone());
         th.verify_lox(&lox_cred);
     }

+ 1 - 1
src/proto/check_blockage.rs

@@ -147,7 +147,7 @@ impl BridgeAuth {
                 Ok(())
             },
             |L: &Lox, _M: &MigrationKey| {
-                if self.id_filter.filter(&L.id.unwrap()) == SeenType::Seen {
+                if self.id_filter.check(&L.id.unwrap()) == SeenType::Seen {
                     return Err(CMZError::RevealAttrMissing("id", "Credential Expired"));
                 }
                 Ok(())

+ 6 - 1
src/proto/migration.rs

@@ -38,8 +38,12 @@ use super::super::{Scalar, G};
 use super::errors::CredentialError;
 use crate::lox_creds::{Lox, Migration};
 #[cfg(feature = "bridgeauth")]
+use crate::migration_table::MigrationType;
+#[cfg(feature = "bridgeauth")]
 use crate::scalar_u32;
 use cmz::*;
+#[cfg(feature = "bridgeauth")]
+use ff::PrimeField;
 use group::Group;
 use rand::{CryptoRng, RngCore};
 use sha2::Sha512;
@@ -48,7 +52,7 @@ const SESSION_ID: &[u8] = b"migration";
 
 muCMZProtocol! { migration,
     [ L: Lox { id: R, bucket: H, trust_level: R, level_since: H, invites_remaining: R, blockages: R },
-    M: Migration { lox_id: R, from_bucket: H, to_bucket: H } ],
+    M: Migration { lox_id: R, from_bucket: H, to_bucket: H, migration_type: I} ],
     N: Lox {id: J, bucket: H, trust_level: I, level_since: S, invites_remaining: I, blockages: I },
     L.id = M.lox_id,
     L.bucket = M.from_bucket,
@@ -125,6 +129,7 @@ impl BridgeAuth {
                 L.set_privkey(&self.lox_priv);
                 M.set_privkey(&self.migration_priv);
                 N.set_privkey(&self.lox_priv);
+                M.migration_type = Some(Scalar::from_u128(MigrationType::TrustUpgrade.into()));
                 N.trust_level = Some(Scalar::ONE);
                 N.level_since = Some(today.into());
                 N.invites_remaining = Some(Scalar::ZERO);