-
Notifications
You must be signed in to change notification settings - Fork 0
/
pypbc.h
75 lines (61 loc) · 2.31 KB
/
pypbc.h
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#pragma once
// python stuff
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h"
// pbc stuff
#include <pbc/pbc.h>
/*******************************************************************************
* pypbc.c *
* *
* Modifications by Jemtaly *
* Copyright (c) 2024 *
* *
* Originally written by Geremy Condra *
* Licensed under GPLv3 *
* Released 11 October 2009 *
* *
* This file contains the types and functions needed to use PBC from Python 3. *
*******************************************************************************/
// we need debugging symbols for compile warnings
#define PBC_DEBUG
// used to see which group a given element is in
enum Group {G1, G2, GT, Zr};
// We're going to need a few types
// the param type
typedef struct {
PyObject_HEAD
int ready;
pbc_param_t pbc_params;
} Parameters;
Parameters *Parameters_create();
PyObject *Parameters_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
void Parameters_dealloc(Parameters *parameter);
PyMemberDef Parameters_members[];
PyMethodDef Parameters_methods[];
PyTypeObject ParametersType;
// the pairing type
typedef struct {
PyObject_HEAD
int ready;
pairing_t pbc_pairing;
} Pairing;
Pairing *Pairing_create();
PyObject *Pairing_new(PyTypeObject *type, PyObject *args, PyObject *kwargs);
void Pairing_dealloc(Pairing *pairing);
PyMemberDef Pairing_members[];
PyMethodDef Pairing_methods[];
PyTypeObject PairingType;
// the element type
typedef struct {
PyObject_HEAD
int ready;
element_t pbc_element;
Pairing *pairing;
} Element;
Element *Element_create();
PyObject *Element_new(PyTypeObject *type, PyObject *args, PyObject *kwargs);
void Element_dealloc(Element *element);
PyMemberDef Element_members[];
PyMethodDef Element_methods[];
PyTypeObject ElementType;