Add ecdsa_sign_recoverable to the ctime tests
This commit is contained in:
parent
2876af4f8d
commit
73596a85a2
|
@ -12,6 +12,10 @@
|
||||||
# include "include/secp256k1_ecdh.h"
|
# include "include/secp256k1_ecdh.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_MODULE_RECOVERY
|
||||||
|
# include "include/secp256k1_recovery.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
secp256k1_context* ctx;
|
secp256k1_context* ctx;
|
||||||
secp256k1_ecdsa_signature signature;
|
secp256k1_ecdsa_signature signature;
|
||||||
|
@ -24,6 +28,10 @@ int main(void) {
|
||||||
unsigned char key[32];
|
unsigned char key[32];
|
||||||
unsigned char sig[74];
|
unsigned char sig[74];
|
||||||
unsigned char spubkey[33];
|
unsigned char spubkey[33];
|
||||||
|
#if ENABLE_MODULE_RECOVERY
|
||||||
|
secp256k1_ecdsa_recoverable_signature recoverable_signature;
|
||||||
|
int recid;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!RUNNING_ON_VALGRIND) {
|
if (!RUNNING_ON_VALGRIND) {
|
||||||
fprintf(stderr, "This test can only usefully be run inside valgrind.\n");
|
fprintf(stderr, "This test can only usefully be run inside valgrind.\n");
|
||||||
|
@ -67,6 +75,17 @@ int main(void) {
|
||||||
CHECK(ret == 1);
|
CHECK(ret == 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ENABLE_MODULE_RECOVERY
|
||||||
|
/* Test signing a recoverable signature. */
|
||||||
|
VALGRIND_MAKE_MEM_UNDEFINED(key, 32);
|
||||||
|
ret = secp256k1_ecdsa_sign_recoverable(ctx, &recoverable_signature, msg, key, NULL, NULL);
|
||||||
|
VALGRIND_MAKE_MEM_DEFINED(&recoverable_signature, sizeof(recoverable_signature));
|
||||||
|
VALGRIND_MAKE_MEM_DEFINED(&ret, sizeof(ret));
|
||||||
|
CHECK(ret);
|
||||||
|
CHECK(secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx, sig, &recid, &recoverable_signature));
|
||||||
|
CHECK(recid >= 0 && recid <= 3);
|
||||||
|
#endif
|
||||||
|
|
||||||
VALGRIND_MAKE_MEM_UNDEFINED(key, 32);
|
VALGRIND_MAKE_MEM_UNDEFINED(key, 32);
|
||||||
ret = secp256k1_ec_seckey_verify(ctx, key);
|
ret = secp256k1_ec_seckey_verify(ctx, key);
|
||||||
VALGRIND_MAKE_MEM_DEFINED(&ret, sizeof(ret));
|
VALGRIND_MAKE_MEM_DEFINED(&ret, sizeof(ret));
|
||||||
|
|
Loading…
Reference in New Issue