{"id":20368857,"url":"https://github.com/xevisalle/zpie","last_synced_at":"2025-07-03T23:33:58.283Z","repository":{"id":65301052,"uuid":"358229144","full_name":"xevisalle/zpie","owner":"xevisalle","description":"ZPiE: Zero-knowledge Proofs in Embedded systems","archived":false,"fork":false,"pushed_at":"2023-11-13T23:29:37.000Z","size":140,"stargazers_count":24,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T05:51:37.835Z","etag":null,"topics":["arithmetic-circuits","bulletproofs","c","cryptography","range-proofs","zero-knowledge-proofs","zk-snarks"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xevisalle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-15T11:09:31.000Z","updated_at":"2025-03-12T07:53:59.000Z","dependencies_parsed_at":"2023-01-16T15:15:28.575Z","dependency_job_id":"fb20d753-5a6b-4b24-875d-b6953b055ee4","html_url":"https://github.com/xevisalle/zpie","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/xevisalle/zpie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xevisalle%2Fzpie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xevisalle%2Fzpie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xevisalle%2Fzpie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xevisalle%2Fzpie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xevisalle","download_url":"https://codeload.github.com/xevisalle/zpie/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xevisalle%2Fzpie/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263421502,"owners_count":23464013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arithmetic-circuits","bulletproofs","c","cryptography","range-proofs","zero-knowledge-proofs","zk-snarks"],"created_at":"2024-11-15T00:43:23.713Z","updated_at":"2025-07-03T23:33:58.188Z","avatar_url":"https://github.com/xevisalle.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ZPiE: Zero-knowledge Proofs in Embedded systems\n\n![Build Status](https://github.com/xevisalle/zpie/workflows/tests/badge.svg)\n[![Repository](https://img.shields.io/badge/github-zpie-blueviolet?logo=github)](https://github.com/xevisalle/zpie)\n\nA portable and efficient C library for developing Zero-Knowledge applications for embedded systems. \n\n**DISCLAIMER**: this library is currently **unstable**. Furthermore, **it has not gone through an exhaustive security analysis**, so it is not intended to be used in a production environment, only for academic purposes.\n\nAn academic paper about ZPiE has been published in the special issue *Recent Advances in Security, Privacy, and Applied Cryptography* of the journal *Mathematics* (2021) and can be found [here](https://doi.org/10.3390/math9202569).\n\n## Overview\n\nZPiE supports the following Zero-Knowledge schemes, defined over the elliptic curves BN128 and BLS12-381:\n\n- zk-SNARKs for arithmetic circuits. We support the [Groth'16](https://eprint.iacr.org/2016/260.pdf) scheme. ZPiE includes the following arithmetic circuits:\n    - [EdDSA](https://eprint.iacr.org/2015/677.pdf) signature algorithm over [Baby JubJub](https://iden3-docs.readthedocs.io/en/latest/_downloads/33717d75ab84e11313cc0d8a090b636f/Baby-Jubjub.pdf) elliptic curve and BN128.\n    - [MiMC-7](https://eprint.iacr.org/2016/492.pdf) hashing function (BN128 order).\n- [Bulletproofs](https://eprint.iacr.org/2017/1066.pdf). We support range proofs (and aggregated range proofs).\n\nIn order to compute the circuit inputs for the above described circuits, you can use this [repository](https://github.com/xevisalle/cryptoolz).\n\n\n## Install dependencies\nZPiE needs [GMP](https://gmplib.org/) and [MCL](https://github.com/herumi/mcl). To install them, and some other required dependencies, simply run:\n\n```\nsudo apt install libgmp-dev libcunit1-dev\ngit clone https://github.com/herumi/mcl\ncd mcl\nmake -j8\n```\n\nIf willing to use the multi-thread execution, compile MCL using `make -j8 MCL_USE_OMP=1`.\n\n## Test\nZPiE can be tested as follows:\n\n```\ngit clone https://github.com/xevisalle/zpie\ncd zpie\nmake test\n```\n\n## Benchmarks\n\nYou can compile a benchmarking application by running the following command, which will also prompt you with a set of available options to benchmark all the features of ZPiE:\n\n```\nmake bench\n```\n\n## Compiling options\n\nWe can specify the elliptic curve to be used:\n\n```\nmake bench CURVE=[OPTION]\n\nWhere [OPTION] can be:\nBN128 (default)\nBLS12_381\n```\n\nWe can specify to run the code in multi-thread mode (if MCL was compiled accordingly):\n\n```\nmake bench MULTI=on\n```\n\n## zk-SNARKs for arithmetic circuits\n\nHere there is an example on how to use zk-SNARKs. Copy the following snippet into a file (e.g. called `/src/main.c`):\n\n```c\n#include \"zpie.h\"\n\nvoid circuit()\n{\n    // set a public element\n    element out;\n    init_public(\u0026out);\n\n    // set private elements\n    element a, b;\n    init(\u0026a);\n    init(\u0026b);\n\n    // input a value for the elements\n    input(\u0026a, \"1234\");\n    input(\u0026b, \"5678\");\n\n    // apply a constraint multiplying such elements\n    mul(\u0026out, \u0026a, \u0026b);\n}\n\nint main()\n{\n    // we perform the setup\n    setup_keys keys = perform_setup(\u0026circuit); \n\n    // we generate a proof\n    proof p = generate_proof(\u0026circuit, keys.pk);\n\n    // we verify the proof \n    if (verify_proof(\u0026circuit, p, keys.vk)) \n        printf(\"Proof verified.\\n\");\n    else \n        printf(\"Proof cannot be verified.\\n\");\n}\n```\n\nAnd compile and execute using:\n\n```\nmake MAIN=main \u0026\u0026 ./zpie\n```\n\nMore circuit examples can be found in the `/src/tests.c` file.\n\n## Bulletproofs\n\nTBC.\n\n## Cross-compile\n\n### Build for x86_64\n\nFirst we need to download and compile GMP for i386 64-bits:\n\n```\nwget https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz\ntar -xf gmp-6.2.0.tar.xz\ncd gmp-6.2.0\n./configure --enable-cxx ABI=64\nmake -j12\nsudo make install\n```\n\nThen, we have to build MCL for i386 64-bits:\n\n```\ngit clone https://github.com/herumi/mcl\ncd mcl\nmake -j12 ARCH=x86_64\n```\n\nWe finally build ZPiE:\n\n```\nmake bench ARCH=x86_64\n```\n\n### Build for x86\n\nFirst we need to download and compile GMP for i386 32-bits:\n\n```\nwget https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz\ntar -xf gmp-6.2.0.tar.xz\ncd gmp-6.2.0\n./configure --enable-cxx ABI=32\nmake -j12\nsudo make install\n```\n\nThen, we have to build MCL for i386 32-bits:\n\n```\ngit clone https://github.com/herumi/mcl\ncd mcl\nmake -j12 ARCH=x86\n```\n\nWe finally build ZPiE:\n\n```\nmake bench ARCH=x86\n```\n\n### Build for ARM 64-bits\n\nFirst we need to download and compile GMP for ARM 64-bits:\n\n```\nwget https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz\ntar -xf gmp-6.2.0.tar.xz\ncd gmp-6.2.0\n./configure --host=aarch64 ABI=64 CC=aarch64-linux-gnu-gcc\nmake -j12\nsudo make install\n```\n\nThen, we have to build MCL for 32-bits:\n\n```\ngit clone https://github.com/herumi/mcl\ncd mcl\nmake -j12 CXX=aarch64-linux-gnu-g++ ARCH=aarch64 MCL_USE_GMP=0\n```\n\nWe finally build ZPiE:\n\n```\nmake bench ARCH=aarch64\n```\n\n### Build for ARM 32-bits\n\nFirst we need to download and compile GMP for ARM 32-bits:\n\n```\nwget https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz\ntar -xf gmp-6.2.0.tar.xz\ncd gmp-6.2.0\n./configure --enable-cxx --host=armv6l ABI=32 CC=arm-linux-gnueabihf-gcc\nmake -j12\nsudo make install\n```\n\nThen, we have to build MCL for ARM 32-bits:\n\n```\ngit clone https://github.com/herumi/mcl\ncd mcl\nmake -j12 CXX=arm-linux-gnueabihf-g++ ARCH=armv6l CFLAGS_USER=\"-I /usr/local/include\" LDFLAGS=\"/usr/local/lib/libgmp.a /usr/local/lib/libgmpxx.a\"\n```\n\nWe finally build ZPiE:\n\n```\nmake bench ARCH=arm\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxevisalle%2Fzpie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxevisalle%2Fzpie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxevisalle%2Fzpie/lists"}