{"id":21102158,"url":"https://github.com/juanelas/bigint-mod-arith","last_synced_at":"2025-05-16T18:34:38.941Z","repository":{"id":34300751,"uuid":"176075836","full_name":"juanelas/bigint-mod-arith","owner":"juanelas","description":"Some extra functions to work with modular arithmetics using native JS implementation of BigInt.","archived":false,"fork":false,"pushed_at":"2023-07-18T21:37:15.000Z","size":616,"stargazers_count":23,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-09T06:15:55.375Z","etag":null,"topics":["bigint","biginteger","bignum","bignumber","modular-arithmetic","modular-exponentiation"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juanelas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2019-03-17T08:38:13.000Z","updated_at":"2024-09-03T03:21:58.000Z","dependencies_parsed_at":"2024-06-18T15:28:08.387Z","dependency_job_id":"3a86ddd3-2773-4002-9316-619884867912","html_url":"https://github.com/juanelas/bigint-mod-arith","commit_stats":{"total_commits":77,"total_committers":2,"mean_commits":38.5,"dds":0.2727272727272727,"last_synced_commit":"8f97d626a5bf53e0ea27d4e983250075ab4abde5"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juanelas%2Fbigint-mod-arith","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juanelas%2Fbigint-mod-arith/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juanelas%2Fbigint-mod-arith/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juanelas%2Fbigint-mod-arith/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juanelas","download_url":"https://codeload.github.com/juanelas/bigint-mod-arith/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225444688,"owners_count":17475354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bigint","biginteger","bignum","bignumber","modular-arithmetic","modular-exponentiation"],"created_at":"2024-11-19T23:54:16.673Z","updated_at":"2024-11-19T23:54:17.208Z","avatar_url":"https://github.com/juanelas.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Node.js CI](https://github.com/juanelas/bigint-mod-arith/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/juanelas/bigint-mod-arith/actions/workflows/build-and-test.yml)\n[![Coverage Status](https://coveralls.io/repos/github/juanelas/bigint-mod-arith/badge.svg?branch=main)](https://coveralls.io/github/juanelas/bigint-mod-arith?branch=main)\n\n# bigint-mod-arith\n\nSome extra functions to work with modular arithmetic using native JS ([ES-2020](https://tc39.es/ecma262/#sec-bigint-objects)) implementation of BigInt. It can be used by any [Web Browser or webview supporting BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#Browser_compatibility) and with Node.js (\u003e=10.4.0).\n\n\u003e The operations supported on BigInts are not constant time. BigInt can be therefore **[unsuitable for use in cryptography](https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html).** Many platforms provide native support for cryptography, such as [Web Cryptography API](https://w3c.github.io/webcrypto/) or [Node.js Crypto](https://nodejs.org/dist/latest/docs/api/crypto.html).\n\n## Usage\n\n`bigint-mod-arith` can be imported to your project with `npm`:\n\n```console\nnpm install bigint-mod-arith\n```\n\nThen either require (Node.js CJS):\n\n```javascript\nconst bigintModArith = require('bigint-mod-arith')\n```\n\n\u003e **Node \u003e=10.4 \u003c11**. `bigint-mod-arith` uses workers to speed up some operations. Workers are enabled by default with Node.js from version 11. In order to use them with Node \u003e=10.4 and \u003c11, you need to execute node with the flag `--experimental-worker`, and require the `.js` file manually (otherwise `.cjs` is required by default and would not be supported by the workers)\n\u003e\n\u003e ```javascript\n\u003e const bigintCryptoUtils = require('bigint-crypto-utils/dist/cjs/index.node')  // ONLY FOR node \u003e=10.4 \u003c11 !\n\u003e ```\n\nor import (JavaScript ES module):\n\n```javascript\nimport * as bigintModArith from 'bigint-mod-arith'\n```\n\nThe appropriate version for browser or node is automatically exported.\n\nYou can also download the [IIFE bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/main/dist/bundle.iife.js), the [ESM bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/main/dist/bundle.esm.min.js) or the [UMD bundle](https://raw.githubusercontent.com/juanelas/bigint-mod-arith/main/dist/bundle.umd.js) and manually add it to your project, or, if you have already imported `bigint-mod-arith` to your project, just get the bundles from `node_modules/bigint-mod-arith/dist/bundles/`.\n\nAn example of usage could be:\n\n```typescript\n/* Stage 3 BigInts with value 666 can be declared as BigInt('666')\nor the shorter syntax 666n.\nNotice that you can also pass a number, e.g. BigInt(666), but it is not\nrecommended since values over 2**53 - 1 won't be safe but no warning will\nbe raised.\n*/\nconst a = BigInt('5')\nconst b = BigInt('2')\nconst n = 19n\n\nconsole.log(bigintModArith.modPow(a, b, n)) // prints 6\n\nconsole.log(bigintModArith.modInv(2n, 5n)) // prints 3\n\nconsole.log(bigintModArith.modInv(BigInt('3'), BigInt('5'))) // prints 2\n```\n\n## API reference documentation\n\n[Check the API](./docs/API.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuanelas%2Fbigint-mod-arith","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuanelas%2Fbigint-mod-arith","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuanelas%2Fbigint-mod-arith/lists"}