diff options
Diffstat (limited to 'smc.c')
-rw-r--r-- | smc.c | 104 |
1 files changed, 63 insertions, 41 deletions
@@ -22,63 +22,85 @@ #include <gcrypt.h> #include "crypto.h" -#include "util.h" #include "smc.h" +#include "util.h" extern gcry_ctx_t ec_ctx; +/** + * smc_zkp_dl + * + * @param v TODO + * @param g TODO + * @param x TODO + * @param a TODO + * @param c TODO + * @param r TODO + */ void -smc_zkp_dl (gcry_mpi_point_t v, gcry_mpi_point_t g, gcry_mpi_t x, gcry_mpi_point_t *a, gcry_mpi_t *c, gcry_mpi_t *r) +smc_zkp_dl (gcry_mpi_point_t v, gcry_mpi_point_t g, gcry_mpi_t x, + gcry_mpi_point_t *a, gcry_mpi_t *c, + gcry_mpi_t *r) { - gcry_mpi_t z = gcry_mpi_new(0); + gcry_mpi_t z = gcry_mpi_new (0); - brandt_ec_keypair_create_base(a, &z, g); + brandt_ec_keypair_create_base (a, &z, g); /**TODO: generate c from HASH(g,v,a) and don't output it */ - brandt_ec_skey_create(c); - *r = gcry_mpi_new(0); - gcry_mpi_mul(*r, *c, x); - gcry_mpi_add(*r, *r, z); + brandt_ec_skey_create (c); + *r = gcry_mpi_new (0); + gcry_mpi_mul (*r, *c, x); + gcry_mpi_add (*r, *r, z); - gcry_mpi_release(z); + gcry_mpi_release (z); } +/** + * smc_zkp_dl_check + * + * @param v TODO + * @param g TODO + * @param a TODO + * @param c TODO + * @param r TODO + * @return 0 if the proof is correct, something else otherwise + */ int -smc_zkp_dl_check (gcry_mpi_point_t v, gcry_mpi_point_t g, gcry_mpi_point_t a, gcry_mpi_t c, gcry_mpi_t r) +smc_zkp_dl_check (gcry_mpi_point_t v, gcry_mpi_point_t g, gcry_mpi_point_t a, + gcry_mpi_t c, + gcry_mpi_t r) { - int ret; - gcry_mpi_point_t left = gcry_mpi_point_new(0); - gcry_mpi_point_t right = gcry_mpi_point_new(0); + int ret; + gcry_mpi_point_t left = gcry_mpi_point_new (0); + gcry_mpi_point_t right = gcry_mpi_point_new (0); - gcry_mpi_ec_mul(left, r, g, ec_ctx); - gcry_mpi_ec_mul(right, c, v, ec_ctx); - gcry_mpi_ec_add(right, a, right, ec_ctx); + gcry_mpi_ec_mul (left, r, g, ec_ctx); + gcry_mpi_ec_mul (right, c, v, ec_ctx); + gcry_mpi_ec_add (right, a, right, ec_ctx); - ret = brandt_ec_point_cmp(left, right); - gcry_mpi_point_release(left); - gcry_mpi_point_release(right); + ret = brandt_ec_point_cmp (left, right); + gcry_mpi_point_release (left); + gcry_mpi_point_release (right); return ret; } -/* -GEN -smc_hextodec (const char *s) -{ - size_t i; - char c; - pari_sp ltop = avma; - GEN ret = gen_0; - - for (i = 0; i < strlen (s); i++) - { - errno = 0; - if (1 != sscanf (&s[i], "%1hhx", &c)) - { - brandt_eprintf ("failed to parse hex (\"%s\") to decimal:", s); - return NULL; - } - ret = addis (shifti (ret, 4), c); - } - return gerepilecopy (ltop, ret); -} -*/ +//GEN +//smc_hextodec (const char *s) +//{ +// size_t i; +// char c; +// pari_sp ltop = avma; +// GEN ret = gen_0; +// +// for (i = 0; i < strlen (s); i++) +// { +// errno = 0; +// if (1 != sscanf (&s[i], "%1hhx", &c)) +// { +// brandt_eprintf ("failed to parse hex (\"%s\") to decimal:", s); +// return NULL; +// } +// ret = addis (shifti (ret, 4), c); +// } +// return gerepilecopy (ltop, ret); +//} |