aboutsummaryrefslogtreecommitdiff
path: root/primes.h
blob: eb817b112739f8fa47a676b18af02410d91984c9 (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
#pragma once

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

extern std::vector<int> smallprimes;

void fillsmallprimes();

//for use in RSA (pass target number of bits of N)
std::pair<Bigint,Bigint> genprimepair(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(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);