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>
|
2018-03-08 04:24:14 +01:00
|
|
|
#include <common/type_to_string.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
|
|
|
}
|
2018-03-08 04:24:14 +01:00
|
|
|
REGISTER_TYPE_TO_HEXSTR(sha256_double);
|
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);
|
|
|
|
}
|