-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
v1rtl
committed
Sep 30, 2021
1 parent
c5d7a84
commit d47d5df
Showing
5 changed files
with
83 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# These are supported funding model platforms | ||
|
||
ko_fi: v1rtl | ||
liberapay: v1rtl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: CI | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x | ||
- name: Run tests | ||
run: deno test --coverage=coverage | ||
- name: Create coverage report | ||
run: deno coverage ./coverage --lcov > coverage.lcov | ||
- name: Coveralls | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
path-to-lcov: ./coverage.lcov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
<div align="center"> | ||
|
||
# miller_rabin | ||
|
||
[![GitHub Workflow Status][gh-actions-img]][github-actions] | ||
[![Coverage][cov-badge]][cov] [![][docs-badge]][docs] [![][code-quality-img]][code-quality] | ||
|
||
</div> | ||
|
||
Modern rewrite of [miller-rabin](https://github.com/indutny/miller-rabin). | ||
|
||
```ts | ||
import { MillerRabin } from 'https://deno.land/x/miller_rabin/mod.ts' | ||
|
||
const md = new MillerRabin() | ||
``` | ||
|
||
[docs-badge]: https://img.shields.io/github/v/release/deno-libs/miller_rabin?label=Docs&logo=deno&style=for-the-badge&color=black | ||
[docs]: https://doc.deno.land/https/deno.land/x/miller_rabin/mod.ts | ||
[gh-actions-img]: https://img.shields.io/github/workflow/status/deno-libs/miller_rabin/CI?style=for-the-badge&logo=github&label=&color=black | ||
[cov]: https://coveralls.io/github/deno-libs/miller_rabin | ||
[github-actions]: https://github.com/deno-libs/miller_rabin/actions | ||
[cov-badge]: https://img.shields.io/coveralls/github/deno-libs/miller_rabin?style=for-the-badge&color=black& | ||
[code-quality-img]: https://img.shields.io/codefactor/grade/github/deno-libs/miller_rabin?style=for-the-badge&color=black& | ||
[code-quality]: https://www.codefactor.io/repository/github/deno-libs/miller_rabin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { describe, it, expect, run } from 'https://deno.land/x/tincan@0.2.2/mod.ts' | ||
import { BN } from 'https://deno.land/x/bn_deno@1.0.0/lib/bn.js' | ||
import { MillerRabin } from './mod.ts' | ||
|
||
describe('MillerRabin', () => { | ||
it('should test number for primality', function () { | ||
const mr = new MillerRabin() | ||
|
||
expect(!mr.test(new BN(221))).toBe(true) | ||
expect(mr.test(new BN(257))).toBe(true) | ||
|
||
const p = new BN( | ||
'dba8191813fe8f51eaae1de70213aafede8f323f95f32cff' + | ||
'8b64ebada275cfb18a446a0150e5fdaee246244c5f002ce0' + | ||
'aca97584be1745f2dd1eea2849c52aac8c4b5fb78a1c4da7' + | ||
'052774338d3310a6e020c46168cb1f94014e9312511cc4fb' + | ||
'79d695bb732449f0e015745b86bfa371dc6ca7386e9c7309' + | ||
'5549c2e4b8002873', | ||
16 | ||
) | ||
expect(mr.test(p)).toBe(true) | ||
}) | ||
}) | ||
|
||
run() |