-
Notifications
You must be signed in to change notification settings - Fork 125
Description
The function miller_loop takes an IntoIterator<Item = &'a (&'a _, &' _)> which agrees with the IntoIterator for a &Vec<(&_,&_)>, but basically nothing else.
There is no way to construct the outer &'a from iterator adapters, requiring a fresh allocation. Yet, you could easily make any collection work without the outer &'a using .into_iter().map(|t| *t) or |(x,y)| (x,y) or similar. I'd think the G2 prepared points are commonly ephemeral, so this requires two ephemeral data structures, one containing the prepared points, and one containing the references to them, while both sound superfluous.
We cannot wrap the current miller_loop in an interface that takes borrows, but maybe it'd work if miller_loop took them directly, so maybe try
fn miller_loop<I,P1,P2>(i: I) -> Self::Fqk
where
I: IntoIterator<Item=(P1,P2)>,
P1: Borrow<<Self::G1Affine as CurveAffine>::Prepared>,
P2: Borrow<<Self::G2Affine as CurveAffine>::Prepared>,
You could make Item: Borrow<(P1,P2)> too if you wanted backwards compatibility with the current interface, but I'd make callers use .into_iter().map(|t| *t) here myself.
In fact, you allocate internally anyways, so maybe one should favor &[P1,P2] over the iterator anyways, not sure.