You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This works fine, but requires generic code working with the Aggregator to specify L as an explicit const generic in functions that work with an Aggregator<L>; the Rust compiler is not yet clever enough to infer L.
I think we could work around this by instead specifying the verify key length as an associated constant, something like:
Each implementation of the Aggregator trait would then define its verify key length. Concrete VDAF implementations which want to support multiple verify key lengths (which I think is common) can keep the concrete struct implementing Aggregator generic on L, as it already is for e.g. Prio3:
I tried this out in 7b5ae53 and unfortunately got the following error:
error: generic parameters may not be used in const operations
--> src/vdaf.rs:200:27
|
200 | verify_key: &[u8; Self::VERIFY_KEY_LEN],
| ^^^^^^^^^^^^^^^^^^^^ cannot perform const operation using `Self`
|
= note: type parameters may not be used in const expressions
Googling finds rust-lang/rust#60551 -- it doesn't look like there's any reason this code couldn't work, the Rust maintainers simply haven't gotten around to stabilizing it yet. :-(
Currently, the length of an Aggregator's verify key length is defined by the const generic
L
parameter on theAggregator
trait:libprio-rs/src/vdaf.rs
Line 173 in 7b8a9bc
This works fine, but requires generic code working with the
Aggregator
to specifyL
as an explicit const generic in functions that work with anAggregator<L>
; the Rust compiler is not yet clever enough to inferL
.I think we could work around this by instead specifying the verify key length as an associated constant, something like:
Each implementation of the
Aggregator
trait would then define its verify key length. Concrete VDAF implementations which want to support multiple verify key lengths (which I think is common) can keep the concrete struct implementingAggregator
generic onL
, as it already is for e.g.Prio3
:libprio-rs/src/vdaf/prio3.rs
Line 315 in 7b8a9bc
Example Rust playground showing this technique: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e4507e8cb4677ffef618304f3ec9d0e4
This suggestion would be a breaking change, so it should be implemented as part of a major version cutover.
The text was updated successfully, but these errors were encountered: