primeorder/
mul_backend.rs1#[cfg(feature = "basepoint-table")]
4mod precomputed_tables;
5mod variable_only;
6
7use crate::{PrimeCurveParams, ProjectivePoint};
8use elliptic_curve::Scalar;
9use elliptic_curve::ops::LinearCombination;
10
11#[cfg(feature = "basepoint-table")]
12pub use self::precomputed_tables::PrecomputedTables;
13pub use self::variable_only::VariableOnly;
14
15pub trait MulBackend<C: PrimeCurveParams> {
17 #[inline]
21 fn mul_by_generator(k: &Scalar<C>) -> ProjectivePoint<C> {
22 ProjectivePoint::GENERATOR * k
23 }
24
25 #[inline]
29 fn mul_by_generator_vartime(k: &Scalar<C>) -> ProjectivePoint<C> {
30 ProjectivePoint::GENERATOR.mul_vartime(k)
31 }
32
33 #[inline]
36 fn mul_by_generator_and_mul_add_vartime(
37 a: &Scalar<C>,
38 b_scalar: &Scalar<C>,
39 b_point: &ProjectivePoint<C>,
40 ) -> ProjectivePoint<C> {
41 ProjectivePoint::<C>::lincomb_vartime(&[
42 (ProjectivePoint::GENERATOR, *a),
43 (*b_point, *b_scalar),
44 ])
45 }
46}