2015-06-26 04:24:07 +02:00
|
|
|
#ifndef LIGHTNING_BITCOIN_PRIVKEY_H
|
|
|
|
#define LIGHTNING_BITCOIN_PRIVKEY_H
|
2016-01-21 21:08:08 +01:00
|
|
|
#include "config.h"
|
2015-06-26 04:24:07 +02:00
|
|
|
#include <ccan/short_types/short_types.h>
|
2018-07-04 07:30:02 +02:00
|
|
|
#include <ccan/structeq/structeq.h>
|
2024-03-20 01:40:16 +01:00
|
|
|
#include <ccan/tal/tal.h>
|
2015-06-26 04:24:07 +02:00
|
|
|
|
2019-07-26 18:30:08 +02:00
|
|
|
#define PRIVKEY_LEN 32
|
|
|
|
|
2017-05-06 04:19:44 +02:00
|
|
|
/* General 256-bit secret, which must be private. Used in various places. */
|
|
|
|
struct secret {
|
|
|
|
u8 data[32];
|
|
|
|
};
|
2018-08-17 06:16:34 +02:00
|
|
|
|
|
|
|
/* You probably shouldn't compare secrets in non-const time! */
|
|
|
|
bool secret_eq_consttime(const struct secret *a, const struct secret *b);
|
2017-05-06 04:19:44 +02:00
|
|
|
|
2015-06-26 04:24:07 +02:00
|
|
|
/* This is a private key. Keep it secret. */
|
|
|
|
struct privkey {
|
2017-05-06 04:19:44 +02:00
|
|
|
struct secret secret;
|
2015-06-26 04:24:07 +02:00
|
|
|
};
|
2020-05-16 03:29:05 +02:00
|
|
|
|
|
|
|
/* marshal/unmarshal functions */
|
|
|
|
void fromwire_secret(const u8 **cursor, size_t *max, struct secret *secret);
|
|
|
|
void fromwire_privkey(const u8 **cursor, size_t *max, struct privkey *privkey);
|
|
|
|
void towire_privkey(u8 **pptr, const struct privkey *privkey);
|
|
|
|
void towire_secret(u8 **pptr, const struct secret *secret);
|
|
|
|
|
2024-03-20 01:40:16 +01:00
|
|
|
char *fmt_privkey(const tal_t *ctx, const struct privkey *privkey);
|
|
|
|
char *fmt_secret(const tal_t *ctx, const struct secret *secret);
|
|
|
|
|
2015-06-26 04:24:07 +02:00
|
|
|
#endif /* LIGHTNING_BITCOIN_PRIVKEY_H */
|