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

Link example #47

Open
wants to merge 2 commits into
base: monolithic
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
10 changes: 10 additions & 0 deletions link_example/Makefile
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions link_example/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <iostream>

#include <gadgetlib2/examples/simple_example.hpp>
#include <zk_proof_systems/ppzksnark/r1cs_ppzksnark/examples/run_r1cs_ppzksnark.hpp>

int main() {
const libsnark::r1cs_example<libsnark::Fr<libsnark::default_ec_pp> > example = libsnark::gen_r1cs_example_from_gadgetlib2_protoboard(100);
const bool test_serialization = true;
const bool bit = libsnark::run_r1cs_ppzksnark<libsnark::default_ec_pp>(example, test_serialization);
std::cout << (bit ? "Success" : "Failure") << std::endl;
}
1 change: 0 additions & 1 deletion src/gadgetlib2/examples/tutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<libsnark::Fr<libsnark::default_ec_pp> > example = libsnark::gen_r1cs_example_from_gadgetlib2_protoboard(100);
const bool test_serialization = false;
Expand Down