Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "libpep"
edition = "2021"
version = "0.10.0"
version = "0.10.1"
authors = ["Bernard van Gastel <bvgastel@bitpowder.com>", "Job Doesburg <job@jobdoesburg.nl>"]
homepage = "https://github.com/NOLAI/libpep"
repository = "https://github.com/NOLAI/libpep"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nolai/libpep-wasm",
"version": "0.10.0",
"version": "0.10.1",
"description": "Library for polymorphic encryption and pseudonymization (in WASM)",
"repository": {
"type": "git",
Expand Down
5 changes: 2 additions & 3 deletions src/lib/factors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
//! - [`contexts`]: Context types (PseudonymizationDomain, EncryptionContext)
//! - [`secrets`]: Secret types (PseudonymizationSecret, EncryptionSecret)
//! - [`types`]: Factor types and Info type aliases
//! - [`derivation`]: Functions for deriving factors from contexts and secrets

pub mod contexts;
pub mod secrets;
Expand All @@ -30,6 +29,6 @@ pub use secrets::{
};
pub use types::{
AttributeRekeyFactor, AttributeRekeyInfo, PseudonymRSKFactors, PseudonymRekeyFactor,
PseudonymRekeyInfo, PseudonymizationInfo, RekeyFactor, RerandomizeFactor, ReshuffleFactor,
TranscryptionInfo,
PseudonymRekeyInfo, PseudonymizationInfo, RekeyFactor, RekeyInfoProvider, RerandomizeFactor,
ReshuffleFactor, TranscryptionInfo,
};
18 changes: 18 additions & 0 deletions src/lib/factors/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Cryptographic factor types for rerandomization, reshuffling, and rekeying operations.

use crate::arithmetic::scalars::ScalarNonZero;
use crate::factors::EncryptionContext;
use derive_more::From;

/// High-level type for the factor used to [`rerandomize`](crate::core::primitives::rerandomize) an [ElGamal](crate::core::elgamal::ElGamal) ciphertext.
Expand Down Expand Up @@ -106,3 +107,20 @@ impl TranscryptionInfo {
}
}
}

/// A trait for types that can provide rekey information for a specific rekey info type.
///
/// This trait is parameterized by the rekey info type, allowing different implementations
/// for different encrypted types (e.g., `AttributeRekeyInfo` vs `PseudonymRekeyInfo`).
///
/// # Examples
///
/// ```rust,ignore
/// // Transcryptor implements RekeyInfoProvider for both types
/// let attr_info: AttributeRekeyInfo = transcryptor.rekey_info(&from_ctx, &to_ctx);
/// let pseudo_info: PseudonymRekeyInfo = transcryptor.rekey_info(&from_ctx, &to_ctx);
/// ```
pub trait RekeyInfoProvider<Info> {
/// Get the rekey information for transcryption between encryption contexts.
fn rekey_info(&self, session_from: &EncryptionContext, session_to: &EncryptionContext) -> Info;
}
1 change: 1 addition & 0 deletions src/lib/transcryptor/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

pub use super::{pseudonymize, rekey, rerandomize, rerandomize_known, transcrypt, Transcryptor};
pub use crate::data::simple::{Attribute, EncryptedAttribute, EncryptedPseudonym, Pseudonym};
pub use crate::data::traits::Rekeyable;
pub use crate::factors::contexts::{EncryptionContext, PseudonymizationDomain};
pub use crate::factors::{EncryptionSecret, PseudonymizationSecret, TranscryptionInfo};
21 changes: 21 additions & 0 deletions src/lib/transcryptor/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use crate::data::traits::{Pseudonymizable, Rekeyable, Transcryptable};
use crate::factors::contexts::*;
use crate::factors::types::RekeyInfoProvider;
use crate::factors::{
AttributeRekeyInfo, EncryptionSecret, PseudonymRekeyInfo, PseudonymizationInfo,
PseudonymizationSecret, TranscryptionInfo,
Expand Down Expand Up @@ -184,3 +185,23 @@ impl Transcryptor {
super::batch::transcrypt_batch(encrypted, transcryption_info, rng)
}
}

impl RekeyInfoProvider<AttributeRekeyInfo> for Transcryptor {
fn rekey_info(
&self,
session_from: &EncryptionContext,
session_to: &EncryptionContext,
) -> AttributeRekeyInfo {
self.attribute_rekey_info(session_from, session_to)
}
}

impl RekeyInfoProvider<PseudonymRekeyInfo> for Transcryptor {
fn rekey_info(
&self,
session_from: &EncryptionContext,
session_to: &EncryptionContext,
) -> PseudonymRekeyInfo {
self.pseudonym_rekey_info(session_from, session_to)
}
}
Loading