Skip to content

Commit

Permalink
Add basic benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanSchmiedmayer committed Apr 29, 2024
1 parent a530453 commit f9df59b
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(BBS_FIX_TESTS
create_test_sourcelist(fixture-tests bbs-test-fixtures.c ${BBS_FIX_TESTS})

set(BBS_E2E_TESTS bbs_e2e_sign_n_proof.c)
set(BBS_BENCH_TESTS bbs_e2e_sign_n_proof.c, bbs_e2e_bench.c)

create_test_sourcelist(e2e-tests bbs-test-e2e.c ${BBS_E2E_TESTS})

Expand Down
108 changes: 108 additions & 0 deletions test/bbs_e2e_bench.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#include "fixtures.h"
#include "test_util.h"
#include <string.h>

int
bbs_e2e_bench ()
{
BBS_BENCH_START(e2e)

if (core_init () != RLC_OK)
{
core_clean ();
return 1;
}
if (pc_param_set_any () != RLC_OK)
{
core_clean ();
return 1;
}

bbs_secret_key sk;
bbs_public_key pk;

if (BBS_OK != bbs_sha256_keygen_full (sk, pk))
{
puts ("Error during key generation");
return 1;
}

bbs_signature sig;
static char msg1[] = "I am a message";
static char msg2[] = "And so am I. Crazy...";
// static char header[] = "But I am a header!";
static char header[] = "";

if (BBS_OK != bbs_sha256_sign (sk,
pk,
sig,
(uint8_t*) header,
strlen (header),
2,
msg1,
strlen (msg1),
msg2,
strlen (msg2)))
{
puts ("Error during signing");
return 1;
}

if (BBS_OK != bbs_sha256_verify (pk,
sig,
(uint8_t*) header,
strlen (header),
2,
msg1,
strlen (msg1),
msg2,
strlen (msg2)))
{
puts ("Error during signature verification");
return 1;
}

uint8_t proof[BBS_PROOF_LEN (1)];
uint64_t disclosed_indexes[] = {0};
static char ph[] = "I am a challenge nonce!";

if (BBS_OK != bbs_sha256_proof_gen (pk,
sig,
proof,
(uint8_t*) header,
strlen (header),
(uint8_t*) ph,
strlen (ph),
disclosed_indexes,
1,
2,
msg1,
strlen (msg1),
msg2,
strlen (msg2)))
{
puts ("Error during proof generation");
return 1;
}

if (BBS_OK != bbs_sha256_proof_verify (pk,
proof,
BBS_PROOF_LEN (1),
(uint8_t*) header,
strlen (header),
(uint8_t*) ph,
strlen (ph),
disclosed_indexes,
1,
2,
msg1,
strlen (msg1)))
{
puts ("Error during proof verification");
return 1;
}

BBS_BENCH_END(e2e, "bbs_e2e_sign_n_proof")

return 0;
}

0 comments on commit f9df59b

Please sign in to comment.