-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorisign.c
More file actions
77 lines (64 loc) · 2.31 KB
/
Copy pathorisign.c
File metadata and controls
77 lines (64 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "api.h"
#include "constants.h"
#include "utilities.h"
#include <stdint.h>
int main () {
unsigned char pk[CRYPTO_PUBLICKEYBYTES];
unsigned char sk[CRYPTO_SECRETKEYBYTES];
unsigned char pk2[CRYPTO_PUBLICKEYBYTES];
unsigned char sk2[CRYPTO_SECRETKEYBYTES];
unsigned long long siglen;
typedef unsigned char sig_t[CRYPTO_BYTES];
sqisign_keypair(pk, sk);
sqisign_keypair(pk2, sk2);
print_hex("SK : ", sk, CRYPTO_SECRETKEYBYTES, 1);
print_hex("PK : ", pk, CRYPTO_PUBLICKEYBYTES, 1);
const char *msg = "static inline int evaluate_random_aux_isogeny_signature(ec_curve_t *E_aux, ec_basis_t *B_aux, const ibz_t *norm, const quat_left_ideal_t *lideal_com_resp) {";
#if DEBUG_MODINV
const int N = 1;
#else
const int N = 100;
#endif
sig_t sig[N];
int ctr;
#if DEBUG_MODINV
printf("\n=== SIGN START ===\n");
#endif
uint64_t t0 = get_time_monotonic_ns();
ctr = 0;
for (int i = 0; i < N; i++) {
int ret = sqisign_sign(sig[i], &siglen, (const unsigned char *)msg, strlen(msg), sk);
if (i == 0 || i == 1) print_hex("SIG: ", sig[i], CRYPTO_BYTES, 1);
if (ret == 0) ctr++;
}
uint64_t t1 = get_time_monotonic_ns();
uint64_t total_ns = t1 - t0;
double total_ms = total_ns / 1e6;
double per_sign_us = (double)total_ns / N / 1000.0;
double sign_per_sec = (double)N / ((double)total_ns / 1e9);
printf("\n=== SIGN PROFILING ===\n");
printf("Total time : %.3f ms\n", total_ms);
printf("Avg per sign : %.3f us\n", per_sign_us);
printf("Sign per sec : %.2f ops/sec\n", sign_per_sec);
printf("Success : %d/%d\n", ctr, N);
#if DEBUG_MODINV
printf("\n=== VRF START ===\n");
#endif
uint64_t t02 = get_time_monotonic_ns();
ctr = 0;
for (int i = 0; i < N; i++) {
int ret = sqisign_verify((const unsigned char *)msg, strlen(msg), sig[i], CRYPTO_BYTES, pk);
if (ret == 0) ctr++;
}
uint64_t t12 = get_time_monotonic_ns();
uint64_t total_ns2 = t12 - t02;
double total_ms2 = total_ns2 / 1e6;
double per_sign_us2 = (double)total_ns2 / N / 1000.0;
double sign_per_sec2 = (double)N / ((double)total_ns2 / 1e9);
printf("\n=== VRF PROFILING ===\n");
printf("Total time : %.3f ms\n", total_ms2);
printf("Avg per vrf : %.3f us\n", per_sign_us2);
printf("Vrf per sec : %.2f ops/sec\n", sign_per_sec2);
printf("Success : %d/%d\n", ctr, N);
return 0;
}