Skip to content

Commit

Permalink
wip: fix: serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrezot committed Jan 31, 2024
1 parent 0c05ea1 commit c99a629
Show file tree
Hide file tree
Showing 12 changed files with 811 additions and 321 deletions.
13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ name = "cosmian_cover_crypt"
# The cdylib is only interesting if the `--features ffi` flag is set on build
# This does not seem to be actionable conditionally https://github.com/rust-lang/cargo/issues/4881

[[example]]
name = "encrypt"
required-features = ["serialization"]

[[example]]
name = "decrypt"
required-features = ["serialization"]

[features]
full_bench = []
hybridized_bench = []
serialization = []

[dependencies]
cosmian_crypto_core = { git="https://github.com/Cosmian/crypto_core.git", branch="feat/add_neutral_scalars", default-features = false, features = ["ser", "sha3", "aes", "curve25519"] }
Expand All @@ -32,5 +41,5 @@ tiny-keccak = { version = "2.0.2", features = ["shake", "kmac"] }
zeroize = "1.6.0"

[dev-dependencies]
base64 = { version = "0.21.0" }
criterion = { version = "0.4", features = ["html_reports"], default_features = false }
# base64 = { version = "0.21.0" }
# criterion = { version = "0.4", features = ["html_reports"], default_features = false }
45 changes: 20 additions & 25 deletions examples/decrypt.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
fn main() {
#[cfg(feature = "serialization")]
{
use base64::{
alphabet::STANDARD,
engine::{GeneralPurpose, GeneralPurposeConfig},
Engine,
};
use cosmian_cover_crypt::{Covercrypt, EncryptedHeader, UserSecretKey};
use cosmian_crypto_core::bytes_ser_de::Serializable;
const USK: &str = "sUBriVEsM8HowAKOsIs9Y5p+Xa8JwJf84rlBHXzfkg+BJ6PzK79cT37Wsku5pMVKrfi/eIWhufC2pjYNMBOUAgMAH+waKc6AuwtAaYXXUAJA0K/uc5A22nXEShVXykjZ8QIBuNMsBrpSQaW0hAZ0AFvJTlwSM2BgI8m5k4wj3kQQ9NaP4cK6VvwyFlx7ZwwMZkJoCSgfiPvN4XqeWmiw/heh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Purpose, GeneralPurposeConfig},
Engine,
};
use cosmian_cover_crypt::{Covercrypt, EncryptedHeader, UserSecretKey};
use cosmian_crypto_core::bytes_ser_de::Serializable;

let config: GeneralPurposeConfig = GeneralPurposeConfig::default();
let transcoder: GeneralPurpose = GeneralPurpose::new(&STANDARD, config);
let config: GeneralPurposeConfig = GeneralPurposeConfig::default();
let transcoder: GeneralPurpose = GeneralPurpose::new(&STANDARD, config);

let cc = Covercrypt::default();
let usk = UserSecretKey::deserialize(&transcoder.decode(USK.as_bytes()).unwrap()).unwrap();
let encrypted_header =
EncryptedHeader::deserialize(&transcoder.decode(HEADER.as_bytes()).unwrap()).unwrap();
for _ in 0..1000 {
encrypted_header
.decrypt(&cc, &usk, None)
.expect("cannot decrypt hybrid header");
}
let cc = Covercrypt::default();
let usk = UserSecretKey::deserialize(&transcoder.decode(USK.as_bytes()).unwrap()).unwrap();
let encrypted_header =
EncryptedHeader::deserialize(&transcoder.decode(HEADER.as_bytes()).unwrap()).unwrap();
for _ in 0..1000 {
encrypted_header
.decrypt(&cc, &usk, None)
.expect("cannot decrypt hybrid header");
}
#[cfg(not(feature = "serialization"))]
println!("Use the `serialization` feature to run this example")
}
116 changes: 50 additions & 66 deletions examples/encrypt.rs
Original file line number Diff line number Diff line change
@@ -1,80 +1,64 @@
fn main() {
// create policy
#[cfg(all(feature = "serialization", feature = "test_utils"))]
use cosmian_cover_crypt::{
abe_policy::{AccessPolicy, Policy},
test_utils::policy,
Covercrypt, EncryptedHeader, MasterPublicKey, MasterSecretKey,
};

/// Generates a new USK and encrypted header and prints them.
fn generate_new(
cc: &Covercrypt,
policy: &Policy,
_msk: &mut MasterSecretKey,
mpk: &MasterPublicKey,
) {
let access_policy =
AccessPolicy::parse("Department::FIN && Security Level::Top Secret").unwrap();

let (_, _header) = EncryptedHeader::generate(cc, policy, mpk, &access_policy, None, None)
.expect("cannot encrypt header");

#[cfg(feature = "serialization")]
{
use base64::{
alphabet::STANDARD,
engine::{GeneralPurpose, GeneralPurposeConfig},
Engine,
};
use cosmian_cover_crypt::{
abe_policy::{AccessPolicy, Policy},
test_utils::policy,
Covercrypt, EncryptedHeader, MasterPublicKey, MasterSecretKey,
};
use cosmian_crypto_core::bytes_ser_de::Serializable;

fn generate_new(
cc: &Covercrypt,
policy: &Policy,
_msk: &MasterSecretKey,
mpk: &MasterPublicKey,
) {
let access_policy = AccessPolicy::from_boolean_expression(
"Department::FIN && Security Level::Top Secret",
let config: GeneralPurposeConfig = GeneralPurposeConfig::default();
let transcoder: GeneralPurpose = GeneralPurpose::new(&STANDARD, config);
println!(
"USK = {}",
transcoder.encode(
cc.generate_user_secret_key(&mut _msk, &access_policy, policy)
.unwrap()
.serialize()
.unwrap()
)
.unwrap();

let (_, _header) =
EncryptedHeader::generate(cc, policy, mpk, &access_policy, None, None)
.expect("cannot encrypt header");

#[cfg(feature = "serialization")]
{
let config: GeneralPurposeConfig = GeneralPurposeConfig::default();
let transcoder: GeneralPurpose = GeneralPurpose::new(&STANDARD, config);

println!(
"usk = {}",
transcoder.encode(
cc.generate_user_secret_key(_msk, &access_policy, policy)
.unwrap()
.serialize()
.unwrap()
)
);
println!(
"header = {}",
transcoder.encode(_header.serialize().unwrap())
);
}
}

let policy = policy().expect("cannot generate policy");
);
println!(
"header = {}",
transcoder.encode(_header.serialize().unwrap())
);
}
}

let cc = Covercrypt::default();
let (_msk, mpk) = cc
.generate_master_keys(&policy)
.expect("cannot generate master keys");
fn main() {
let policy = policy().expect("cannot generate policy");
let ap = AccessPolicy::parse("Department::FIN && Security Level::Top Secret")
.expect("cannot parse given access policy");

// Encryption of a hybridized ciphertext
let access_policy =
AccessPolicy::from_boolean_expression("Department::FIN && Security Level::Top Secret")
.unwrap();
let cc = Covercrypt::default();
let (mut msk, _) = cc.setup().expect("cannot generate master keys");
let mpk = cc
.update_master_keys(&policy, &mut msk)
.expect("cannot update master keys");

//
// Use the following to update `examples/decrypt.rs` constants.
//
generate_new(&cc, &policy, &_msk, &mpk);
generate_new(&cc, &policy, &mut msk, &mpk);

// encrypt header, use loop to add weight in the flamegraph on it
for _ in 0..1000 {
let _encrypted_header =
EncryptedHeader::generate(&cc, &policy, &mpk, &access_policy, None, None)
.expect("cannot encrypt header");
}
// Encrypt header, use loop to increase its wight in the flame graph.
for _ in 0..1000 {
EncryptedHeader::generate(&cc, &policy, &mpk, &ap, None, None)
.expect("cannot encrypt header");
}

#[cfg(not(all(feature = "test_utils", feature = "serialization")))]
println!("Use the `serialization` feature to run this example")
}
21 changes: 18 additions & 3 deletions src/core/api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Defines the `Covercrypt` API.
use std::{fmt::Debug, sync::Mutex};
use std::{collections::HashMap, fmt::Debug, sync::Mutex};

use cosmian_crypto_core::{
reexport::rand_core::SeedableRng, Aes256Gcm, CsRng, Dem, FixedSizeCBytes, Instantiable, Nonce,
Expand All @@ -12,7 +12,7 @@ use super::{
MIN_TRACING_LEVEL,
};
use crate::{
abe_policy::{AccessPolicy, Policy},
abe_policy::{AccessPolicy, AttributeStatus, Coordinate, EncryptionHint, Policy},
core::{
primitives::{decaps, encaps, refresh, rekey, setup},
Encapsulation, MasterPublicKey, MasterSecretKey, UserSecretKey, SEED_LENGTH,
Expand Down Expand Up @@ -47,11 +47,26 @@ impl Covercrypt {
/// They only hold keys for the origin coordinate: only broadcast
/// encapsulations can be created.
pub fn setup(&self) -> Result<(MasterSecretKey, MasterPublicKey), Error> {
let msk = setup(
let mut msk = setup(
&mut *self.rng.lock().expect("Mutex lock failed!"),
MIN_TRACING_LEVEL,
)?;

// Add broadcast coordinate with classic encryption level.
//
// TODO replace this function by `add_coordinates`,
// `remove_coordinates`, `hybridize_coordinates` and
// `deprecate_coordinates`.
update_coordinate_keys(
&mut *self.rng.lock().expect("Mutex lock failed!"),
&mut msk,
HashMap::from_iter([(
Coordinate::from_attribute_ids(vec![])?,
(EncryptionHint::Classic, AttributeStatus::EncryptDecrypt),
)]),
)?;
let mpk = mpk_keygen(&msk)?;

Ok((msk, mpk))
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub mod macros;
pub mod api;
pub mod pq_kem;
pub mod primitives;

// #[cfg(feature = "serialization")]
// pub mod serialization;

mod pke;
Expand Down
4 changes: 4 additions & 0 deletions src/core/primitives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ pub fn rekey(
coordinate,
CoordinateKeypair::random(rng, &h, is_hybridized),
);
} else {
return Err(Error::OperationNotPermitted(
"cannot re-key coordinate that does not belong to the MSK".to_string(),
));
}
}
Ok(())
Expand Down
Loading

0 comments on commit c99a629

Please sign in to comment.