Make BridgeAuth (de)serializable

This commit is contained in:
Vecna 2022-11-22 19:15:09 -05:00
parent 2cd4d96b73
commit 3945ed5b60
4 changed files with 14 additions and 7 deletions

View File

@ -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<BridgeLine, Vec<(u32, usize)>>,

View File

@ -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<IdType> {
#[derive(Default, Debug, Serialize, Deserialize)]
pub struct DupFilter<IdType: Hash + Eq + Copy + Serialize> {
seen_table: HashMap<IdType, ()>,
}
@ -23,7 +25,7 @@ pub enum SeenType {
Seen,
}
impl<IdType: Hash + Eq + Copy> DupFilter<IdType> {
impl<IdType: Hash + Eq + Copy + Serialize> DupFilter<IdType> {
/// 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.

View File

@ -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<Scalar>,
/// For testing only: offset of the true time to the simulated time
#[serde(skip)]
time_offset: time::Duration,
}

View File

@ -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<MigrationType> for Scalar {
}
/// The migration table
#[derive(Default, Debug)]
#[derive(Default, Debug, Serialize, Deserialize)]
pub struct MigrationTable {
pub table: HashMap<u32, u32>,
pub migration_type: Scalar,