mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-10 21:21:13 +00:00
Add multiscalar_mult to Decaf.
This commit is contained in:
parent
d2ce1ce5dc
commit
ddaf602a09
1 changed files with 18 additions and 0 deletions
18
src/decaf.rs
18
src/decaf.rs
|
|
@ -577,6 +577,24 @@ impl<'a, 'b> Mul<&'b DecafPoint> for &'a Scalar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Given a vector of (possibly secret) scalars and a vector of
|
||||||
|
/// (possibly secret) points, compute `c_1 P_1 + ... + c_n P_n`.
|
||||||
|
///
|
||||||
|
/// This function has the same behaviour as
|
||||||
|
/// `vartime::multiscalar_mult` but is constant-time.
|
||||||
|
///
|
||||||
|
/// # Input
|
||||||
|
///
|
||||||
|
/// A vector of `Scalar`s and a vector of `DecafPoints`. It is an
|
||||||
|
/// error to call this function with two vectors of different lengths.
|
||||||
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
|
pub fn multiscalar_mult<'a, 'b, I, J>(scalars: I, points: J) -> DecafPoint
|
||||||
|
where I: IntoIterator<Item = &'a Scalar>,
|
||||||
|
J: IntoIterator<Item = &'b DecafPoint>,
|
||||||
|
{
|
||||||
|
let extended_points = points.into_iter().map(|P| &P.0);
|
||||||
|
DecafPoint(curve::multiscalar_mult(scalars, extended_points))
|
||||||
|
}
|
||||||
|
|
||||||
/// Precomputation
|
/// Precomputation
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue