diff --git a/.gitignore b/.gitignore index 1cfc1b2a..1d0ec79d 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ libsnark/zk_proof_systems/zksnark/ram_zksnark/profiling/profile_ram_zksnark libsnark/zk_proof_systems/zksnark/ram_zksnark/tests/test_ram_zksnark build +.DS_Store diff --git a/.gitmodules b/.gitmodules index c00570fa..a445c7c2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,18 +1,18 @@ [submodule "depends/gtest"] path = depends/gtest - url = git://github.com/google/googletest.git + url = https://github.com/google/googletest.git [submodule "depends/ate-pairing"] path = depends/ate-pairing - url = git://github.com/herumi/ate-pairing.git + url = https://github.com/herumi/ate-pairing.git [submodule "depends/xbyak"] path = depends/xbyak - url = git://github.com/herumi/xbyak.git + url = https://github.com/herumi/xbyak.git [submodule "depends/libsnark-supercop"] path = depends/libsnark-supercop - url = git://github.com/mbbarbosa/libsnark-supercop.git + url = https://github.com/mbbarbosa/libsnark-supercop.git [submodule "depends/libff"] path = depends/libff - url = https://github.com/scipr-lab/libff.git + url = https://github.com/meilof/libff.git [submodule "depends/libfqfft"] path = depends/libfqfft - url = https://github.com/scipr-lab/libfqfft.git + url = https://github.com/meilof/libfqfft.git diff --git a/CMakeLists.txt b/CMakeLists.txt index c4d4e222..6832e338 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) project (libsnark) @@ -105,7 +105,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # Common compilation flags and warning configuration set( CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wfatal-errors" + "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-unused-variable -Wfatal-errors" ) if("${MULTICORE}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") @@ -119,6 +119,8 @@ if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") endif() endif() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPT_FLAGS}" @@ -166,6 +168,12 @@ if(${CURVE} STREQUAL "BN128") add_definitions( -DBN_SUPPORT_SNARK=1 ) + + install( + DIRECTORY "depends/ate-pairing/include/" DESTINATION "include/libff/algebra/curves/bn128/depends/ate-pairing/include" + FILES_MATCHING + PATTERN "*.h" + ) endif() if("${DEBUG}") diff --git a/depends/libff b/depends/libff index 176f3f42..40c1ce57 160000 --- a/depends/libff +++ b/depends/libff @@ -1 +1 @@ -Subproject commit 176f3f42fdef791f12b24417a400c4b6d386863c +Subproject commit 40c1ce578550fa06a851bb80ecf4b686c612c226 diff --git a/depends/libfqfft b/depends/libfqfft index 7e1e957d..c00010cf 160000 --- a/depends/libfqfft +++ b/depends/libfqfft @@ -1 +1 @@ -Subproject commit 7e1e957d0e84accadcf92e88162510c0ad886709 +Subproject commit c00010cf7edf9bba6579cd06aa36a853f8c7171d diff --git a/depends/xbyak b/depends/xbyak index f0a8f7fa..590c10e3 160000 --- a/depends/xbyak +++ b/depends/xbyak @@ -1 +1 @@ -Subproject commit f0a8f7faa27121f28186c2a7f4222a9fc66c283d +Subproject commit 590c10e3746978dbfcf102d6da933ac2659e4544 diff --git a/libsnark/knowledge_commitment/kc_multiexp.tcc b/libsnark/knowledge_commitment/kc_multiexp.tcc index 6ca3a198..b40ac0a9 100644 --- a/libsnark/knowledge_commitment/kc_multiexp.tcc +++ b/libsnark/knowledge_commitment/kc_multiexp.tcc @@ -86,10 +86,14 @@ knowledge_commitment kc_multi_exp_with_mixed_addition(const knowledge_co ++index_it; ++value_it; } - + + if (!libff::inhibit_profiling_info) + { libff::print_indent(); printf("* Elements of w skipped: %zu (%0.2f%%)\n", num_skip, 100.*num_skip/(num_skip+num_add+num_other)); libff::print_indent(); printf("* Elements of w processed with special addition: %zu (%0.2f%%)\n", num_add, 100.*num_add/(num_skip+num_add+num_other)); libff::print_indent(); printf("* Elements of w remaining: %zu (%0.2f%%)\n", num_other, 100.*num_other/(num_skip+num_add+num_other)); + } + libff::leave_block("Process scalar vector"); return acc + libff::multi_exp, FieldT, Method>(g.begin(), g.end(), p.begin(), p.end(), chunks); diff --git a/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.tcc b/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.tcc index 23b89fb7..eb33ddc3 100644 --- a/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.tcc +++ b/libsnark/relations/constraint_satisfaction_problems/r1cs/r1cs.tcc @@ -224,7 +224,10 @@ void r1cs_constraint_system::swap_AB_if_beneficial() } else { + if (!libff::inhibit_profiling_info) + { libff::print_indent(); printf("Swap is not beneficial, not performing\n"); + } } libff::leave_block("Call to r1cs_constraint_system::swap_AB_if_beneficial"); diff --git a/libsnark/zk_proof_systems/ppzksnark/r1cs_gg_ppzksnark/r1cs_gg_ppzksnark.tcc b/libsnark/zk_proof_systems/ppzksnark/r1cs_gg_ppzksnark/r1cs_gg_ppzksnark.tcc index 0acb1905..5f8ddebc 100644 --- a/libsnark/zk_proof_systems/ppzksnark/r1cs_gg_ppzksnark/r1cs_gg_ppzksnark.tcc +++ b/libsnark/zk_proof_systems/ppzksnark/r1cs_gg_ppzksnark/r1cs_gg_ppzksnark.tcc @@ -229,10 +229,13 @@ r1cs_gg_ppzksnark_keypair r1cs_gg_ppzksnark_generator(const r1cs_gg_ppzksna /* A quadratic arithmetic program evaluated at t. */ qap_instance_evaluation > qap = r1cs_to_qap_instance_map_with_evaluation(r1cs_copy, t); + if (!libff::inhibit_profiling_info) + { libff::print_indent(); printf("* QAP number of variables: %zu\n", qap.num_variables()); libff::print_indent(); printf("* QAP pre degree: %zu\n", r1cs_copy.constraints.size()); libff::print_indent(); printf("* QAP degree: %zu\n", qap.degree()); libff::print_indent(); printf("* QAP number of input variables: %zu\n", qap.num_inputs()); + } libff::enter_block("Compute query densities"); size_t non_zero_At = 0; @@ -299,7 +302,10 @@ r1cs_gg_ppzksnark_keypair r1cs_gg_ppzksnark_generator(const r1cs_gg_ppzksna const size_t g1_scalar_size = libff::Fr::size_in_bits(); const size_t g1_window_size = libff::get_exp_window_size >(g1_scalar_count); + if (!libff::inhibit_profiling_info) + { libff::print_indent(); printf("* G1 window: %zu\n", g1_window_size); + } libff::window_table > g1_table = libff::get_window_table(g1_scalar_size, g1_window_size, g1_generator); libff::leave_block("Generating G1 MSM window table"); @@ -309,7 +315,10 @@ r1cs_gg_ppzksnark_keypair r1cs_gg_ppzksnark_generator(const r1cs_gg_ppzksna const size_t g2_scalar_size = libff::Fr::size_in_bits(); size_t g2_window_size = libff::get_exp_window_size >(g2_scalar_count); + if (!libff::inhibit_profiling_info) + { libff::print_indent(); printf("* G2 window: %zu\n", g2_window_size); + } libff::window_table > g2_table = libff::get_window_table(g2_scalar_size, g2_window_size, G2_gen); libff::leave_block("Generating G2 MSM window table"); @@ -381,8 +390,11 @@ r1cs_gg_ppzksnark_keypair r1cs_gg_ppzksnark_generator(const r1cs_gg_ppzksna std::move(L_query), std::move(r1cs_copy)); + if (!libff::inhibit_profiling_info) + { pk.print_size(); vk.print_size(); + } return r1cs_gg_ppzksnark_keypair(std::move(pk), std::move(vk)); } @@ -499,7 +511,10 @@ r1cs_gg_ppzksnark_proof r1cs_gg_ppzksnark_prover(const r1cs_gg_ppzksnark_pr libff::leave_block("Call to r1cs_gg_ppzksnark_prover"); r1cs_gg_ppzksnark_proof proof = r1cs_gg_ppzksnark_proof(std::move(g1_A), std::move(g2_B), std::move(g1_C)); + if (!libff::inhibit_profiling_info) + { proof.print_size(); + } return proof; } diff --git a/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc b/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc index 21dea1da..06369eae 100644 --- a/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc +++ b/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc @@ -253,10 +253,13 @@ r1cs_ppzksnark_keypair r1cs_ppzksnark_generator(const r1cs_ppzksnark_constr qap_instance_evaluation > qap_inst = r1cs_to_qap_instance_map_with_evaluation(cs_copy, t); + if (!libff::inhibit_profiling_info) + { libff::print_indent(); printf("* QAP number of variables: %zu\n", qap_inst.num_variables()); libff::print_indent(); printf("* QAP pre degree: %zu\n", cs_copy.constraints.size()); libff::print_indent(); printf("* QAP degree: %zu\n", qap_inst.degree()); libff::print_indent(); printf("* QAP number of input variables: %zu\n", qap_inst.num_inputs()); + } libff::enter_block("Compute query densities"); size_t non_zero_At = 0, non_zero_Bt = 0, non_zero_Ct = 0, non_zero_Ht = 0; @@ -329,8 +332,11 @@ r1cs_ppzksnark_keypair r1cs_ppzksnark_generator(const r1cs_ppzksnark_constr size_t g1_window = libff::get_exp_window_size >(g1_exp_count); size_t g2_window = libff::get_exp_window_size >(g2_exp_count); + if (!libff::inhibit_profiling_info) + { libff::print_indent(); printf("* G1 window: %zu\n", g1_window); libff::print_indent(); printf("* G2 window: %zu\n", g2_window); + } #ifdef MULTICORE const size_t chunks = omp_get_max_threads(); // to override, set OMP_NUM_THREADS env var or call omp_set_num_threads() @@ -419,9 +425,11 @@ r1cs_ppzksnark_keypair r1cs_ppzksnark_generator(const r1cs_ppzksnark_constr std::move(H_query), std::move(K_query), std::move(cs_copy)); - + if (!libff::inhibit_profiling_info) + { pk.print_size(); vk.print_size(); + } return r1cs_ppzksnark_keypair(std::move(pk), std::move(vk)); } @@ -537,7 +545,11 @@ r1cs_ppzksnark_proof r1cs_ppzksnark_prover(const r1cs_ppzksnark_proving_key libff::leave_block("Call to r1cs_ppzksnark_prover"); r1cs_ppzksnark_proof proof = r1cs_ppzksnark_proof(std::move(g_A), std::move(g_B), std::move(g_C), std::move(g_H), std::move(g_K)); + + if (!libff::inhibit_profiling_info) + { proof.print_size(); + } return proof; } diff --git a/macos.txt b/macos.txt new file mode 100644 index 00000000..88a9b5f7 --- /dev/null +++ b/macos.txt @@ -0,0 +1 @@ +sudo cmake -DCMAKE_PREFIX_PATH=/usr/local/Cellar/openssl/1.0.2t -DCMAKE_SHARED_LINKER_FLAGS=-L/usr/local/Cellar/openssl/1.0.2t/lib -DWITH_PROCPS=OFF -DWITH_SUPERCOP=OFF -DOPT_FLAGS=-std=c++11 -DCURVE=ALT_BN128 .. \ No newline at end of file diff --git a/updating.txt b/updating.txt new file mode 100644 index 00000000..f159a454 --- /dev/null +++ b/updating.txt @@ -0,0 +1,11 @@ +git checkout master +git pull + + + +git remote add upstream https://github.com/whoever/whatever.git +git fetch upstream + +git checkout master +#git rebase upstream/master +git merge upstream/master \ No newline at end of file