1 /* Example: local Diffie-Hellman key exchange */
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)
42 RandomBnd(a, pZZ*pZZ);
44 RandomBnd(b, pZZ*pZZ);
53 if ( b * Q1 == a * Q2 )
54 cout << "DH key exchange succeeded!" << endl;
56 cout << "DH key exchange failed!" << endl;