summaryrefslogtreecommitdiffstats
path: root/moon-abe/pbc-0.5.14/gen/gendparam.c
diff options
context:
space:
mode:
authorWuKong <rebirthmonkey@gmail.com>2015-09-04 09:25:34 +0200
committerWuKong <rebirthmonkey@gmail.com>2015-09-04 09:25:34 +0200
commit3baeb11a8fbcfcdbc31976d421f17b85503b3ecd (patch)
tree04891d88c1127148f1b390b5a24414e85b270aee /moon-abe/pbc-0.5.14/gen/gendparam.c
parent67c5b73910f5fc437429c356978081b252a59480 (diff)
init attribute-based encryption
Change-Id: Iba1a3d722110abf747a0fba366f3ebc911d25b25
Diffstat (limited to 'moon-abe/pbc-0.5.14/gen/gendparam.c')
-rw-r--r--moon-abe/pbc-0.5.14/gen/gendparam.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/moon-abe/pbc-0.5.14/gen/gendparam.c b/moon-abe/pbc-0.5.14/gen/gendparam.c
new file mode 100644
index 00000000..8506e52a
--- /dev/null
+++ b/moon-abe/pbc-0.5.14/gen/gendparam.c
@@ -0,0 +1,35 @@
+// Generate MNT curve(s) for a given D.
+
+#include <stdint.h> // for intptr_t
+#include "pbc.h"
+#include "pbc_utils.h" // for UNUSED_VAR
+
+int generate(pbc_cm_t cm, void *data) {
+ UNUSED_VAR(data);
+ pbc_param_t param;
+ pbc_info("gendparam: computing Hilbert polynomial and finding roots...");
+ pbc_param_init_d_gen(param, cm);
+ pbc_info("gendparam: bits in q = %zu\n", mpz_sizeinbase(cm->q, 2));
+ pbc_param_out_str(stdout, param);
+ pbc_param_clear(param);
+ return 1;
+}
+
+int main(int argc, char **argv) {
+ int D = 9563;
+
+ if (argc > 1) {
+ int m;
+ D = atoi(argv[1]);
+ m = D % 4;
+ if (D <= 0 || m == 1 || m == 2) {
+ pbc_die("D must be 0 or 3 mod 4 and positive");
+ }
+ }
+ pbc_info("Using D = %d\n", D);
+
+ if (!pbc_cm_search_d(generate, NULL, D, 500)) {
+ pbc_die("no suitable curves for this D");
+ }
+ return 0;
+}