Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/modules/recovery/main_impl.h
/********************************************************************** | /********************************************************************** | ||||
* Copyright (c) 2013-2015 Pieter Wuille * | * Copyright (c) 2013-2015 Pieter Wuille * | ||||
* Distributed under the MIT software license, see the accompanying * | * Distributed under the MIT software license, see the accompanying * | ||||
* file COPYING or http://www.opensource.org/licenses/mit-license.php.* | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* | ||||
**********************************************************************/ | **********************************************************************/ | ||||
#ifndef _SECP256K1_MODULE_RECOVERY_MAIN_ | #ifndef SECP256K1_MODULE_RECOVERY_MAIN_H | ||||
#define _SECP256K1_MODULE_RECOVERY_MAIN_ | #define SECP256K1_MODULE_RECOVERY_MAIN_H | ||||
#include "include/secp256k1_recovery.h" | #include "include/secp256k1_recovery.h" | ||||
static void secp256k1_ecdsa_recoverable_signature_load(const secp256k1_context* ctx, secp256k1_scalar* r, secp256k1_scalar* s, int* recid, const secp256k1_ecdsa_recoverable_signature* sig) { | static void secp256k1_ecdsa_recoverable_signature_load(const secp256k1_context* ctx, secp256k1_scalar* r, secp256k1_scalar* s, int* recid, const secp256k1_ecdsa_recoverable_signature* sig) { | ||||
(void)ctx; | (void)ctx; | ||||
if (sizeof(secp256k1_scalar) == 32) { | if (sizeof(secp256k1_scalar) == 32) { | ||||
/* When the secp256k1_scalar type is exactly 32 byte, use its | /* When the secp256k1_scalar type is exactly 32 byte, use its | ||||
* representation inside secp256k1_ecdsa_signature, as conversion is very fast. | * representation inside secp256k1_ecdsa_signature, as conversion is very fast. | ||||
▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | if (secp256k1_ecdsa_sig_recover(&ctx->ecmult_ctx, &r, &s, &q, &m, recid)) { | ||||
secp256k1_pubkey_save(pubkey, &q); | secp256k1_pubkey_save(pubkey, &q); | ||||
return 1; | return 1; | ||||
} else { | } else { | ||||
memset(pubkey, 0, sizeof(*pubkey)); | memset(pubkey, 0, sizeof(*pubkey)); | ||||
return 0; | return 0; | ||||
} | } | ||||
} | } | ||||
#endif | #endif /* SECP256K1_MODULE_RECOVERY_MAIN_H */ |