{"name":"mcl-wasm","version":"2.0.4","keywords":["elliptic curve","WebAssembly","pairing"],"author":{"url":"https://github.com/herumi/","name":"herumi","email":"herumi@nifty.com"},"license":"BSD-3-Clause","_id":"mcl-wasm@2.0.4","maintainers":[{"name":"herumi","email":"herumi@nifty.com"}],"homepage":"https://github.com/herumi/mcl-wasm#readme","bugs":{"url":"https://github.com/herumi/mcl-wasm/issues"},"dist":{"shasum":"77ff7268d5c6647e504223f887ed29f4632753da","tarball":"http://registry-npm.ywwl.com/mcl-wasm/download/mcl-wasm-2.0.4.tgz","fileCount":16,"integrity":"sha512-QPdRMmBi12tdmL9MnkuUEZ/9JoTz5rYZxiOeVLEzRp90Fbzh+U+KSrTnpn5gS8+lEAaYhW1yrRQfn60V032rlQ==","signatures":[{"sig":"MEUCIQDH38r8O4Cmd60h0XhDviB8SD8deM9p5qbgmvCajlDQzgIgKtmRY8DvdXlbKHUCosniNEX7ctbpCIFU2g8N42IBJLE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/mcl-wasm@2.0.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":1362520,"size":416182,"noattachment":false,"key":"/mcl-wasm/-/mcl-wasm-2.0.4.tgz"},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=14.17","pnpm":">=10.0.0"},"gitHead":"b66c6ba471d69d6c665e6293113337b8ec1040d3","scripts":{"lint":"standard --verbose test/test.js; ts-standard --verbose src/*.ts","test":"tsc && node test/test.js && node test/eth-test.js","build":"pnpm run build:mcl_c.js && pnpm run build:dist && pnpm run build:browser","test-ts":"tsc && tsc test/test-ts.ts && node test/test-ts.js","lint-fix":"standard --fix test/test.js; ts-standard --fix src/*.ts","build:dist":"tsc","build:browser":"webpack","build:mcl_c.js":"make"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:3253802d-3371-4cf3-87c8-174db9231645"}},"standard":{"ignore":["src/mcl_c.js"]},"repository":{"url":"git+https://github.com/herumi/mcl-wasm.git","type":"git"},"_npmVersion":"11.12.1","description":"mcl ; A portable and fast pairing-based cryptography library for Node.js by WebAssembly","directories":{},"ts-standard":{"project":"./tsconfig.json"},"_nodeVersion":"24.15.0","_hasShrinkwrap":false,"packageManager":"pnpm@10.29.1+sha512.48dae233635a645768a3028d19545cacc1688639eeb1f3734e42d6d6b971afbf22aa1ac9af52a173d9c3a20c15857cfa400f19994d79a2f626fcc73fccda9bbc","devDependencies":{"assert":"^2.1.0","webpack":"^5.106.2","standard":"^17.1.2","ts-loader":"^9.5.7","perf_hooks":"^0.0.1","typescript":"^5.9.3","@types/node":"^25.8.0","ts-standard":"^12.0.2","webpack-cli":"^6.0.1"},"_npmOperationalInternal":{"tmp":"tmp/mcl-wasm_2.0.4_1779497471750_0.45295070863702747","host":"s3://npm-registry-packages-npm-production"},"readme":"[![Build Status](https://github.com/herumi/mcl-wasm/actions/workflows/main.yml/badge.svg)](https://github.com/herumi/mcl-wasm/actions/workflows/main.yml)\r\n\r\n# A portable and fast pairing-based cryptography library for Node.js by WebAssembly\r\n\r\n# Abstract\r\n\r\nsee [mcl](https://github.com/herumi/mcl)\r\n\r\n## News\r\n- 2026/Nov/06 v2.6.0: bump mcl to v4.42. mulVec (MSM) is about 2.4x faster for n=1024 on both G1 and G2.\r\n- 2026/Oct/02 improve the performance of finalExp by about 20% and pairing by about 10%.\r\n- 2026/Sep/17 add mulUnit. stack pointer is now always restored.\r\n- 2026/Jun/16 change build from emcc to clang\r\n\r\n## How to use\r\nThe version `v0.6.0` breaks backward compatibility of the entry point.\r\n\r\n- Node.js : `const mcl = require('mcl-wasm')`\r\n- React : `const mcl = require('mcl-wasm')`\r\n- HTML : `<script src=\"https://herumi.github.io/mcl-wasm/browser/mcl.js\"></script>`\r\n\r\n## for Node.js\r\n```\r\nnode test/test.js\r\n```\r\n\r\n## browser demo\r\n[ID-based encryption](https://herumi.github.io/mcl-wasm/browser/demo.html)\r\n\r\n# usages\r\n\r\n## init\r\n\r\n```\r\n// Ethereum 2.0 spec mode\r\nmcl.init(mcl.BLS12_381)\r\n  .then(() => {\r\n    mcl.setETHserialization(true) // Ethereum serialization\r\n    mcl.setMapToMode(mcl.IRTF) // for G2.setHashOf(msg)\r\n    ...\r\n  })\r\n```\r\n\r\n## string conversion\r\n\r\n```\r\na = new mcl.Fr()\r\na.setStr('255') // set 255\r\na.setStr('0xff') // set 0xff = 255\r\na.setStr('ff', 16) // set ff as hex-string\r\n\r\na.getStr() // '255'\r\na.getStr(16) // 'ff'\r\n```\r\n\r\n## serialization\r\n\r\n```\r\n// byte array serialization\r\nb.deserialize(a.serialize()) // b.isEqualTo(a)\r\n// hex string of serialization()\r\nb.deserializeHexStr(a.serializeToHexStr())\r\n```\r\n\r\n```\r\n// serialization like Ethereum 2.0 only for BLS12-381\r\nmcl.setETHserialization(true)\r\n```\r\n\r\n## deserialization\r\n```\r\n/*\r\n  it is big cost to to verify the order\r\n  call once after init() if you want to disable it\r\n  cf. sub group problem\r\n*/\r\nmcl.verifyOrderG1(false)\r\nmcl.verifyOrderG2(false)\r\n```\r\n\r\nsee [test.js](https://github.com/herumi/mcl-wasm/blob/master/test/test.js)\r\n\r\n## Secret Sharing\r\n\r\n```typescript\r\nshareFr = (cVec: Fr[], id: Fr): Fr\r\nshareG1 = (cVec: G1[], id: Fr): G1\r\nshareG2 = (cVec: G2[], id: Fr): G2\r\n```\r\nEvaluate the value of the polynomial `f(x)` whose coefficients `cVec[]` are vec with x=id.\r\nReturn `f(id)`.\r\n\r\n```typescript\r\nrecoverFr = (idVec: Fr[], yVec: Fr[]): Fr\r\nrecoverG1 = (idVec: Fr[], yVec: G1[]): G1\r\nrecoverG2 = (idVec: Fr[], yVec: G2[]): G2\r\n```\r\nRecover the polynomial `f(x)` through the point `(idVec[0], yVec[0])`, `(idVec[1], yVec[1])`, ... and return `f(0)`.\r\nNote that the order of arguments is reversed from that of the recover function in bls-eth-wasm.\r\n\r\n# License\r\n\r\nmodified new BSD License\r\nhttp://opensource.org/licenses/BSD-3-Clause\r\n\r\n# History\r\n\r\n- 2025/Jun/14 fix wrong performance of G1::deserialize on BN curvers.\r\n- 2025/May/23 bump mcl to v3.00\r\n- 2025/Feb/26 support BLS12_377\r\n- 2024/Sep/18 Add batch inversion for Fr and Fp elements, and batch normalization for G1 and G2 points.\r\n- 2023/Sep/08 improve the performance a little\r\n- 2023/Aug/17 improve the invMod performance\r\n- 2023/Jun/10 add share/recover functions of Fr, G1, G2 for secret sharing.\r\n- 2022/May/08 fix get{X,Y,Z} and get\\_{a,b}.\r\n- 2021/Dec/15 rewritten by TypeScript (Thanks to asa-taka)\r\n- 2021/Nov/11 unify index.js of Node.js and browser (Thanks to Futa HIRAKOBA)\r\n- 2021/Aug/28 improve performance of `{G1,G2}::isValidOrder()`\r\n- 2021/Jun/22 add index.d.ts\r\n- 2021/Mar/02 improve performance\r\n- 2020/Nov/10 setup function has changed.\r\n- 2019/Jan/31 add Fp.mapToG1\r\n\r\n# Author\r\n\r\nMITSUNARI Shigeo(herumi@nifty.com)\r\n\r\n# Sponsors welcome\r\n[GitHub Sponsor](https://github.com/sponsors/herumi)\r\n","publish_time":1779497471960,"_cnpm_publish_time":1779497471960,"dist-tags":{"latest":"2.6.0"}}