core-lightning/lightningd/hsm/client.c
Rusty Russell 10b8dc5950 lightningd/hsm: simple daemon to control the keys.
This provides APIs to access the keys.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-10 15:38:33 +10:30

32 lines
575 B
C

#include <lightningd/hsm/client.h>
#include <lightningd/hsm/gen_hsm_client_wire.h>
#include <wire/wire_sync.h>
static int hsm_fd = -1;
void hsm_setup(int fd)
{
hsm_fd = fd;
}
bool hsm_do_ecdh(struct sha256 *ss, const struct pubkey *point)
{
u8 *req = towire_hsm_ecdh_req(NULL, point), *resp;
size_t len;
if (!wire_sync_write(hsm_fd, req))
goto fail;
resp = wire_sync_read(req, hsm_fd);
if (!resp)
goto fail;
len = tal_count(resp);
if (!fromwire_hsm_ecdh_resp(resp, &len, ss))
goto fail;
tal_free(req);
return true;
fail:
tal_free(req);
return false;
}