1 /* Example: local ElGamal encryption */
2 /* Note that because we have a static g2hcurve member s_hcurve in the
3 divisor class and this memeber may result in chaos when we swith moduli,
4 we require that there is only one modulus per process
7 #include <g2hec_nsfieldtype.h>
9 #include <g2hec_Genus2_ops.h>
12 #define MAX_STRING_LEN 300
19 SetSeed(to_ZZ(19800729));
21 char p[MAX_STRING_LEN];
23 cout << "Please choose your modulus p (up to "
24 << MAX_STRING_LEN << " decimal digits):" << endl;
26 cin.getline(p, MAX_STRING_LEN);
30 field_t::init(pZZ); // define GF(p)
36 divisor m, g, h, a, b;
41 RandomBnd(x, pZZ*pZZ);
43 RandomBnd(k, pZZ*pZZ);
47 /* random message m as divisor */
50 /* random base point */
56 /* cipher text (a, b) */
60 /* message decryption */
63 cout << "ElGamal decryption succeeded!" << endl;
65 cout << "ElGamal decryption failed!" << endl;