/* GNU Guix --- Functional package management for GNU
   Copyright © 2020 Maxime Devos <maxime.devos@student.kuleuven.be>

   This file is part of GNU Guix.

   GNU Guix is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or (at
   your option) any later version.

   GNU Guix is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>. */

#ifndef _GNUNET_REHASH_TYPES_H
#define _GNUNET_REHASH_TYPES_H 1

#include <gnunet/gnunet_common.h>

GNUNET_NETWORK_STRUCT_BEGIN
/* Needs to be hashed first */
struct GNUNET_REHASH_Request {
  uint32_t key_type; /* network byte order */
  uint32_t value_type; /* network byte order */
  /* Followed by char[], length depending on key_type */
};

/* Answer: char[hash_lengths[value_type]].
   TODO: would encrypting the response with a key
   derived from the GNUNET_REHASH_Request make sense?
   (Otherwise peers can sniff for hashes on the network
   even if they don't know the hash in the first place.) */
GNUNET_NETWORK_STRUCT_END

enum GNUNET_REHASH_Hash_Type {
  /* Never used on the network, not a real hash type! */
  GNUNET_REHASH_HASH_NONE = 0,
  /* Found in guix/packages.scm */
  GNUNET_REHASH_HASH_SHA256 = 1,
  GNUNET_REHASH_HASH_SHA512 = 2,
  GNUNET_REHASH_HASH_SHA3_256 = 3,
  GNUNET_REHASH_HASH_SHA3_512 = 4,
  GNUNET_REHASH_HASH_BLAKE2S_256 = 5,
  /* A gnunet://fs/chk/... URI (regular file)
     Not formatted as a string, is in some binary format.
     (struct FileIdentifier) */
  GNUNET_REHASH_HASH_FS_REGULAR = 6,
  /* TODO: map nix archives to GNUnet directories */
};
#define GNUNET_REHASH_HASH_LAST GNUNET_REHASH_HASH_FS_REGULAR

#endif
