{"_id":"rustbn.js","_rev":"4629072","name":"rustbn.js","description":"Javascript bindings for https://github.com/paritytech/bn (using asm.js)","dist-tags":{"latest":"0.3.0"},"maintainers":[{"name":"axic","email":""},{"name":"holgerd77","email":""},{"name":"jwasinger","email":""},{"name":"null_radix","email":""}],"time":{"modified":"2026-04-10T18:46:31.000Z","created":"2017-10-11T09:58:04.102Z","0.3.0":"2023-05-23T11:19:27.584Z","0.2.0":"2018-07-20T08:08:29.778Z","0.1.2":"2018-02-08T12:24:31.205Z","0.1.1":"2017-10-27T07:46:41.050Z","0.1.0":"2017-10-11T09:58:04.102Z"},"users":{},"author":{"name":"cdetrio","email":"cdetrio@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn.js.git"},"versions":{"0.3.0":{"name":"rustbn.js","version":"0.3.0","description":"Javascript bindings for https://github.com/paritytech/bn (using asm.js)","main":"index.js","scripts":{"test":"tape ./tests/index.js"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn.js.git"},"keywords":["ethereum","ecc","bn128","pairing"],"author":{"name":"cdetrio","email":"cdetrio@gmail.com"},"contributors":[{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},{"name":"Alex Beregszaszi","email":"alex@rtfs.hu"}],"license":"(MIT OR Apache-2.0)","bugs":{"url":"https://github.com/ethereumjs/rustbn.js/issues"},"homepage":"https://github.com/ethereumjs/rustbn.js#readme","devDependencies":{"tape":"^4.8.0"},"gitHead":"e8fc67d8f1aeac4e60fdcaad10d4f35a1a67d222","_id":"rustbn.js@0.3.0","_nodeVersion":"18.14.2","_npmVersion":"9.5.0","dist":{"shasum":"79cdeda8a1158f21eecc5a765d1d893c52cb7df7","size":433956,"noattachment":false,"key":"/rustbn.js/-/rustbn.js-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rustbn.js/download/rustbn.js-0.3.0.tgz"},"_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"directories":{},"maintainers":[{"name":"axic","email":""},{"name":"holgerd77","email":""},{"name":"jwasinger","email":""},{"name":"null_radix","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rustbn.js_0.3.0_1684840767353_0.3074200484941081"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-05-23T11:19:27.584Z","publish_time":1684840767584,"_source_registry_name":"default","_cnpm_publish_time":1684840767584},"0.2.0":{"name":"rustbn.js","version":"0.2.0","description":"Javascript bindings for https://github.com/paritytech/bn (using asm.js)","main":"index.js","scripts":{"test":"tape ./tests/index.js"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn.js.git"},"keywords":["ethereum","ecc","bn128","pairing"],"author":{"name":"cdetrio","email":"cdetrio@gmail.com"},"contributors":[{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},{"name":"Alex Beregszaszi","email":"alex@rtfs.hu"}],"license":"(MIT OR Apache-2.0)","bugs":{"url":"https://github.com/ethereumjs/rustbn.js/issues"},"homepage":"https://github.com/ethereumjs/rustbn.js#readme","devDependencies":{"tape":"^4.8.0"},"gitHead":"89e48b0e23c0f790a545ce1d869b82cd38e297e6","_id":"rustbn.js@0.2.0","_npmVersion":"5.8.0","_nodeVersion":"7.10.1","_npmUser":{"name":"axic","email":"alex@rtfs.hu"},"dist":{"shasum":"8082cb886e707155fd1cb6f23bd591ab8d55d0ca","size":156707,"noattachment":false,"key":"/rustbn.js/-/rustbn.js-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rustbn.js/download/rustbn.js-0.2.0.tgz"},"maintainers":[{"name":"axic","email":""},{"name":"holgerd77","email":""},{"name":"jwasinger","email":""},{"name":"null_radix","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rustbn.js_0.2.0_1532074109661_0.08728884634728384"},"_hasShrinkwrap":false,"publish_time":1532074109778,"_cnpm_publish_time":1532074109778,"_cnpmcore_publish_time":"2021-12-16T17:18:37.055Z"},"0.1.2":{"name":"rustbn.js","version":"0.1.2","description":"Javascript bindings for https://github.com/paritytech/bn (using asm.js)","main":"index.js","scripts":{"test":"tape ./tests/index.js"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn.js.git"},"keywords":["ethereum","ecc","bn128","pairing"],"author":{"name":"cdetrio","email":"cdetrio@gmail.com"},"contributors":[{"name":"holgerd77","email":"Holger.Drewes@gmail.com"}],"license":"(MIT OR Apache-2.0)","bugs":{"url":"https://github.com/ethereumjs/rustbn.js/issues"},"homepage":"https://github.com/ethereumjs/rustbn.js#readme","devDependencies":{"tape":"^4.8.0"},"gitHead":"90eb667c6f4da26810584573b8f4ea7750b9bbbc","_id":"rustbn.js@0.1.2","_npmVersion":"5.6.0","_nodeVersion":"8.4.0","_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"dist":{"shasum":"979fa0f9562216dd667c9d2cd179ae5d13830eff","size":166889,"noattachment":false,"key":"/rustbn.js/-/rustbn.js-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/rustbn.js/download/rustbn.js-0.1.2.tgz"},"maintainers":[{"name":"axic","email":""},{"name":"holgerd77","email":""},{"name":"jwasinger","email":""},{"name":"null_radix","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rustbn.js_0.1.2_1518092670271_0.46727221439443034"},"_hasShrinkwrap":false,"publish_time":1518092671205,"_cnpm_publish_time":1518092671205,"_cnpmcore_publish_time":"2021-12-16T17:18:37.278Z"},"0.1.1":{"name":"rustbn.js","version":"0.1.1","description":"Javascript bindings for https://github.com/paritytech/bn (using asm.js)","main":"index.js","scripts":{"test":"tape ./tests/index.js"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn.js.git"},"keywords":["ethereum","ecc","pairing"],"author":"","license":"ISC","bugs":{"url":"https://github.com/ethereumjs/rustbn.js/issues"},"homepage":"https://github.com/ethereumjs/rustbn.js#readme","devDependencies":{"tape":"^4.8.0"},"gitHead":"4d5785f77b59123b295ffac312956c98b66146c8","_id":"rustbn.js@0.1.1","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"dist":{"shasum":"088b8c29d5f6d7d9f56ffb545f5d110e4a6801eb","size":166022,"noattachment":false,"key":"/rustbn.js/-/rustbn.js-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/rustbn.js/download/rustbn.js-0.1.1.tgz"},"maintainers":[{"name":"axic","email":""},{"name":"holgerd77","email":""},{"name":"jwasinger","email":""},{"name":"null_radix","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rustbn.js-0.1.1.tgz_1509090399810_0.6146806019823998"},"directories":{},"publish_time":1509090401050,"_hasShrinkwrap":false,"_cnpm_publish_time":1509090401050,"_cnpmcore_publish_time":"2021-12-16T17:18:37.543Z"},"0.1.0":{"name":"rustbn.js","version":"0.1.0","description":"Javascript bindings for https://github.com/paritytech/bn (using asm.js)","main":"index.js","scripts":{"test":"tape ./tests/index.js"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn.js.git"},"keywords":["ethereum","ecc","pairing"],"author":"","license":"ISC","bugs":{"url":"https://github.com/ethereumjs/rustbn.js/issues"},"homepage":"https://github.com/ethereumjs/rustbn.js#readme","devDependencies":{"tape":"^4.8.0"},"gitHead":"788bec05cd7b4f0d6ffde251128ff35ea06ff599","_id":"rustbn.js@0.1.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"dist":{"shasum":"ddfea5f55bed7acd9ca34f26d7fd80971c225cc4","size":161608,"noattachment":false,"key":"/rustbn.js/-/rustbn.js-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rustbn.js/download/rustbn.js-0.1.0.tgz"},"maintainers":[{"name":"axic","email":""},{"name":"holgerd77","email":""},{"name":"jwasinger","email":""},{"name":"null_radix","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rustbn.js-0.1.0.tgz_1507715882776_0.07717440789565444"},"directories":{},"publish_time":1507715884102,"_hasShrinkwrap":false,"_cnpm_publish_time":1507715884102,"_cnpmcore_publish_time":"2021-12-16T17:18:37.764Z"}},"readme":"# SYNOPSIS \n[![Build Status](https://img.shields.io/travis/ethereumjs/rustbn.js.svg?branch=master&style=flat-square)](https://travis-ci.org/ethereumjs/rustbn.js)\n[![Gitter](https://img.shields.io/gitter/room/ethereum/ethereumjs-lib.svg?style=flat-square)](https://gitter.im/ethereum/ethereumjs-lib) or #ethereumjs on freenode  \n\nRust to Javascript/Webassembly compilation of [ethereum-bn128.rs](https://github.com/ewasm/ethereum-bn128.rs).\n\nInternally it uses the [Parity fork](https://github.com/paritytech/bn) of the [Zcash bn\npairing cryptography library](https://github.com/zcash/bn), implementing an efficient bilinear pairing on the Barreto-Naehrig (BN) curve. \n\nIt implements helpers to support the functionality defined in [EIP-196](https://eips.ethereum.org/EIPS/eip-196) and [EIP-197](https://eips.ethereum.org/EIPS/eip-197).\n\n## Installation\n\n`npm install rustbn.js`\n\n## Usage\n\nRequire the module:\n\n```\nconst bn128 = require('rustbn.js')\n```\n\nCurve Addition\n\n```\nlet inputHexString = ...\nlet outputHexString = bn128.add(inputHexString)\n```\n\nCurve Multiplication\n\n```\nlet inputHexString = ...\nlet outputHexString = bn128.mul(inputHexString)\n```\n\nCurve Pairing\n```\nlet inputHexString = ...\nlet outputHexString = bn128.pairing(inputHexString)\n```\n\n## Developer\n\n### Compilation\n\nCompilation process is based on [this tutorial](http://asquera.de/blog/2017-04-10/the-path-to-rust-on-the-web/) using [Emscripten](http://kripken.github.io/emscripten-site/) to compile the original Rust sources to [asm.js](http://asmjs.org/) ([Wikipedia](https://en.wikipedia.org/wiki/Asm.js)). This might be extended in the future to also include a ``WASM`` compiled version to choose from.\n\nFor basic setup follow the \"Installing the Tools\" section of the tutorial (make sure to use the ``incoming`` branch of ``emsdk``).\n\nFor ``asm.js`` compilation ``asmjs-unknown-emscripten`` target has to be added with ``rustup``:\n\n```\nrustup target add asmjs-unknown-emscripten\n```\n\nCompilation steps can be found in the ``makefile`` in the main directory and executed simply by\nrunning:\n\n```\nmake\n```\n\n### Docker\n\nThis repository also contains a `Dockefile` which makes it easier to install\nthe dependencies and tools described above in a docker container by following\nthe next instructions.\n\nBuild the docker image:\n\n```\ndocker build . -t rustbn\n```\n\nRun the container:\n\n```\ndocker run -v <path_to_the_rustbn.js_project>:/rustbn.js  -it rustbn\n```\n\nOnce inside the container the project can be compiled by executing:\n\n```\nmake\n```\n\n### WASM (Experimental)\n\nWASM files can be compiled with ``make wasm`` to the ``exp``. This is just intended for experimentation\nworking in browser only (not with Node.js) and not ready for production use!\n\nStart a server with ``python -m SimpleHTTPServer`` and browse to http://localhost:8000/. You might have\nto modify the ``exp/index.html`` file to get things to work.\n\n### Testing\n\nUnit tests can be found in the ``tests`` directory. Run the tests with:\n\n```\nnpm run test\n```\n\n## Additional Resources\n\n- Another [compilation tutorial](https://medium.com/@ianjsikes/get-started-with-rust-webassembly-and-webpack-58d28e219635) using ``Webpack``\n- [Talk](https://rreverser.com/rust-javascript-interop/) on ``Emscripten`` and ``Rust``\n- [Compiling Rust to your Browser](https://www.hellorust.com/emscripten/)\n\n\n## License\n\nLicensed under either of\n\n * MIT license, ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n\nat your option.\n\nCopyright 2016 [Zcash Electric Coin Company](https://z.cash/). The Zcash Company promises to maintain the \"bn\" crate on crates.io under this MIT/Apache-2.0 dual license.\n \n","_attachments":{},"homepage":"https://github.com/ethereumjs/rustbn.js#readme","bugs":{"url":"https://github.com/ethereumjs/rustbn.js/issues"},"license":"(MIT OR Apache-2.0)"}