Debian Codegraph @

src/ec.h

raw symbols SCIP
1 #ifndef _EC_H
2 #define _EC_H
3
4 #include "common.h"
5 #include "mont.h"
6 #include "modexp_utils.h"
7
8 typedef struct {
9 uint64_t *a, *b, *c, *d, *e, *f, *g, *h, *i, *j, *k;
10 uint64_t *scratch;
11 } Workplace;
12
13 /*
14 * The description of a short Weierstrass curve, with y²=x³-3x+b
15 */
16 typedef struct _EcContext {
17 MontContext *mont_ctx;
18 uint64_t *b; /* encoded in Montgomery form */
19 uint64_t *order; /* big-endian plain form */
20 ProtMemory **prot_g; /* optional pre-computed tables for generator */
21 } EcContext;
22
23 /*
24 * An EC point in Jacobian coordinates
25 */
26 typedef struct _EcPoint {
27 const EcContext *ec_ctx;
28 uint64_t *x;
29 uint64_t *y;
30 uint64_t *z;
31 } EcPoint;
32
33 EXPORT_SYM int ec_ws_new_context(EcContext **pec_ctx,
34 const uint8_t *modulus,
35 const uint8_t *b,
36 const uint8_t *order,
37 size_t len,
38 uint64_t seed);
39 EXPORT_SYM void ec_free_context(EcContext *ec_ctx);
40 EXPORT_SYM int ec_ws_new_point(EcPoint **pecp,
41 const uint8_t *x,
42 const uint8_t *y,
43 size_t len,
44 const EcContext *ec_ctx);
45 EXPORT_SYM void ec_ws_free_point(EcPoint *ecp);
46 EXPORT_SYM int ec_ws_get_xy(uint8_t *x,
47 uint8_t *y,
48 size_t len,
49 const EcPoint *ecp);
50 EXPORT_SYM int ec_ws_double(EcPoint *p);
51 EXPORT_SYM int ec_ws_add(EcPoint *ecpa,
52 EcPoint *ecpb);
53 EXPORT_SYM int ec_ws_scalar(EcPoint *ecp,
54 const uint8_t *k,
55 size_t len,
56 uint64_t seed);
57 EXPORT_SYM int ec_ws_clone(EcPoint **pecp2, const EcPoint *ecp);
58 EXPORT_SYM int ec_ws_copy(EcPoint *ecp1, const EcPoint *ecp2);
59 EXPORT_SYM int ec_ws_cmp(const EcPoint *ecp1, const EcPoint *ecp2);
60 EXPORT_SYM int ec_ws_neg(EcPoint *p);
61 EXPORT_SYM int ec_ws_normalize(EcPoint *ecp);
62 EXPORT_SYM int ec_ws_is_pai(EcPoint *ecp);
63 #endif