CRS
Isogeny-based post-quantum Diffie-Hellman protocol.
Functions
memory.h File Reference
#include <string.h>
#include <gmp.h>
#include <flint/fmpz.h>
#include <flint/fq.h>
#include "models.h"

Go to the source code of this file.

Functions

void SW_curve_init (SW_curve_t *, const fq_ctx_t *)
 
void SW_curve_set (SW_curve_t *, const fq_ctx_t *, const fq_t, const fq_t)
 
void SW_curve_set_si (SW_curve_t *, const fq_ctx_t *, const slong, const slong)
 
void SW_curve_set_ui (SW_curve_t *, const fq_ctx_t *, const ulong, const ulong)
 
int SW_curve_set_str (SW_curve_t *, const fq_ctx_t *, const char *, const char *, int)
 
void SW_curve_clear (SW_curve_t *)
 
void SW_point_init (SW_point_t *, SW_curve_t *)
 
void SW_point_set (SW_point_t *, const fq_t, const fq_t, const fq_t, SW_curve_t *)
 
void SW_point_set_si (SW_point_t *, const slong, const slong, const slong, SW_curve_t *)
 
void SW_point_set_ui (SW_point_t *, const ulong, const ulong, const ulong, SW_curve_t *)
 
void SW_point_clear (SW_point_t *)
 
void MG_curve_init (MG_curve_t *, const fq_ctx_t *)
 
void MG_curve_set (MG_curve_t *, const fq_ctx_t *, const fq_t, const fq_t)
 
void MG_curve_set_ (MG_curve_t *, MG_curve_t *)
 
void MG_curve_set_si (MG_curve_t *, const fq_ctx_t *, const slong, const slong)
 
int MG_curve_set_str (MG_curve_t *, const fq_ctx_t *, const char *, const char *, int)
 
void MG_curve_clear (MG_curve_t *)
 
void MG_point_init (MG_point_t *, MG_curve_t *)
 
void MG_point_set (MG_point_t *, const fq_t, const fq_t, MG_curve_t *)
 
void MG_point_set_ (MG_point_t *, MG_point_t *)
 
void MG_point_set_si (MG_point_t *, const slong, const slong, MG_curve_t *)
 
void MG_point_set_ui (MG_point_t *, const ulong, const ulong, MG_curve_t *)
 
void MG_point_set_fmpz (MG_point_t *, const fmpz_t, const fmpz_t, MG_curve_t *)
 
void MG_point_set_str (MG_point_t *, const char *, const char *, MG_curve_t *)
 
void MG_point_set_infty (MG_point_t *)
 
void MG_point_clear (MG_point_t *)
 
void TN_curve_init (TN_curve_t *, fmpz_t, const fq_ctx_t *)
 
void TN_curve_set (TN_curve_t *, const fq_t, const fq_t, fmpz_t, const fq_ctx_t *)
 
void TN_curve_set_ (TN_curve_t *, TN_curve_t *)
 
void TN_curve_set_si (TN_curve_t *, const slong, const slong, const slong, const fq_ctx_t *)
 
int TN_curve_set_str (TN_curve_t *, const char *, const char *, const char *, int, const fq_ctx_t *)
 
void TN_curve_clear (TN_curve_t *)
 

Function Documentation

◆ MG_curve_clear()

void MG_curve_clear ( MG_curve_t E)

Clears the given curve, releasing any memory used. It must be reinitialised in order to be used again.

◆ MG_curve_init()

void MG_curve_init ( MG_curve_t E,
const fq_ctx_t *  F 
)

Initializes E for use, with context F, and setting its coefficients to zero. A corresponding call to MG_curve_clear() must be made after finishing with the MG_curve_t to free the memory used by the curve.

◆ MG_curve_set()

void MG_curve_set ( MG_curve_t E,
const fq_ctx_t *  F,
const fq_t  A,
const fq_t  B 
)

Sets E to elliptic curve over F in Montgomery form with coefficients A and B. Curve parameters are given as elements of F.

◆ MG_curve_set_()

void MG_curve_set_ ( MG_curve_t rop,
MG_curve_t op 
)

Sets elliptic curve rop in Montgomery form to curve op. This is aking to a deep copy. rop must be initialized.

◆ MG_curve_set_si()

void MG_curve_set_si ( MG_curve_t E,
const fq_ctx_t *  F,
const slong  A,
const slong  B 
)

See MG_curve_set(). Curve coefficients are given as signed integers.

◆ MG_curve_set_str()

int MG_curve_set_str ( MG_curve_t E,
const fq_ctx_t *  F,
const char *  str_A,
const char *  str_B,
int  b 
)

See MG_curve_set(). Parameters are given as null-terminated strings, in base b. The base b can vary between 2 and 62, inclusive. Returns 0 if the string contain valid inputs and −1 otherwise.

◆ MG_point_clear()

void MG_point_clear ( MG_point_t P)

Clears the given point, releasing anZ memorZ used. It must be reinitialised in order to be used again.

◆ MG_point_init()

void MG_point_init ( MG_point_t P,
MG_curve_t E 
)

Initializes P for use, with context F, and setting its coefficients to zero. A corresponding call to SW_point_clear() must be made after finishing with the SW_point_t to free the memorZ used bZ the curve. TODO: swap F for E in parameters. A point is member of E not of F.

◆ MG_point_set()

void MG_point_set ( MG_point_t P,
const fq_t  X,
const fq_t  Z,
MG_curve_t E 
)

Sets P to point of elliptic curve E with coordinates X, Z, z. Point parameters are given as elements of F. TODO: Check if P and E's fields are correct

◆ MG_point_set_()

void MG_point_set_ ( MG_point_t P,
MG_point_t Q 
)

Sets P to the same point as Q.

◆ MG_point_set_fmpz()

void MG_point_set_fmpz ( MG_point_t P,
const fmpz_t  X,
const fmpz_t  Z,
MG_curve_t E 
)

See MG_point_set(). Point coordinates are given as strings of integers.

◆ MG_point_set_infty()

void MG_point_set_infty ( MG_point_t P)

Sets P to the point at infinity on the underlying curve.

◆ MG_point_set_si()

void MG_point_set_si ( MG_point_t P,
const slong  X,
const slong  Z,
MG_curve_t E 
)

See MG_point_set(). Point coordinates are given as signed integers.

◆ MG_point_set_str()

void MG_point_set_str ( MG_point_t P,
const char *  X,
const char *  Z,
MG_curve_t E 
)

See MG_point_set(). Point coordinates are given as strings of integers.

◆ MG_point_set_ui()

void MG_point_set_ui ( MG_point_t P,
const ulong  X,
const ulong  Z,
MG_curve_t E 
)

See MG_point_set(). Point coordinates are given as unsigned integers.

◆ SW_curve_clear()

void SW_curve_clear ( SW_curve_t E)

Clears the given curve, releasing any memory used. It must be reinitialised in order to be used again.

◆ SW_curve_init()

void SW_curve_init ( SW_curve_t E,
const fq_ctx_t *  F 
)

Initializes E for use, with context F, and setting its coefficients to zero. A corresponding call to SW_curve_clear() must be made after finishing with the SW_curve_t to free the memory used by the curve.

◆ SW_curve_set()

void SW_curve_set ( SW_curve_t E,
const fq_ctx_t *  F,
const fq_t  a,
const fq_t  b 
)

Sets E to elliptic curve over F in Weierstrass form with coefficients a and b. Curve parameters are given as elements of F.

◆ SW_curve_set_si()

void SW_curve_set_si ( SW_curve_t E,
const fq_ctx_t *  F,
const slong  a,
const slong  b 
)

See SW_curve_set(). Curve coefficients are given as signed integers.

◆ SW_curve_set_str()

int SW_curve_set_str ( SW_curve_t E,
const fq_ctx_t *  F,
const char *  str_a,
const char *  str_b,
int  b 
)

See SW_curve_set(). Parameters are given as null-terminated strings, in base b. The base b can vary between 2 and 62, inclusive. Returns 0 if the string contain valid inputs and −1 otherwise.

◆ SW_point_clear()

void SW_point_clear ( SW_point_t P)

Clears the given point, releasing any memory used. It must be reinitialised in order to be used again.

◆ SW_point_init()

void SW_point_init ( SW_point_t P,
SW_curve_t E 
)

Initializes P for use, with context F, and setting its coefficients to zero. A corresponding call to SW_point_clear() must be made after finishing with the SW_point_t to free the memory used by the curve. TODO: swap F for E in parameters. A point is member of E not of F.

◆ SW_point_set()

void SW_point_set ( SW_point_t P,
const fq_t  x,
const fq_t  y,
const fq_t  z,
SW_curve_t E 
)

Sets P to point of elliptic curve E with coordinates x, y, z. Point parameters are given as elements of F. TODO: Check if P and E's fields are correct

◆ SW_point_set_si()

void SW_point_set_si ( SW_point_t P,
const slong  x,
const slong  y,
const slong  z,
SW_curve_t E 
)

See SW_point_set(). Point coordinates are given as signed integers.

◆ SW_point_set_ui()

void SW_point_set_ui ( SW_point_t P,
const ulong  x,
const ulong  y,
const ulong  z,
SW_curve_t E 
)

See SW_point_set(). Point coordinates are given as unsigned integers.

◆ TN_curve_clear()

void TN_curve_clear ( TN_curve_t E)

Clears the given curve, releasing any memory used. It must be reinitialised in order to be used again.

◆ TN_curve_init()

void TN_curve_init ( TN_curve_t E,
fmpz_t  l,
const fq_ctx_t *  F 
)

Initializes E for use, with context F, and setting its coefficients to zero. A corresponding call to TN_curve_clear() must be made after finishing with the TN_curve_t to free the memory used by the curve.

◆ TN_curve_set()

void TN_curve_set ( TN_curve_t E,
const fq_t  b,
const fq_t  c,
fmpz_t  l,
const fq_ctx_t *  F 
)

Sets E to elliptic curve over F in Tate-normal form with coefficients A and B. Curve parameters are given as elements of F.

◆ TN_curve_set_()

void TN_curve_set_ ( TN_curve_t rop,
TN_curve_t op 
)

Deep copy

◆ TN_curve_set_si()

void TN_curve_set_si ( TN_curve_t E,
const slong  b,
const slong  c,
const slong  l,
const fq_ctx_t *  F 
)

See TN_curve_set(). Curve coefficients are given as signed integers.

◆ TN_curve_set_str()

int TN_curve_set_str ( TN_curve_t E,
const char *  str_b,
const char *  str_c,
const char *  str_l,
int  base,
const fq_ctx_t *  F 
)

See TN_curve_set(). Parameters are given as null-terminated strings, in base b. The base b can vary between 2 and 62, inclusive. Returns 0 if the string contain valid inputs and −1 otherwise.