Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC][oprf][shuffle] OPRF Shuffle using a 2-round 4-message shuffle protocol #809

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod oprf_shuffle;

use std::{
fmt::{Debug, Display, Formatter},
num::NonZeroU32,
Expand Down Expand Up @@ -206,6 +208,7 @@ pub enum QueryType {
MaliciousIpa(IpaQueryConfig),
SemiHonestSparseAggregate(SparseAggregateQueryConfig),
MaliciousSparseAggregate(SparseAggregateQueryConfig),
OPRFShuffle(oprf_shuffle::QueryConfig),
}

impl QueryType {
Expand All @@ -214,6 +217,7 @@ impl QueryType {
pub const MALICIOUS_IPA_STR: &'static str = "malicious-ipa";
pub const SEMIHONEST_AGGREGATE_STR: &'static str = "semihonest-sparse-aggregate";
pub const MALICIOUS_AGGREGATE_STR: &'static str = "malicious-sparse-aggregate";
pub const OPRF_SHUFFLE_STR: &'static str = "oprf-shuffle";
}

/// TODO: should this `AsRef` impl (used for `Substep`) take into account config of IPA?
Expand All @@ -226,6 +230,7 @@ impl AsRef<str> for QueryType {
QueryType::MaliciousIpa(_) => Self::MALICIOUS_IPA_STR,
QueryType::SemiHonestSparseAggregate(_) => Self::SEMIHONEST_AGGREGATE_STR,
QueryType::MaliciousSparseAggregate(_) => Self::MALICIOUS_AGGREGATE_STR,
QueryType::OPRFShuffle(_) => Self::OPRF_SHUFFLE_STR,
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/helpers/transport/query/oprf_shuffle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
pub struct QueryConfig {
pub bk_size: u8, // breakdown key size bits
pub tv_size: u8, // trigger value size bits
}

impl Default for QueryConfig {
fn default() -> Self {
Self {
bk_size: 40,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably be smaller.

tv_size: 40,
}
}
}
8 changes: 8 additions & 0 deletions src/net/http_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ pub mod query {
let Query(q) = req.extract().await?;
Ok(QueryType::MaliciousSparseAggregate(q))
}
QueryType::OPRF_SHUFFLE_STR => {
let Query(q) = req.extract().await?;
Ok(QueryType::OPRFShuffle(q))
}
other => Err(Error::bad_query_value("query_type", other)),
}?;
Ok(QueryConfigQueryParams(QueryConfig {
Expand Down Expand Up @@ -188,6 +192,10 @@ pub mod query {

Ok(())
}
QueryType::OPRFShuffle(config) => {
write!(f, "&bk_size={}&tv_size={}", config.bk_size, config.tv_size)?;
Ok(())
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/protocol/context/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod malicious;
pub mod oprf;
pub mod prss;
pub mod semi_honest;
pub mod upgrade;
Expand All @@ -8,6 +9,7 @@ use std::{num::NonZeroUsize, sync::Arc};

use async_trait::async_trait;
pub use malicious::{Context as MaliciousContext, Upgraded as UpgradedMaliciousContext};
pub use oprf::Context as OPRFContext;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover?

use prss::{InstrumentedIndexedSharedRandomness, InstrumentedSequentialSharedRandomness};
pub use semi_honest::{Context as SemiHonestContext, Upgraded as UpgradedSemiHonestContext};
pub use upgrade::{UpgradeContext, UpgradeToMalicious};
Expand Down
88 changes: 88 additions & 0 deletions src/protocol/context/oprf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
use std::num::NonZeroUsize;

use crate::{
helpers::{Gateway, Message, ReceivingEnd, Role, SendingEnd, TotalRecords},
protocol::{
context::{
Base, InstrumentedIndexedSharedRandomness, InstrumentedSequentialSharedRandomness,
},
prss::Endpoint as PrssEndpoint,
step::{Gate, Step, StepNarrow},
},
seq_join::SeqJoin,
};

#[derive(Clone)]
pub struct Context<'a> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this code?

inner: Base<'a>,
}

impl<'a> Context<'a> {
pub fn new(participant: &'a PrssEndpoint, gateway: &'a Gateway) -> Self {
Self {
inner: Base::new(participant, gateway),
}
}

#[cfg(test)]
#[must_use]
pub fn from_base(base: Base<'a>) -> Self {
Self { inner: base }
}
}

impl<'a> super::Context for Context<'a> {
fn role(&self) -> Role {
self.inner.role()
}

fn gate(&self) -> &Gate {
self.inner.gate()
}

fn narrow<S: Step + ?Sized>(&self, step: &S) -> Self
where
Gate: StepNarrow<S>,
{
Self {
inner: self.inner.narrow(step),
}
}

fn set_total_records<T: Into<TotalRecords>>(&self, total_records: T) -> Self {
Self {
inner: self.inner.set_total_records(total_records),
}
}

fn total_records(&self) -> TotalRecords {
self.inner.total_records()
}

fn prss(&self) -> InstrumentedIndexedSharedRandomness<'_> {
self.inner.prss()
}

fn prss_rng(
&self,
) -> (
InstrumentedSequentialSharedRandomness,
InstrumentedSequentialSharedRandomness,
) {
self.inner.prss_rng()
}

fn send_channel<M: Message>(&self, role: Role) -> SendingEnd<M> {
self.inner.send_channel(role)
}

fn recv_channel<M: Message>(&self, role: Role) -> ReceivingEnd<M> {
self.inner.recv_channel(role)
}
}

impl<'a> SeqJoin for Context<'a> {
fn active_work(&self) -> NonZeroUsize {
self.inner.active_work()
}
}
1 change: 1 addition & 0 deletions src/protocol/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod context;
pub mod dp;
pub mod ipa;
pub mod modulus_conversion;
pub mod oprf;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub mod oprf;
#[cfg(feature = "ipa-prf")]
pub mod oprf;

I used the ipa-prf feature which requires descriptive gate, but it hasn't landed yet but probably will land soon.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably not call this oprf since it is just a shuffle and a basic protocol that could be used in different context. It is not related to an oprf other than that we want to use it together with a prf/orpf in our new IPA version.

#[cfg(feature = "descriptive-gate")]
pub mod prf_sharding;
pub mod prss;
Expand Down
Loading
Loading