{"id":18450294,"url":"https://github.com/jacob-ian/deno_random_primes","last_synced_at":"2026-05-02T06:33:53.542Z","repository":{"id":57675338,"uuid":"277756953","full_name":"jacob-ian/deno_random_primes","owner":"jacob-ian","description":"Generate random prime numbers with Deno and the Miller-Rabin test.","archived":false,"fork":false,"pushed_at":"2020-07-18T12:56:53.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T09:42:05.368Z","etag":null,"topics":["cryptography","deno","typescript"],"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/jacob-ian.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-07T08:11:38.000Z","updated_at":"2022-12-05T13:20:10.000Z","dependencies_parsed_at":"2022-09-05T21:51:28.752Z","dependency_job_id":null,"html_url":"https://github.com/jacob-ian/deno_random_primes","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jacob-ian/deno_random_primes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-ian%2Fdeno_random_primes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-ian%2Fdeno_random_primes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-ian%2Fdeno_random_primes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-ian%2Fdeno_random_primes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacob-ian","download_url":"https://codeload.github.com/jacob-ian/deno_random_primes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-ian%2Fdeno_random_primes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32525890,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cryptography","deno","typescript"],"created_at":"2024-11-06T07:24:37.313Z","updated_at":"2026-05-02T06:33:53.512Z","avatar_url":"https://github.com/jacob-ian.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deno Random Prime Numbers 🦕\nA random prime number generator for Deno.\n\nThis module can generate a pseudorandom prime number with a `bigint` type from a:\n* desired bit-length (e.g. 1024-bit); and\n* an optional number of primality tests\n\n**NOTE: This module is currently exposed to a variable time attack and therefore shouldn't be used for cryptography until further notice.**\n\n*Created by Jacob Ian Matthews - [Website](https://jacobianmatthews.com)  | [GitHub](https://github.com/jacob-ian)*\n\n## Usage\n### Generate a Random Prime Number\n`randomPrime(bitlength, tests)`\n\nWhere:\n* `randomPrime()` returns a `bigint`.\n* `bitlength` is a `number` that is \u003e= 8.\n* `tests` is an optional `number` with a default value of 5.\n\n**Example:**\n```typescript\nimport { randomPrime } from \"https://deno.land/x/random_prime/mod.ts\";\n\n// Generate a random 1024-bit prime number with 5 primality tests\nvar prime: bigint = randomPrime(1024)\n\n// Generate a random 2048-bit prime number with 10 primality tests\nvar prime: bigint = randomPrime(2048, 10)\n```\n### Test if a BigInt is a Prime Number with Miller-Rabin\n`isProbablePrime(candidate, tests)`\n\nWhere:\n* `isProbablePrime()` returns a `boolean`.\n* `candidate` is a `bigint`.\n* `tests` is an optional `number` with a default value of 10.\n\n**Example:**\n```typescript\nimport { isProbablePrime } from \"https://deno.land/x/random_prime/mod.ts\";\n\n// Have a number to test for primality\nconst candidate: bigint = 167n;\n\n// Check if candidate is a probable prime with 10 primality tests\nisProbablePrime(candidate) ? console.log(\"probable prime\") : console.log(\"composite\");\n```\n## Performance Information\nIncreasing the number of primality tests and increasing the bit-length will decrease the speed of prime number generation. \n\nThe probability that a composite number is incorrectly classified as a prime number decreases with an increased number of primality tests such that:\n\n`P(misclassified)=(1/4)^t`\n\nWhere: \n* `t` is the number of tests.\n\n## License\nMIT License.\n\n## References\nThe Miller-Rabin Primality Test algorithm was sourced from:\u003cbr\u003e\nMenezes, A., P. van Oorschot and S. Vanstone. 1996. *Handbook of Applied Cryptography*. Boca Raton, Florida: Taylor \u0026 Francis Group, LLC.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacob-ian%2Fdeno_random_primes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacob-ian%2Fdeno_random_primes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacob-ian%2Fdeno_random_primes/lists"}