Skip to content

Commit

Permalink
try to pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phochard committed Oct 28, 2024
1 parent ae73e47 commit 415439b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/core/serialization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Serializable for MasterPublicKey {
let pk = de.read::<CoordinatePublicKey>()?;
coordinate_keys.insert(coordinate, pk);
}
let policy = Policy::try_from(de.read()?)?;
let policy = de.read::<Policy>()?;
Ok(Self {
tpk,
coordinate_keys,
Expand Down Expand Up @@ -200,7 +200,7 @@ impl Serializable for MasterSecretKey {
if let Some(kmac_key) = &self.signing_key {
n += ser.write_array(kmac_key)?;
}
n += ser.write_vec(&self.policy)?;
n += ser.write(&self.policy)?;
Ok(n)
}

Expand Down Expand Up @@ -230,7 +230,7 @@ impl Serializable for MasterSecretKey {
)?)
};

let policy = Policy::try_from(de.read()?)?;
let policy = de.read::<Policy>()?;

Ok(Self {
s,
Expand Down Expand Up @@ -540,21 +540,25 @@ impl Serializable for Policy {
self.attributes().len()
}

fn write(&self, ser: &mut cosmian_crypto_core::bytes_ser_de::Serializer) -> Result<usize, Self::Error> {
let n =ser.write(&self.to_bytes())?;
fn write(
&self,
ser: &mut cosmian_crypto_core::bytes_ser_de::Serializer,
) -> Result<usize, Self::Error> {
let n = ser.write(self)?;
Ok(n)
}

fn read(de: &mut cosmian_crypto_core::bytes_ser_de::Deserializer) -> Result<Self, Self::Error> {
de.read();
let n = de.read::<Policy>()?;
Ok(n)
}
}

#[cfg(test)]

mod tests {
use std::collections::HashMap;

use cosmian_crypto_core::{reexport::rand_core::SeedableRng, CsRng};

use super::*;
use crate::{
abe_policy::{AttributeStatus, EncryptionHint},
Expand Down

0 comments on commit 415439b

Please sign in to comment.