<commit_before>/** Test_AES.cpp - test program for homomorphic AES using HElib
 */
#if defined(__unix__) || defined(__unix) || defined(unix)
#include <sys/time.h>
#include <sys/resource.h>
#endif

namespace std {} using namespace std;
namespace NTL {} using namespace NTL;
#include <cstring>
#include "homAES.h"
#include "Ctxt.h"

static long mValues[][14] = { 
//{ p, phi(m),  m,   d, m1, m2, m3,   g1,    g2,   g3,ord1,ord2,ord3, c_m}
  { 2,  512,    771, 16,771,  0,  0,     5,    0,    0,-32,  0,  0, 100}, // m=(3)*{257} :-( m/phim(m)=1.5 C=77 D=2 E=4
  { 2, 4096,   4369, 16, 17, 257, 0,   258, 4115,    0, 16,-16,  0, 100}, // m=17*(257) :-( m/phim(m)=1.06 C=61 D=3 E=4
  { 2, 16384, 21845, 16, 17, 5, 257,  8996,17477,21591, 16,  4,-16,1600}, // m=5*17*(257) :-( m/phim(m)=1.33 C=65 D=4 E=4
  { 2, 23040, 28679, 24, 17, 7, 241, 15184, 4098,28204, 16,  6,-10,1500}, // m=7*17*(241) m/phim(m)=1.24    C=63  D=4 E=3
  { 2, 46080, 53261, 24, 17,13, 241, 43863,28680,15913, 16, 12,-10, 100}, // m=13*17*(241) m/phim(m)=1.15   C=69  D=4 E=3
  { 2, 64512, 65281, 48, 97,673,  0, 43073,22214,    0, 96,-14,  0, 100}  // m=97*(673) :-( m/phim(m)=1.01  C=169 D=3 E=4 
};

#ifdef DEBUG_PRINTOUT
extern FHESecKey* dbgKey;
extern EncryptedArray* dbgEa;
#define FLAG_PRINT_ZZX  1
#define FLAG_PRINT_POLY 2
#define FLAG_PRINT_VEC  4
extern void decryptAndPrint(ostream& s, const Ctxt& ctxt, const FHESecKey& sk,
			    const EncryptedArray& ea, long flags=0);
#endif

void printState(Vec<uint8_t>& st);
extern long AESKeyExpansion(unsigned char RoundKey[],
			    unsigned char Key[], int NN);
extern void Cipher(unsigned char out[16],
		   unsigned char in[16], unsigned char RoundKey[], int Nr);

int main(int argc, char **argv)
{
  ArgMapping amap;

  long idx = 0;
  amap.arg("sz", idx, "parameter-sets: toy=0 through huge=5");

  long c=3;
  amap.arg("c", c, "number of columns in the key-switching matrices");

  long L=0;
  amap.arg("L", L, "# of levels in the modulus chain",  "heuristic");

  long B=23;
  amap.arg("B", B, "# of bits per level (only 64-bit machines)");

  bool boot=false;
  amap.arg("boot", boot, "includes bootstrapping");

  bool packed=true;
  amap.arg("packed", packed, "use packed bootstrapping");

  amap.parse(argc, argv);
  if (idx>5) idx = 5;

  Vec<long> mvec;
  vector<long> gens;
  vector<long> ords;

  if (boot) { 
    if (L<22) L=22;
    if (idx<1) idx=1; // the sz=0 params are incompatible with bootstrapping
  } else { 
    if (L<44) L=44; 
  }

  long p = mValues[idx][0];
  //  long phim = mValues[idx][1];
  long m = mValues[idx][2];
<commit_msg>changed default size of modulus-chain<commit_after>/** Test_AES.cpp - test program for homomorphic AES using HElib
 */
#if defined(__unix__) || defined(__unix) || defined(unix)
#include <sys/time.h>
#include <sys/resource.h>
#endif

namespace std {} using namespace std;
namespace NTL {} using namespace NTL;
#include <cstring>
#include "homAES.h"
#include "Ctxt.h"

static long mValues[][14] = { 
//{ p, phi(m),  m,   d, m1, m2, m3,   g1,    g2,   g3,ord1,ord2,ord3, c_m}
  { 2,  512,    771, 16,771,  0,  0,     5,    0,    0,-32,  0,  0, 100}, // m=(3)*{257} :-( m/phim(m)=1.5 C=77 D=2 E=4
  { 2, 4096,   4369, 16, 17, 257, 0,   258, 4115,    0, 16,-16,  0, 100}, // m=17*(257) :-( m/phim(m)=1.06 C=61 D=3 E=4
  { 2, 16384, 21845, 16, 17, 5, 257,  8996,17477,21591, 16,  4,-16,1600}, // m=5*17*(257) :-( m/phim(m)=1.33 C=65 D=4 E=4
  { 2, 23040, 28679, 24, 17, 7, 241, 15184, 4098,28204, 16,  6,-10,1500}, // m=7*17*(241) m/phim(m)=1.24    C=63  D=4 E=3
  { 2, 46080, 53261, 24, 17,13, 241, 43863,28680,15913, 16, 12,-10, 100}, // m=13*17*(241) m/phim(m)=1.15   C=69  D=4 E=3
  { 2, 64512, 65281, 48, 97,673,  0, 43073,22214,    0, 96,-14,  0, 100}  // m=97*(673) :-( m/phim(m)=1.01  C=169 D=3 E=4 
};

#ifdef DEBUG_PRINTOUT
extern FHESecKey* dbgKey;
extern EncryptedArray* dbgEa;
#define FLAG_PRINT_ZZX  1
#define FLAG_PRINT_POLY 2
#define FLAG_PRINT_VEC  4
extern void decryptAndPrint(ostream& s, const Ctxt& ctxt, const FHESecKey& sk,
			    const EncryptedArray& ea, long flags=0);
#endif

void printState(Vec<uint8_t>& st);
extern long AESKeyExpansion(unsigned char RoundKey[],
			    unsigned char Key[], int NN);
extern void Cipher(unsigned char out[16],
		   unsigned char in[16], unsigned char RoundKey[], int Nr);

int main(int argc, char **argv)
{
  ArgMapping amap;

  long idx = 0;
  amap.arg("sz", idx, "parameter-sets: toy=0 through huge=5");

  long c=3;
  amap.arg("c", c, "number of columns in the key-switching matrices");

  long L=0;
  amap.arg("L", L, "# of levels in the modulus chain",  "heuristic");

  long B=23;
  amap.arg("B", B, "# of bits per level (only 64-bit machines)");

  bool boot=false;
  amap.arg("boot", boot, "includes bootstrapping");

  bool packed=true;
  amap.arg("packed", packed, "use packed bootstrapping");

  amap.parse(argc, argv);
  if (idx>5) idx = 5;

  Vec<long> mvec;
  vector<long> gens;
  vector<long> ords;

  if (boot) { 
    if (L<23) L=23;
    if (idx<1) idx=1; // the sz=0 params are incompatible with bootstrapping
  } else { 
    if (L<42) L=42; 
  }

  long p = mValues[idx][0];
  //  long phim = mValues[idx][1];
  long m = mValues[idx][2];

{'fraction_non_alphanumeric': 0.18526356290881107, 'fraction_numerical': 0.13197383609080415, 'mean_word_length': 3.4974048442906573, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5791209', 'n_tokens_mistral': 2698, 'n_tokens_neox': 2218, 'n_words': 616}