CRS
Isogeny-based post-quantum Diffie-Hellman protocol.
arithmetic.h
1#ifndef _ARITHMETIC_H_
2#define _ARITHMETIC_H_
3
4#include "string.h"
5#include "stdbool.h"
6
7#include "memory.h"
8#include "models.h"
9#include "auxiliary.h"
10#include "pretty_print.h"
11
12#include <gmp.h>
13#include <flint/fmpz.h>
14#include <flint/fq.h>
15
16#include "../Polynomials/roots.h"
17
18/*********************************************
19 Base field embbeding
20*********************************************/
21void MG_curve_update_field(MG_curve_t *, MG_curve_t *, const fq_ctx_t *);
22void MG_curve_update_field_(MG_curve_t *, const fq_ctx_t *);
23
24/*********************************************
25 Elliptic curves
26*********************************************/
27void SW_j_invariant(fq_t *, SW_curve_t *);
28void MG_j_invariant(fq_t *, MG_curve_t *);
29void TN_j_invariant(fq_t *, TN_curve_t *);
30
31/*********************************************
32 Points on elliptic curves
33*********************************************/
34void SW_point_isinfinity(bool *, SW_point_t *);
35void MG_point_isinfinity(bool *, MG_point_t *);
36bool MG_point_isinfinity_(MG_point_t *);
37int SW_point_isvalid(bool *, SW_point_t *);
38int MG_point_isvalid(bool *, MG_point_t *);
39void MG_point_isinfty(bool *, MG_point_t *);
40void MG_point_normalize(MG_point_t *);
41
42/*********************************************
43 Random torsion point generation
44*********************************************/
45void SW_point_rand_ninfty(SW_point_t *);
46void MG_point_rand_ninfty(MG_point_t *, flint_rand_t);
47void MG_point_rand_ninfty_nsquare(MG_point_t *, flint_rand_t);
48
49/*********************************************
50 Montgomery curve arithmetic
51*********************************************/
52int MG_curve_normalize(MG_curve_t *);
53int MG_rec_y(fq_t, MG_point_t *);
55void MG_xDBL(MG_point_t *, MG_point_t);
56void MG_xDBL_const(MG_point_t *, MG_point_t ,const fq_t);
57
58/*********************************************
59 Montgomery ladder
60*********************************************/
61void MG_ladder_rec(MG_point_t *, MG_point_t *, fmpz_t, MG_point_t, const fq_ctx_t *);
62void MG_ladder(MG_point_t *x0, fmpz_t k, MG_point_t P);
63void MG_ladder_iter(MG_point_t *, MG_point_t *, fmpz_t, MG_point_t, fq_ctx_t *);
64void MG_ladder_iter_(MG_point_t *, fmpz_t, MG_point_t *);
65
66/*********************************************
67 Torsion
68*********************************************/
69void MG_curve_trace(fmpz_t);
70void MG_curve_card_base(fmpz_t, MG_curve_t *);
71void MG_curve_card_ext(fmpz_t, MG_curve_t *, fmpz_t r);
72int MG_curve_rand_torsion(MG_point_t *, fmpz_t, fmpz_t);
73int MG_curve_rand_torsion_(MG_point_t *, fmpz_t, fmpz_t);
74
75/*********************************************
76 Tate normal curve and Montgomery conversion
77*********************************************/
78void MG_get_TN(TN_curve_t *, MG_curve_t *, MG_point_t *, fmpz_t);
79int TN_get_MG(MG_curve_t *, TN_curve_t *);
80#endif
81
Definition: models.h:34
Definition: models.h:43
Definition: models.h:16
Definition: models.h:25
Definition: models.h:52