fq.h File Reference

Definition of Fq math. More...

#include <stddef.h>
#include <stdint.h>
#include "epid/common/bitsupplier.h"

Functions

int FqInField (FqElem const *in)
 Test if an element is in Fq. More...
 
void FqAdd (FqElem *result, FqElem const *left, FqElem const *right)
 Add two elements of Fq. More...
 
void FqSub (FqElem *result, FqElem const *left, FqElem const *right)
 Subtract two elements of Fq. More...
 
void FqMul (FqElem *result, FqElem const *left, FqElem const *right)
 Multiply two elements of Fq. More...
 
void FqExp (FqElem *result, FqElem const *base, VeryLargeInt const *exp)
 Exponentiate an element of Fq by a large integer. More...
 
void FqCp (FqElem *result, FqElem const *in)
 Copy an element's value. More...
 
int FqIsZero (FqElem const *value)
 Test if an element is zero. More...
 
void FqInv (FqElem *result, FqElem const *in)
 Invert an element of Fq. More...
 
void FqNeg (FqElem *result, FqElem const *in)
 Negate an element of Fq. More...
 
void FqSquare (FqElem *result, FqElem const *in)
 Square an element of Fq. More...
 
void FqClear (FqElem *result)
 Clear an element's value. More...
 
void FqSet (FqElem *result, uint32_t in)
 Set an element's value. More...
 
int FqEq (FqElem const *left, FqElem const *right)
 Test if two elements in Fq are equal. More...
 
void FqCondSet (FqElem *result, FqElem const *true_val, FqElem const *false_val, int truth_val)
 Conditionally Set an element's value to one of two values. More...
 
int FqSqrt (FqElem *result, FqElem const *in)
 Compute the Square root of an element of Fq. More...
 
int FqRand (FqElem *result, BitSupplier rnd_func, void *rnd_param)
 Generate a random element of Fq. More...
 
void FqFromHash (FqElem *result, unsigned char const *hash, size_t len)
 Reinterpret a buffer as an element of Fq. More...
 

Detailed Description

Definition of Fq math.

Function Documentation

◆ FqAdd()

void FqAdd ( FqElem result,
FqElem const *  left,
FqElem const *  right 
)

Add two elements of Fq.

Parameters
[out]resultof adding left and right.
[in]leftThe first operand to be added.
[in]rightThe second operand to be added.

◆ FqClear()

void FqClear ( FqElem result)

Clear an element's value.

Parameters
[out]resultelement to clear.

◆ FqCondSet()

void FqCondSet ( FqElem result,
FqElem const *  true_val,
FqElem const *  false_val,
int  truth_val 
)

Conditionally Set an element's value to one of two values.

Parameters
[out]resulttarget.
[in]true_valvalue to set if condition is true.
[in]false_valvalue to set if condition is false.
[in]truth_valvalue of condition.

◆ FqCp()

void FqCp ( FqElem result,
FqElem const *  in 
)

Copy an element's value.

Parameters
[out]resultcopy target.
[in]incopy source.

◆ FqEq()

int FqEq ( FqElem const *  left,
FqElem const *  right 
)

Test if two elements in Fq are equal.

Parameters
[in]leftThe first operand to be tested.
[in]rightThe second operand to be tested.
Returns
A value different from zero (i.e., true) if indeed the values are equal. Zero (i.e., false) otherwise.

◆ FqExp()

void FqExp ( FqElem result,
FqElem const *  base,
VeryLargeInt const *  exp 
)

Exponentiate an element of Fq by a large integer.

Parameters
[out]resulttarget.
[in]basethe base.
[in]expthe exponent.

◆ FqFromHash()

void FqFromHash ( FqElem result,
unsigned char const *  hash,
size_t  len 
)

Reinterpret a buffer as an element of Fq.

Parameters
[out]resulttarget.
[in]hashbuffer to reinterpret.
[in]lenlength of hash in bytes.

◆ FqInField()

int FqInField ( FqElem const *  in)

Test if an element is in Fq.

Parameters
[in]inthe element to test.
Returns
A value different from zero (i.e., true) indeed the value is in the field. Zero (i.e., false) otherwise.

◆ FqInv()

void FqInv ( FqElem result,
FqElem const *  in 
)

Invert an element of Fq.

Parameters
[out]resultthe inverse of the element.
[in]inthe element to invert.

◆ FqIsZero()

int FqIsZero ( FqElem const *  value)

Test if an element is zero.

Parameters
[in]valuethe element to test.
Returns
A value different from zero (i.e., true) if indeed the value is zero. Zero (i.e., false) otherwise.

◆ FqMul()

void FqMul ( FqElem result,
FqElem const *  left,
FqElem const *  right 
)

Multiply two elements of Fq.

Parameters
[out]resultof multiplying left and right.
[in]leftThe first operand to be multiplied.
[in]rightThe second operand to be multiplied.

◆ FqNeg()

void FqNeg ( FqElem result,
FqElem const *  in 
)

Negate an element of Fq.

This function was formerly called as FqConst.

Parameters
[out]resultthe negative of the element.
[in]inthe element to negate.

◆ FqRand()

int FqRand ( FqElem result,
BitSupplier  rnd_func,
void *  rnd_param 
)

Generate a random element of Fq.

Parameters
[in]resultthe random value.
[in]rnd_funcRandom number generator.
[in]rnd_paramPass through context data for rnd_func.
Returns
A value different from zero (i.e., true) if on success. Zero (i.e., false) otherwise.

◆ FqSet()

void FqSet ( FqElem result,
uint32_t  in 
)

Set an element's value.

Parameters
[out]resulttarget.
[in]invalue to set.

◆ FqSqrt()

int FqSqrt ( FqElem result,
FqElem const *  in 
)

Compute the Square root of an element of Fq.

Parameters
[out]resultthe square root of the element.
[in]inthe element to find the square root of.
Returns
A value different from zero (i.e., true) if the square root exists. Zero (i.e., false) otherwise.

◆ FqSquare()

void FqSquare ( FqElem result,
FqElem const *  in 
)

Square an element of Fq.

Parameters
[out]resultthe square of the element.
[in]inthe element to square.

◆ FqSub()

void FqSub ( FqElem result,
FqElem const *  left,
FqElem const *  right 
)

Subtract two elements of Fq.

Parameters
[out]resultof subtracting left from right.
[in]leftThe operand to be subtracted from.
[in]rightThe operand to subtract.