Browse Source

secp256k1_ecdsa_recoverable_signature: add support.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
a02ca46b03
  1. 2
      external/Makefile
  2. 16
      wire/fromwire.c
  3. 14
      wire/towire.c
  4. 6
      wire/wire.h

2
external/Makefile

@ -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:

16
wire/fromwire.c

@ -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)
{

14
wire/towire.c

@ -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));

6
wire/wire.h

@ -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,

Loading…
Cancel
Save