bigint-crypto-utils/test/prime.js

27 lines
813 B
JavaScript
Raw Normal View History

2019-04-19 07:42:28 +00:00
'use strict';
// For the browser test builder to work you MUST import them module in a variable that
// is the camelised version of the package name.
2019-04-19 10:04:06 +00:00
const bigintCryptoUtils = require('../dist/bigint-crypto-utils-latest.node');
2019-04-19 07:42:28 +00:00
const chai = require('chai');
const bitLengths = [
2019-05-27 14:42:46 +00:00
256,
512,
2019-04-19 07:42:28 +00:00
1024,
2048,
2019-04-19 10:04:06 +00:00
3072,
4096
2019-04-19 07:42:28 +00:00
];
describe('prime', function () {
2019-04-19 07:42:28 +00:00
for (const bitLength of bitLengths) {
describe(`prime(${bitLength})`, function () {
2019-04-19 07:42:28 +00:00
it(`should return a random ${bitLength}-bits probable prime`, async function () {
const prime = await bigintCryptoUtils.prime(bitLength);
const primeBitLength = bigintCryptoUtils.bitLength(prime);
chai.expect(primeBitLength).to.equal(bitLength);
2019-04-19 07:42:28 +00:00
});
});
}
});