2015-06-12 04:23:27 +02:00
|
|
|
#ifndef LIGHTNING_BITCOIN_PUBKEY_H
|
|
|
|
#define LIGHTNING_BITCOIN_PUBKEY_H
|
2016-01-21 21:08:08 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "secp256k1.h"
|
2015-06-02 04:23:59 +02:00
|
|
|
#include <ccan/short_types/short_types.h>
|
|
|
|
#include <ccan/tal/tal.h>
|
2015-09-30 03:24:54 +02:00
|
|
|
|
|
|
|
struct privkey;
|
2015-06-02 04:23:59 +02:00
|
|
|
|
|
|
|
struct pubkey {
|
2015-09-30 03:24:54 +02:00
|
|
|
/* DER-encoded key (as hashed by bitcoin, for addresses) */
|
2016-03-30 08:24:16 +02:00
|
|
|
u8 der[33];
|
2015-09-30 03:24:54 +02:00
|
|
|
/* Unpacked pubkey (as used by libsecp256k1 internally) */
|
|
|
|
secp256k1_pubkey pubkey;
|
2015-06-02 04:23:59 +02:00
|
|
|
};
|
|
|
|
|
2015-09-30 03:24:54 +02:00
|
|
|
/* Convert from hex string of DER (scriptPubKey from validateaddress) */
|
2016-01-21 21:11:47 +01:00
|
|
|
bool pubkey_from_hexstr(secp256k1_context *secpctx,
|
|
|
|
const char *derstr, size_t derlen, struct pubkey *key);
|
2015-09-30 03:24:54 +02:00
|
|
|
|
|
|
|
/* Pubkey from privkey */
|
2016-01-21 21:11:47 +01:00
|
|
|
bool pubkey_from_privkey(secp256k1_context *secpctx,
|
|
|
|
const struct privkey *privkey,
|
2015-09-30 03:24:54 +02:00
|
|
|
struct pubkey *key,
|
|
|
|
unsigned int compressed_flags);
|
2015-06-02 04:23:59 +02:00
|
|
|
|
2015-09-30 03:24:54 +02:00
|
|
|
/* Pubkey from DER encoding. */
|
2016-01-21 21:11:47 +01:00
|
|
|
bool pubkey_from_der(secp256k1_context *secpctx,
|
|
|
|
const u8 *der, size_t len, struct pubkey *key);
|
2015-06-05 04:54:58 +02:00
|
|
|
|
2015-09-30 03:24:54 +02:00
|
|
|
/* Are these keys equal? */
|
|
|
|
bool pubkey_eq(const struct pubkey *a, const struct pubkey *b);
|
2015-06-02 04:23:59 +02:00
|
|
|
#endif /* LIGHTNING_PUBKEY_H */
|