/* This file is part of GNUnet. Copyright (C) 2015 GNUnet e.V. GNUnet 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, or (at your option) any later version. GNUnet 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 GNUnet; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * @file util/test_ecc_scalarproduct.c * @brief testcase for math behind ECC SP calculation * @author Christian Grothoff */ #include "platform.h" #include "gnunet_util_lib.h" #include /** * Global context. */ static struct GNUNET_CRYPTO_EccDlogContext *edc; /** * Perform SP calculation. * * @param avec 0-terminated vector of Alice's values * @param bvec 0-terminated vector of Bob's values * @return avec * bvec */ static int test_sp (const unsigned int *avec, const unsigned int *bvec) { unsigned int len; unsigned int i; gcry_mpi_t a; gcry_mpi_t a_inv; gcry_mpi_t ri; gcry_mpi_t val; gcry_mpi_t ria; gcry_mpi_t tmp; gcry_mpi_point_t *g; gcry_mpi_point_t *h; gcry_mpi_point_t pg; gcry_mpi_point_t ph; gcry_mpi_point_t pgi; gcry_mpi_point_t gsp; int sp; /* determine length */ for (len=0;0 != avec[len];len++) ; if (0 == len) return 0; /* Alice */ GNUNET_CRYPTO_ecc_rnd_mpi (edc, &a, &a_inv); g = GNUNET_new_array (len, gcry_mpi_point_t); h = GNUNET_new_array (len, gcry_mpi_point_t); ria = gcry_mpi_new (0); tmp = gcry_mpi_new (0); for (i=0;i