#ifndef SIGSUM_CHECKPOINT_H_INCLUDED
#define SIGSUM_CHECKPOINT_H_INCLUDED

#include <stdlib.h>

#include "merkle.h"

/* 19 is max size for 2^63-1 = 9223372036854775807 */
#define CHECKPOINT_DECIMAL_MAX_SIZE 19

/* A checkpoint is formatted like
   sigsum.org/v1/tree/<hex keyhash>\n    (84 octets)
   <decimal size>\n                      (2-20 octets)
   <base64 root hash>\n                  (45 octets)
*/
#define CHECKPOINT_BODY_MAX_SIZE 149
/* Formats a checkpoint body for a Sigsum log, i.e., the data covered
   by the log's own signature. */
size_t
_sigsum_checkpoint_body (uint8_t out[CHECKPOINT_BODY_MAX_SIZE],
			 const struct sigsum_hash *key_hash,
			 const struct sigsum_tree_head *tree_head);

/* The cosignature prefix is formatted like
   cosignature/v1\n                      (15 octets)
   time <decimal timestamp>\n            (7-25 octets)
 */
#define COSIGNATURE_PREFIX_MAX_SIZE 40
/* Formats right-justified prefix, the data prependended to the
   checkpoint body for a witness cosignature. */
size_t
_sigsum_cosignature_prefix (uint8_t out[COSIGNATURE_PREFIX_MAX_SIZE],
			    uint64_t timestamp);

#endif /* SIGSUM_CHECKPOINT_H_INCLUDED */
