{"_id":"@ctrlc03/baby-jubjub","name":"@ctrlc03/baby-jubjub","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.2":{"name":"@ctrlc03/baby-jubjub","version":"0.1.2","description":"A JavaScript library for adding points to the curve.","type":"module","license":"MIT","iife":"dist/index.js","unpkg":"dist/index.min.js","jsdelivr":"dist/index.min.js","main":"dist/index.js","types":"dist/types/index.d.ts","exports":{".":{"types":"./dist/types/index.d.ts","require":"./dist/index.cjs","default":"./dist/index.js"}},"repository":{"type":"git","url":"git+ssh://git@github.com/privacy-scaling-explorations/zk-kit.git"},"homepage":"https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/baby-jubjub","bugs":{"url":"https://github.com/privacy-scaling-explorations/zk-kit.git/issues"},"scripts":{"build":"rimraf dist && rollup -c rollup.config.ts --configPlugin typescript && yarn build:iife","build:iife":"rollup -c rollup.iife.config.ts --configPlugin typescript","prepublishOnly":"yarn build"},"publishConfig":{"access":"public"},"devDependencies":{"@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-terser":"^0.4.4","@rollup/plugin-typescript":"^11.1.6","circomlibjs":"0.0.8","ffjavascript":"0.2.38","rimraf":"^5.0.5","rollup":"^4.12.0","rollup-plugin-cleanup":"^3.2.1","rollup-plugin-polyfill-node":"^0.13.0"},"dependencies":{"@zk-kit/utils":"0.1.0"},"_id":"@ctrlc03/baby-jubjub@0.1.2","gitHead":"17837b96de3312d776ff903c676fc5eb17335c77","_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-T9+ZQBwrID0BVDsb6s+CkLwGHBHk8WIrwQmPKeE6u7yVdXiJx5pUw5yNi42fyrr5dAZcjW/0LyyzPuspuCgMYw==","shasum":"68ea8d880d9d38c8a440a3abbbada1a6ae64e11a","tarball":"https://registry.npmjs.org/@ctrlc03/baby-jubjub/-/baby-jubjub-0.1.2.tgz","fileCount":14,"unpackedSize":115104,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIChu3ZTfbWPpLmRzF5EySXLoQMjLU+d3a+WErtzmjCqzAiEAky2RJmx7qhMsKnebbEqmT2I8AbcWsOGZXoymxXuk55w="}]},"_npmUser":{"name":"ctrlc03","email":"ctrlc03@proton.me"},"directories":{},"maintainers":[{"name":"ctrlc03","email":"ctrlc03@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/baby-jubjub_0.1.2_1708603711195_0.10691456767309204"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-22T12:08:31.052Z","0.1.2":"2024-02-22T12:08:31.356Z","modified":"2024-02-22T12:08:31.883Z"},"maintainers":[{"name":"ctrlc03","email":"ctrlc03@proton.me"}],"description":"A JavaScript library for adding points to the curve.","homepage":"https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/baby-jubjub","repository":{"type":"git","url":"git+ssh://git@github.com/privacy-scaling-explorations/zk-kit.git"},"bugs":{"url":"https://github.com/privacy-scaling-explorations/zk-kit.git/issues"},"license":"MIT","readme":"<p align=\"center\">\n    <h1 align=\"center\">\n        Baby Jubjub\n    </h1>\n    <p align=\"center\">A JavaScript library for adding points to the Baby Jubjub curve.</p>\n</p>\n\n<p align=\"center\">\n    <a href=\"https://github.com/privacy-scaling-explorations/zk-kit\">\n        <img src=\"https://img.shields.io/badge/project-zk--kit-blue.svg?style=flat-square\">\n    </a>\n    <a href=\"https://github.com/privacy-scaling-explorations/zk-kit/tree/main/packages/baby-jubjub/LICENSE\">\n        <img alt=\"NPM license\" src=\"https://img.shields.io/npm/l/%40zk-kit%2Fbaby-jubjub?style=flat-square\">\n    </a>\n    <a href=\"https://www.npmjs.com/package/@zk-kit/baby-jubjub\">\n        <img alt=\"NPM version\" src=\"https://img.shields.io/npm/v/@zk-kit/baby-jubjub?style=flat-square\" />\n    </a>\n    <a href=\"https://npmjs.org/package/@zk-kit/baby-jubjub\">\n        <img alt=\"Downloads\" src=\"https://img.shields.io/npm/dm/@zk-kit/baby-jubjub.svg?style=flat-square\" />\n    </a>\n    <a href=\"https://bundlephobia.com/package/@zk-kit/baby-jubjub\">\n        <img alt=\"npm bundle size (scoped)\" src=\"https://img.shields.io/bundlephobia/minzip/@zk-kit/baby-jubjub\" />\n    </a>\n    <a href=\"https://eslint.org/\">\n        <img alt=\"Linter eslint\" src=\"https://img.shields.io/badge/linter-eslint-8080f2?style=flat-square&logo=eslint\" />\n    </a>\n    <a href=\"https://prettier.io/\">\n        <img alt=\"Code style prettier\" src=\"https://img.shields.io/badge/code%20style-prettier-f8bc45?style=flat-square&logo=prettier\" />\n    </a>\n</p>\n\n<div align=\"center\">\n    <h4>\n        <a href=\"https://appliedzkp.org/discord\">\n            🗣️ Chat &amp; Support\n        </a>\n        <span>&nbsp;&nbsp;|&nbsp;&nbsp;</span>\n        <a href=\"https://zkkit.pse.dev/modules/_zk_kit_baby_jubjub.html\">\n            📘 Docs\n        </a>\n    </h4>\n</div>\n\n> [!WARNING]  \n> This library has **not** been audited.\n\nBabyJubJub is an elliptic curve optimized for secure, efficient cryptographic operations in constrained environments like blockchain and zero-knowledge proofs. It's designed for fast, privacy-preserving transactions, balancing cryptographic strength with performance, making it ideal for modern cryptographic solutions.\n\n## References\n\n1. Barry WhiteHat, Marta Bellés, Jordi Baylina. _ERC-2494: Baby Jubjub Elliptic Curve_. 2020-01-29. https://eips.ethereum.org/EIPS/eip-2494.\n2. Barry WhiteHat, Marta Bellés, Jordi Baylina. _Baby Jubjub Elliptic Curve_. https://docs.iden3.io/publications/pdfs/Baby-Jubjub.pdf\n\n---\n\n## 🛠 Install\n\n### npm or yarn\n\nInstall the `@zk-kit/baby-jubjub` package and its peer dependencies with npm:\n\n```bash\nnpm i @zk-kit/baby-jubjub\n```\n\nor yarn:\n\n```bash\nyarn add @zk-kit/baby-jubjub\n```\n\n### CDN\n\nYou can also load it using a `script` tag using [unpkg](https://unpkg.com/):\n\n```html\n<script src=\"https://unpkg.com/@zk-kit/baby-jubjub\"></script>\n```\n\nor [JSDelivr](https://www.jsdelivr.com/):\n\n```html\n<script src=\"https://cdn.jsdelivr.net/npm/@zk-kit/baby-jubjub\"></script>\n```\n\n## 📜 Usage\n\n```typescript\nimport { packPoint, unpackPoint, Base8, mulPointEscalar, Point, addPoint } from \"@zk-kit/baby-jubjub\"\n\n// Define two points on the BabyJubJub curve.\nconst p1: Point<bigint> = [BigInt(0), BigInt(1)] // Point at infinity (neutral element).\nconst p2: Point<bigint> = [BigInt(1), BigInt(0)] // Example point.\n\n// Add the two points on the curve.\nconst p3 = addPoint(p1, p2)\n\n// Add the result with Base8, another point on the curve, to get a new point.\nconst secretScalar = addPoint(Base8, p3)\n\n// Multiply the base point by the x-coordinate of the secret scalar to get the public key.\nconst publicKey = mulPointEscalar(Base8, secretScalar[0])\n\n// Pack the public key into a compressed format.\nconst packedPoint = packPoint(publicKey)\n\n// Unpack the compressed public key back into its original form.\nconst unpackedPoint = unpackPoint(packedPoint)\n\nif (unpackedPoint) {\n    console.log(publicKey[0] === unpackedPoint[0]) // true, checks if x-coordinates match\n    console.log(publicKey[1] === unpackedPoint[1]) // true, checks if y-coordinates match\n}\n```\n","readmeFilename":"README.md"}