solana_curve25519::curve_syscall_traits

Trait MultiScalarMultiplication

Source
pub trait MultiScalarMultiplication {
    type Scalar;
    type Point;

    // Required method
    fn multiscalar_multiply(
        scalars: &[Self::Scalar],
        points: &[Self::Point],
    ) -> Option<Self::Point>;
}

Required Associated Types§

Required Methods§

Source

fn multiscalar_multiply( scalars: &[Self::Scalar], points: &[Self::Point], ) -> Option<Self::Point>

Given a vector of scalsrs S_1, …, S_N, and curve points P_1, …, P_N, computes the “inner product”: S_1P_1 + … + S_NP_N.

NOTE: This operation can be represented by combining add and multiply functions in GroupOperations, but computing it in a single batch is significantly cheaper. Given how commonly used the multiscalar multiplication (MSM) is, it seems to make sense to have a designated trait for MSM support.

NOTE: The inputs to the function is a non-fixed size vector and hence, there are some complications in computing the cost for the syscall. The computational costs should only depend on the length of the vectors (and the curve), so it would be ideal to support variable length inputs and compute the syscall cost as is done in eip-197: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-197.md#gas-costs. If not, then we can consider bounding the length of the input and assigning worst-case cost.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§