aboutsummaryrefslogtreecommitdiff
path: root/src/util/perf_crypto_cs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/perf_crypto_cs.c')
-rw-r--r--src/util/perf_crypto_cs.c183
1 files changed, 0 insertions, 183 deletions
diff --git a/src/util/perf_crypto_cs.c b/src/util/perf_crypto_cs.c
deleted file mode 100644
index 54c9c8e0e..000000000
--- a/src/util/perf_crypto_cs.c
+++ /dev/null
@@ -1,183 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2014 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @author Lucien Heuzeveldt <lucienclaude.heuzeveldt@students.bfh.ch>
23 * @author Gian Demarmels <gian@demarmels.org>
24 * @file util/perf_crypto_cs.c
25 * @brief measure performance of Clause Blind Schnorr Signatures
26 */
27
28#include "platform.h"
29#include "gnunet_util_lib.h"
30#include <gauger.h>
31
32#define ITER 10
33
34/**
35 * Evaluate Clause Blind Schnorr Signature performance.
36 *
37 */
38static void
39eval ()
40{
41 struct GNUNET_TIME_Absolute start;
42 unsigned int i;
43
44 struct GNUNET_CRYPTO_CsPrivateKey priv;
45 struct GNUNET_CRYPTO_CsPublicKey pub;
46
47 struct GNUNET_CRYPTO_CsRSecret r_priv[2];
48 struct GNUNET_CRYPTO_CsRPublic r_pub[2];
49
50 char message[] = "test message";
51 size_t message_len = strlen ("test message");
52
53 // derive a test nonce
54 struct GNUNET_CRYPTO_CsNonce nonce;
55 GNUNET_assert (GNUNET_YES == GNUNET_CRYPTO_hkdf (nonce.nonce,
56 sizeof(nonce.nonce),
57 GCRY_MD_SHA512,
58 GCRY_MD_SHA256,
59 "nonce",
60 strlen ("nonce"),
61 "nonce_secret",
62 strlen ("nonce_secret"),
63 NULL,
64 0));
65
66 struct GNUNET_CRYPTO_CsBlindingSecret bs[2];
67 struct GNUNET_CRYPTO_CsC blinded_cs[2];
68 struct GNUNET_CRYPTO_CsRPublic blinded_r_pub[2];
69 struct GNUNET_CRYPTO_CsBlindS blinded_s;
70 struct GNUNET_CRYPTO_CsS signature_scalar;
71 struct GNUNET_CRYPTO_CsSignature sig;
72
73 // BENCHMARK keygen
74 start = GNUNET_TIME_absolute_get ();
75
76 for (i = 0; i < ITER; i++)
77 {
78 GNUNET_CRYPTO_cs_private_key_generate (&priv);
79 GNUNET_CRYPTO_cs_private_key_get_public (&priv, &pub);
80 }
81 printf ("10x key generation took %s\n",
82 GNUNET_STRINGS_relative_time_to_string (
83 GNUNET_TIME_absolute_get_duration (start),
84 GNUNET_YES));
85
86
87 // BENCHMARK r derive and calc R pub
88 start = GNUNET_TIME_absolute_get ();
89 for (i = 0; i < ITER; i++)
90 {
91 GNUNET_CRYPTO_cs_r_derive (&nonce, &priv, r_priv);
92 GNUNET_CRYPTO_cs_r_get_public (&r_priv[0], &r_pub[0]);
93 GNUNET_CRYPTO_cs_r_get_public (&r_priv[1], &r_pub[1]);
94 }
95 printf ("10x r0, r1 derive and R1,R2 calculation took %s\n",
96 GNUNET_STRINGS_relative_time_to_string (
97 GNUNET_TIME_absolute_get_duration (start),
98 GNUNET_YES));
99
100
101 // BENCHMARK derive blinding secrets
102 start = GNUNET_TIME_absolute_get ();
103 for (i = 0; i < ITER; i++)
104 {
105 GNUNET_CRYPTO_cs_blinding_secrets_derive (&nonce,
106 bs);
107 }
108 printf ("10x derive blinding secrets took %s\n",
109 GNUNET_STRINGS_relative_time_to_string (
110 GNUNET_TIME_absolute_get_duration (start),
111 GNUNET_YES));
112
113
114 // BENCHMARK calculating C
115 start = GNUNET_TIME_absolute_get ();
116 for (i = 0; i < ITER; i++)
117 {
118 GNUNET_CRYPTO_cs_calc_blinded_c (bs,
119 r_pub,
120 &pub,
121 message,
122 message_len,
123 blinded_cs,
124 blinded_r_pub);
125 }
126 printf ("10x calculating the blinded c took %s\n",
127 GNUNET_STRINGS_relative_time_to_string (
128 GNUNET_TIME_absolute_get_duration (start),
129 GNUNET_YES));
130
131
132 // BENCHMARK sign derive
133 unsigned int b;
134 start = GNUNET_TIME_absolute_get ();
135 for (i = 0; i < ITER; i++)
136 {
137 b = GNUNET_CRYPTO_cs_sign_derive (&priv,
138 r_priv,
139 blinded_cs,
140 &nonce,
141 &blinded_s);
142 }
143 printf ("10x signing blinded c took %s\n",
144 GNUNET_STRINGS_relative_time_to_string (
145 GNUNET_TIME_absolute_get_duration (start),
146 GNUNET_YES));
147
148
149 // BENCHMARK unblind signature
150 start = GNUNET_TIME_absolute_get ();
151
152 for (i = 0; i < ITER; i++)
153 {
154 GNUNET_CRYPTO_cs_unblind (&blinded_s, &bs[b], &signature_scalar);
155 sig.r_point = blinded_r_pub[b];
156 sig.s_scalar = signature_scalar;
157 }
158 printf ("10x unblinding s took %s\n",
159 GNUNET_STRINGS_relative_time_to_string (
160 GNUNET_TIME_absolute_get_duration (start),
161 GNUNET_YES));
162
163 // BENCHMARK verify signature
164 start = GNUNET_TIME_absolute_get ();
165 for (i = 0; i < ITER; i++)
166 {
167 GNUNET_CRYPTO_cs_verify (&sig,
168 &pub,
169 message,
170 message_len);
171 }
172 printf ("10x verifying signatures took %s\n",
173 GNUNET_STRINGS_relative_time_to_string (
174 GNUNET_TIME_absolute_get_duration (start),
175 GNUNET_YES));
176}
177
178int
179main (int argc, char *argv[])
180{
181 eval ();
182 return 0;
183}