#ifndef SIGSUM_CRYPTO_H_INCLUDED
#define SIGSUM_CRYPTO_H_INCLUDED

#include <stdint.h>
#include <stdlib.h>

typedef uint64_t sigsum_size_t;

/* Sigsum uses SHA256 hashing. */
#define SIGSUM_DIGEST_SIZE 32

struct sigsum_hash
{
  uint8_t h[SIGSUM_DIGEST_SIZE];
};

/* Sigsum uses Ed25519 signatures. */
#define SIGSUM_PUBKEY_SIZE 32
#define SIGSUM_SIGNATURE_SIZE 64

struct sigsum_pubkey
{
  uint8_t k[SIGSUM_PUBKEY_SIZE];
};

struct sigsum_signature
{
  uint8_t s[SIGSUM_SIGNATURE_SIZE];
};

struct sigsum_cosignature
{
  uint64_t timestamp; /* At most 63 bits. */
  struct sigsum_hash key_hash;
  struct sigsum_signature signature;
};

/* Computes the key hash for a public key. */
void
sigsum_hash_key (struct sigsum_hash *kh, const struct sigsum_pubkey *key);

#endif /* SIGSUM_CRYPTO_H_INCLUDED */
