{"_id":"rustbn-wasm","_rev":"4659931","name":"rustbn-wasm","description":"Javascript bindings for https://github.com/paritytech/bn (using WASM)","dist-tags":{"latest":"0.4.0"},"maintainers":[{"name":"acolytec3","email":""},{"name":"holgerd77","email":""}],"time":{"modified":"2026-04-10T21:52:38.000Z","created":"2023-06-29T12:01:02.307Z","0.4.0":"2024-03-08T08:29:05.147Z","0.3.0":"2024-02-14T18:06:07.443Z","0.2.0":"2023-07-04T08:41:55.369Z","0.1.0":"2023-06-29T12:01:02.307Z"},"users":{},"author":{"name":"acolytec3"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn-wasm.git"},"versions":{"0.4.0":{"name":"rustbn-wasm","version":"0.4.0","description":"Javascript bindings for https://github.com/paritytech/bn (using WASM)","keywords":["ethereum","ecc","bn128","pairing"],"author":{"name":"acolytec3"},"homepage":"https://github.com/ethereumjs/rustbn-wasm","bugs":{"url":"https://github.com/ethereumjs/rustbn-wasm/issues"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn-wasm.git"},"license":"(MIT OR Apache-2.0)","scripts":{"build:node":"babel dist/esm --out-dir dist/cjs","build:esm":"tsc","build":"rm -rf dist && scripts/ts-build.sh","prepare":"npm run build","test":"vitest run test/*","build:wasm":"wasm-pack build --target web -d wasm","wasm2b64":"node scripts/wasmToB64.js"},"main":"dist/cjs/rustbn.js","module":"dist/esm/rustbn.js","exports":{"require":"./dist/cjs/rustbn.js","import":"./dist/esm/rustbn.js"},"dependencies":{"@scure/base":"^1.1.5"},"devDependencies":{"@wasm-tool/wasm-pack-plugin":"^1.1.0","copy-webpack-plugin":"^5.0.3","typescript":"^5.1.5","vitest":"^1.2.2","@babel/cli":"^7.23.9","@babel/core":"^7.23.9","@babel/preset-env":"^7.23.9"},"_id":"rustbn-wasm@0.4.0","gitHead":"44e22d0ec5cdf042b8c12f5563c7ea51acb93b61","types":"./dist/cjs/rustbn.d.ts","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"shasum":"fe5601c8d795dd9aa91c19cfad9637ec1df941b0","size":162542,"noattachment":false,"key":"/rustbn-wasm/-/rustbn-wasm-0.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rustbn-wasm/download/rustbn-wasm-0.4.0.tgz"},"_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"directories":{},"maintainers":[{"name":"acolytec3","email":""},{"name":"holgerd77","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rustbn-wasm_0.4.0_1709886544926_0.6566573890569036"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-03-08T08:29:05.147Z","publish_time":1709886545147,"_source_registry_name":"default","_cnpm_publish_time":1709886545147},"0.3.0":{"name":"rustbn-wasm","version":"0.3.0","description":"Javascript bindings for https://github.com/paritytech/bn (using WASM)","keywords":["ethereum","ecc","bn128","pairing"],"author":{"name":"acolytec3"},"homepage":"https://github.com/ethereumjs/rustbn-wasm","bugs":{"url":"https://github.com/ethereumjs/rustbn-wasm/issues"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn-wasm.git"},"license":"(MIT OR Apache-2.0)","scripts":{"build-node":"wasm-pack build --target nodejs -d dist/cjs","build-esm":"tsc","build":"npm run build-node && npm run wasm2b64 && npm run build-esm","test":"vitest run test/*","wasm2b64":"node scripts/wasmToB64.js"},"main":"dist/cjs/rustbn.js","module":"dist/esm/rustbn.js","dependencies":{"@scure/base":"^1.1.5"},"devDependencies":{"@wasm-tool/wasm-pack-plugin":"^1.1.0","copy-webpack-plugin":"^5.0.3","typescript":"^5.1.5","vitest":"^1.2.2"},"_id":"rustbn-wasm@0.3.0","gitHead":"be38c9172e5db06a3e32af1d4db4958fb9c6432a","types":"./dist/cjs/rustbn.d.ts","_nodeVersion":"18.18.0","_npmVersion":"9.8.1","dist":{"shasum":"989a404a7bc58381656553d603419b44d522e910","size":205454,"noattachment":false,"key":"/rustbn-wasm/-/rustbn-wasm-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rustbn-wasm/download/rustbn-wasm-0.3.0.tgz"},"_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"directories":{},"maintainers":[{"name":"acolytec3","email":""},{"name":"holgerd77","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rustbn-wasm_0.3.0_1707933967244_0.36278412345114286"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-02-14T18:06:07.443Z","publish_time":1707933967443,"_source_registry_name":"default","_cnpm_publish_time":1707933967443},"0.2.0":{"name":"rustbn-wasm","version":"0.2.0","description":"Javascript bindings for https://github.com/paritytech/bn (using WASM)","keywords":["ethereum","ecc","bn128","pairing"],"author":{"name":"acolytec3"},"homepage":"https://github.com/ethereumjs/rustbn-wasm","bugs":{"url":"https://github.com/ethereumjs/rustbn-wasm/issues"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn-wasm.git"},"license":"(MIT OR Apache-2.0)","scripts":{"build-node":"wasm-pack build --target nodejs -d dist/cjs","build-esm":"tsc","build":"npm run build-node && npm run wasm2b64 && npm run build-esm","wasm2b64":"node scripts/wasmToB64.js"},"main":"dist/cjs/rustbn.js","module":"dist/esm/rustbn.js","dependencies":{"@scure/base":"^1.1.1"},"devDependencies":{"@wasm-tool/wasm-pack-plugin":"^1.1.0","copy-webpack-plugin":"^5.0.3","typescript":"^5.1.5"},"types":"./dist/cjs/rustbn.d.ts","gitHead":"43a395f6b6bca942244d66e6fbddd69d0b69b91f","_id":"rustbn-wasm@0.2.0","_nodeVersion":"18.14.2","_npmVersion":"9.5.0","dist":{"shasum":"0407521fb55ae69eeb4968d01885d63efd1c4ff9","size":141575,"noattachment":false,"key":"/rustbn-wasm/-/rustbn-wasm-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rustbn-wasm/download/rustbn-wasm-0.2.0.tgz"},"_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"directories":{},"maintainers":[{"name":"acolytec3","email":""},{"name":"holgerd77","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rustbn-wasm_0.2.0_1688460115129_0.4255209175572763"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-07-04T08:41:55.369Z","publish_time":1688460115369,"_source_registry_name":"default","_cnpm_publish_time":1688460115369},"0.1.0":{"name":"rustbn-wasm","version":"0.1.0","description":"Javascript bindings for https://github.com/paritytech/bn (using WASM)","keywords":["ethereum","ecc","bn128","pairing"],"author":{"name":"acolytec3"},"homepage":"https://github.com/ethereumjs/rustbn-wasm","bugs":{"url":"https://github.com/ethereumjs/rustbn-wasm/issues"},"repository":{"type":"git","url":"git+https://github.com/ethereumjs/rustbn-wasm.git"},"license":"(MIT OR Apache-2.0)","scripts":{"build-node":"wasm-pack build --target nodejs -d dist/cjs","build-esm":"tsc","build":"npm run build-node && npm run wasm2b64 && npm run build-esm","wasm2b64":"node scripts/wasmToB64.js"},"main":"dist/cjs/rustbn.js","module":"dist/esm/rustbn.js","dependencies":{"@scure/base":"^1.1.1"},"devDependencies":{"@wasm-tool/wasm-pack-plugin":"^1.1.0","copy-webpack-plugin":"^5.0.3","typescript":"^5.1.5"},"types":"./dist/cjs/rustbn.d.ts","gitHead":"a20bb6b5bcc2d0be2939f8eea3aaec02ec880e09","_id":"rustbn-wasm@0.1.0","_nodeVersion":"18.14.2","_npmVersion":"9.5.0","dist":{"shasum":"1c8b052f2640778763faa1415ffc64ba44656e6f","size":139738,"noattachment":false,"key":"/rustbn-wasm/-/rustbn-wasm-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/rustbn-wasm/download/rustbn-wasm-0.1.0.tgz"},"_npmUser":{"name":"holgerd77","email":"Holger.Drewes@gmail.com"},"directories":{},"maintainers":[{"name":"acolytec3","email":""},{"name":"holgerd77","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rustbn-wasm_0.1.0_1688040061975_0.4165451382140093"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-06-29T12:01:02.307Z","publish_time":1688040062307,"_source_registry_name":"default","_cnpm_publish_time":1688040062307}},"readme":"# SYNOPSIS \nRust to Javascript/Webassembly compilation of [ethereum-bn128.rs](https://github.com/ewasm/ethereum-bn128.rs).\n\nDerived largely from [rustbn.js](https://github.com/ethereumjs/rustbn.js) and recompiled used [`wasm-pack`](https://rustwasm.github.io/docs/wasm-pack/introduction.html)\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\nClone this repo and build following the [Compilation] instructions below.\n\n## Usage\n\nImport the module:\n\n```\nimport { initRustBN } from 'rustbn'\n\nconst bn128 = await initRustBN()\n```\n\nCurve Addition\n\n```\nlet inputHexString = ...\nlet outputHexString = bn128.ec_add(inputHexString)\n```\n\nCurve Multiplication\n\n```\nlet inputHexString = ...\nlet outputHexString = bn128.ec_mul(inputHexString)\n```\n\nCurve Pairing\n```\nlet inputHexString = ...\nlet outputHexString = bn128.ec_pairing(inputHexString)\n```\n\n## Developer\n\n### Building the module\n\nFor basic setup:\n\n- Install `rust` and `wasm-pack` via the [`wasm-pack` prerequisites](https://rustwasm.github.io/docs/wasm-pack/prerequisites/index.html)\n- Clone this repo\n- Install JS dependencies - `npm i`\n- Run `npm run build:wasm` to compile the Rust code to WASM\n- Run `npm run wasm2b64` to convert the WASM bytecode to a base64 string consumable by the Typescript wrapper\n- Run `npm run build` to build the final JS outputs\n\n### Build Outputs\n\nThe build process outputs both CommonJS and ESM builds of the library and specifies entry points based on the `main`, `module`, and alternatively the `exports` fields in `package.json`. Both builds start with the wasm build from `wasm-bindgen` which is then loaded by a Typescript wrapper of the WASM output.  Our Typescript code is slightly different than the original Javascript generated by `wasm-bindgen` because the default ESM output would require a bundler.  \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-wasm","bugs":{"url":"https://github.com/ethereumjs/rustbn-wasm/issues"},"license":"(MIT OR Apache-2.0)"}