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

Refactor and cleaup daphne and daphne_worker crates #395

Merged
merged 8 commits into from
Sep 27, 2023
Merged
6 changes: 5 additions & 1 deletion daphne/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ name = "aggregation"
harness = false

[dependencies]
assert_matches.workspace = true
async-trait.workspace = true
assert_matches = { workspace = true, optional = true }
base64.workspace = true
futures.workspace = true
hex.workspace = true
Expand All @@ -41,7 +41,11 @@ tracing.workspace = true
url.workspace = true

[dev-dependencies]
assert_matches.workspace = true
criterion.workspace = true
matchit.workspace = true
paste.workspace = true
tokio.workspace = true

[features]
test-utils = ["dep:assert_matches"]
9 changes: 4 additions & 5 deletions daphne/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub mod messages;
pub mod metrics;
pub mod roles;
pub mod taskprov;
#[cfg(any(test, feature = "test-utils"))]
pub mod testing;
pub mod vdaf;

Expand Down Expand Up @@ -158,11 +159,9 @@ pub struct DapGlobalConfig {
/// receiver config.
pub supported_hpke_kems: Vec<HpkeKemId>,

/// Is the taskprov extension allowed?
pub allow_taskprov: bool,

/// Which taskprov draft should be used?
pub taskprov_version: TaskprovVersion,
/// Is the taskprov extension allowed and which taskprov draft should be used?
#[serde(default)]
pub taskprov_version: Option<TaskprovVersion>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't forget to make the corresponding change to the testing/staging/prod configs.

}

impl DapGlobalConfig {
Expand Down
11 changes: 8 additions & 3 deletions daphne/src/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const EXTENSION_TASKPROV: u16 = 0xff00;
macro_rules! id_struct {
($sname:ident, $len:expr, $doc:expr) => {
#[doc=$doc]
#[derive(Clone, Debug, Default, Deserialize, Hash, PartialEq, Eq, Serialize)]
#[derive(Clone, Default, Deserialize, Hash, PartialEq, Eq, Serialize)]
pub struct $sname(#[serde(with = "hex")] pub [u8; $len]);

impl $sname {
Expand Down Expand Up @@ -84,6 +84,12 @@ macro_rules! id_struct {
write!(f, "{}", self.to_hex())
}
}

impl fmt::Debug for $sname {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}({})", ::std::stringify!($sname), self.to_hex())
}
}
};
}

Expand Down Expand Up @@ -1171,9 +1177,8 @@ pub fn decode_base64url_vec<T: AsRef<[u8]>>(input: T) -> Option<Vec<u8>> {
mod test {
use super::*;

use crate::{test_version, test_versions};
use crate::test_versions;
use hpke_rs::HpkePublicKey;
use paste::paste;
use prio::codec::{Decode, Encode, ParameterizedDecode, ParameterizedEncode};
use rand::prelude::*;

Expand Down
Loading
Loading