mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-04 20:24:10 +00:00
Add Decaf wrapper for k-fold vartime
This commit is contained in:
parent
5100ba4a07
commit
a479b627a8
1 changed files with 25 additions and 0 deletions
25
src/decaf.rs
25
src/decaf.rs
|
|
@ -36,6 +36,7 @@ use collections::boxed::Box;
|
|||
#[cfg(all(feature = "std", feature = "basepoint_table_creation"))]
|
||||
use std::boxed::Box;
|
||||
|
||||
use curve;
|
||||
use curve::ExtendedPoint;
|
||||
use curve::EdwardsBasepointTable;
|
||||
use curve::BasepointMult;
|
||||
|
|
@ -304,6 +305,30 @@ impl Debug for DecafPoint {
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Variable-time functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
pub mod vartime {
|
||||
//! Variable-time operations on decaf points, useful for non-secret data.
|
||||
use super::*;
|
||||
|
||||
/// Given a vector of public scalars and a vector of (possibly secret)
|
||||
/// points, compute
|
||||
///
|
||||
/// c_1 P_1 + ... + c_n P_n.
|
||||
///
|
||||
/// # Input
|
||||
///
|
||||
/// A vector of `Scalar`s and a vector of `ExtendedPoints`. It is an
|
||||
/// error to call this function with two vectors of different lengths.
|
||||
pub fn k_fold_scalar_mult(scalars: &Vec<Scalar>,
|
||||
points: &Vec<DecafPoint>) -> DecafPoint {
|
||||
let extended_points: Vec<ExtendedPoint> = points.iter().map(|P| P.0).collect();
|
||||
DecafPoint(curve::vartime::k_fold_scalar_mult(scalars, &extended_points))
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests
|
||||
// ------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue