Skip to content

Commit

Permalink
ecp_curves: Renamed ecp_mod_p256k1 -> mbedtls_ecp_mod_p256k1
Browse files Browse the repository at this point in the history
Signed-off-by: Minos Galanakis <[email protected]>
  • Loading branch information
minosgalanakis committed Apr 21, 2023
1 parent 014d938 commit 1ef49e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion library/ecp_curves.c
Original file line number Diff line number Diff line change
Expand Up @@ -4617,6 +4617,7 @@ MBEDTLS_STATIC_TESTABLE
int mbedtls_ecp_mod_p224k1(mbedtls_mpi *);
#endif
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
static int ecp_mod_p256k1(mbedtls_mpi *);
MBEDTLS_STATIC_TESTABLE
int ecp_mod_p256k1(mbedtls_mpi *);
#endif
Expand Down Expand Up @@ -5656,12 +5657,18 @@ int mbedtls_ecp_mod_p224k1(mbedtls_mpi *N)
#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */

#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)

static int ecp_mod_p256k1(mbedtls_mpi *N)
{
return mbedtls_ecp_mod_p256k1(N);
}

/*
* Fast quasi-reduction modulo p256k1 = 2^256 - R,
* with R = 2^32 + 2^9 + 2^8 + 2^7 + 2^6 + 2^4 + 1 = 0x01000003D1
*/
MBEDTLS_STATIC_TESTABLE
int ecp_mod_p256k1(mbedtls_mpi *N)
int mbedtls_ecp_mod_p256k1(mbedtls_mpi *N)
{
static mbedtls_mpi_uint Rp[] = {
MBEDTLS_BYTES_TO_T_UINT_8(0xD1, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00,
Expand Down
2 changes: 1 addition & 1 deletion library/ecp_invasive.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int mbedtls_ecp_mod_p224k1(mbedtls_mpi *N);
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)

MBEDTLS_STATIC_TESTABLE
int ecp_mod_p256k1(mbedtls_mpi *N);
int mbedtls_ecp_mod_p256k1(mbedtls_mpi *N);

#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */

Expand Down
2 changes: 1 addition & 1 deletion tests/suites/test_suite_ecp.function
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ void ecp_mod_p256k1(char *input_N,
&m, N, limbs,
MBEDTLS_MPI_MOD_REP_MONTGOMERY), 0);

TEST_EQUAL(ecp_mod_p256k1(&X), 0);
TEST_EQUAL(mbedtls_ecp_mod_p256k1(&X), 0);
TEST_LE_U(mbedtls_mpi_core_bitlen(X.p, X.n), 256);
mbedtls_mpi_mod_raw_fix_quasi_reduction(X.p, &m);
ASSERT_COMPARE(X.p, bytes, res, bytes);
Expand Down

0 comments on commit 1ef49e7

Please sign in to comment.