12
12
# include "include/secp256k1_ecdh.h"
13
13
#endif
14
14
15
+ #if ENABLE_MODULE_RECOVERY
16
+ # include "include/secp256k1_recovery.h"
17
+ #endif
18
+
15
19
int main (void ) {
16
20
secp256k1_context * ctx ;
17
21
secp256k1_ecdsa_signature signature ;
@@ -24,6 +28,10 @@ int main(void) {
24
28
unsigned char key [32 ];
25
29
unsigned char sig [74 ];
26
30
unsigned char spubkey [33 ];
31
+ #if ENABLE_MODULE_RECOVERY
32
+ secp256k1_ecdsa_recoverable_signature recoverable_signature ;
33
+ int recid ;
34
+ #endif
27
35
28
36
if (!RUNNING_ON_VALGRIND ) {
29
37
fprintf (stderr , "This test can only usefully be run inside valgrind.\n" );
@@ -67,6 +75,17 @@ int main(void) {
67
75
CHECK (ret == 1 );
68
76
#endif
69
77
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
+
70
89
VALGRIND_MAKE_MEM_UNDEFINED (key , 32 );
71
90
ret = secp256k1_ec_seckey_verify (ctx , key );
72
91
VALGRIND_MAKE_MEM_DEFINED (& ret , sizeof (ret ));
0 commit comments