2021-12-04 12:23:56 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include <bitcoin/shadouble.h>
|
2015-10-26 11:35:28 +01:00
|
|
|
#include <ccan/mem/mem.h>
|
2024-03-20 01:47:55 +01:00
|
|
|
#include <common/utils.h>
|
2020-05-16 03:29:05 +02:00
|
|
|
#include <wire/wire.h>
|
2015-05-26 06:38:12 +02:00
|
|
|
|
|
|
|
void sha256_double(struct sha256_double *shadouble, const void *p, size_t len)
|
|
|
|
{
|
2015-10-26 11:35:28 +01:00
|
|
|
sha256(&shadouble->sha, memcheck(p, len), len);
|
2015-05-27 06:25:20 +02:00
|
|
|
sha256(&shadouble->sha, &shadouble->sha, sizeof(shadouble->sha));
|
2015-05-26 06:38:12 +02:00
|
|
|
}
|
|
|
|
|
2015-05-27 06:25:20 +02:00
|
|
|
void sha256_double_done(struct sha256_ctx *shactx, struct sha256_double *res)
|
2015-05-26 06:38:12 +02:00
|
|
|
{
|
2015-05-27 06:25:20 +02:00
|
|
|
sha256_done(shactx, &res->sha);
|
|
|
|
sha256(&res->sha, &res->sha, sizeof(res->sha));
|
2015-05-26 06:38:12 +02:00
|
|
|
}
|
2024-03-20 01:40:16 +01:00
|
|
|
|
|
|
|
char *fmt_sha256_double(const tal_t *ctx, const struct sha256_double *shad)
|
|
|
|
{
|
|
|
|
return tal_hexstr(ctx, shad, sizeof(*shad));
|
|
|
|
}
|
2020-05-16 03:29:05 +02:00
|
|
|
|
|
|
|
void towire_sha256_double(u8 **pptr, const struct sha256_double *sha256d)
|
|
|
|
{
|
|
|
|
towire_sha256(pptr, &sha256d->sha);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fromwire_sha256_double(const u8 **cursor, size_t *max,
|
|
|
|
struct sha256_double *sha256d)
|
|
|
|
{
|
|
|
|
fromwire_sha256(cursor, max, &sha256d->sha);
|
|
|
|
}
|