mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 21:52:19 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
2
web/node_modules/miller-rabin/.npmignore
generated
vendored
Normal file
2
web/node_modules/miller-rabin/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules/
|
||||
npm-debug.log
|
7
web/node_modules/miller-rabin/1.js
generated
vendored
Normal file
7
web/node_modules/miller-rabin/1.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
const BN = require('bn.js');
|
||||
|
||||
const p = new BN('2e1b162f326430f5ac6af10f96b2a8350e01675d22324c9f', 'hex');
|
||||
|
||||
console.log(p.bitLength());
|
26
web/node_modules/miller-rabin/README.md
generated
vendored
Normal file
26
web/node_modules/miller-rabin/README.md
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Miller-Rabin
|
||||
|
||||
#### LICENSE
|
||||
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
Copyright Fedor Indutny, 2014.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to permit
|
||||
persons to whom the Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
web/node_modules/miller-rabin/bin/miller-rabin
generated
vendored
Executable file
29
web/node_modules/miller-rabin/bin/miller-rabin
generated
vendored
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env node
|
||||
var bn = require('bn.js');
|
||||
var fs = require('fs');
|
||||
var mr = require('../').create();
|
||||
|
||||
var num = '';
|
||||
if (process.argv[2]) {
|
||||
num += fs.readFileSync(process.argv[2]);
|
||||
start(num);
|
||||
} else {
|
||||
process.stdin.on('data', function(chunk) {
|
||||
num += chunk.toString().replace(/[^0-9a-f]/gi, '');
|
||||
});
|
||||
process.stdin.once('end', function() {
|
||||
start(num);
|
||||
});
|
||||
}
|
||||
|
||||
function start(text) {
|
||||
var num = new bn(text, 16);
|
||||
|
||||
var divisor = mr.getDivisor(num);
|
||||
if (!divisor)
|
||||
process.exit(1);
|
||||
if (divisor.cmpn(1) === 0)
|
||||
process.exit(0);
|
||||
|
||||
console.log(divisor.toString(16));
|
||||
}
|
115
web/node_modules/miller-rabin/lib/mr.js
generated
vendored
Normal file
115
web/node_modules/miller-rabin/lib/mr.js
generated
vendored
Normal file
|
@ -0,0 +1,115 @@
|
|||
var bn = require('bn.js');
|
||||
var brorand = require('brorand');
|
||||
|
||||
function MillerRabin(rand) {
|
||||
this.rand = rand || new brorand.Rand();
|
||||
}
|
||||
module.exports = MillerRabin;
|
||||
|
||||
MillerRabin.create = function create(rand) {
|
||||
return new MillerRabin(rand);
|
||||
};
|
||||
|
||||
MillerRabin.prototype._randbelow = function _randbelow(n) {
|
||||
var len = n.bitLength();
|
||||
var min_bytes = Math.ceil(len / 8);
|
||||
|
||||
// Generage random bytes until a number less than n is found.
|
||||
// This ensures that 0..n-1 have an equal probability of being selected.
|
||||
do
|
||||
var a = new bn(this.rand.generate(min_bytes));
|
||||
while (a.cmp(n) >= 0);
|
||||
|
||||
return a;
|
||||
};
|
||||
|
||||
MillerRabin.prototype._randrange = function _randrange(start, stop) {
|
||||
// Generate a random number greater than or equal to start and less than stop.
|
||||
var size = stop.sub(start);
|
||||
return start.add(this._randbelow(size));
|
||||
};
|
||||
|
||||
MillerRabin.prototype.test = function test(n, k, cb) {
|
||||
var len = n.bitLength();
|
||||
var red = bn.mont(n);
|
||||
var rone = new bn(1).toRed(red);
|
||||
|
||||
if (!k)
|
||||
k = Math.max(1, (len / 48) | 0);
|
||||
|
||||
// Find d and s, (n - 1) = (2 ^ s) * d;
|
||||
var n1 = n.subn(1);
|
||||
for (var s = 0; !n1.testn(s); s++) {}
|
||||
var d = n.shrn(s);
|
||||
|
||||
var rn1 = n1.toRed(red);
|
||||
|
||||
var prime = true;
|
||||
for (; k > 0; k--) {
|
||||
var a = this._randrange(new bn(2), n1);
|
||||
if (cb)
|
||||
cb(a);
|
||||
|
||||
var x = a.toRed(red).redPow(d);
|
||||
if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
|
||||
continue;
|
||||
|
||||
for (var i = 1; i < s; i++) {
|
||||
x = x.redSqr();
|
||||
|
||||
if (x.cmp(rone) === 0)
|
||||
return false;
|
||||
if (x.cmp(rn1) === 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i === s)
|
||||
return false;
|
||||
}
|
||||
|
||||
return prime;
|
||||
};
|
||||
|
||||
MillerRabin.prototype.getDivisor = function getDivisor(n, k) {
|
||||
var len = n.bitLength();
|
||||
var red = bn.mont(n);
|
||||
var rone = new bn(1).toRed(red);
|
||||
|
||||
if (!k)
|
||||
k = Math.max(1, (len / 48) | 0);
|
||||
|
||||
// Find d and s, (n - 1) = (2 ^ s) * d;
|
||||
var n1 = n.subn(1);
|
||||
for (var s = 0; !n1.testn(s); s++) {}
|
||||
var d = n.shrn(s);
|
||||
|
||||
var rn1 = n1.toRed(red);
|
||||
|
||||
for (; k > 0; k--) {
|
||||
var a = this._randrange(new bn(2), n1);
|
||||
|
||||
var g = n.gcd(a);
|
||||
if (g.cmpn(1) !== 0)
|
||||
return g;
|
||||
|
||||
var x = a.toRed(red).redPow(d);
|
||||
if (x.cmp(rone) === 0 || x.cmp(rn1) === 0)
|
||||
continue;
|
||||
|
||||
for (var i = 1; i < s; i++) {
|
||||
x = x.redSqr();
|
||||
|
||||
if (x.cmp(rone) === 0)
|
||||
return x.fromRed().subn(1).gcd(n);
|
||||
if (x.cmp(rn1) === 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i === s) {
|
||||
x = x.redSqr();
|
||||
return x.fromRed().subn(1).gcd(n);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
19
web/node_modules/miller-rabin/node_modules/bn.js/LICENSE
generated
vendored
Normal file
19
web/node_modules/miller-rabin/node_modules/bn.js/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright Fedor Indutny, 2015.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
200
web/node_modules/miller-rabin/node_modules/bn.js/README.md
generated
vendored
Normal file
200
web/node_modules/miller-rabin/node_modules/bn.js/README.md
generated
vendored
Normal file
|
@ -0,0 +1,200 @@
|
|||
# <img src="./logo.png" alt="bn.js" width="160" height="160" />
|
||||
|
||||
> BigNum in pure javascript
|
||||
|
||||
[](http://travis-ci.org/indutny/bn.js)
|
||||
|
||||
## Install
|
||||
`npm install --save bn.js`
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const BN = require('bn.js');
|
||||
|
||||
var a = new BN('dead', 16);
|
||||
var b = new BN('101010', 2);
|
||||
|
||||
var res = a.add(b);
|
||||
console.log(res.toString(10)); // 57047
|
||||
```
|
||||
|
||||
**Note**: decimals are not supported in this library.
|
||||
|
||||
## Notation
|
||||
|
||||
### Prefixes
|
||||
|
||||
There are several prefixes to instructions that affect the way the work. Here
|
||||
is the list of them in the order of appearance in the function name:
|
||||
|
||||
* `i` - perform operation in-place, storing the result in the host object (on
|
||||
which the method was invoked). Might be used to avoid number allocation costs
|
||||
* `u` - unsigned, ignore the sign of operands when performing operation, or
|
||||
always return positive value. Second case applies to reduction operations
|
||||
like `mod()`. In such cases if the result will be negative - modulo will be
|
||||
added to the result to make it positive
|
||||
|
||||
### Postfixes
|
||||
|
||||
The only available postfix at the moment is:
|
||||
|
||||
* `n` - which means that the argument of the function must be a plain JavaScript
|
||||
Number. Decimals are not supported.
|
||||
|
||||
### Examples
|
||||
|
||||
* `a.iadd(b)` - perform addition on `a` and `b`, storing the result in `a`
|
||||
* `a.umod(b)` - reduce `a` modulo `b`, returning positive value
|
||||
* `a.iushln(13)` - shift bits of `a` left by 13
|
||||
|
||||
## Instructions
|
||||
|
||||
Prefixes/postfixes are put in parens at the of the line. `endian` - could be
|
||||
either `le` (little-endian) or `be` (big-endian).
|
||||
|
||||
### Utilities
|
||||
|
||||
* `a.clone()` - clone number
|
||||
* `a.toString(base, length)` - convert to base-string and pad with zeroes
|
||||
* `a.toNumber()` - convert to Javascript Number (limited to 53 bits)
|
||||
* `a.toJSON()` - convert to JSON compatible hex string (alias of `toString(16)`)
|
||||
* `a.toArray(endian, length)` - convert to byte `Array`, and optionally zero
|
||||
pad to length, throwing if already exceeding
|
||||
* `a.toArrayLike(type, endian, length)` - convert to an instance of `type`,
|
||||
which must behave like an `Array`
|
||||
* `a.toBuffer(endian, length)` - convert to Node.js Buffer (if available). For
|
||||
compatibility with browserify and similar tools, use this instead:
|
||||
`a.toArrayLike(Buffer, endian, length)`
|
||||
* `a.bitLength()` - get number of bits occupied
|
||||
* `a.zeroBits()` - return number of less-significant consequent zero bits
|
||||
(example: `1010000` has 4 zero bits)
|
||||
* `a.byteLength()` - return number of bytes occupied
|
||||
* `a.isNeg()` - true if the number is negative
|
||||
* `a.isEven()` - no comments
|
||||
* `a.isOdd()` - no comments
|
||||
* `a.isZero()` - no comments
|
||||
* `a.cmp(b)` - compare numbers and return `-1` (a `<` b), `0` (a `==` b), or `1` (a `>` b)
|
||||
depending on the comparison result (`ucmp`, `cmpn`)
|
||||
* `a.lt(b)` - `a` less than `b` (`n`)
|
||||
* `a.lte(b)` - `a` less than or equals `b` (`n`)
|
||||
* `a.gt(b)` - `a` greater than `b` (`n`)
|
||||
* `a.gte(b)` - `a` greater than or equals `b` (`n`)
|
||||
* `a.eq(b)` - `a` equals `b` (`n`)
|
||||
* `a.toTwos(width)` - convert to two's complement representation, where `width` is bit width
|
||||
* `a.fromTwos(width)` - convert from two's complement representation, where `width` is the bit width
|
||||
* `BN.isBN(object)` - returns true if the supplied `object` is a BN.js instance
|
||||
|
||||
### Arithmetics
|
||||
|
||||
* `a.neg()` - negate sign (`i`)
|
||||
* `a.abs()` - absolute value (`i`)
|
||||
* `a.add(b)` - addition (`i`, `n`, `in`)
|
||||
* `a.sub(b)` - subtraction (`i`, `n`, `in`)
|
||||
* `a.mul(b)` - multiply (`i`, `n`, `in`)
|
||||
* `a.sqr()` - square (`i`)
|
||||
* `a.pow(b)` - raise `a` to the power of `b`
|
||||
* `a.div(b)` - divide (`divn`, `idivn`)
|
||||
* `a.mod(b)` - reduct (`u`, `n`) (but no `umodn`)
|
||||
* `a.divRound(b)` - rounded division
|
||||
|
||||
### Bit operations
|
||||
|
||||
* `a.or(b)` - or (`i`, `u`, `iu`)
|
||||
* `a.and(b)` - and (`i`, `u`, `iu`, `andln`) (NOTE: `andln` is going to be replaced
|
||||
with `andn` in future)
|
||||
* `a.xor(b)` - xor (`i`, `u`, `iu`)
|
||||
* `a.setn(b)` - set specified bit to `1`
|
||||
* `a.shln(b)` - shift left (`i`, `u`, `iu`)
|
||||
* `a.shrn(b)` - shift right (`i`, `u`, `iu`)
|
||||
* `a.testn(b)` - test if specified bit is set
|
||||
* `a.maskn(b)` - clear bits with indexes higher or equal to `b` (`i`)
|
||||
* `a.bincn(b)` - add `1 << b` to the number
|
||||
* `a.notn(w)` - not (for the width specified by `w`) (`i`)
|
||||
|
||||
### Reduction
|
||||
|
||||
* `a.gcd(b)` - GCD
|
||||
* `a.egcd(b)` - Extended GCD results (`{ a: ..., b: ..., gcd: ... }`)
|
||||
* `a.invm(b)` - inverse `a` modulo `b`
|
||||
|
||||
## Fast reduction
|
||||
|
||||
When doing lots of reductions using the same modulo, it might be beneficial to
|
||||
use some tricks: like [Montgomery multiplication][0], or using special algorithm
|
||||
for [Mersenne Prime][1].
|
||||
|
||||
### Reduction context
|
||||
|
||||
To enable this tricks one should create a reduction context:
|
||||
|
||||
```js
|
||||
var red = BN.red(num);
|
||||
```
|
||||
where `num` is just a BN instance.
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.red(primeName);
|
||||
```
|
||||
|
||||
Where `primeName` is either of these [Mersenne Primes][1]:
|
||||
|
||||
* `'k256'`
|
||||
* `'p224'`
|
||||
* `'p192'`
|
||||
* `'p25519'`
|
||||
|
||||
Or:
|
||||
|
||||
```js
|
||||
var red = BN.mont(num);
|
||||
```
|
||||
|
||||
To reduce numbers with [Montgomery trick][0]. `.mont()` is generally faster than
|
||||
`.red(num)`, but slower than `BN.red(primeName)`.
|
||||
|
||||
### Converting numbers
|
||||
|
||||
Before performing anything in reduction context - numbers should be converted
|
||||
to it. Usually, this means that one should:
|
||||
|
||||
* Convert inputs to reducted ones
|
||||
* Operate on them in reduction context
|
||||
* Convert outputs back from the reduction context
|
||||
|
||||
Here is how one may convert numbers to `red`:
|
||||
|
||||
```js
|
||||
var redA = a.toRed(red);
|
||||
```
|
||||
Where `red` is a reduction context created using instructions above
|
||||
|
||||
Here is how to convert them back:
|
||||
|
||||
```js
|
||||
var a = redA.fromRed();
|
||||
```
|
||||
|
||||
### Red instructions
|
||||
|
||||
Most of the instructions from the very start of this readme have their
|
||||
counterparts in red context:
|
||||
|
||||
* `a.redAdd(b)`, `a.redIAdd(b)`
|
||||
* `a.redSub(b)`, `a.redISub(b)`
|
||||
* `a.redShl(num)`
|
||||
* `a.redMul(b)`, `a.redIMul(b)`
|
||||
* `a.redSqr()`, `a.redISqr()`
|
||||
* `a.redSqrt()` - square root modulo reduction context's prime
|
||||
* `a.redInvm()` - modular inverse of the number
|
||||
* `a.redNeg()`
|
||||
* `a.redPow(b)` - modular exponentiation
|
||||
|
||||
## LICENSE
|
||||
|
||||
This software is licensed under the MIT License.
|
||||
|
||||
[0]: https://en.wikipedia.org/wiki/Montgomery_modular_multiplication
|
||||
[1]: https://en.wikipedia.org/wiki/Mersenne_prime
|
3446
web/node_modules/miller-rabin/node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
3446
web/node_modules/miller-rabin/node_modules/bn.js/lib/bn.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
36
web/node_modules/miller-rabin/node_modules/bn.js/package.json
generated
vendored
Normal file
36
web/node_modules/miller-rabin/node_modules/bn.js/package.json
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"name": "bn.js",
|
||||
"version": "4.12.0",
|
||||
"description": "Big number implementation in pure javascript",
|
||||
"main": "lib/bn.js",
|
||||
"scripts": {
|
||||
"lint": "semistandard",
|
||||
"unit": "mocha --reporter=spec test/*-test.js",
|
||||
"test": "npm run lint && npm run unit"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:indutny/bn.js"
|
||||
},
|
||||
"keywords": [
|
||||
"BN",
|
||||
"BigNum",
|
||||
"Big number",
|
||||
"Modulo",
|
||||
"Montgomery"
|
||||
],
|
||||
"author": "Fedor Indutny <fedor@indutny.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/indutny/bn.js/issues"
|
||||
},
|
||||
"homepage": "https://github.com/indutny/bn.js",
|
||||
"browser": {
|
||||
"buffer": false
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "^0.3.5",
|
||||
"mocha": "^2.1.0",
|
||||
"semistandard": "^7.0.4"
|
||||
}
|
||||
}
|
32
web/node_modules/miller-rabin/package.json
generated
vendored
Normal file
32
web/node_modules/miller-rabin/package.json
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "miller-rabin",
|
||||
"version": "4.0.1",
|
||||
"description": "Miller Rabin algorithm for primality test",
|
||||
"main": "lib/mr.js",
|
||||
"bin": "bin/miller-rabin",
|
||||
"scripts": {
|
||||
"test": "mocha --reporter=spec test/**/*-test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@github.com:indutny/miller-rabin"
|
||||
},
|
||||
"keywords": [
|
||||
"prime",
|
||||
"miller-rabin",
|
||||
"bignumber"
|
||||
],
|
||||
"author": "Fedor Indutny <fedor@indutny.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/indutny/miller-rabin/issues"
|
||||
},
|
||||
"homepage": "https://github.com/indutny/miller-rabin",
|
||||
"devDependencies": {
|
||||
"mocha": "^2.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"bn.js": "^4.0.0",
|
||||
"brorand": "^1.0.1"
|
||||
}
|
||||
}
|
25
web/node_modules/miller-rabin/test.js
generated
vendored
Normal file
25
web/node_modules/miller-rabin/test.js
generated
vendored
Normal file
|
@ -0,0 +1,25 @@
|
|||
var mr = require('./').create();
|
||||
var BN = require('bn.js');
|
||||
|
||||
var p = new BN(
|
||||
`00:d3:99:af:83:02:de:91:f8:cc:1b:4e:2e:e0:18:
|
||||
b3:0a:41:a4:77:98:d2:ad:66:0f:dc:17:85:ca:58:
|
||||
b4:e4:88:55:c5:0a:82:08:7c:fb:70:a9:41:30:be:
|
||||
af:50:d2:ce:93:cd:46:83:47:6e:c0:51:a7:10:e6:
|
||||
66:d1:08:e8:3d:b8:ce:fe:3e:4e:48:96:82:15:f7:
|
||||
2c:83:80:05:f2:14:3a:a4:5a:44:2b:22:22:67:e5:
|
||||
21:23:b7:cb:0f:71:5b:12:8b:3d:81:f6:5e:dc:99:
|
||||
8f:f9:80:38:75:57:c2:dd:9b:7a:b2:24:97:42:60:
|
||||
92:1f:1d:8a:68:c5:b8:7f:5d:c0:53:3d:15:f2:95:
|
||||
b8:1d:8b:c2:e6:ca:a6:4c:bd:bf:88:9f:3e:d3:d7:
|
||||
24:18:27:62:6e:d0:52:75:68:9f:2a:c9:39:af:95:
|
||||
55:bb:11:08:dc:51:e9:8b:5a:38:e0:c0:e9:d8:a6:
|
||||
71:a5:03:f9:a7:2c:dd:1a:63:8e:7f:f0:36:68:a0:
|
||||
44:f8:09:48:3d:bd:de:b3:2d:3a:2f:73:88:8a:0c:
|
||||
e2:7f:9b:dd:e8:c2:0e:ee:21:e4:a7:f9:4d:46:2f:
|
||||
a7:f6:6d:fa:88:2e:95:60:ac:53:2e:45:a2:9d:9e:
|
||||
c4:80:fc:c7:49:c9:42:bb:2b:66:f6:14:6d:7f:03:
|
||||
4e:f3`.replace(/[^a-f0-9]/g, ''), 16);
|
||||
console.time();
|
||||
mr.test(p);
|
||||
console.timeEnd();
|
18
web/node_modules/miller-rabin/test/api-test.js
generated
vendored
Normal file
18
web/node_modules/miller-rabin/test/api-test.js
generated
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
var assert = require('assert');
|
||||
var mr = require('../').create();
|
||||
var bn = require('bn.js');
|
||||
|
||||
describe('Miller-Rabin', function() {
|
||||
it('should test number for primality', function() {
|
||||
assert(!mr.test(new bn(221)));
|
||||
assert(mr.test(new bn(257)));
|
||||
|
||||
var p = new bn('dba8191813fe8f51eaae1de70213aafede8f323f95f32cff' +
|
||||
'8b64ebada275cfb18a446a0150e5fdaee246244c5f002ce0' +
|
||||
'aca97584be1745f2dd1eea2849c52aac8c4b5fb78a1c4da7' +
|
||||
'052774338d3310a6e020c46168cb1f94014e9312511cc4fb' +
|
||||
'79d695bb732449f0e015745b86bfa371dc6ca7386e9c7309' +
|
||||
'5549c2e4b8002873', 16);
|
||||
assert(mr.test(p));
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue