From 20bc9200b2c28172cb5e04ccbd1cde5a6e47fa79 Mon Sep 17 00:00:00 2001 From: Christopher Patton Date: Mon, 13 Jan 2025 13:03:26 -0800 Subject: [PATCH] Move `szk` module from `flp` to `vdaf::mastic` Some of the implementation details of SZK are, for the moment, specific to Mastic. For example, the domain separation tag for each XOF invocation is prefixed by `b"mastic"`. It therefore makes sense to move this module to `mastic` until such time we need to refactor in order to use SZK in multiple places. --- src/flp.rs | 2 -- src/vdaf.rs | 4 ++-- src/vdaf/mastic.rs | 15 ++++++++------- src/{flp => vdaf/mastic}/szk.rs | 0 4 files changed, 10 insertions(+), 11 deletions(-) rename src/{flp => vdaf/mastic}/szk.rs (100%) diff --git a/src/flp.rs b/src/flp.rs index a34f3cf0..d6e1bdf8 100644 --- a/src/flp.rs +++ b/src/flp.rs @@ -57,8 +57,6 @@ use std::convert::TryFrom; use std::fmt::Debug; pub mod gadgets; -#[cfg(all(feature = "crypto-dependencies", feature = "experimental"))] -pub mod szk; pub mod types; /// Errors propagated by methods in this module. diff --git a/src/vdaf.rs b/src/vdaf.rs index c992869b..c76bf456 100644 --- a/src/vdaf.rs +++ b/src/vdaf.rs @@ -8,10 +8,10 @@ #[cfg(feature = "experimental")] use crate::dp::DifferentialPrivacyStrategy; #[cfg(all(feature = "crypto-dependencies", feature = "experimental"))] -use crate::flp::szk::SzkError; -#[cfg(all(feature = "crypto-dependencies", feature = "experimental"))] use crate::idpf::IdpfError; #[cfg(all(feature = "crypto-dependencies", feature = "experimental"))] +use crate::vdaf::mastic::szk::SzkError; +#[cfg(all(feature = "crypto-dependencies", feature = "experimental"))] use crate::vidpf::VidpfError; use crate::{ codec::{CodecError, Decode, Encode, ParameterizedDecode}, diff --git a/src/vdaf/mastic.rs b/src/vdaf/mastic.rs index f0bf9a4a..0b165552 100644 --- a/src/vdaf/mastic.rs +++ b/src/vdaf/mastic.rs @@ -8,10 +8,7 @@ use crate::{ bt::BinaryTree, codec::{CodecError, Decode, Encode, ParameterizedDecode}, field::{decode_fieldvec, FieldElement, FieldElementWithInteger}, - flp::{ - szk::{Szk, SzkInputShare, SzkJointShare, SzkQueryShare, SzkQueryState}, - Type, - }, + flp::Type, vdaf::{ poplar1::{Poplar1, Poplar1AggregationParam}, xof::{Seed, Xof}, @@ -24,6 +21,8 @@ use crate::{ }, }; +use szk::{Szk, SzkInputShare, SzkJointShare, SzkQueryShare, SzkQueryState}; + use rand::prelude::*; use std::io::{Cursor, Read}; use std::ops::BitAnd; @@ -33,6 +32,8 @@ use subtle::{Choice, ConstantTimeEq}; use super::xof::XofTurboShake128; +pub(crate) mod szk; + pub(crate) const SEED_SIZE: usize = 32; pub(crate) const NONCE_SIZE: usize = 16; @@ -319,9 +320,9 @@ impl Client<16> for Mastic { /// Mastic preparation state. /// -/// State held by an aggregator waiting for a message during Mastic preparation. Includes intermediate -/// state for [`Szk`] verification, the output shares currently being validated, and -/// parameters of Mastic used for encoding. +/// State held by an aggregator waiting for a message during Mastic preparation. Includes +/// intermediate state for the evaluation check, the range check (if applicable) verification, and +/// the output shares currently being validated. #[derive(Clone, Debug, Eq, PartialEq)] pub struct MasticPrepareState { /// The counter and truncated weight for each candidate prefix. diff --git a/src/flp/szk.rs b/src/vdaf/mastic/szk.rs similarity index 100% rename from src/flp/szk.rs rename to src/vdaf/mastic/szk.rs