Sitelet https://github.com/erigontech/silkpre/commit/02ee7dfd5e5cb82dfba0578f11b4d72fa01735aa
Skip to content

Commit 02ee7df

Browse files
committed
Expose secp256k1_ecdh
1 parent 873f488 commit 02ee7df

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ else()
7575
target_compile_definitions(secp256k1 PUBLIC USE_FIELD_5X52 USE_SCALAR_4X64 HAVE___INT128)
7676
endif()
7777
target_compile_definitions(secp256k1 PUBLIC ECMULT_WINDOW_SIZE=15 ECMULT_GEN_PREC_BITS=4 USE_ENDOMORPHISM)
78+
target_compile_definitions(secp256k1 PUBLIC ENABLE_MODULE_ECDH)
7879
target_compile_definitions(secp256k1 PUBLIC ENABLE_MODULE_RECOVERY)
7980
target_include_directories(secp256k1 PRIVATE secp256k1 INTERFACE third_party/secp256k1/include)
8081

‎lib/silkpre/ecdsa.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <string.h>
2020

2121
#include <ethash/keccak.h>
22+
#include <secp256k1_ecdh.h>
2223
#include <secp256k1_recovery.h>
2324

2425
//! \brief Tries recover public key used for message signing.
@@ -62,3 +63,12 @@ bool silkpre_recover_address(uint8_t out[20], const uint8_t message[32], const u
6263
}
6364
return public_key_to_address(out, public_key);
6465
}
66+
67+
bool silkpre_secp256k1_ecdh(
68+
const secp256k1_context* context,
69+
uint8_t* output,
70+
const secp256k1_pubkey* public_key,
71+
const uint8_t* private_key) {
72+
73+
return secp256k1_ecdh(context, output, public_key, private_key, NULL, NULL);
74+
}

‎lib/silkpre/ecdsa.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ enum { SILKPRE_SECP256K1_CONTEXT_FLAGS = (SECP256K1_CONTEXT_SIGN | SECP256K1_CON
3939
bool silkpre_recover_address(uint8_t out[20], const uint8_t message[32], const uint8_t signature[64], bool odd_y_parity,
4040
secp256k1_context* context);
4141

42+
bool silkpre_secp256k1_ecdh(
43+
const secp256k1_context* context,
44+
uint8_t* output,
45+
const secp256k1_pubkey* public_key,
46+
const uint8_t* private_key);
47+
4248
#if defined(__cplusplus)
4349
}
4450
#endif

0 commit comments

Comments
 (0)