diff options
Diffstat (limited to 'src/util/perf_crypto_paillier.c')
-rw-r--r-- | src/util/perf_crypto_paillier.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/src/util/perf_crypto_paillier.c b/src/util/perf_crypto_paillier.c index a62b72c96..f2aa132d5 100644 --- a/src/util/perf_crypto_paillier.c +++ b/src/util/perf_crypto_paillier.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author Christian Grothoff | 22 | * @author Christian Grothoff |
@@ -29,7 +29,7 @@ | |||
29 | 29 | ||
30 | 30 | ||
31 | int | 31 | int |
32 | main (int argc, char *argv[]) | 32 | main(int argc, char *argv[]) |
33 | { | 33 | { |
34 | struct GNUNET_TIME_Absolute start; | 34 | struct GNUNET_TIME_Absolute start; |
35 | struct GNUNET_CRYPTO_PaillierPublicKey public_key; | 35 | struct GNUNET_CRYPTO_PaillierPublicKey public_key; |
@@ -38,51 +38,51 @@ main (int argc, char *argv[]) | |||
38 | gcry_mpi_t m1; | 38 | gcry_mpi_t m1; |
39 | unsigned int i; | 39 | unsigned int i; |
40 | 40 | ||
41 | start = GNUNET_TIME_absolute_get (); | 41 | start = GNUNET_TIME_absolute_get(); |
42 | for (i=0;i<10;i++) | 42 | for (i = 0; i < 10; i++) |
43 | GNUNET_CRYPTO_paillier_create (&public_key, | 43 | GNUNET_CRYPTO_paillier_create(&public_key, |
44 | &private_key); | 44 | &private_key); |
45 | printf ("10x key generation took %s\n", | 45 | printf("10x key generation took %s\n", |
46 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), | 46 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start), |
47 | GNUNET_YES)); | 47 | GNUNET_YES)); |
48 | GAUGER ("UTIL", "Paillier key generation", | 48 | GAUGER("UTIL", "Paillier key generation", |
49 | 64 * 1024 / (1 + | 49 | 64 * 1024 / (1 + |
50 | GNUNET_TIME_absolute_get_duration | 50 | GNUNET_TIME_absolute_get_duration |
51 | (start).rel_value_us / 1000LL), "keys/ms"); | 51 | (start).rel_value_us / 1000LL), "keys/ms"); |
52 | 52 | ||
53 | m1 = gcry_mpi_new (0); | 53 | m1 = gcry_mpi_new(0); |
54 | m1 = gcry_mpi_set_ui (m1, 1); | 54 | m1 = gcry_mpi_set_ui(m1, 1); |
55 | /* m1 = m1 * 2 ^ (GCPB - 3) */ | 55 | /* m1 = m1 * 2 ^ (GCPB - 3) */ |
56 | gcry_mpi_mul_2exp (m1, | 56 | gcry_mpi_mul_2exp(m1, |
57 | m1, | 57 | m1, |
58 | GNUNET_CRYPTO_PAILLIER_BITS - 3); | 58 | GNUNET_CRYPTO_PAILLIER_BITS - 3); |
59 | start = GNUNET_TIME_absolute_get (); | 59 | start = GNUNET_TIME_absolute_get(); |
60 | for (i=0;i<10;i++) | 60 | for (i = 0; i < 10; i++) |
61 | GNUNET_CRYPTO_paillier_encrypt (&public_key, | 61 | GNUNET_CRYPTO_paillier_encrypt(&public_key, |
62 | m1, | 62 | m1, |
63 | 2, | 63 | 2, |
64 | &c1); | 64 | &c1); |
65 | printf ("10x encryption took %s\n", | 65 | printf("10x encryption took %s\n", |
66 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), | 66 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start), |
67 | GNUNET_YES)); | 67 | GNUNET_YES)); |
68 | GAUGER ("UTIL", "Paillier encryption", | 68 | GAUGER("UTIL", "Paillier encryption", |
69 | 64 * 1024 / (1 + | 69 | 64 * 1024 / (1 + |
70 | GNUNET_TIME_absolute_get_duration | 70 | GNUNET_TIME_absolute_get_duration |
71 | (start).rel_value_us / 1000LL), "ops/ms"); | 71 | (start).rel_value_us / 1000LL), "ops/ms"); |
72 | 72 | ||
73 | start = GNUNET_TIME_absolute_get (); | 73 | start = GNUNET_TIME_absolute_get(); |
74 | for (i=0;i<10;i++) | 74 | for (i = 0; i < 10; i++) |
75 | GNUNET_CRYPTO_paillier_decrypt (&private_key, | 75 | GNUNET_CRYPTO_paillier_decrypt(&private_key, |
76 | &public_key, | 76 | &public_key, |
77 | &c1, | 77 | &c1, |
78 | m1); | 78 | m1); |
79 | printf ("10x decryption took %s\n", | 79 | printf("10x decryption took %s\n", |
80 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), | 80 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start), |
81 | GNUNET_YES)); | 81 | GNUNET_YES)); |
82 | GAUGER ("UTIL", "Paillier decryption", | 82 | GAUGER("UTIL", "Paillier decryption", |
83 | 64 * 1024 / (1 + | 83 | 64 * 1024 / (1 + |
84 | GNUNET_TIME_absolute_get_duration | 84 | GNUNET_TIME_absolute_get_duration |
85 | (start).rel_value_us / 1000LL), "ops/ms"); | 85 | (start).rel_value_us / 1000LL), "ops/ms"); |
86 | 86 | ||
87 | 87 | ||
88 | return 0; | 88 | return 0; |