Trait curve25519_dalek::traits::VartimePrecomputedMultiscalarMul[][src]

pub trait VartimePrecomputedMultiscalarMul: Sized {
    type Point: Clone;
    fn new<I>(static_points: I) -> Self
    where
        I: IntoIterator,
        I::Item: Borrow<Self::Point>
;
fn optional_mixed_multiscalar_mul<I, J, K>(
        &self,
        static_scalars: I,
        dynamic_scalars: J,
        dynamic_points: K
    ) -> Option<Self::Point>
    where
        I: IntoIterator,
        I::Item: Borrow<Scalar>,
        J: IntoIterator,
        J::Item: Borrow<Scalar>,
        K: IntoIterator<Item = Option<Self::Point>>
; fn vartime_multiscalar_mul<I>(&self, static_scalars: I) -> Self::Point
    where
        I: IntoIterator,
        I::Item: Borrow<Scalar>
, { ... }
fn vartime_mixed_multiscalar_mul<I, J, K>(
        &self,
        static_scalars: I,
        dynamic_scalars: J,
        dynamic_points: K
    ) -> Self::Point
    where
        I: IntoIterator,
        I::Item: Borrow<Scalar>,
        J: IntoIterator,
        J::Item: Borrow<Scalar>,
        K: IntoIterator,
        K::Item: Borrow<Self::Point>
, { ... } }
Expand description

A trait for variable-time multiscalar multiplication with precomputation.

A general multiscalar multiplication with precomputation can be written as $$ Q = a_1 A_1 + \cdots + a_n A_n + b_1 B_1 + \cdots + b_m B_m, $$ where the \(B_i\) are static points, for which precomputation is possible, and the \(A_j\) are dynamic points, for which precomputation is not possible.

This trait has three methods for performing this computation:

  • [vartime_multiscalar_mul], which handles the special case where \(n = 0\) and there are no dynamic points;

  • [vartime_mixed_multiscalar_mul], which takes the dynamic points as already-validated Points and is infallible;

  • [optional_mixed_multiscalar_mul], which takes the dynamic points as Option<Point>s and returns an Option<Point>, allowing decompression to be composed into the input iterators.

All methods require that the lengths of the input iterators be known and matching, as if they were ExactSizeIterators. (It does not require ExactSizeIterator only because that trait is broken).

Associated Types

The type of point to be multiplied, e.g., RistrettoPoint.

Required methods

Given the static points \( B_i \), perform precomputation and return the precomputation data.

Given static_scalars, an iterator of public scalars \(b_i\), dynamic_scalars, an iterator of public scalars \(a_i\), and dynamic_points, an iterator of points \(A_i\), compute $$ Q = a_1 A_1 + \cdots + a_n A_n + b_1 B_1 + \cdots + b_m B_m, $$ where the \(B_j\) are the points that were supplied to new.

If any of the dynamic points were None, return None.

It is an error to call this function with iterators of inconsistent lengths.

This function is particularly useful when verifying statements involving compressed points. Accepting Option<Point> allows inlining point decompression into the multiscalar call, avoiding the need for temporary buffers.

Provided methods

Given static_scalars, an iterator of public scalars \(b_i\), compute $$ Q = b_1 B_1 + \cdots + b_m B_m, $$ where the \(B_j\) are the points that were supplied to new.

It is an error to call this function with iterators of inconsistent lengths.

The trait bound aims for maximum flexibility: the input must be convertable to iterators (I: IntoIter), and the iterator’s items must be Borrow<Scalar>, to allow iterators returning either Scalars or &Scalars.

Given static_scalars, an iterator of public scalars \(b_i\), dynamic_scalars, an iterator of public scalars \(a_i\), and dynamic_points, an iterator of points \(A_i\), compute $$ Q = a_1 A_1 + \cdots + a_n A_n + b_1 B_1 + \cdots + b_m B_m, $$ where the \(B_j\) are the points that were supplied to new.

It is an error to call this function with iterators of inconsistent lengths.

The trait bound aims for maximum flexibility: the inputs must be convertable to iterators (I: IntoIter), and the iterator’s items must be Borrow<Scalar> (or Borrow<Point>), to allow iterators returning either Scalars or &Scalars.

Implementors