aboutsummaryrefslogtreecommitdiff
path: root/primes.h
blob: 7d3edac527f99c75dd13fda1b904bf19e887f6b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#pragma once

#include <vector>
#include <utility>
#include "bigint.h"
#include "rng.h"

extern std::vector<int> smallprimes;

void fillsmallprimes();

//For use in RSA (pass target number of bits of N)
std::pair<Bigint,Bigint> genprimepair(Rng &rng,int nbits);

//Finds random in range [low,high]; throws range_error("No primes") if no prime found
//Will call fillsmallprimes() if not yet done
Bigint randprime(Rng &rng,const Bigint &low,const Bigint &high);

//checks Fermat [pseudo- or actual] primality
bool strongPseudoPrime2(const Bigint &n);

//checks Lucas [pseudo- or actual] primality
bool strongLucasPrime(const Bigint &n);

//checks primality
bool bailliePSW(const Bigint &n);