From 3fff75c90efc34d0a169b100797322009a760ddc Mon Sep 17 00:00:00 2001 From: Darnell Andries Date: Mon, 26 Aug 2024 13:09:18 -0700 Subject: [PATCH] Feature gate ppoprf key sync --- ppoprf/Cargo.toml | 3 +++ ppoprf/src/ppoprf.rs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/ppoprf/Cargo.toml b/ppoprf/Cargo.toml index 2af946ae..c7a1136f 100644 --- a/ppoprf/Cargo.toml +++ b/ppoprf/Cargo.toml @@ -34,3 +34,6 @@ warp = "0.3.7" [[bench]] name = "bench" harness = false + +[features] +key-sync = [] diff --git a/ppoprf/src/ppoprf.rs b/ppoprf/src/ppoprf.rs index 0a8e3fe1..9bb28d3d 100644 --- a/ppoprf/src/ppoprf.rs +++ b/ppoprf/src/ppoprf.rs @@ -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, @@ -315,6 +316,7 @@ 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, @@ -322,6 +324,7 @@ pub struct ServerKeyStateRef<'a> { ggm_key: &'a GGMPuncturableKey, } +#[cfg(feature = "key-sync")] impl ServerKeyState { pub fn as_ref(&self) -> ServerKeyStateRef<'_> { ServerKeyStateRef { @@ -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, @@ -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;