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 31, 2024
1 parent 8d4131c commit 72de55c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/abe_policy/dimension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ impl DimensionBuilder {
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)]
/// Represents an `Attribute` inside a `Dimension`.
pub struct AttributeParameters {
pub(super) id: u32,
pub(super) encryption_hint: EncryptionHint,
pub(super) write_status: AttributeStatus,
pub(crate) id: u32,
pub(crate) encryption_hint: EncryptionHint,
pub(crate) write_status: AttributeStatus,
}

impl AttributeParameters {
Expand Down
1 change: 0 additions & 1 deletion src/abe_policy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ pub enum PolicyVersion {
V1,
V2,
}

14 changes: 6 additions & 8 deletions src/core/serialization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::{
SIGNATURE_LENGTH, SIGNING_KEY_LENGTH, TAG_LENGTH,
};
use crate::{
abe_policy::{AttributeParameters, Coordinate, Policy},
abe_policy::{Coordinate, Policy},
core::{
CleartextHeader, Encapsulation, EncryptedHeader, MasterPublicKey, MasterSecretKey,
SeedEncapsulation, UserSecretKey, SEED_LENGTH,
Expand Down Expand Up @@ -541,21 +541,19 @@ impl Serializable for Policy {

fn length(&self) -> usize {
to_leb128_len(self.version.clone() as usize)
+ to_leb128_len(self.last_attribute_value.try_into().unwrap())
+ to_leb128_len(usize::try_from(self.last_attribute_value).unwrap())
+ self
.dimensions
.iter()
.map(|(s, dim)| {
to_leb128_len(s.len())
+ dim
.attributes()
.into_iter()
.iter()
.map(|d | {
d.id.len() + d.encryption_hint.len() + d.write_status.len()
})
.product::<usize>()
})
.sum::<usize>()
to_leb128_len(usize::try_from(d.id).unwrap()) + to_leb128_len(d.encryption_hint.clone() as usize) + to_leb128_len(d.write_status.clone() as usize)
}).sum::<usize>()
}).sum::<usize>()
}

fn write(
Expand Down

0 comments on commit 72de55c

Please sign in to comment.