Skip to content

Commit

Permalink
rename lincomb_generic to lincomb and expose it.
Browse files Browse the repository at this point in the history
  • Loading branch information
ycscaly committed Nov 8, 2023
1 parent d66e8ac commit bdab1e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions k256/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub(crate) mod scalar;
mod dev;

pub use field::FieldElement;
pub use mul::lincomb;

use self::{affine::AffinePoint, projective::ProjectivePoint, scalar::Scalar};
use crate::Secp256k1;
Expand Down
6 changes: 3 additions & 3 deletions k256/src/arithmetic/mul.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ fn static_zip_map<T: Copy, S: Copy, V: Copy, const N: usize>(

/// Calculates a linear combination `sum(x[i] * k[i])`, `i = 0..N`
#[inline(always)]
fn lincomb_generic<const N: usize>(xs: &[ProjectivePoint; N], ks: &[Scalar; N]) -> ProjectivePoint {
pub fn lincomb<const N: usize>(xs: &[ProjectivePoint; N], ks: &[Scalar; N]) -> ProjectivePoint {
let rs = static_map(
|k| decompose_scalar(&k),
ks,
Expand Down Expand Up @@ -429,7 +429,7 @@ impl MulByGenerator for ProjectivePoint {

#[inline(always)]
fn mul(x: &ProjectivePoint, k: &Scalar) -> ProjectivePoint {
lincomb_generic(&[*x], &[*k])
lincomb(&[*x], &[*k])
}

impl LinearCombination for ProjectivePoint {
Expand All @@ -439,7 +439,7 @@ impl LinearCombination for ProjectivePoint {
y: &ProjectivePoint,
l: &Scalar,
) -> ProjectivePoint {
lincomb_generic(&[*x, *y], &[*k, *l])
lincomb(&[*x, *y], &[*k, *l])
}
}

Expand Down
2 changes: 2 additions & 0 deletions k256/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#[cfg(feature = "arithmetic")]
mod arithmetic;
#[cfg(feature = "arithmetic")]
pub use arithmetic::lincomb;

#[cfg(feature = "ecdh")]
pub mod ecdh;
Expand Down

0 comments on commit bdab1e5

Please sign in to comment.