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

Increase cmake version, avoid printing debugging values (do not pull automatically!) #161

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.1)

project (libsnark)

Expand Down Expand Up @@ -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")
Expand All @@ -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}"
Expand Down Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion depends/libff
Submodule libff updated 40 files
+1 −0 libff/CMakeLists.txt
+11 −15 libff/algebra/curves/alt_bn128/alt_bn128_g1.cpp
+0 −1 libff/algebra/curves/alt_bn128/alt_bn128_g1.hpp
+11 −15 libff/algebra/curves/alt_bn128/alt_bn128_g2.cpp
+0 −1 libff/algebra/curves/alt_bn128/alt_bn128_g2.hpp
+0 −4 libff/algebra/curves/alt_bn128/alt_bn128_init.cpp
+24 −27 libff/algebra/curves/bn128/bn128_g1.cpp
+0 −1 libff/algebra/curves/bn128/bn128_g1.hpp
+23 −27 libff/algebra/curves/bn128/bn128_g2.cpp
+0 −1 libff/algebra/curves/bn128/bn128_g2.hpp
+6 −6 libff/algebra/curves/bn128/bn128_gt.cpp
+0 −4 libff/algebra/curves/bn128/bn128_init.cpp
+18 −18 libff/algebra/curves/bn128/bn128_pairing.cpp
+11 −15 libff/algebra/curves/edwards/edwards_g1.cpp
+0 −1 libff/algebra/curves/edwards/edwards_g1.hpp
+11 −15 libff/algebra/curves/edwards/edwards_g2.cpp
+0 −1 libff/algebra/curves/edwards/edwards_g2.hpp
+1 −2 libff/algebra/curves/edwards/edwards_init.cpp
+11 −15 libff/algebra/curves/mnt/mnt4/mnt4_g1.cpp
+0 −1 libff/algebra/curves/mnt/mnt4/mnt4_g1.hpp
+11 −15 libff/algebra/curves/mnt/mnt4/mnt4_g2.cpp
+0 −1 libff/algebra/curves/mnt/mnt4/mnt4_g2.hpp
+0 −2 libff/algebra/curves/mnt/mnt4/mnt4_init.cpp
+11 −15 libff/algebra/curves/mnt/mnt6/mnt6_g1.cpp
+0 −1 libff/algebra/curves/mnt/mnt6/mnt6_g1.hpp
+11 −15 libff/algebra/curves/mnt/mnt6/mnt6_g2.cpp
+0 −1 libff/algebra/curves/mnt/mnt6/mnt6_g2.hpp
+0 −2 libff/algebra/curves/mnt/mnt6/mnt6_init.cpp
+0 −9 libff/algebra/curves/tests/test_bilinearity.cpp
+0 −9 libff/algebra/curves/tests/test_groups.cpp
+26 −26 libff/algebra/fields/bigint.tcc
+2 −2 libff/algebra/fields/field_utils.tcc
+8 −32 libff/algebra/fields/fp.tcc
+1 −1 libff/algebra/fields/fp12_2over3over2.tcc
+1 −10 libff/algebra/fields/tests/test_fields.cpp
+4 −4 libff/algebra/scalar_multiplication/multiexp.tcc
+1 −1 libff/common/rng.tcc
+21 −0 libff/common/serialization.cpp
+14 −8 libff/common/serialization.hpp
+6 −6 libff/common/serialization.tcc
2 changes: 1 addition & 1 deletion depends/libfqfft
Submodule libfqfft updated 458 files
2 changes: 1 addition & 1 deletion depends/xbyak
Submodule xbyak updated 62 files
+11 −0 .github/workflows/main.yml
+1 −0 .gitignore
+43 −3 CMakeLists.txt
+1 −1 Makefile
+1 −0 cmake/config.cmake.in
+10 −0 gen/avx_type.hpp
+86 −68 gen/gen_avx512.cpp
+286 −148 gen/gen_code.cpp
+362 −205 readme.md
+98 −14 readme.txt
+19 −5 sample/Makefile
+16 −18 sample/bf.cpp
+0 −427 sample/bf.vcproj
+228 −0 sample/bf.vcxproj
+3 −3 sample/calc.cpp
+0 −423 sample/calc.vcproj
+228 −0 sample/calc.vcxproj
+2 −2 sample/calc2.cpp
+90 −0 sample/profiler.cpp
+70 −0 sample/protect-re.cpp
+16 −19 sample/quantize.cpp
+0 −427 sample/quantize.vcproj
+228 −0 sample/quantize.vcxproj
+6 −2 sample/static_buf.cpp
+13 −9 sample/test0.cpp
+0 −427 sample/test0.vcproj
+228 −0 sample/test0.vcxproj
+16 −2 sample/test_util.cpp
+0 −427 sample/test_util.vcproj
+228 −0 sample/test_util.vcxproj
+25 −25 sample/toyvm.cpp
+0 −427 sample/toyvm.vcproj
+228 −0 sample/toyvm.vcxproj
+33 −2 test/Makefile
+15 −32 test/bad_address.cpp
+79 −53 test/cvt_test.cpp
+0 −27 test/cybozu/COPYRIGHT
+59 −17 test/cybozu/inttype.hpp
+1 −1 test/cybozu/test.hpp
+248 −15 test/jmp.cpp
+230 −220 test/make_512.cpp
+253 −122 test/make_nm.cpp
+162 −1 test/misc.cpp
+13 −24 test/nm_frame.cpp
+111 −0 test/noexception.cpp
+1 −1 test/normalize_prefix.cpp
+2 −2 test/rip-label-imm.cpp
+2 −0 test/set_opt.bat
+85 −7 test/sf_test.cpp
+1 −1 test/test_address.bat
+1 −2 test/test_address.sh
+1 −1 test/test_avx.bat
+29 −25 test/test_avx.sh
+1 −1 test/test_avx512.bat
+18 −16 test/test_avx512.sh
+4 −0 test/test_avx_all.bat
+6 −3 test/test_nm.bat
+42 −31 test/test_nm.sh
+14 −10 xbyak.sln
+731 −435 xbyak/xbyak.h
+395 −305 xbyak/xbyak_mnemonic.h
+385 −128 xbyak/xbyak_util.h
6 changes: 5 additions & 1 deletion libsnark/knowledge_commitment/kc_multiexp.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,14 @@ knowledge_commitment<T1, T2> 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<knowledge_commitment<T1, T2>, FieldT, Method>(g.begin(), g.end(), p.begin(), p.end(), chunks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ void r1cs_constraint_system<FieldT>::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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,13 @@ r1cs_gg_ppzksnark_keypair<ppT> r1cs_gg_ppzksnark_generator(const r1cs_gg_ppzksna
/* A quadratic arithmetic program evaluated at t. */
qap_instance_evaluation<libff::Fr<ppT> > 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;
Expand Down Expand Up @@ -299,7 +302,10 @@ r1cs_gg_ppzksnark_keypair<ppT> r1cs_gg_ppzksnark_generator(const r1cs_gg_ppzksna
const size_t g1_scalar_size = libff::Fr<ppT>::size_in_bits();
const size_t g1_window_size = libff::get_exp_window_size<libff::G1<ppT> >(g1_scalar_count);

if (!libff::inhibit_profiling_info)
{
libff::print_indent(); printf("* G1 window: %zu\n", g1_window_size);
}
libff::window_table<libff::G1<ppT> > g1_table = libff::get_window_table(g1_scalar_size, g1_window_size, g1_generator);
libff::leave_block("Generating G1 MSM window table");

Expand All @@ -309,7 +315,10 @@ r1cs_gg_ppzksnark_keypair<ppT> r1cs_gg_ppzksnark_generator(const r1cs_gg_ppzksna
const size_t g2_scalar_size = libff::Fr<ppT>::size_in_bits();
size_t g2_window_size = libff::get_exp_window_size<libff::G2<ppT> >(g2_scalar_count);

if (!libff::inhibit_profiling_info)
{
libff::print_indent(); printf("* G2 window: %zu\n", g2_window_size);
}
libff::window_table<libff::G2<ppT> > g2_table = libff::get_window_table(g2_scalar_size, g2_window_size, G2_gen);
libff::leave_block("Generating G2 MSM window table");

Expand Down Expand Up @@ -381,8 +390,11 @@ r1cs_gg_ppzksnark_keypair<ppT> 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<ppT>(std::move(pk), std::move(vk));
}
Expand Down Expand Up @@ -499,7 +511,10 @@ r1cs_gg_ppzksnark_proof<ppT> r1cs_gg_ppzksnark_prover(const r1cs_gg_ppzksnark_pr
libff::leave_block("Call to r1cs_gg_ppzksnark_prover");

r1cs_gg_ppzksnark_proof<ppT> proof = r1cs_gg_ppzksnark_proof<ppT>(std::move(g1_A), std::move(g2_B), std::move(g1_C));
if (!libff::inhibit_profiling_info)
{
proof.print_size();
}

return proof;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,13 @@ r1cs_ppzksnark_keypair<ppT> r1cs_ppzksnark_generator(const r1cs_ppzksnark_constr

qap_instance_evaluation<libff::Fr<ppT> > 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;
Expand Down Expand Up @@ -329,8 +332,11 @@ r1cs_ppzksnark_keypair<ppT> r1cs_ppzksnark_generator(const r1cs_ppzksnark_constr

size_t g1_window = libff::get_exp_window_size<libff::G1<ppT> >(g1_exp_count);
size_t g2_window = libff::get_exp_window_size<libff::G2<ppT> >(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()
Expand Down Expand Up @@ -419,9 +425,11 @@ r1cs_ppzksnark_keypair<ppT> 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<ppT>(std::move(pk), std::move(vk));
}
Expand Down Expand Up @@ -537,7 +545,11 @@ r1cs_ppzksnark_proof<ppT> r1cs_ppzksnark_prover(const r1cs_ppzksnark_proving_key
libff::leave_block("Call to r1cs_ppzksnark_prover");

r1cs_ppzksnark_proof<ppT> proof = r1cs_ppzksnark_proof<ppT>(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;
}
Expand Down
1 change: 1 addition & 0 deletions macos.txt
Original file line number Diff line number Diff line change
@@ -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 ..
11 changes: 11 additions & 0 deletions updating.txt
Original file line number Diff line number Diff line change
@@ -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