diff --git a/crates/lox-library/src/bridge_table.rs b/crates/lox-library/src/bridge_table.rs index 6f385a6..aa64d98 100644 --- a/crates/lox-library/src/bridge_table.rs +++ b/crates/lox-library/src/bridge_table.rs @@ -207,10 +207,12 @@ impl BridgeLine { /// the encrypted buckets. The encrypted buckets will be exposed to the /// users of the system, and each user credential will contain the /// decryption key for one bucket. -#[derive(Debug, Default)] +#[serde_as] +#[derive(Debug, Default, Serialize, Deserialize)] pub struct BridgeTable { pub keys: Vec<[u8; 16]>, pub buckets: Vec<[BridgeLine; MAX_BRIDGES_PER_BUCKET]>, + #[serde_as(as = "Vec<[_; ENC_BUCKET_BYTES]>")] pub encbuckets: Vec<[u8; ENC_BUCKET_BYTES]>, /// Individual bridges that are reachable pub reachable: HashMap>, diff --git a/crates/lox-library/src/dup_filter.rs b/crates/lox-library/src/dup_filter.rs index 3a2a797..6f874ba 100644 --- a/crates/lox-library/src/dup_filter.rs +++ b/crates/lox-library/src/dup_filter.rs @@ -8,10 +8,12 @@ use std::cmp::Eq; use std::collections::HashMap; use std::hash::Hash; +use serde::{Deserialize, Serialize}; + /// Each instance of DupFilter maintains its own independent table of /// seen ids. IdType will typically be Scalar. -#[derive(Default, Debug)] -pub struct DupFilter { +#[derive(Default, Debug, Serialize, Deserialize)] +pub struct DupFilter { seen_table: HashMap, } @@ -23,7 +25,7 @@ pub enum SeenType { Seen, } -impl DupFilter { +impl DupFilter { /// Check to see if the id is in the seen table, but do not add it /// to the seen table. Return Seen if it is already in the table, /// Fresh if not. diff --git a/crates/lox-library/src/lib.rs b/crates/lox-library/src/lib.rs index 65709e0..0cd9b45 100644 --- a/crates/lox-library/src/lib.rs +++ b/crates/lox-library/src/lib.rs @@ -47,7 +47,7 @@ use migration_table::{MigrationTable, MigrationType}; use lazy_static::lazy_static; -use serde::{Serialize, Deserialize}; +use serde::{Deserialize, Serialize}; lazy_static! { pub static ref CMZ_A: RistrettoPoint = @@ -197,7 +197,7 @@ impl Default for BridgeDb { } /// The bridge authority. This will typically be a singleton object. -#[derive(Debug)] +#[derive(Debug, Serialize, Deserialize)] pub struct BridgeAuth { /// The private key for the main Lox credential lox_priv: IssuerPrivKey, @@ -241,6 +241,7 @@ pub struct BridgeAuth { trust_promotion_filter: dup_filter::DupFilter, /// For testing only: offset of the true time to the simulated time + #[serde(skip)] time_offset: time::Duration, } diff --git a/crates/lox-library/src/migration_table.rs b/crates/lox-library/src/migration_table.rs index 86d5aa8..9f98c34 100644 --- a/crates/lox-library/src/migration_table.rs +++ b/crates/lox-library/src/migration_table.rs @@ -22,6 +22,8 @@ use rand::RngCore; use std::collections::HashMap; +use serde::{Deserialize, Serialize}; + use super::bridge_table; use super::cred::Migration; use super::IssuerPrivKey; @@ -57,7 +59,7 @@ impl From for Scalar { } /// The migration table -#[derive(Default, Debug)] +#[derive(Default, Debug, Serialize, Deserialize)] pub struct MigrationTable { pub table: HashMap, pub migration_type: Scalar,