+/**
+ * shachain_add_hash - record the hash for the next index.
+ * @chain: the chain to add to
+ * @index: the index of the hash
+ * @hash: the hash value.
+ *
+ * You can only add shachain_next_index(@chain).
+ *
+ * This can fail (return false without altering @chain) if the hash
+ * for this index isn't consistent with previous hashes (ie. wasn't
+ * generated from the same seed), though it can't always detect that.
+ * If the hash is inconsistent yet undetected, a future addition will
+ * fail.
+ *
+ * Example:
+ * static void next_hash(const struct sha256 *hash)
+ * {
+ * static uint64_t index = 0xFFFFFFFFFFFFFFFFULL;
+ * static struct shachain chain;
+ *
+ * if (!shachain_add_hash(&chain, index--, hash))
+ * errx(1, "Corrupted hash value?");
+ * }
+ */
+bool shachain_add_hash(struct shachain *chain,
+ uint64_t index, const struct sha256 *hash);
+
+/**
+ * shachain_get_hash - get the hash for a given index.
+ * @chain: the chain query
+ * @index: the index of the hash to get
+ * @hash: the hash value.
+ *
+ * This will return true and set @hash to that given in the successful
+ * shachain_get_hash() call for that index. If there was no
+ * successful shachain_get_hash() for that index, it will return
+ * false.
+ *
+ * Example:
+ * #include <ccan/structeq/structeq.h>
+ * // Defines sha256_eq
+ * STRUCTEQ_DEF(sha256, 0, u);
+ *
+ * static void next_hash(const struct sha256 *hash)
+ * {
+ * static uint64_t index = 0xFFFFFFFFFFFFFFFFULL;
+ * static struct shachain chain;
+ *
+ * if (!shachain_add_hash(&chain, index--, hash))
+ * errx(1, "Corrupted hash value?");
+ * else {
+ * struct sha256 check;
+ * assert(shachain_get_hash(&chain, index+1, &check));
+ * assert(sha256_eq(&check, hash));
+ * }
+ * }
+ */
+bool shachain_get_hash(const struct shachain *chain,
+ uint64_t index, struct sha256 *hash);