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

Extend blanket Parameterized{En,De}code impls #204

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

tgeoghegan
Copy link
Contributor

Extends the implementation of ParameterizedDecode<()> for D: Decode to
be ParameterizedDecode<T> for D: Decode, T, and similarly extends the
blanket ParameterizedEncode impl. This way, VDAFs like the fake one
in janus
that use () as their associated types can still satisfy
bounds like Self::VerifyParam: ParameterizedDecode<Self>. ()
satisfies the trivial trait bound T so this is strictly more
permissive than what was there before.

Extends the implementation of `ParameterizedDecode<()> for D: Decode` to
be `ParameterizedDecode<T> for D: Decode, T`, and similarly extends the
blanket `ParameterizedEncode` impl. This way, VDAFs like the [fake one
in `janus`][1] that use `()` as their associated types can still satisfy
bounds like `Self::VerifyParam: ParameterizedDecode<Self>`. `()`
satisfies the trivial trait bound `T` so this is strictly more
permissive than what was there before.

[1]: https://github.com/divviup/janus/blob/main/janus_server/src/aggregator.rs#L789
@tgeoghegan tgeoghegan requested a review from a team as a code owner April 6, 2022 21:38
@tgeoghegan tgeoghegan requested a review from cjpatton April 6, 2022 21:38
@tgeoghegan
Copy link
Contributor Author

The motivation here: Prio3VerifyParam is ParameterizedDecode<Prio3<...>> and Poplar1VerifyParam is ParameterizedDecode<Poplar1<...>>. The fake VDAF in Janus follows that pattern, and its VerifyParam is (), so we need this broader blanket impl so that #55 can do:

impl<A, C> Aggregator<A, C>
where
    A: 'static + vdaf::Aggregator,
    A::AggregationParam: Send + Sync,
    A::VerifyParam: ParameterizedDecode<A>, // <-- this is the trait bound enabled by this change
    for<'a> &'a A::AggregateShare: Into<Vec<u8>>,
    A::PrepareStep: Send + Sync + Encode + ParameterizedDecode<A::VerifyParam>,
    A::OutputShare: Send + Sync + for<'a> TryFrom<&'a [u8]>,
    for<'a> &'a A::OutputShare: Into<Vec<u8>>,
    C: Clock,
{ ... }

I need that trait bound on janus::aggregator::Aggregator so that its constructor can decode a verify param from bytes.

@tgeoghegan tgeoghegan merged commit bc11957 into main Apr 6, 2022
@tgeoghegan tgeoghegan deleted the timg/unit-type-blanket-codec branch October 12, 2022 19:21
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