From f6ffdd77bb95390e5c55a49f3251ce0a86d1946d Mon Sep 17 00:00:00 2001 From: onyinyang Date: Wed, 26 May 2021 17:29:53 -0400 Subject: [PATCH] Added serialization/deserialization for check_blockage and trust_promotion --- crates/lox-library/src/proto/check_blockage.rs | 8 +++++++- crates/lox-library/src/proto/trust_promotion.rs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/lox-library/src/proto/check_blockage.rs b/crates/lox-library/src/proto/check_blockage.rs index a60958c..a879aa3 100644 --- a/crates/lox-library/src/proto/check_blockage.rs +++ b/crates/lox-library/src/proto/check_blockage.rs @@ -37,6 +37,9 @@ use zkp::CompactProof; use zkp::ProofError; use zkp::Transcript; +use serde::{Serialize,Deserialize}; +use serde_with::serde_as; + use std::collections::HashMap; use super::super::cred; @@ -50,6 +53,7 @@ use super::super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE}; /// perform this protocol. pub const MIN_TRUST_LEVEL: u32 = 3; +#[derive(Serialize, Deserialize)] pub struct Request { // Fields for blind showing the Lox credential P: RistrettoPoint, @@ -78,7 +82,8 @@ pub struct State { bucket: Scalar, } -#[derive(Debug)] +#[serde_as] +#[derive(Serialize, Deserialize, Debug)] pub struct Response { // The encrypted MAC for the Migration Key credential Pk: RistrettoPoint, @@ -87,6 +92,7 @@ pub struct Response { // A table of encrypted Migration credentials; the encryption keys // are formed from the possible values of Qk (the decrypted form of // EncQk) + #[serde_as(as = "Vec<(_,[_; migration_table::ENC_MIGRATION_BYTES])>")] enc_migration_table: HashMap<[u8; 16], [u8; migration_table::ENC_MIGRATION_BYTES]>, } diff --git a/crates/lox-library/src/proto/trust_promotion.rs b/crates/lox-library/src/proto/trust_promotion.rs index bced670..a49a77b 100644 --- a/crates/lox-library/src/proto/trust_promotion.rs +++ b/crates/lox-library/src/proto/trust_promotion.rs @@ -36,6 +36,9 @@ use zkp::CompactProof; use zkp::ProofError; use zkp::Transcript; +use serde::{Serialize, Deserialize}; +use serde_with::serde_as; + use std::collections::HashMap; use super::super::cred; @@ -54,6 +57,7 @@ use super::super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE}; /// with the system in order to move up trust levels. pub const UNTRUSTED_INTERVAL: u32 = 30; +#[derive(Serialize, Deserialize)] pub struct Request { // Fields for blind showing the Lox credential // We don't need to include trust_level, invites_remaining, or @@ -101,7 +105,8 @@ pub struct State { bucket: Scalar, } -#[derive(Debug)] +#[serde_as] +#[derive(Serialize, Deserialize, Debug)] pub struct Response { // The encrypted MAC for the Migration Key credential Pk: RistrettoPoint, @@ -110,6 +115,7 @@ pub struct Response { // A table of encrypted Migration credentials; the encryption keys // are formed from the possible values of Qk (the decrypted form of // EncQk) + #[serde_as(as = "Vec<(_,[_; migration_table::ENC_MIGRATION_BYTES])>")] enc_migration_table: HashMap<[u8; 16], [u8; migration_table::ENC_MIGRATION_BYTES]>, }