Create a new scalar_mul module hierarchy.

This should contain generic implementations of scalar multiplication algorithms
that can be used with multiple backends.  The goal is to move the existing
scalar multiplication code into this submodule, then call it from the
user-facing API.  This can also contain code for things we can't do now, like
multiscalar multiplication with precomputation.
This commit is contained in:
Henry de Valence 2018-03-20 12:10:39 -07:00
parent ed4b1c6b6b
commit 76a8d43a04
7 changed files with 24 additions and 5 deletions

View file

@ -54,6 +54,8 @@ mod field;
mod curve_models;
#[path="src/backend/mod.rs"]
mod backend;
#[path="src/scalar_mul/mod.rs"]
mod scalar_mul;
use edwards::EdwardsBasepointTable;
@ -77,9 +79,9 @@ use backend::u32::field::FieldElement32;
use edwards::EdwardsBasepointTable;
use curve_models::window::LookupTable;
use curve_models::AffineNielsPoint;
use scalar_mul::window::LookupTable;
/// Table containing precomputed multiples of the Ed25519 basepoint \\\\(B = (x, 4/5)\\\\).
pub const ED25519_BASEPOINT_TABLE: EdwardsBasepointTable = ED25519_BASEPOINT_TABLE_INNER_DOC_HIDDEN;

View file

@ -24,7 +24,7 @@ use subtle::Choice;
use edwards;
use scalar::Scalar;
use curve_models::window::LookupTable;
use scalar_mul::window::LookupTable;
use traits::Identity;

View file

@ -135,8 +135,6 @@ use field::FieldElement;
use edwards::EdwardsPoint;
use traits::ValidityCheck;
pub mod window;
// ------------------------------------------------------------------------
// Internal point representations
// ------------------------------------------------------------------------

View file

@ -117,7 +117,7 @@ use curve_models::CompletedPoint;
use curve_models::AffineNielsPoint;
use curve_models::ProjectiveNielsPoint;
use curve_models::window::LookupTable;
use scalar_mul::window::LookupTable;
use traits::{Identity, IsIdentity};
use traits::ValidityCheck;

View file

@ -67,14 +67,19 @@ pub(crate) mod macros;
// Scalar arithmetic mod l = 2^252 + ..., the order of the Ristretto group
pub mod scalar;
// Point operations on the Montgomery form of Curve25519
pub mod montgomery;
// Point operations on the Edwards form of Curve25519
pub mod edwards;
// Group operations on the Ristretto group
pub mod ristretto;
// Useful constants, like the Ed25519 basepoint
pub mod constants;
// External (and internal) traits.
pub mod traits;
@ -90,3 +95,6 @@ pub(crate) mod backend;
// Internal curve models which are not part of the public API.
pub(crate) mod curve_models;
// Implementations of scalar mul algorithms live here
pub(crate) mod scalar_mul;

11
src/scalar_mul/mod.rs Normal file
View file

@ -0,0 +1,11 @@
// -*- mode: rust; -*-
//
// This file is part of curve25519-dalek.
// Copyright (c) 2016-2018 Isis Lovecruft, Henry de Valence
// See LICENSE for licensing information.
//
// Authors:
// - Isis Agora Lovecruft <isis@patternsinthevoid.net>
// - Henry de Valence <hdevalence@hdevalence.ca>
pub mod window;