{"id":26224161,"url":"https://github.com/aprismatic/bigintegerext","last_synced_at":"2025-12-29T01:32:29.397Z","repository":{"id":43296202,"uuid":"93833186","full_name":"aprismatic/bigintegerext","owner":"aprismatic","description":"Extension methods for .NET BigInteger class","archived":false,"fork":false,"pushed_at":"2022-07-31T21:11:06.000Z","size":597,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-19T01:56:38.597Z","etag":null,"topics":["bigint","biginteger","bignum","bignumber","bignumbers","csharp","csharp-library","dotnet","dotnet-core","dotnet-library","dotnet-standard","dotnetcore","dotnetstandard"],"latest_commit_sha":null,"homepage":"","language":"C#","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/aprismatic.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":"2017-06-09T07:47:11.000Z","updated_at":"2022-09-10T21:46:06.000Z","dependencies_parsed_at":"2022-08-28T20:52:09.147Z","dependency_job_id":null,"html_url":"https://github.com/aprismatic/bigintegerext","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aprismatic%2Fbigintegerext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aprismatic%2Fbigintegerext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aprismatic%2Fbigintegerext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aprismatic%2Fbigintegerext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aprismatic","download_url":"https://codeload.github.com/aprismatic/bigintegerext/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243268076,"owners_count":20263803,"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","bignumbers","csharp","csharp-library","dotnet","dotnet-core","dotnet-library","dotnet-standard","dotnetcore","dotnetstandard"],"created_at":"2025-03-12T18:18:30.143Z","updated_at":"2025-12-29T01:32:29.325Z","avatar_url":"https://github.com/aprismatic.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BigIntegerExt\n\n![Test .NET (Windows)](https://github.com/aprismatic/bigintegerext/workflows/Test%20.NET%20(Windows)/badge.svg?branch=master)\n\nA set of extension methods for the .NET `System.Numerics.BigInteger` class, including methods like `BitCount`, `ModInverse`, `GenPseudoPrime`, `GenSafePseudoPrime`, `GenRandomBits` (using cryptographically strong RNG), `IsProbablePrime` (implemented using Rabin-Miller test).\n\n### Installation\n\n`Aprismatic.BigIntegerExt` library is available in GitHub package repo as well as on NuGet.org: \u003chttps://www.nuget.org/packages/Aprismatic.BigIntegerExt/\u003e.\n\nYou can install it through NuGet package manager in Visual Studion or Rider or run `dotnet add package Aprismatic.BigIntegerExt`.\n\n### Usage\n\n```csharp\nusing Aprismatic;\nusing System.Security.Cryptography; // for RandomNumberGenerator\n\n// ...\n\nvar bi = new BigInteger(123);\nvar bi2 = new BigInteger(345);\nvar rng = RandomNumberGenerator.Create();\n\nvar bitCount = bi.BitCount(); // returns the position (int) of the most significant bit\n                              // of the BigInteger's absolute value.\n\nvar r1 = bi.ModInverse(bi2); // returns BigInteger x such that (bi * x) % bi2 == 1\nvar r2 = bi.IsProbablePrime(8, rng); // returns true if bi is a probable prime, false otherwise\n                                     // confidence parameter 8 is the number of iterations to\n                                     // use in the Rabin-Miller (RM) test\n\n// C# currently doesn't support static extension methods, so we need to use the instance\n// method instead. We can use a pre-defined instance of the BigInteger class such as\n// `BigInteger.One` or any other instance that is already defined, in our case - `bi` or `bi2`\n\nvar r3 = bi.GenPseudoPrime(128, 8, rng); // returns a BigInteger probable prime of 128 bits\n                                         // tested with 8 loops of RM test; doesn't change `bi`\n\nvar r4 = bi.GenSafePseudoPrime(128, 8, rng); // same but returns a safe prime (i.e., a prime x\n                                             // such that (x-1)/2 is also prime)\n\nvar r5 = bi.GenRandomBits(128, rng); // returns a BigInteger x with exaxctly 128 random bits,\n                                     // i.e., such that x.BitCount() == 128\nvar r6 = bi.GenRandomBits(bi, bi2, rng); // return a random BigInteger x such that bi ≤ x \u003c bi2\n```\n\n### Licensing \u0026 Contributions\n\nThis library is provided free of charge under the MIT license. See the LICENSE file for more details. Contributions are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faprismatic%2Fbigintegerext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faprismatic%2Fbigintegerext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faprismatic%2Fbigintegerext/lists"}