From 46eeb6a10f9b5da8aed80af89999357891c70f4a Mon Sep 17 00:00:00 2001 From: benma Date: Wed, 10 Aug 2016 12:27:00 +0200 Subject: [PATCH 1/2] Remove superfluous line initPublicParamsFromDefaultPp is alreadycalled in gen_r1cs_example_from_gadgetlib2_protoboard. --- src/gadgetlib2/examples/tutorial.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gadgetlib2/examples/tutorial.cpp b/src/gadgetlib2/examples/tutorial.cpp index 511edc07..740dd934 100644 --- a/src/gadgetlib2/examples/tutorial.cpp +++ b/src/gadgetlib2/examples/tutorial.cpp @@ -488,7 +488,6 @@ TEST(Examples, R1P_VerifyTransactionAmounts_Gadget) { */ TEST(gadgetLib2,Integration) { - initPublicParamsFromDefaultPp(); // Create an example constraint system and translate to libsnark format const libsnark::r1cs_example > example = libsnark::gen_r1cs_example_from_gadgetlib2_protoboard(100); const bool test_serialization = false; From 6be0121cbeedefc2bffd4b89e7ef268a7da90efe Mon Sep 17 00:00:00 2001 From: benma Date: Wed, 10 Aug 2016 12:21:51 +0200 Subject: [PATCH 2/2] Add an example of how to link to libsnark.so Issue #18 --- README.md | 1 + link_example/Makefile | 10 ++++++++++ link_example/main.cpp | 11 +++++++++++ 3 files changed, 22 insertions(+) create mode 100644 link_example/Makefile create mode 100644 link_example/main.cpp diff --git a/README.md b/README.md index d5aa3400..06f46e11 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,7 @@ with some (currently sparse) comments, install the `doxygen` and `graphviz` pack To develop an application that uses libsnark, you could add it within the libsnark directory tree and adjust the Makefile, but it is far better to build libsnark as a (shared or static) library. You can then write your code in a separate directory tree, and link it against libsnark. +See a full example in ./link_example/. To build just the shared object library `libsnark.so`, run: diff --git a/link_example/Makefile b/link_example/Makefile new file mode 100644 index 00000000..4ba12d77 --- /dev/null +++ b/link_example/Makefile @@ -0,0 +1,10 @@ +# Set this to the directory where you installed libsnark. +# If you install to link_example (`make install PREFIX=link_example`), +# the default prefix will work. +INSTALL_PREFIX=. + +all: + $(CXX) main.cpp -o main -std=c++11 -L$(INSTALL_PREFIX)/lib -lsnark -lsupercop -lgmp -lgmpxx -I$(INSTALL_PREFIX)/include -I$(INSTALL_PREFIX)/include/libsnark -DCURVE_BN128 + +run: + LD_LIBRARY_PATH=$(INSTALL_PREFIX)/lib ./main diff --git a/link_example/main.cpp b/link_example/main.cpp new file mode 100644 index 00000000..3a4962cb --- /dev/null +++ b/link_example/main.cpp @@ -0,0 +1,11 @@ +#include + +#include +#include + +int main() { + const libsnark::r1cs_example > example = libsnark::gen_r1cs_example_from_gadgetlib2_protoboard(100); + const bool test_serialization = true; + const bool bit = libsnark::run_r1cs_ppzksnark(example, test_serialization); + std::cout << (bit ? "Success" : "Failure") << std::endl; +}