2017-02-06 22:11:22 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-02-06 22:28:11 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-02-06 22:11:22 +00:00
|
|
|
/**
|
|
|
|
* General helpers for ephemeral keys
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct EphemeralPublicKey {
|
2017-02-07 00:04:01 +00:00
|
|
|
size_t num_bits;
|
2017-02-06 22:11:22 +00:00
|
|
|
uint64_t x;
|
|
|
|
uint64_t y;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EphemeralPrivateKey {
|
2017-02-07 00:04:01 +00:00
|
|
|
size_t num_bits;
|
2017-02-06 22:11:22 +00:00
|
|
|
uint64_t secret_key;
|
|
|
|
struct EphemeralPublicKey* public_key;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a Ephemeral Public Key as well as a shared key
|
|
|
|
* @param curve the curve to use (P-256, P-384, or P-521)
|
|
|
|
* @param private_key where to store the private key
|
|
|
|
* @reutrns true(1) on success, otherwise false(0)
|
|
|
|
*/
|
2017-02-07 00:04:01 +00:00
|
|
|
int libp2p_crypto_ephemeral_keypair_generate(char* curve, struct EphemeralPrivateKey** private_key);
|