From d16d90acd5e90e48820461d2156c194483450498 Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Mon, 19 Aug 2019 19:27:47 +0200 Subject: [PATCH 01/15] Increase cmake version (helps with building on Mac OS X) Setting version to 3.1 enables using CMAKE_PREFIX_PATH to specify pkg-config locations (see https://github.com/Kitware/CMake/blob/master/Modules/FindPkgConfig.cmake#L115). This heps for example on Mac OS X if you want to provide a location for libcrypto. With this patch I was able to compile libsnark with "cmake .. -DCMAKE_PREFIX_PATH=/usr/local/Cellar/openssl/1.0.2s -DWITH_PROCPS=OFF -DWITH_SUPERCOP=OFF" --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4d4e222..b93b9597 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) From aad309eb88d2d985a061616232c987d64cdc7ba0 Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Mon, 19 Aug 2019 22:37:11 +0200 Subject: [PATCH 02/15] avoid printing libsnark debugging outputs --- .gitmodules | 2 +- depends/libff | 2 +- libsnark/knowledge_commitment/kc_multiexp.tcc | 6 +++++- .../ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc | 8 +++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index c00570fa..8fce131b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,7 +12,7 @@ url = git://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 [submodule "depends/libfqfft"] path = depends/libfqfft url = https://github.com/scipr-lab/libfqfft.git diff --git a/depends/libff b/depends/libff index f2067162..cbb00cbc 160000 --- a/depends/libff +++ b/depends/libff @@ -1 +1 @@ -Subproject commit f2067162520f91438b44e71a2cab2362f1c3cab4 +Subproject commit cbb00cbc970ac7284fc39173568a63392f3c8ad8 diff --git a/libsnark/knowledge_commitment/kc_multiexp.tcc b/libsnark/knowledge_commitment/kc_multiexp.tcc index e3d09e90..16adb31d 100644 --- a/libsnark/knowledge_commitment/kc_multiexp.tcc +++ b/libsnark/knowledge_commitment/kc_multiexp.tcc @@ -79,10 +79,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/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc b/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc index 21dea1da..3d5f57bd 100644 --- a/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc +++ b/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc @@ -419,9 +419,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 +539,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; } From bd155487f6a0e46e9c8eab6c87564eb0619e258d Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Tue, 27 Aug 2019 22:13:57 +0200 Subject: [PATCH 03/15] modified gitmodules to refer to https:// for jekyll building --- .gitmodules | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index 8fce131b..7bac730a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,15 @@ [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/meilof/libff From 7a004bedb53f4741b0037ea0315110cc447273d1 Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Fri, 6 Sep 2019 07:28:25 +0200 Subject: [PATCH 04/15] remove more debugging info --- .../constraint_satisfaction_problems/r1cs/r1cs.tcc | 3 +++ .../ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc | 6 ++++++ 2 files changed, 9 insertions(+) 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_ppzksnark/r1cs_ppzksnark.tcc b/libsnark/zk_proof_systems/ppzksnark/r1cs_ppzksnark/r1cs_ppzksnark.tcc index 3d5f57bd..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() From f7385fd4b481a9793b98b1509007d43a81cc1a07 Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Wed, 11 Sep 2019 19:53:11 +0200 Subject: [PATCH 05/15] switch to own libfqfft --- .gitmodules | 4 ++-- depends/libfqfft | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 7bac730a..a445c7c2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -12,7 +12,7 @@ url = https://github.com/mbbarbosa/libsnark-supercop.git [submodule "depends/libff"] path = depends/libff - url = https://github.com/meilof/libff + 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/depends/libfqfft b/depends/libfqfft index e0183b2c..30c37832 160000 --- a/depends/libfqfft +++ b/depends/libfqfft @@ -1 +1 @@ -Subproject commit e0183b2cef7d4c5deb21a6eaf3fe3b586d738fe0 +Subproject commit 30c378328177d5d8cf2afd2cd2b36c7a6241a003 From 1697ad3121d928067e7b53ded8ce06c06e608dc5 Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Sun, 6 Oct 2019 21:39:24 +0200 Subject: [PATCH 06/15] suppress debug output --- .../r1cs_gg_ppzksnark/r1cs_gg_ppzksnark.tcc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; } From 31e1ba1884362fe60b89c7073874a930d58b2610 Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Fri, 11 Oct 2019 22:27:06 +0200 Subject: [PATCH 07/15] no warnings please --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b93b9597..db2aa43a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 -Wfatal-errors" ) if("${MULTICORE}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") From b34c1cf54a8837c5911d4fae8706fc8f701e3112 Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Fri, 11 Oct 2019 22:32:41 +0200 Subject: [PATCH 08/15] no warn --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db2aa43a..4e288662 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 -Wfatal-errors" + "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-unused-variable -Wfatal-errors" ) if("${MULTICORE}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") From 73d5dcf08190cb143be91417da3474b7bce5e0b9 Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Sat, 12 Oct 2019 18:47:49 +0200 Subject: [PATCH 09/15] should install headers --- CMakeLists.txt | 6 ++++++ depends/libfqfft | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b93b9597..1440056e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,6 +166,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/libfqfft b/depends/libfqfft index 30c37832..c00010cf 160000 --- a/depends/libfqfft +++ b/depends/libfqfft @@ -1 +1 @@ -Subproject commit 30c378328177d5d8cf2afd2cd2b36c7a6241a003 +Subproject commit c00010cf7edf9bba6579cd06aa36a853f8c7171d From 28f1edc584c5df10dec097b8b27f063b67839b64 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Sat, 12 Oct 2019 17:06:53 +0000 Subject: [PATCH 10/15] add fpic --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c379231d..6832e338 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}" From cc7f5bf952bed0108550a4ec8a4ed5c7c4181500 Mon Sep 17 00:00:00 2001 From: Meilof Date: Fri, 18 Oct 2019 22:45:23 +0000 Subject: [PATCH 11/15] Update libff --- depends/libff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/libff b/depends/libff index cbb00cbc..47d998b0 160000 --- a/depends/libff +++ b/depends/libff @@ -1 +1 @@ -Subproject commit cbb00cbc970ac7284fc39173568a63392f3c8ad8 +Subproject commit 47d998b01050d7026596aae6d0ba6f39e1e95a1a From 0699ea412229b373e2898b236ee29a06108d5b9a Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Mon, 21 Oct 2019 20:03:43 +0200 Subject: [PATCH 12/15] Update libff --- depends/libff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/libff b/depends/libff index 47d998b0..40c1ce57 160000 --- a/depends/libff +++ b/depends/libff @@ -1 +1 @@ -Subproject commit 47d998b01050d7026596aae6d0ba6f39e1e95a1a +Subproject commit 40c1ce578550fa06a851bb80ecf4b686c612c226 From 1baff7408e5ce7b32975c47c5350e9015659136d Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Thu, 1 Apr 2021 21:37:24 +0200 Subject: [PATCH 13/15] macos command --- .gitignore | 1 + macos.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 macos.txt 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/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 From d389c513763ae88dcf4b42e28826fb626b234ed5 Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Sat, 3 Apr 2021 16:08:07 +0200 Subject: [PATCH 14/15] updated depends --- depends/xbyak | 2 +- updating.txt | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 updating.txt 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/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 From cef2a9c8efbde081dd07ae813f5563e939dbe88d Mon Sep 17 00:00:00 2001 From: Meilof Veeningen Date: Sun, 15 May 2022 21:35:05 +0200 Subject: [PATCH 15/15] switch libff version --- depends/libff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/libff b/depends/libff index cdc8d01c..40c1ce57 160000 --- a/depends/libff +++ b/depends/libff @@ -1 +1 @@ -Subproject commit cdc8d01cbb8c7709f75b6c90deed4e8522da93e5 +Subproject commit 40c1ce578550fa06a851bb80ecf4b686c612c226