aboutsummaryrefslogtreecommitdiff
path: root/test_crypto.c
diff options
context:
space:
mode:
authorMarkus Teich <markus.teich@stusta.mhn.de>2016-06-15 00:52:18 +0200
committerMarkus Teich <markus.teich@stusta.mhn.de>2016-06-15 00:52:18 +0200
commit8035afa583d323060c6f05804024bbe4069a1f60 (patch)
tree06e22415b1a7a260ff2091438f87053006b78abb /test_crypto.c
parent338c95de4190065149ddc995e5404d335c05f432 (diff)
add second ZKP (equality of two EC DLs) with test case
Diffstat (limited to 'test_crypto.c')
-rw-r--r--test_crypto.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/test_crypto.c b/test_crypto.c
index d692055..5103e0e 100644
--- a/test_crypto.c
+++ b/test_crypto.c
@@ -86,6 +86,58 @@ test_smc_zkp_dl ()
}
int
+test_smc_zkp_2dle ()
+{
+ static int first = 1;
+ gcry_mpi_t c;
+ gcry_mpi_t r;
+ gcry_mpi_t s;
+ gcry_mpi_t x;
+ gcry_mpi_point_t a;
+ gcry_mpi_point_t b;
+ gcry_mpi_point_t g1;
+ gcry_mpi_point_t g2;
+ gcry_mpi_point_t v = gcry_mpi_point_new (0);
+ gcry_mpi_point_t w = gcry_mpi_point_new (0);
+
+ check (v, "no pub1 key initialized");
+ check (w, "no pub2 key initialized");
+ brandt_ec_keypair_create (&g1, &s);
+ gcry_mpi_release (s);
+ brandt_ec_keypair_create (&g2, &s);
+ check (g1, "no gen1 created");
+ check (g2, "no gen2 created");
+
+ if (first)
+ {
+ gcry_mpi_ec_mul (g1, GCRYMPI_CONST_ONE, ec_gen, ec_ctx);
+ gcry_mpi_ec_mul (g2, GCRYMPI_CONST_ONE, ec_gen, ec_ctx);
+ first = 0;
+ }
+
+ brandt_ec_skey_create (&x);
+ check (x, "no sec key created");
+ gcry_mpi_ec_mul (v, x, g1, ec_ctx);
+ check (v, "no pub1 key created");
+ gcry_mpi_ec_mul (w, x, g2, ec_ctx);
+ check (w, "no pub2 key created");
+
+ smc_zkp_2dle (v, w, g1, g2, x, &a, &b, &c, &r);
+ check (!smc_zkp_2dle_check (v, w, g1, g2, a, b, c, r), "zkp was false, should be true");
+
+ gcry_mpi_release (c);
+ gcry_mpi_release (r);
+ gcry_mpi_release (s);
+ gcry_mpi_release (x);
+ gcry_mpi_point_release (a);
+ gcry_mpi_point_release (b);
+ gcry_mpi_point_release (g1);
+ gcry_mpi_point_release (g2);
+ gcry_mpi_point_release (v);
+ gcry_mpi_point_release (w);
+}
+
+int
main (int argc, char *argv[])
{
int repeat = 50;