mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-06 20:41:14 +00:00
fixup! Allow Options in the VartimeMultiscalarMul trait
This commit is contained in:
parent
36ade94596
commit
f675f4cd2b
1 changed files with 11 additions and 7 deletions
|
|
@ -72,21 +72,24 @@ impl MultiscalarMul for Straus {
|
||||||
impl VartimeMultiscalarMul for Straus {
|
impl VartimeMultiscalarMul for Straus {
|
||||||
type Point = EdwardsPoint;
|
type Point = EdwardsPoint;
|
||||||
|
|
||||||
fn vartime_multiscalar_mul<I, J>(scalars: I, points: J) -> EdwardsPoint
|
fn optional_multiscalar_mul<I, J>(scalars: I, points: J) -> Option<EdwardsPoint>
|
||||||
where
|
where
|
||||||
I: IntoIterator,
|
I: IntoIterator,
|
||||||
I::Item: Borrow<Scalar>,
|
I::Item: Borrow<Scalar>,
|
||||||
J: IntoIterator,
|
J: IntoIterator<Item = Option<EdwardsPoint>>,
|
||||||
J::Item: Borrow<EdwardsPoint>,
|
|
||||||
{
|
{
|
||||||
let nafs: Vec<_> = scalars
|
let nafs: Vec<_> = scalars
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|c| c.borrow().non_adjacent_form(5))
|
.map(|c| c.borrow().non_adjacent_form(5))
|
||||||
.collect();
|
.collect();
|
||||||
let lookup_tables: Vec<_> = points
|
let lookup_tables: Vec<_> = match points
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|point| NafLookupTable5::<CachedPoint>::from(point.borrow()))
|
.map(|P_opt| P_opt.map(|P| NafLookupTable5::<CachedPoint>::from(&P)))
|
||||||
.collect();
|
.collect::<Option<Vec<_>>>()
|
||||||
|
{
|
||||||
|
Some(x) => x,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
let mut Q = ExtendedPoint::identity();
|
let mut Q = ExtendedPoint::identity();
|
||||||
|
|
||||||
|
|
@ -101,6 +104,7 @@ impl VartimeMultiscalarMul for Straus {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Q.into()
|
|
||||||
|
Some(Q.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue