{"id":24528025,"url":"https://github.com/erhant/circomkit-ffi","last_synced_at":"2026-02-18T14:01:47.469Z","repository":{"id":271621831,"uuid":"911781640","full_name":"erhant/circomkit-ffi","owner":"erhant","description":"A Rust-based shared library for alternative prover backends.","archived":false,"fork":false,"pushed_at":"2025-04-04T10:06:57.000Z","size":2771,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-07T22:35:07.623Z","etag":null,"topics":["circom","ffi","rust","zero-knowledge"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/circomkit-ffi","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erhant.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":"2025-01-03T20:48:55.000Z","updated_at":"2025-04-09T00:02:58.000Z","dependencies_parsed_at":"2025-01-08T22:09:25.599Z","dependency_job_id":"69695930-2b09-4a25-af95-14c9c6892c68","html_url":"https://github.com/erhant/circomkit-ffi","commit_stats":null,"previous_names":["erhant/circomkit-ffi"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/erhant/circomkit-ffi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fcircomkit-ffi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fcircomkit-ffi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fcircomkit-ffi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fcircomkit-ffi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erhant","download_url":"https://codeload.github.com/erhant/circomkit-ffi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erhant%2Fcircomkit-ffi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29581499,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T13:56:48.962Z","status":"ssl_error","status_checked_at":"2026-02-18T13:54:34.145Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["circom","ffi","rust","zero-knowledge"],"created_at":"2025-01-22T06:33:38.158Z","updated_at":"2026-02-18T14:01:47.433Z","avatar_url":"https://github.com/erhant.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e\n    Circomkit FFI\n  \u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\u003ci\u003eRust-based shared library for alternative provers.\u003c/i\u003e\u003c/p\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/erhant/circomkit-ffi/releases/latest\" target=\"_blank\"\u003e\n    \u003cimg alt=\"Release\" src=\"https://img.shields.io/github/v/release/erhant/circomkit-ffi?logo=github\u0026label=lib\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/circomkit-ffi\" target=\"_blank\"\u003e\n      \u003cimg alt=\"NPM\" src=\"https://img.shields.io/npm/v/circomkit-ffi?logo=npm\u0026color=CB3837\u0026label=sdk\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"./.github/workflows/test-lib.yml\" target=\"_blank\"\u003e\n      \u003cimg alt=\"Workflow: Tests\" src=\"https://github.com/erhant/circomkit-ffi/actions/workflows/test-lib.yaml/badge.svg?branch=main\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://opensource.org/licenses/MIT\" target=\"_blank\"\u003e\n      \u003cimg src=\"https://img.shields.io/badge/license-MIT-blue.svg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nThis repository contains an all-in-one adapter for several backends, mainly to be used by existing Javascript code via FFI. It features prover backends via:\n\n- [Arkworks](https://github.com/arkworks-rs/circom-compat) Circom adapter for **Groth16** over **BN254**.\n- [Lambdaworks](https://github.com/lambdaclass/lambdaworks/tree/main/provers/groth16/circom-adapter) Circom adapter for **Groth16** over **BLS12-381**\n- [Ingonyama ICICLE](https://github.com/ingonyama-zk/icicle-snark) for **Groth16** over **BN254** (via `icicle` feature).\n\nIt also provides [SnarkJS](https://github.com/iden3/snarkjs) exports for both prover backends, to export proof objects and public signals.\n\n\u003e [!NOTE]\n\u003e\n\u003e ICICLE is feature-gated because it requires a bit harder build process, and is in a very early stage of development.\n\n## Installation\n\nThe FFI libraries are exposed through an SDK, which is published on NPM.\n\n```sh\nnpm install circomkit-ffi\n```\n\nThe libraries are kept under this repository's releases, and supports the following platforms \u0026 architectures:\n\n- Linux amd64\n- Linux arm64\n- MacOS Intel (amd64)\n- MacoS Apple Silicon (arm64)\n- Windows x86_64 (amd64)\n\n## Usage\n\nThe SDK exposes two types of classes:\n\n- `CircomkitFFIBun` is exported at `/circomkit-ffi/bun` and uses [`bun:ffi`](https://bun.sh/docs/api/ffi) and must be used within a Bun runtime.\n- `CircomkitFFINode` uses [`ffi-rs`](https://github.com/zhangyuang/node-ffi-rs/) and can be used by both Bun and Node.\n\n\u003e [!NOTE]\n\u003e\n\u003e `CircomkitFFINode` has a peer dependency for `ffi-rs` as well:\n\u003e\n\u003e ```sh\n\u003e npm install ffi-rs\n\u003e ```\n\n### Downloading the library\n\nFirst you need to download the library suited to your machine. We provide some utilities for this:\n\n```ts\nimport { downloadRelease, getLibPath } from \"circomkit-ffi\";\nimport { existsSync } from \"fs\";\n\n// you can point to any directory for the library to be downloaded at:\nconst libDir = \"~/path/to/somewhere\";\n\n// you can get the path to library with `getLibPath`, it will attach the machine information to the file,\n// e.g.: on MacOS \u0026 Apple Silicon it will be:\n//   ~/path/to/somewhere/libcircomkit_ffi-macOS-arm64.dylib\nconst libPath = getLibPath(libDir);\n\n// now we can download if needed\nif (!existsSync(libPath)) {\n  console.info(\"Downloading FFI library.\");\n  await downloadRelease(libDir);\n}\n```\n\n### Preparing Node SDK\n\nThe Node SDK is exported from `/node` path, and requires `ffi-rs` as a peer dependency.\n\n```ts\nimport { CircomkitFFINode } from \"circomkit-ffi/node\";\nimport { open, load, close } from \"ffi-rs\";\n\n// assume library exists at path `libPath`\nconst lib = new CircomkitFFINode(libPath, open, close, load);\n```\n\n### Preparing Bun SDK\n\nThe Bun SDK is exported from `/bun` path, and works only for Bun runtime; trying to import this within Node runtime will cause an error.\n\n```ts\nimport { CircomkitFFIBun } from \"circomkit-ffi/bun\";\n\n// assume library exists at path `libPath`\nconst lib = new CircomkitFFIBun(libPath);\n```\n\n### Using the SDK\n\nWe are all set! We now have access to all the functions within our shared library. For example, we can call `arkworks_prove` to generate a proof using Arkworks. We just have to provide the necessary paths to R1CS, witness file and the prover key.\n\nWe can use a Circomkit instance to get these paths, but they can be manually written as well:\n\n```ts\nconst { proof, publicSignals } = lib.arkworks_prove(\n  circomkit.path.ofCircuitWithInput(circuitName, inputName, \"wtns\"),\n  circomkit.path.ofCircuit(circuitName, \"r1cs\"),\n  circomkit.path.ofCircuit(circuitName, \"pkey\")\n);\n```\n\n\u003e [!TIP]\n\u003e\n\u003e If for any reason you have to know whether you are in Bun or Node, you can use the `isBun` function exported by our SDK.\n\n## Development\n\nClone the repository:\n\n```sh\ngit clone https://github.com/erhant/circomkit-ffi\n```\n\n### Library\n\nThe library called by FFI is written in Rust. You can build the library (for your own machine) using:\n\n```sh\ncargo build\n```\n\nYou can run the tests with:\n\n```sh\ncargo test\n```\n\nBefore running tests:\n\n- you need to have installed [SnarkJS](https://github.com/iden3/snarkjs) globally, to verify that the FFI-generated proof is valid.\n- you need generated circuit files, which can be done using the commands below.\n\n```sh\n# preparations (do only once)\ncd example\nbun install\n\n# create circuit (e.g. multiplier_3) artifacts for tests\nCIRCUIT=multiplier_3\nbunx circomkit witness $CIRCUIT default\nbunx circomkit prove $CIRCUIT default\nbunx circomkit json wtns $CIRCUIT default\nbunx circomkit json r1cs $CIRCUIT\n```\n\n\u003e [!TIP]\n\u003e\n\u003e You can take the library directly from within `/target/debug/libcircomkit_ffi.\u003cyour-extension\u003e` and use with the SDK, for easier debugging with the SDK tests.\n\n### SDK\n\nThe SDK that provides an interface to the FFI-library is written in TypeScript, and we use Bun for this. Install packages with:\n\n```sh\nbun install\n```\n\nRun tests with:\n\n```sh\nbun test\n```\n\nYou can build the package using:\n\n```sh\nbun run build.ts\n```\n\nNote that we only export ESM modules, we do not have CommonJS support.\n\n## Example\n\nSee the [`example`](./example/) folder.\n\n## Benchmarks\n\nSee the [`bench`](./bench/) folder.\n\n## Acknowledgements\n\nThis project is kindly supported by [Soulforge zkBankai](https://soulforge.zkbankai.com/) grant, with the application [here](https://github.com/zk-bankai/soulforge/blob/main/applications/circomkit-bunffi.md).\n\nYou can find the presentation [here](./example/presentation.pdf) and its live video [here](https://youtu.be/uJjhsrP15L0).\n\nSome helpful resources for this project on FFI usage were:\n\n- \u003chttps://jakegoulding.com/rust-ffi-omnibus/string_return/\u003e\n- \u003chttps://jakegoulding.com/rust-ffi-omnibus/string_arguments/\u003e\n- \u003chttps://bun.sh/docs/api/ffi\u003e\n- \u003chttps://github.com/node-ffi/node-ffi/wiki/Node-FFI-Tutorial\u003e\n- \u003chttps://tokio.rs/tokio/topics/bridging\u003e\n\n## License\n\nThis project is [MIT](./LICENSE) licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferhant%2Fcircomkit-ffi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferhant%2Fcircomkit-ffi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferhant%2Fcircomkit-ffi/lists"}