Rm ecp_add() and add ecp_muladd()
diff --git a/library/ecp.c b/library/ecp.c
index f0fcc1f..52cedd3 100644
--- a/library/ecp.c
+++ b/library/ecp.c
@@ -1049,24 +1049,6 @@
}
/*
- * Addition: R = P + Q, result's coordinates normalized
- */
-int mbedtls_ecp_add( const mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
- const mbedtls_ecp_point *P, const mbedtls_ecp_point *Q )
-{
- int ret;
-
- if( ecp_get_type( grp ) != ECP_TYPE_SHORT_WEIERSTRASS )
- return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE );
-
- MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, P, Q ) );
- MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) );
-
-cleanup:
- return( ret );
-}
-
-/*
* Randomize jacobian coordinates:
* (X, Y, Z) -> (l^2 X, l^3 Y, l Z) for random l
* This is sort of the reverse operation of ecp_normalize_jac().
@@ -1684,6 +1666,32 @@
}
#endif /* ECP_SHORTWEIERSTRASS */
+/*
+ * Linear combination
+ */
+int mbedtls_ecp_muladd( mbedtls_ecp_group *grp, mbedtls_ecp_point *R,
+ const mbedtls_mpi *m, const mbedtls_ecp_point *P,
+ const mbedtls_mpi *n, const mbedtls_ecp_point *Q )
+{
+ int ret;
+ mbedtls_ecp_point mP;
+
+ if( ecp_get_type( grp ) != ECP_TYPE_SHORT_WEIERSTRASS )
+ return( MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE );
+
+ mbedtls_ecp_point_init( &mP );
+
+ MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, &mP, m, P, NULL, NULL ) );
+ MBEDTLS_MPI_CHK( mbedtls_ecp_mul( grp, R, n, Q, NULL, NULL ) );
+ MBEDTLS_MPI_CHK( ecp_add_mixed( grp, R, &mP, R ) );
+ MBEDTLS_MPI_CHK( ecp_normalize_jac( grp, R ) );
+
+cleanup:
+ mbedtls_ecp_point_free( &mP );
+
+ return( ret );
+}
+
#if defined(ECP_MONTGOMERY)
/*