Added serialization/deserialization for check_blockage and trust_promotion

This commit is contained in:
onyinyang 2021-05-26 17:29:53 -04:00
parent 179fea5e23
commit f6ffdd77bb
No known key found for this signature in database
GPG Key ID: 156A6435430C2036
2 changed files with 14 additions and 2 deletions

View File

@ -37,6 +37,9 @@ use zkp::CompactProof;
use zkp::ProofError; use zkp::ProofError;
use zkp::Transcript; use zkp::Transcript;
use serde::{Serialize,Deserialize};
use serde_with::serde_as;
use std::collections::HashMap; use std::collections::HashMap;
use super::super::cred; use super::super::cred;
@ -50,6 +53,7 @@ use super::super::{CMZ_A, CMZ_A_TABLE, CMZ_B, CMZ_B_TABLE};
/// perform this protocol. /// perform this protocol.
pub const MIN_TRUST_LEVEL: u32 = 3; pub const MIN_TRUST_LEVEL: u32 = 3;
#[derive(Serialize, Deserialize)]
pub struct Request { pub struct Request {
// Fields for blind showing the Lox credential // Fields for blind showing the Lox credential
P: RistrettoPoint, P: RistrettoPoint,
@ -78,7 +82,8 @@ pub struct State {
bucket: Scalar, bucket: Scalar,
} }
#[derive(Debug)] #[serde_as]
#[derive(Serialize, Deserialize, Debug)]
pub struct Response { pub struct Response {
// The encrypted MAC for the Migration Key credential // The encrypted MAC for the Migration Key credential
Pk: RistrettoPoint, Pk: RistrettoPoint,
@ -87,6 +92,7 @@ pub struct Response {
// A table of encrypted Migration credentials; the encryption keys // A table of encrypted Migration credentials; the encryption keys
// are formed from the possible values of Qk (the decrypted form of // are formed from the possible values of Qk (the decrypted form of
// EncQk) // EncQk)
#[serde_as(as = "Vec<(_,[_; migration_table::ENC_MIGRATION_BYTES])>")]
enc_migration_table: HashMap<[u8; 16], [u8; migration_table::ENC_MIGRATION_BYTES]>, enc_migration_table: HashMap<[u8; 16], [u8; migration_table::ENC_MIGRATION_BYTES]>,
} }

View File

@ -36,6 +36,9 @@ use zkp::CompactProof;
use zkp::ProofError; use zkp::ProofError;
use zkp::Transcript; use zkp::Transcript;
use serde::{Serialize, Deserialize};
use serde_with::serde_as;
use std::collections::HashMap; use std::collections::HashMap;
use super::super::cred; 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. /// with the system in order to move up trust levels.
pub const UNTRUSTED_INTERVAL: u32 = 30; pub const UNTRUSTED_INTERVAL: u32 = 30;
#[derive(Serialize, Deserialize)]
pub struct Request { pub struct Request {
// Fields for blind showing the Lox credential // Fields for blind showing the Lox credential
// We don't need to include trust_level, invites_remaining, or // We don't need to include trust_level, invites_remaining, or
@ -101,7 +105,8 @@ pub struct State {
bucket: Scalar, bucket: Scalar,
} }
#[derive(Debug)] #[serde_as]
#[derive(Serialize, Deserialize, Debug)]
pub struct Response { pub struct Response {
// The encrypted MAC for the Migration Key credential // The encrypted MAC for the Migration Key credential
Pk: RistrettoPoint, Pk: RistrettoPoint,
@ -110,6 +115,7 @@ pub struct Response {
// A table of encrypted Migration credentials; the encryption keys // A table of encrypted Migration credentials; the encryption keys
// are formed from the possible values of Qk (the decrypted form of // are formed from the possible values of Qk (the decrypted form of
// EncQk) // EncQk)
#[serde_as(as = "Vec<(_,[_; migration_table::ENC_MIGRATION_BYTES])>")]
enc_migration_table: HashMap<[u8; 16], [u8; migration_table::ENC_MIGRATION_BYTES]>, enc_migration_table: HashMap<[u8; 16], [u8; migration_table::ENC_MIGRATION_BYTES]>,
} }