mbedtls_ecp_mul() function
This function performs a scalar multiplication of a point by an integer: \p R = \p m * \p P. It is not thread-safe to use same group in multiple threads.
Arguments
grp
The ECP group to use. This must be initialized and have group parameters set, for example through mbedtls_ecp_group_load().
R
The point in which to store the result of the calculation. This must be initialized.
m
The integer by which to multiply. This must be initialized.
P
The point to multiply. This must be initialized.
f_rng
The RNG function. This may be \c NULL if randomization of intermediate results isn't desired (discouraged).
p_rng
The RNG context to be passed to \p p_rng.
Return value
\c 0 on success. #MBEDTLS_ERR_ECP_INVALID_KEY if \p m is not a valid private key, or \p P is not a valid public key. #MBEDTLS_ERR_MPI_ALLOC_FAILED on memory-allocation failure. Another negative error code on other kinds of failure.
Notes
To prevent timing attacks, this function executes the exact same sequence of base-field operations for any valid \p m. It avoids any if-branch or array index depending on the value of \p m. If \p f_rng is not NULL, it is used to randomize intermediate results to prevent potential timing attacks targeting these results. We recommend always providing a non-NULL \p f_rng. The overhead is negligible.