Skip to content

Commit

Permalink
Improve serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
xevisalle committed Nov 4, 2023
1 parent 225dea6 commit 694352b
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 181 deletions.
4 changes: 2 additions & 2 deletions src/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ int main(int argc, char *argv[])
if (strcmp(argv[1], "-s") == 0)
{
setup_keys keys = perform_setup(&bench_circuit);
store_setup(keys);
store_setup(&keys);
}
else if (strcmp(argv[1], "-p") == 0)
{
setup_keys keys = read_setup(&bench_circuit);
proof p = generate_proof(&bench_circuit, keys.pk);
store_proof(p);
store_proof(&p);
}
else if (strcmp(argv[1], "-v") == 0)
{
Expand Down
32 changes: 0 additions & 32 deletions src/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,32 +52,6 @@ void test_mimc_hash()
mimc7(&h, &x_in, &k);
}

void test_setup(void)
{
test_no_rand = 1;
setup_keys keys = perform_setup(&test_single_constraint);

char* pk_bytes = serialize_pk(&keys.pk);
char* vk_bytes = serialize_vk(&keys.vk);

BYTE hash_bytes[SHA256_BLOCK_SIZE];
SHA256_CTX ctx;

sha256_init(&ctx);
sha256_update(&ctx, pk_bytes, strlen(pk_bytes));
sha256_final(&ctx, hash_bytes);

CU_ASSERT(!strcmp(to_hex(hash_bytes, sizeof hash_bytes), "26047d607444ba18b641499f11483896560195b1f16b0a12c734ccf0f6552cf4"));

sha256_init(&ctx);
sha256_update(&ctx, vk_bytes, strlen(vk_bytes));
sha256_final(&ctx, hash_bytes);

CU_ASSERT(!strcmp(to_hex(hash_bytes, sizeof hash_bytes), "1c91757242555e6705802233a5b7ca934fd33278c2461f21df343321c8ffb5d0"));

test_no_rand = 0;
}

void test_prover(void)
{
test_no_rand = 1;
Expand Down Expand Up @@ -156,12 +130,6 @@ int main()
return CU_get_error();
}

if ((NULL == suite) || (NULL == CU_add_test(suite, "\n\nSetup Testing\n\n", test_setup)))
{
CU_cleanup_registry();
return CU_get_error();
}

CU_basic_run_tests();
if(CU_get_number_of_failures()) abort();

Expand Down
Loading

0 comments on commit 694352b

Please sign in to comment.