summaryrefslogtreecommitdiffstats
path: root/moon-abe/pbc-0.5.14/include/pbc_mnt.h
blob: 82e4993b27fb1e76c68e0d8cdbbf4d5cfd12235b (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//requires
// * gmp.h
#ifndef __PBC_MNT_H__
#define __PBC_MNT_H__

struct pbc_cm_s {
  mpz_t q; //curve defined over F_q
  mpz_t n; //has order n (= q - t + 1) in F_q (and r^2 in F_q^k)
  mpz_t h; //h * r = n, r is prime
  mpz_t r;
  int D; //discrminant needed to find j-invariant
  int k; //embedding degree
};

typedef struct pbc_cm_s *pbc_cm_ptr;
typedef struct pbc_cm_s pbc_cm_t[1];

/*@manual cminfo
Initializes 'cm'.
*/
void pbc_cm_init(pbc_cm_t cm);
/*@manual cminfo
Clears 'cm'.
*/
void pbc_cm_clear(pbc_cm_t cm);

/*@manual cminfo
For a given discriminant D, searches for type D pairings suitable for
cryptography (MNT curves of embedding degree 6).
The group order is at most 'bitlimit' bits. For each set of CM parameters
found, call 'callback' with +pbc_cm_t+ and given +void *+. If the callback
returns nonzero, stops search and returns that value.
Otherwise returns 0.
*/
int pbc_cm_search_d(int (*callback)(pbc_cm_ptr, void *), void *data,
  unsigned int D, unsigned int bitlimit);

/*@manual cminfo
For a given discriminant D, searches for type G pairings suitable for
cryptography (Freeman curve).
The group order is at most 'bitlimit' bits. For each set of CM parameters
found, call 'callback' with +pbc_cm_t+ and given +void *+. If the callback
returns nonzero, stops search and returns that value.
Otherwise returns 0.
*/
int pbc_cm_search_g(int (*callback)(pbc_cm_ptr, void *), void *data,
  unsigned int D, unsigned int bitlimit);

#endif //__PBC_MNT_H__