secp256k1_ecdsa_recoverable_signature: add support.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-10-26 13:31:19 +10:30
parent 753f15f503
commit a02ca46b03
4 changed files with 37 additions and 1 deletions

2
external/Makefile vendored
View File

@ -37,7 +37,7 @@ external/libsecp256k1.% external/libwallycore.%: external/libwally-core/src/secp
$(MAKE) -C external/libwally-core install-exec
external/libwally-core/src/libwallycore.% external/libwally-core/src/secp256k1/libsecp256k1.%: $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS)
cd external/libwally-core && ./tools/autogen.sh && ./configure CC="$(CC)" --enable-static=yes --enable-shared=no --libdir=`pwd`/.. && $(MAKE)
cd external/libwally-core && ./tools/autogen.sh && ./configure CC="$(CC)" --enable-static=yes --enable-module-recovery --enable-shared=no --libdir=`pwd`/.. && $(MAKE)
# Git submodules are seriously broken.
external/jsmn/jsmn.h:

View File

@ -129,6 +129,22 @@ void fromwire_secp256k1_ecdsa_signature(const u8 **cursor,
fromwire_fail(cursor, max);
}
void fromwire_secp256k1_ecdsa_recoverable_signature(const u8 **cursor,
size_t *max,
secp256k1_ecdsa_recoverable_signature *rsig)
{
u8 compact[64];
int recid;
fromwire(cursor, max, compact, sizeof(compact));
recid = fromwire_u8(cursor, max);
if (secp256k1_ecdsa_recoverable_signature_parse_compact(secp256k1_ctx,
rsig, compact,
recid) != 1)
fromwire_fail(cursor, max);
}
void fromwire_channel_id(const u8 **cursor, size_t *max,
struct channel_id *channel_id)
{

View File

@ -79,6 +79,20 @@ void towire_secp256k1_ecdsa_signature(u8 **pptr,
towire(pptr, compact, sizeof(compact));
}
void towire_secp256k1_ecdsa_recoverable_signature(u8 **pptr,
const secp256k1_ecdsa_recoverable_signature *rsig)
{
u8 compact[64];
int recid;
secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_ctx,
compact,
&recid,
rsig);
towire(pptr, compact, sizeof(compact));
towire_u8(pptr, recid);
}
void towire_channel_id(u8 **pptr, const struct channel_id *channel_id)
{
towire(pptr, channel_id, sizeof(*channel_id));

View File

@ -8,6 +8,7 @@
#include <bitcoin/signature.h>
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/short_types/short_types.h>
#include <secp256k1_recovery.h>
#include <stdlib.h>
struct channel_id {
@ -30,6 +31,8 @@ void towire_privkey(u8 **pptr, const struct privkey *privkey);
void towire_secret(u8 **pptr, const struct secret *secret);
void towire_secp256k1_ecdsa_signature(u8 **pptr,
const secp256k1_ecdsa_signature *signature);
void towire_secp256k1_ecdsa_recoverable_signature(u8 **pptr,
const secp256k1_ecdsa_recoverable_signature *rsig);
void towire_channel_id(u8 **pptr, const struct channel_id *channel_id);
void towire_short_channel_id(u8 **pptr,
const struct short_channel_id *short_channel_id);
@ -57,6 +60,9 @@ void fromwire_privkey(const u8 **cursor, size_t *max, struct privkey *privkey);
void fromwire_pubkey(const u8 **cursor, size_t *max, struct pubkey *pubkey);
void fromwire_secp256k1_ecdsa_signature(const u8 **cursor, size_t *max,
secp256k1_ecdsa_signature *signature);
void fromwire_secp256k1_ecdsa_recoverable_signature(const u8 **cursor,
size_t *max,
secp256k1_ecdsa_recoverable_signature *rsig);
void fromwire_channel_id(const u8 **cursor, size_t *max,
struct channel_id *channel_id);
void fromwire_short_channel_id(const u8 **cursor, size_t *max,