-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a530453
commit f9df59b
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |