Add missing Ristretto vartime-double-base fn

This commit is contained in:
Henry de Valence 2018-07-16 22:22:21 -07:00
parent 5bb6cd42a2
commit f7f3f79da8
2 changed files with 20 additions and 9 deletions

View file

@ -587,16 +587,12 @@ impl EdwardsPoint {
pub fn vartime_double_scalar_mul_basepoint(a: &Scalar, A: &EdwardsPoint, b: &Scalar) -> EdwardsPoint {
// If we built with AVX2, use the AVX2 backend.
#[cfg(all(feature="avx2_backend", target_feature="avx2"))]
{
use backend::avx2::scalar_mul::vartime_double_base::mul;
mul(a, A, b)
}
// Otherwise, proceed as normal:
use backend::avx2::scalar_mul::vartime_double_base;
// Otherwise, use the serial backend:
#[cfg(not(all(feature="avx2_backend", target_feature="avx2")))]
{
use scalar_mul::vartime_double_base::mul;
mul(a, A, b)
}
use scalar_mul::vartime_double_base;
vartime_double_base::mul(a, A, b)
}
}

View file

@ -830,6 +830,21 @@ impl VartimeMultiscalarMul for RistrettoPoint {
}
}
impl RistrettoPoint {
/// Compute \\(aA + bB\\) in variable time, where \\(B\\) is the
/// Ristretto basepoint.
#[cfg(feature = "stage2_build")]
pub fn vartime_double_scalar_mul_basepoint(
a: &Scalar,
A: &RistrettoPoint,
b: &Scalar,
) -> RistrettoPoint {
RistrettoPoint(
EdwardsPoint::vartime_double_scalar_mul_basepoint(a, &A.0, b)
)
}
}
/// A precomputed table of multiples of a basepoint, used to accelerate
/// scalar multiplication.
///