Skip to content

Commit

Permalink
Feature gate ppoprf key sync
Browse files Browse the repository at this point in the history
  • Loading branch information
DJAndries committed Aug 26, 2024
1 parent 70a4bd6 commit 3fff75c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ppoprf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ warp = "0.3.7"
[[bench]]
name = "bench"
harness = false

[features]
key-sync = []
5 changes: 5 additions & 0 deletions ppoprf/src/ppoprf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ where
/// Structure containing all relevant key information
/// for syncing between Server instances.
/// To be used for deserialization.
#[cfg(feature = "key-sync")]
#[derive(Deserialize)]
pub struct ServerKeyState {
oprf_key: RistrettoScalar,
Expand All @@ -315,13 +316,15 @@ pub struct ServerKeyState {
/// Structure containing all relevant key information
/// for syncing between Server instances.
/// To be used for serialization.
#[cfg(feature = "key-sync")]
#[derive(Serialize, Eq, PartialEq, Debug)]
pub struct ServerKeyStateRef<'a> {
oprf_key: &'a RistrettoScalar,
public_key: &'a ServerPublicKey,
ggm_key: &'a GGMPuncturableKey,
}

#[cfg(feature = "key-sync")]
impl ServerKeyState {
pub fn as_ref(&self) -> ServerKeyStateRef<'_> {
ServerKeyStateRef {
Expand Down Expand Up @@ -402,6 +405,7 @@ impl Server {
self.public_key.clone()
}

#[cfg(feature = "key-sync")]
pub fn get_private_key(&self) -> ServerKeyStateRef<'_> {
ServerKeyStateRef {
oprf_key: &self.oprf_key,
Expand All @@ -410,6 +414,7 @@ impl Server {
}
}

#[cfg(feature = "key-sync")]
pub fn set_private_key(&mut self, private_key: ServerKeyState) {
self.oprf_key = private_key.oprf_key;
self.public_key = private_key.public_key;
Expand Down

0 comments on commit 3fff75c

Please sign in to comment.