{"id":29029264,"url":"https://github.com/aionnetwork/bn128-jni","last_synced_at":"2026-06-29T12:31:27.194Z","repository":{"id":92023275,"uuid":"220540229","full_name":"aionnetwork/bn128-jni","owner":"aionnetwork","description":"Alt-Bn 128 JNI Wrapper","archived":false,"fork":false,"pushed_at":"2019-11-09T22:19:39.000Z","size":82,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-26T08:06:42.066Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aionnetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-11-08T20:11:15.000Z","updated_at":"2023-12-02T13:21:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"1829f402-d636-4c64-8264-092d8261d252","html_url":"https://github.com/aionnetwork/bn128-jni","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aionnetwork/bn128-jni","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aionnetwork%2Fbn128-jni","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aionnetwork%2Fbn128-jni/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aionnetwork%2Fbn128-jni/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aionnetwork%2Fbn128-jni/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aionnetwork","download_url":"https://codeload.github.com/aionnetwork/bn128-jni/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aionnetwork%2Fbn128-jni/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34927675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-29T02:00:05.398Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-06-26T08:06:40.648Z","updated_at":"2026-06-29T12:31:27.188Z","avatar_url":"https://github.com/aionnetwork.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Alt-Bn 128 JNI Wrapper\n\nWe wrap the [Parity implementation](https://github.com/paritytech/bn) of the Barreto–Naehrig curve introduced in [BCTV13](https://eprint.iacr.org/2013/879.pdf), using the [Java Native Interface (JNI)](https://docs.oracle.com/en/java/javase/13/docs/specs/jni/index.html). This enables arithmetic and pairing operations over the Alt-BN 128 curve from Java programs. The Alt-Bn 128 curve (which is parameterized differently than the BN 128 curve) is completely specified in section E.1 of the [Ethereum Yellow-paper](https://ethereum.github.io/yellowpaper/paper.pdf).\n\nThis repository contains two projects. First, labelled `native`, generates the native library, and the second, labelled `bench`, tests the JNI functionality.\n\n## Native Library\n\nThe [`native`](https://github.com/aionnetwork/bn128-jni/tree/master/native) directory contains a rust project that leverages the [rust jni bindings](https://docs.rs/jni/0.13.1/jni/) to generate a shared native library. The native library includes the appropriate JNI headers to bridge bytecode running in a JVM and the native code implementing the curve operations. \n\nIn order to build the shared library, first, initialize the project submodules. Then, in the `native` directory, run the following command: \n```\ncargo build --release\n```\nThe build output (available in the `target/release` folder) is `libbn_jni.so`. The file extension will be `.so` on linux, `.dylib` on mac or `.dll` on windows. \n\n## Java Testbench\n\nThe [`bench`](https://github.com/aionnetwork/bn128-jni/tree/master/bench) folder contains a Java testbench to validate invocation of native library from Java. \n\nBefore executing the testbench, make sure to build the native library, since the testbench sets the `java.library.path` to the `native/target/release/` folder. The project uses gradle, so the tests can be executed by running the following command in the `bench` directory:\n ```\n./gradlew test\n ``` \n\n## Improvements and Benchmarking\n\nThe Parity implementation of the Alt-Bn 128 curve was chosen since this implementation boasted the best performance of the well-known open-source implementations for the bn128 curve: \n * [Matter Labs' (Rust)](https://github.com/matter-labs/pairing/tree/master/src/bn256)\n * [Cloudflare's (Go)](https://github.com/cloudflare/bn256)\n * [EthereumJ's (Java)](https://github.com/ethereum/ethereumj/tree/develop/ethereumj-core/src/main/java/org/ethereum/crypto/zksnark)\n * [LibSnarks' Reference](https://github.com/scipr-lab/libff/tree/master/libff/algebra/curves/alt_bn128)\n \nNo serious performance benchmarking was done for this JNI wrapper. Overhead incurred in the JVM while calling native libraries through JNI is well understood (see [this paper](https://pdfs.semanticscholar.org/2b7e/9b075e51c5eb51bb035b39b17617f7428247.pdf) \u0026 [this paper](https://hal.archives-ouvertes.fr/hal-01277940/document)). [Better benchmarking](https://stackoverflow.com/questions/49823418/performance-overhead-jni-vs-java-vs-native-c) needs to be conducted on this library to determine: \n* The real overhead incurred by JNI vs native performance (which was observed not to be preserved from the rudimentary benchmarking conducted), and\n* Comparison of a pure-Java implementation of curve operations versus a native implementation accessed via JNI.\n ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faionnetwork%2Fbn128-jni","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faionnetwork%2Fbn128-jni","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faionnetwork%2Fbn128-jni/lists"}