Skip to content

Commit 73596a8

Browse files
committed
Add ecdsa_sign_recoverable to the ctime tests
1 parent 2876af4 commit 73596a8

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/valgrind_ctime_test.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
# include "include/secp256k1_ecdh.h"
1313
#endif
1414

15+
#if ENABLE_MODULE_RECOVERY
16+
# include "include/secp256k1_recovery.h"
17+
#endif
18+
1519
int main(void) {
1620
secp256k1_context* ctx;
1721
secp256k1_ecdsa_signature signature;
@@ -24,6 +28,10 @@ int main(void) {
2428
unsigned char key[32];
2529
unsigned char sig[74];
2630
unsigned char spubkey[33];
31+
#if ENABLE_MODULE_RECOVERY
32+
secp256k1_ecdsa_recoverable_signature recoverable_signature;
33+
int recid;
34+
#endif
2735

2836
if (!RUNNING_ON_VALGRIND) {
2937
fprintf(stderr, "This test can only usefully be run inside valgrind.\n");
@@ -67,6 +75,17 @@ int main(void) {
6775
CHECK(ret == 1);
6876
#endif
6977

78+
#if ENABLE_MODULE_RECOVERY
79+
/* Test signing a recoverable signature. */
80+
VALGRIND_MAKE_MEM_UNDEFINED(key, 32);
81+
ret = secp256k1_ecdsa_sign_recoverable(ctx, &recoverable_signature, msg, key, NULL, NULL);
82+
VALGRIND_MAKE_MEM_DEFINED(&recoverable_signature, sizeof(recoverable_signature));
83+
VALGRIND_MAKE_MEM_DEFINED(&ret, sizeof(ret));
84+
CHECK(ret);
85+
CHECK(secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx, sig, &recid, &recoverable_signature));
86+
CHECK(recid >= 0 && recid <= 3);
87+
#endif
88+
7089
VALGRIND_MAKE_MEM_UNDEFINED(key, 32);
7190
ret = secp256k1_ec_seckey_verify(ctx, key);
7291
VALGRIND_MAKE_MEM_DEFINED(&ret, sizeof(ret));

0 commit comments

Comments
 (0)