Skip to content

Instantly share code, notes, and snippets.

@fionser
Created June 6, 2017 13:07
Show Gist options
  • Save fionser/08b5253f53a782023e01ad551d48aed2 to your computer and use it in GitHub Desktop.
Save fionser/08b5253f53a782023e01ad551d48aed2 to your computer and use it in GitHub Desktop.
Find good parameter for HElib.
#include "PAlgebra.h"
#include <NTL/ZZ.h>
#include <iostream>
const long MAX_PRIME_BIT = 20;
void search(long m) {
long p = 2;
do {
if ((m % p) != 0) {
PAlgebra zMStar(m, p);
/// Best
if (zMStar.numOfGens() == 1 && zMStar.SameOrd(0))
std::cout << "Best " << m << " " << p << std::endl;
/// Somehow ok to use
else if (zMStar.numOfGens() <= 2)
std::cout << "Somehow ok " << m << " " << p << std::endl;
}
p = NTL::NextPrime(p + 1);
} while (NTL::NumBits(p) < MAX_PRIME_BIT);
}
int main() {
search(4096);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment