Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZPiE v0.5.0 #6

Merged
merged 5 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ else ifeq ($(ARCH), arm)
$(CARM) $(COMMON) $(LIBCROSS) -D $(CURVE) $(MULTI_SET)

else ifeq ($(shell uname), Darwin)
$(CC) $(COMMON) $(LIBMAC)-D $(CURVE) $(MULTI_SET)
$(CC) $(COMMON) $(LIBMAC) -D $(CURVE) $(MULTI_SET) -D IS_MAC_OS

else
$(CC) $(COMMON) $(LIB) -D $(CURVE) $(MULTI_SET)
Expand Down
12 changes: 6 additions & 6 deletions src/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main(int argc, char *argv[])
bench = 1;
if (argc < 3)
{
printf("******************* ZPiE v0.4 *******************\n");
printf("******************* ZPiE v0.5 *******************\n");
printf("USAGE: ./zpie [ACTIONS] [OPTIONS]\n\n");
printf("[ACTIONS]:\n");
printf("-s <c>: Perform setup of 'c' constraints.\n");
Expand All @@ -38,7 +38,7 @@ int main(int argc, char *argv[])

if ((argc == 4) && (strcmp(argv[3], "-l") == 0)) logs = 1;

printf("******************* ZPiE v0.4 *******************\n");
printf("******************* ZPiE v0.5 *******************\n");

if ((strcmp(argv[1], "-s") == 0) || (strcmp(argv[1], "-p") == 0) || (strcmp(argv[1], "-v") == 0))
{
Expand All @@ -47,8 +47,8 @@ int main(int argc, char *argv[])

printf("--- Starting ZPiE - Groth'16...\n");
printf(" |--- # of constraints: %d\n", N);
printf(" |--- # of variables: %d\n", M);
printf(" |--- # of public outputs: %d\n", nPublic);
printf(" |--- # of elements: %d\n", M);
printf(" |--- # of public elements: %d\n", nPublic);
}
else
{
Expand All @@ -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
4 changes: 1 addition & 3 deletions src/common/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ void init_prover(void *circuit, proving_key pk)
BsFr = (mclBnFr*) malloc((n) * sizeof(mclBnFr));
CsFr = (mclBnFr*) malloc((n) * sizeof(mclBnFr));

if (bench) printf(" |--- Mode: Prove\n");

mpz_init(pPrime);
mpz_set_str(pPrime, PRIMESTR, 10);
if (bench) printf(" |--- FFT constraints size : %d\n", n);
if (bench) printf(" |--- FFT domain size : %d\n", n);

rsigma = (mpz_t*) malloc((n) * sizeof(mpz_t));
rsigmaInv = (mpz_t*) malloc((n) * sizeof(mpz_t));
Expand Down
6 changes: 5 additions & 1 deletion src/gro16/prover.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ void mul_exp(struct mulExpResult *result, mpz_t *uwProof, proving_key pk)
if(i >= (nPublic + nConst)) mpz_to_fr(&uwFactorPublic[i-(nPublic + nConst)], &uw[i]);
}

int num_threads = get_nprocs();
#ifdef IS_MAC_OS
int num_threads = 8;
#else
int num_threads = get_nprocs();
#endif

mclBnG1_mulVecMT(&result->uwA1, pk.A1, uwFactor, M, num_threads);
mclBnG1_mulVecMT(&result->uwB1, pk.B1, uwFactor, M, num_threads);
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