From 383e65f6bd5df67079d40cd42e154fcb1c67216c Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Fri, 27 Dec 2019 12:54:52 +0000 Subject: [PATCH] Add a trait for implementing a basepoint table. --- src/traits.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/traits.rs b/src/traits.rs index b024c88..7fa269c 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -47,6 +47,21 @@ where } } +/// A precomputed table of basepoints, for optimising scalar multiplications. +pub trait BasepointTable { + /// The type of point contained within this table. + type Point; + + /// Generate a new precomputed basepoint table from the given basepoint. + fn create(basepoint: &Self::Point) -> Self; + + /// Retrieve the original basepoint from this table. + fn basepoint(&self) -> Self::Point; + + /// Multiply a `scalar` by this precomputed basepoint table, in constant time. + fn basepoint_mul(&self, scalar: &Scalar) -> Self::Point; +} + /// A trait for constant-time multiscalar multiplication without precomputation. pub trait MultiscalarMul { /// The type of point being multiplied, e.g., `RistrettoPoint`.