chiark / gitweb /
6f39f500030ce073883c674ca38c3ad1214ab2d8
[catacomb] / math / strongprime.h
1 /* -*-c-*-
2  *
3  * Generate `strong' prime numbers
4  *
5  * (c) 1999 Straylight/Edgeware
6  */
7
8 /*----- Licensing notice --------------------------------------------------*
9  *
10  * This file is part of Catacomb.
11  *
12  * Catacomb is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU Library General Public License as
14  * published by the Free Software Foundation; either version 2 of the
15  * License, or (at your option) any later version.
16  *
17  * Catacomb is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with Catacomb; if not, write to the Free
24  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25  * MA 02111-1307, USA.
26  */
27
28 #ifndef CATACOMB_STRONGPRIME_H
29 #define CATACOMB_STRONGPRIME_H
30
31 #ifdef __cplusplus
32   extern "C" {
33 #endif
34
35 /*----- Header files ------------------------------------------------------*/
36
37 #ifndef CATACOMB_GRAND_H
38 #  include "grand.h"
39 #endif
40
41 #ifndef CATACOMB_PGEN_H
42 #  include "pgen.h"
43 #endif
44
45 /*----- Functions provided ------------------------------------------------*/
46
47 /* --- @strongprime_setup@ --- *
48  *
49  * Arguments:   @const char *name@ = pointer to name root
50  *              @mp *d@ = destination for search start point
51  *              @pfilt *f@ = where to store filter jump context
52  *              @unsigned nbits@ = number of bits wanted
53  *              @grand *r@ = random number source
54  *              @unsigned n@ = number of attempts to make
55  *              @pgen_proc *event@ = event handler function
56  *              @void *ectx@ = argument for the event handler
57  *
58  * Returns:     A starting point for a `strong' prime search, or zero.
59  *
60  * Use:         Sets up for a strong prime search, so that primes with
61  *              particular properties can be found.  It's probably important
62  *              to note that the number left in the filter context @f@ is
63  *              congruent to 2 (mod 4).
64  */
65
66 extern mp *strongprime_setup(const char */*name*/, mp */*d*/, pfilt */*f*/,
67                              unsigned /*nbits*/, grand */*r*/,
68                              unsigned /*n*/, pgen_proc */*event*/,
69                              void */*ectx*/);
70
71 /* --- @strongprime@ --- *
72  *
73  * Arguments:   @const char *name@ = pointer to name root
74  *              @mp *d@ = destination integer
75  *              @unsigned nbits@ = number of bits wanted
76  *              @grand *r@ = random number source
77  *              @unsigned n@ = number of attempts to make
78  *              @pgen_proc *event@ = event handler function
79  *              @void *ectx@ = argument for the event handler
80  *
81  * Returns:     A `strong' prime, or zero.
82  *
83  * Use:         Finds `strong' primes.  A strong prime %$p$% is such that
84  *
85  *                * %$p - 1$% has a large prime factor %$r$%,
86  *                * %$p + 1$% has a large prime factor %$s$%, and
87  *                * %$r - 1$% has a large prime factor %$t$%.
88  *
89  *              The numbers produced may be slightly larger than requested,
90  *              by a few bits.
91  */
92
93 extern mp *strongprime(const char */*name*/, mp */*d*/, unsigned /*nbits*/,
94                        grand */*r*/, unsigned /*n*/,
95                        pgen_proc */*event*/, void */*ectx*/);
96
97 /*----- That's all, folks -------------------------------------------------*/
98
99 #ifdef __cplusplus
100   }
101 #endif
102
103 #endif