Skip to content

Deduplicate VdafConfig and VDAF constructor arguments (#4711) - #4793

Merged
jcjones merged 4 commits into
mainfrom
jcj/4711-dedup-vdafconfig-and-new-histogram
Aug 13, 2026
Merged

Deduplicate VdafConfig and VDAF constructor arguments (#4711)#4793
jcjones merged 4 commits into
mainfrom
jcj/4711-dedup-vdafconfig-and-new-histogram

Conversation

@jcjones

@jcjones jcjones commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

As David pointed out (see #4711), building a client or collector required stating the VDAF's parameters twice: once to Prio3::new_histogram(2, 12, 4) and again as VdafConfig::Prio3Histogram { length: 12, chunk_length: 4 }. And a mismatch wasn't not a compile error, just a silent HPKE AAD byte-identity bug that surfaces as a decryption failure at the aggregator.

This adds ConfiguredVdaf<V> -- it holds a concrete VDAF alongside the VdafConfig describing it, with prio3_* constructors that build both from one set of parameters.

It also adds Client::builder_from_configured_vdaf, Collector::builder_from_configured_vdaf, and CollectorBuilder::from_configured_vdaf.

with_vdaf_config remains for the configs with no concrete VDAF to derive from.

Note this uncovered two existing mismatches: the client's setup_client and the collector's setup_collector test helpers both hardcoded VdafConfig::Prio3Count while callers passed Prio3Sum, Prio3Histogram, and dummy::Vdaf. Oops.

As David pointed out (see #4711), building a client or collector required
stating the VDAF's parameters twice: once to `Prio3::new_histogram(2, 12, 4)`
and again as `VdafConfig::Prio3Histogram { length: 12, chunk_length: 4 }`.
And a mismatch wasn't not a compile error, just a silent HPKE AAD
byte-identity bug that surfaces as a decryption failure at the aggregator.

This adds `ConfiguredVdaf<V>` -- it holds a concrete VDAF alongside the `VdafConfig` describing
it, with `prio3_*` constructors that build both from one set of parameters.

It also adds `Client::builder_from_configured_vdaf`, `Collector::builder_from_configured_vdaf`,
and `CollectorBuilder::from_configured_vdaf`.

`with_vdaf_config` remains for the configs with no concrete VDAF to derive from.

Note this uncovered two existing mismatches: the client's `setup_client` and the
collector's `setup_collector` test helpers both hardcoded `VdafConfig::Prio3Count`
while callers passed Prio3Sum, Prio3Histogram, and `dummy::Vdaf`. Oops.
@jcjones
jcjones marked this pull request as ready for review August 10, 2026 20:50
@jcjones
jcjones requested a review from a team as a code owner August 10, 2026 20:50
Comment thread client/src/lib.rs Outdated

/// Creates a [`ClientBuilder`] from the required set of DAP task parameters and a
/// [`ConfiguredVdaf`], which supplies both the VDAF and its [`VdafConfig`].
pub fn builder_from_configured_vdaf(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be the main entry point that people use, so I suggest renaming methods so that this is Client::builder(), and the one above as Client::builder_with_custom_vdaf() or similar.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, I should have thought of that -- but I am so glad you did!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread client/src/lib.rs Outdated
Comment on lines 529 to 537

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We could add a VdafConfig to the arguments here, since it is always required, and it should be tightly coupled to the vdaf: V argument. Then, we could get rid of the with_vdaf_config() method on the builder.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread collector/src/lib.rs Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similarly, I suggest adding a VdafConfig argument to this, renaming builder() to builder_with_custom_vdaf() or similar, and builder_from_configured_vdaf() to builder().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jcjones
jcjones requested a review from divergentdave August 12, 2026 23:37
@jcjones
jcjones merged commit a46eedb into main Aug 13, 2026
8 checks passed
@jcjones
jcjones deleted the jcj/4711-dedup-vdafconfig-and-new-histogram branch August 13, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants