Advanced Arithmetic Routines

In these routines a big parameter can also be used wherever a flash is specified, but not visa-versa. Further information may be gleaned from the (lightly) commented source code. An asterisk after the name indicates that the function does not take a mip parameter if MR_GENERIC_MT is defined in mirdef.h .

Function:

void bigdig(n,b,x)

int n,b;

big x;
Module Description Parameters Return value Restrictions
mrrand.c Generates a big random number of given length. Uses the built-in simple random number generator initialised by irand. A big number x and two integers n and b. On exit x contains a big random number n digits long to base b. None The base b must be printable, that is 2 £ b £ 256.

Example:

bigdig(100,10,x);  /* This generates a 100 decimal digit random number */

Function:

void bigrand(w,x)

big w,x;
Module Description Parameters Return value Restrictions
mrrand.c Generates a big random number. Uses the built-in simple random number generator initialised by irand. Two big numbers w and x. On exit x is a big random number in the range 0£x<w. None None

Function:

BOOL brick_init(binst,g,n,w,nb)

brick *binst;

big g,n;

int w,nb;
Module Description Parameters Return value Restrictions
mrbrick.c Initialises an instance of the Comb method for modular exponentiation with precomputation. Internally memory is allocated for 2w big numbers which will be precomputed and stored. For bigger w more space is required, but the exponentiation is quicker. Try w=8. A pointer to the current instance binst, the fixed generator g, the modulus n, the window size w, and the maximum number of bits to be used in the exponent nb. TRUE if all went well, FALSE if there was a problem. Note: If MR_STATIC is defined in mirdef.h, then the g parameter in this function is replaced by an mr_small * pointer to a precomputed table. In this case the function returns a void.

Function:

void brick_end(binst)

brick *binst
Module Description Parameters Return value Restrictions
mrbrick.c Cleans up after an application of the Comb method. A pointer to the current instance None None

Function:

void crt(pbc,rem,x)

big_chinese *pbc;

big *rem;

big x;
Module Description Parameters Return value Restrictions
mrcrt.c Applies Chinese Remainder Theorem. A pointer pbc to the current instance. On exit x contains the big number which yields the given big remainders rem[.] when it is divided by the big moduli specified in a prior call to crt_init. None The routine crt_init must be called first.

Function:

void crt_end(pbc)

big_chinese *pbc;
Module Description Parameters Return value Restrictions
mrcrt.c Cleans up after an application of the Chinese Remainder Theorem. A pointer to the current instance of the Chinese Remainder Theorem. None None

Function:

BOOL crt_init(pbc,np,m)

big_chinese *pbc;

int np;

big *m;
Module Description Parameters Return value Restrictions
mrcrt.c Initialises an instance of the Chinese Remainder Theorem. Some internal workspace is allocated. A pointer to the current instance pbc, the number of co-prime moduli np, and an array of at least two big moduli m[.] TRUE if all went well, FALSE if there was a problem. None

Function:

int egcd(x,y,z)

big x,y,z;
Module Description Parameters Return value Restrictions
mrgcd.c Calculates the Greatest Common Divisor of two big numbers. Three big numbers x, y and z. On exit z=gcd(x,y) GCD as integer, if possible, otherwise MR_TOOBIG

Function:

void expb2(n,x)

int n;

big x;
Module Description Parameters Return value Restrictions
mrbits.c Calculates 2 to the power of an integer as a big An integer n, and a big result x. On exit x=2n. None

Example:

expb2(1398269,x);

decr(x,1,x);

mip->IOBASE=10;

cotnum(x,stdout);

This calculates and prints out the largest known prime number (on a true 32-bit computer with lots of memory!)

Function:

void expint(b,n,x)

int b,n;

big x;
Module Description Parameters Return value Restrictions
mrarth3.c Calculates an integer to the power of an integer as a big An integer b, an integer n, and a big result x. On exit x=bn. None

Function:

void fft_mult(x,y,z)

big x,y,z;
Module Description Parameters Return value Restrictions
mrfast.c Multiplies two big numbers, using the Fast Fourier Method. See [Pollard71]. Three big numbers x, y and z. On exit z=x.y None Should only be used on a 32-bit computer when x and y are very large, at least 1000 decimal digits.

Example:

See mersenne.c

Function:

void gprime(n)|  int n;
Module Description Parameters Return value
mrprime.c Generates all prime numbers up to a certain limit into the instance array PRIMES, terminated by zero. This array is used internally by the routines isprime and nxprime. A positive integer n indicating the maximum prime number to be generated. If n=0 the PRIMES array is deleted. None

Function:

int hamming(n)

big n;
Module Description Parameters Return value
mrarth1.c Calculates the hamming weight of a big number (in fact the number of 1's in its binary representation.) A big number x. Hamming weight of x

Function:

unsigned int invers(x,y)

unsigned int x,y;
Module Description Parameters Return value Restrictions
mrsmall.c Calculates the inverse of an integer modulus a co-prime integer An integer x and a co-prime integer y. x-1 mod y Result unpredictable if x and y not co-prime

Function:

BOOL isprime(x)

big x;
Module Description Parameters Return value Restrictions
mrprime.c Tests whether or not a big number is prime using a probabilistic primality test. The number is assumed to be prime if it passes this test NTRY times, where NTRY is an instance variable with a default initialisation in routine mirsys. NOTE: This routine first test divides x by the list of small primes stored in the instance array PRIMES. The testing of larger primes will be significantly faster in many cases if this list is increased. See gprime. By default only the small primes less than 1000 are used. A big number x. Returns the boolean value TRUE if x is (almost certainly) prime, otherwise FALSE. None

Function:

int jac(x,n)

unsigned int x,n;
Module Description Parameters Return value Restrictions
mrsmall.c Calculates the value of the Jacobi symbol. See [Reisel]. Two unsigned numbers x and n The value of (x/n) as +1 or -1, or 0 if symbol undefined None

Function:

int jack(x,n)

big x,n;
Module Description Parameters Return value Restrictions
mrjack.c Calculates the value of the Jacobi symbol. See [Reisel]. Two big numbers x and n The value of (x/n) as +1 or -1, or 0 if symbol undefined None

Function:

int logb2(x)

big x;
Module Description Parameters Return value
mrbits.c Calculates the approximate integer log to the base 2 of a big number (in fact the number of bits in it.) A big number x. Number of bits in x None

Function:

void lucas(x,e,n,vp,v)

big x,e,n,vp,v
Module Description Parameters Return value Restrictions
mrlucas.c Performs Lucas modular exponentiation. Uses Montgomery arithmetic internally. This function can be speeded up further for particular moduli, by invoking special assembly language routines to implement Montgomery arithmetic. See powmod. Five big numbers x, e, n, vp and v. On exit v=Ve(x) mod n and vp=Ve-1(x) mod n where n is the current Montgomery modulus. Only v is returned if v and vp are not distinct. None The value of n must be odd.

The "sister" Lucas function Ue(x) can, if required, be calculated as Ue(x) º [x.Ve(x)– 2.Ve-1(x)]/(x2 – 4) mod n|

Function:

BOOL multi_inverse(m,x,n,w)

int m;

big n;

big *x,*w;
Module Description Parameters Return value Restrictions
mrxgcd.c Finds the modular inverses of many numbers simultaneously, exploiting Montgomery's observation that x-1 = y.(xy)-1, y-1 = x.(xy)-1. This will be quicker, as modular inverses are slow to calculate, and this way only one is required. The number of inverses required m, an array x[.] of m numbers whose inverses are wanted, the modulus n, and the resulting array of inverses w[.]. TRUE if successful, otherwise FALSE. The parameters x and w must be distinct.

Function:

void nres(x,y)

big x,y;
Module Description Parameters Return value Restrictions
mrmonty.c Converts a big number to n-residue form. Two big numbers x and y. On exit y is the n-residue form of x. None Must be preceded by call to prepare_monty.

Function:

void nres_dotprod(m,x,y,w)
int m;
big x[],y[],w;
Module Description Parameters Return value Restrictions
mrmonty.c Finds the dot product of two arrays of n-residues. So-called "lazy" reduction is used, in that the sum of products is only reduced once with respect to the Montgomery modulus. This is quicker –nearly twice as fast. Two arrays x and y each of m n-residues. On exit w=S xi yi mod n, where n is the current Montgomery modulus. None Must be preceded by call to prepare_monty.

Function:

void nres_double_modadd(x,y,w)

big x,y,w;
Module Description Parameters Return value
mrmonty.c Adds two double length bigs modulo p.R, where R is 2n and n is the smallest multiple of the word-length of the underlying MIRACL type, such that R>p. This is required for lazy reduction. Three big numbers x, y and z. On exit z=a+b mod pR None

Function:

void nres_double_modsub(x,y,w)

big x,y,w;
Module Description Parameters Return value
mrmonty.c Subtracts two double length bigs modulo p.R, where R is 2n and n is the smallest multiple of the word-length of the underlying MIRACL type, such that R>p. This is required for lazy reduction. Three big numbers x, y and z. On exit z=a-b mod pR None

Function:

void nres_lazy(a,b,c,d,x,y)

big a,b,c,d,x,y;
Module Description Parameters Return value
mrmonty.c Uses the method of lazy reduction combined with Karatsuba's method to multiply two zzn2 variables. Requires just 3 multiplications and two modular reductions. Six big numbers. On exit (x+iy)=(a+ib)(c+id), where i is imaginary square root of the quadratic non-residue. None

Function:

void nres_lucas(x,e,vp,v)

big x,e,vp,v;
Module Description Parameters Return value Restrictions
mrlucas.c Modular Lucas exponentiation of an n-residue An n-residue x, a big exponent e, and two n-residue outputs vp and v. On exit v=Ve(x) mod n and vp=Ve-1(x) mod n where n is the current Montgomery modulus. Only v is returned if v and vp are the same big variable. None Must be preceded by call to prepare_monty and conversion of the first parameter to n-residue form. Note that the exponent is not converted to n-residue form.

Function:

void nres_modadd(x,y,z)

big x,y,z;
Module Description Parameters Return value Restrictions
mrmonty.c Modular addition of two n-residues Three n-residue numbers x, y, and z. On exit z=x+y mod n, where n is the current Montgomery modulus. None Must be preceded by a call to prepare_monty.

Function:

int nres_moddiv(x,y,z)

big x,y,z;
Module Description Parameters Return value Restrictions
mrmonty.c Modular division of two n-residues. Three n-residue numbers x, y and z. On exit z =x/y mod n, where n is the current Montgomery modulus. GCD of y and n as an integer, if possible, or MR_TOOBIG. Should be 1 for a valid result. Must be preceded by call to prepare_monty and conversion of parameters to n-residue form. Parameters x and y must be distinct.

Function:

void nres_modmult(x,y,z)

big x,y,z;
Module Description Parameters Return value Restrictions
mrmonty.c Modular multiplication of two n-residues. Note that this routine will invoke a KCM Modular Multiplier if MR_KCM has been defined in mirdef.h and set to an appropriate size for the current modulus, or a Comba fixed size modular multiplier if MR_COMBA is defined as exactly the size of the modulus. Three n-residue numbers x, y and z. On exit z =xy mod n, where n is the current Montgomery modulus. None Must be preceded by call to prepare_monty and conversion of parameters to n-residue form.

Function:

void nres_modsub(x,y,z)

big x,y,z;
Module Description Parameters Return value Restrictions
mrmonty.c Modular subtraction of two n-residues Three n-residue numbers x, y, and z. On exit z=x-y mod n, where n is the current Montgomery modulus. None Must be preceded by a call to prepare_monty.

Function:

BOOL nres_multi_inverse(m,x,w)

int m;

big *x,*w;
Module Description Parameters Return value Restrictions
mrmonty.c Finds the modular inverses of many numbers simultaneously, exploiting Montgomery's observation that x-1 = y.(xy)-1, y-1 = x.(xy)-1. This will be quicker, as modular inverses are slow to calculate, and this way only one is required. The number of inverses required m, an array x[.] of m n-residues whose inverses are wanted, and an array of their inverses w[.]. TRUE if successful, otherwise FALSE. The parameters x and w must be distinct.

Function:

void nres_negate(x,w)

big x,w;
Module Description Parameters Return value Restrictions
mrmonty.c Modular negation. Two n-residue numbers x and w. On exit w= -x mod n, where n is the current Montgomery modulus. None Must be preceded by a call to prepare_monty.

Function:

void powltr(x,e,w)

int x;

big e,w;
Module Description Parameters Return value Restrictions
mrpower.c Modular exponentiation of an n-residue An ordinary small integer x, a big number e and an n-residue result w. On exit w=xe mod n, where n is the current Montgomery modulus. None Must be preceded by call to prepare_monty. Note that the small integer x and the exponent are not converted to n-residue form.

Function:

void nres_powmod(x,y,z)

big x,y,z;
Module Description Parameters Return value Restrictions
mrpower.c Modular exponentiation of an n-residue. An n-residue number x, a big number y and an n-residue result z. On exit z =xy mod n, where n is the current Montgomery modulus. None Must be preceded by call to prepare_monty and conversion of the first parameter to n-residue form. Note that the exponent is not converted to n-residue form.

Example:

prepare_monty(n);

...

...

nres(x,y); /* convert to n-residue form */

nres_powmod(y,e,z);

redc(z,w); /* convert back to normal form */

Function:

void nres_powmod2(x,y,a,b,w)

big x,y,a,b,w;
Module Description Parameters Return value Restrictions
mrpower.c Calculate the product of two modular exponentiations involving n-residues. Three n-residue numbers x, a and w, and two big integers y and b. On exit w = xy .ab mod n, where n is the current Montgomery modulus. None Must be preceded by call to prepare_monty and conversion of the appropriate parameters to n-residue form. Note that the exponents are not converted to n-residue form.

Function:

void nres_powmodn(m,x,y,w)

int m;

big x,y,w;

Module Description Parameters Return value Restrictions
mrpower.c Calculate the product of m modular exponentiations involving n-residues. Extra memory is allocated internally by this function. The integer m, an array of m n-residue numbers x, an array of m big integers y, and an n-residue w. On exit w = x[0]y[0] . x[1]y[1] … . x[m-1]y[m-1] mod n, where n is the current Montgomery modulus. None Must be preceded by call to prepare_monty and conversion of the appropriate parameters to n-residue form. Note that the exponents are not converted to n-residue form.

Function:

void nres_premult(x,k,w)

int k;

big x,w;
Module Description Parameters Return value Restrictions
mrmonty.c Multiplies an n-residue by a small integer. Two n-residues x and w, and a small integer k. On exit w = kx mod n, where n is the current Montgomery modulus. None Must be preceded by call to prepare_monty and conversion of the first parameter to n-residue form. Note that the small integer is not converted to n-residue form.

Function:

BOOL nres_sqroot(x,w)

big x,w;
Module Description Parameters Return value Restrictions
mrsroot.c Calculates the square root of an n-residue mod a prime modulus Two n-residues x and w. On exit w=Öx mod n where n is the current Montgomery modulus. TRUE if the square root exists, otherwise FALSE Must be preceded by call to prepare_monty and conversion of the first parameter to n-residue form.

Function:

BOOL nroot(x,n,z)

big x,z;

int n;
Module Description Parameters Return value Restrictions
mrarth3.c Extracts lower approximation to a root of a big number. Two big numbers x and z, and an integer n. On exit z= ëx1/n û. Returns the boolean value TRUE if the root found is exact, otherwise returns FALSE. The value of n must be positive. If x is negative, then n must be odd.

Function:

BOOL nxprime(w,x)

big w,x;
Module Description Parameters Return value Restrictions
mrprime.c Find next prime number. Two big numbers w and x. On exit x contains the next prime number greater than w. TRUE if successful, FALSE otherwise. None

Function:

BOOL nxsafeprime(type,subset,w,p)

int type,subset;

big w,p;
Module Description Parameters Return value
mrprime.c Find next safe prime number greater than w. A safe prime number p is defined here to be one for which q=(p-1)/2 (type=0) or q=(p+1)/2 (type=1) is also prime. The integer parameter type determines the type of safe prime as above. If the parameter subset=1, then the search is restricted so that the value of the prime q is congruent to 1 mod 4. If subset=3, then the search is restricted so that the value of q is congruent to 3 mod 4. If subset=0 then there is no condition on q: it can be either 1 or 3 mod 4. TRUE if successful, FALSE otherwise

Function:

void pow_brick(binst,e,w)

brick *binst;

big e,w;
Module Description Parameters Return value Restrictions
mrbrick.c Carries out a modular exponentiation, using the precomputed values stored in the brick structure. A pointer to the current instance, a big exponent e and a big number w. On exit w=ge mod n, where g and n are specified in the initial call to brick_init. None Must be preceded by a call to brick_init.

Function:

void power(x,n,z,w)

long n;

big x,z,w;
Module Description Parameters Return value Restrictions
mrarth3.c Raise a big number to an integer power. Two big numbers x and z, and an integer n. On exit w=xn . If w and z are distinct, then w=xn mod z None The value of n must be positive

Function:

int powltr(x,y,z,w)

int x;

big y,z,w;
Module Description Parameters Return value Restrictions
mrpower.c Raise an int to the power of a big number modulus another big number. Uses Left-to-Right binary method, and will be somewhat faster than powmod for small x. Uses Montgomery arithmetic internally if the modulus z is odd. An integer x and three bigs y, z and w. On exit w=xy mod z The result expressed as an integer, if possible. Otherwise the value MR_TOOBIG. The value of y must be positive. The parameters w and z must be distinct.

Function:

void powmod(x,y,z,w)

big x,y,z,w;
Module Description Parameters Return value Restrictions
mrpower.c Raise a big number to a big power modulus another big. Uses a sophisticated 5-bit sliding window technique, which is close to optimal for popular modulus sizes (such as 512 or 1024 bits). Uses Montgomery arithmetic internally if the modulus z is odd. This function can be speeded up further for particular moduli, by invoking special assembly language routines (if your compiler allows it). A KCM Modular Multiplier will be automatically invoked if MR_KCM has been defined in mirdef.h and has been set to an appropriate size. Alternatively a Comba modular multiplier will be used if MR_COMBA is so defined, and the modulus is of the specified size. Experimental coprocessor code will be called if MR_PENTIUM is defined. Only one of these conditionals should be defined. Four big numbers x, y, z and w. On exit w=xy mod z. None The value of y must be positive. The parameters w and z must be distinct.

Function:

void powmod2(a,b,c,d,z,w)

big a,b,c,d,z,w;
Module Description Parameters Return value Restrictions
mrpower.c Calculate the product of two modular exponentiations. This is quicker than doing two separate exponentiations, and is useful for certain Cryptographic protocols. Uses 2-bit sliding window. Six big numbers a ,b, c, d, z and w. On exit w=ab.cd mod z. None The values of b and d must be positive. The parameters w and z must be distinct. The modulus z must be odd.

Example:

See dssver.c

Function:

void powmodn(m,a,b,z,w)

int m;

big *a,*b,z,w;
Module Description Parameters Return value Restrictions
mrpower.c Calculate the product of m modular exponentiations. This is quicker than doing m separate exponentiations, and is useful for certain Cryptographic protocols. Extra memory is allocated internally for this function An integer m, two big number arrays a[] and b[], and two big numbers z and w. On exit w=a[0]b[0].a[1]b[1] … . a[m-1]b[m-1] mod z. None The values of b[] must be positive. The parameters w and z must be distinct. The modulus z must be odd. The underlying number base must be a power of 2.

Function:

void prepare_monty(n)

big n;
Module Description Parameters Return value Restrictions
mrmonty.c Prepares a Montgomery Modulus for use. Each call to this function replaces the previous modulus (if any). A big number n, which is to be the Montgomery modulus. None The parameter n must be positive and odd. Allocated memory is freed when the current instance of MIRACL is terminated by a call to mirexit.

Function:

void redc(x,y)

big x,y;
Module Description Parameters Return value Restrictions
mrmonty.c Converts an n-residue back to normal form. Two big numbers x and y. On exit y is the normal form of the n-residue x. None Use must be preceded by call to prepare_monty.

Function:

void scrt(psc,rem,x)

small_chinese *psc;

int *rem;

big x;
Module Description Parameters Return value Restrictions
mrscrt.c Applies Chinese Remainder Theorem (for small prime moduli). A pointer psc to the current instance of the Chinese Remainder Theorem. On exit x contains the big number which yields the given integer remainders rem[.] when it is divided by the integer moduli specified in a prior call to scrt_init. None The routine scrt_init must be called first.

Function:

void scrt_end(psc)

small_chinese *psc;
Module Description Parameters Return value Restrictions
mrscrt.c Cleans up after an application of the Chinese Remainder Theorem. A pointer to the current instance of the Chinese Remainder Theorem.. None None

Function:

BOOL scrt_init(psc,np,m)

small_chinese *psc;

int np;

int *m;
Module Description Parameters Return value Restrictions
mrscrt.c Initialises an instance of the Chinese Remainder Theorem. Some internal workspace is allocated. A pointer to the current instance psc. The number of co-prime moduli np, and an array of at least two integer moduli m[.]. TRUE if all went well, FALSE if there was a problem. None

Function:

void sftbit(x,n,z)

big x,z;

int n;
Module Description Parameters Return value Restrictions
mrbits.c Shifts a big integer left or right by a number of bits. The big parameter x is shifted by n bits, to give z. Positive n shifts to the left, negative to the right. None None

Function:

unsigned int smul(x,y,z)

Unsigned int x,y,z;
Module Description Parameters Return value
mrsmall.c Multiplies two integers mod a third Integers x, y and z x.y mod z

Function:

unsigned int spmd(x,y,z)

Unsigned int x,y,z;
Module Description Parameters Return value Restrictions
mrsmall.c Raises an integer to an integer power modulus a third Integers x, y, and z xy mod z None

Function:

unsigned int sqrmp(x,p)

Unsigned int x,p;
Module Description Parameters Return value Restrictions
mrsmall.c Calculates the square root of an integer mod an integer prime number An integer x and a prime number p Öx mod p, or 0 if root does not exist Return value unpredictable if p is not prime

Function:

BOOL sqroot(x,p,w)

big x,p;
Module Description Parameters Return value Restrictions
mrsroot.c Calculates the square root of a big integer mod a big integer prime. Two big integers x and w, and a big prime number p. On exit w=Öx mod p if the square root exists, otherwise w=0. Note that the "other" square root may be found by subtracting w from p. TRUE if the square root exists, FALSE otherwise. The number p must be prime.

Function:

int trial_division(x,y)|  big x,y;
Module Description Parameters Return value Restrictions
mrprime.c Dual purpose trial division routine. If x and y are the same big variable then trial division by the small prime numbers in the instance array PRIMES is attempted to determine the primality status of the big number. If x and y are distinct then, after trial division, the unfactored part of x is returned in y. Two big integers x and y. If x and y are the same, then a return value of 0 means that the big number is definitely not prime, a return value of 1 means that it definitely is prime, while a return value of 2 means that it is possibly prime (and that perhaps further testing should be carried out). If x and y are distinct, then a return value of 1 means that x is smooth, that is it is completely factored by trial division (and y is the largest prime factor). A return value of 2 means that the unfactored part y is possibly prime.

Function:

int xgcd(x,y,xd,yd,z)

big x,y,xd,yd,z;
Module Description Parameters Return value Restrictions
mrxgcd.c Calculates extended Greatest Common Divisor of two big numbers. Can be used to calculate modular inverses. Note that this routine is much slower than a mad operation on numbers of similar size. Five big numbers x,y,xd,yd and z. On exit z=gcd(x,y)=x.xd+y.yd GCD as integer, if possible, otherwise MR_TOOBIG If xd and yd are not distinct, only xd is returned. The GCD is only returned if z distinct from both xd and yd.

Example:

xgcd(x,p,x,x,x);  /* x = 1/x mod p  (p is prime) */

Function:

void zzn2_add(x,y,z)

zzn2 *x,*y,*z;
Module Description Parameters Return value
mrzzn2.c Adds two zzn2 variables. Three zzn2 variables x, y and z. On exit z=x+y None

Function:

BOOL zzn2_compare(x,y)

zzn2 *x,*y;
Module Description Parameters Return value
mrzzn2.c Compares two zzn2 variables for equality Two zzn2 values x and y TRUE if x=y, otherwise FALSE

Function:

void zzn2_conj(x,y)

zzn2 *x,*y;
Module Description Parameters Return value
mrzzn2.c Finds the conjugate of a zzn2 Two zzn2 variables x and y. If x=a+ib, then on exit y=a-ib None

Function:

void zzn2_copy(x,y)

zzn2 *x,*y;
Module Description Parameters Return value
mrzzn2.c Copies one zzn2 to another Two zzn2 variables x and y. On exit y=x None

Function:

void zzn2_from_big(a,x)

big a;

zzn2 *x;
Module Description Parameters Return value
mrzzn2.c Creates a zzn2 from a big integer. This is converted internally into n-residue format. A big integer a and a zzn2 x. On exit x=a None

Function:

void zzn2_from_bigs(a,b,x)

big a,b;

zzn2 *x;
Module Description Parameters Return value
mrzzn2.c Creates a zzn2 from two big integers. These are converted internally into n-residue format. Two big integers a and b and a zzn2 x. On exit x=a+ib None

Function:

void zzn2_from_int(a,x)

int a;

zzn2 *x;
Module Description Parameters Return value
mrzzn2.c Converts an integer to zzn2 format An integer a and a zzn2 x. On exit x=a None

Function:

void zzn2_from_ints(a,b,x)

int a,b;

zzn2 *x;
Module Description Parameters Return value
mrzzn2.c Creates a zzn2 from two integers Two integers a and b and a zzn2 x. On exit x=a+ib None

Function:

void zzn2_from_zzn(a,x)

big a;

zzn2 *x;
Module Description Parameters Return value
mrzzn2.c Creates a zzn2 from a big already in n-residue format. A big a and a zzn2 x. On exit x=a None

Function:

void zzn2_from_zzns(a,b,x)

big a,b;

zzn2 *x;
Module Description Parameters Return value
mrzzn2.c Creates a zzn2 from two bigs already in n-residue format. Two bigs a and b and a zzn2 x. On exit x=a+ib None

Function:

void zzn2_simul(x,y,z)

zzn2 *x,*z;

int y;
Module Description Parameters Return value
mrzzn2.c Multiplies a zzn2 variable by an integer. Two zzn2 variables x and z, and an integer y. On exit z=x.y None

Function:

BOOL zzn2_inv(x)

zzn2 *x;
Module Description Parameters Return value
mrzzn2.c In-place inversion of a zzn2 variable A single zzn2 variable x. On exit x=1/x. None

Function:

BOOL zzn2_isunity(x)|      zzn2 *x;
Module Description Parameters Return value
mrzzn2.c Tests a zzn2 value for equality to one A single zzn2 variable x TRUE if x is one, otherwise FALSE.

Function:

BOOL zzn2_iszero(x)|      zzn2 *x;
Module Description Parameters Return value
mrzzn2.c Tests a zzn2 variable for equality to zero A single zzn2 value x TRUE if x is zero, otherwise FALSE.

Function:

void zzn2_mul(x,y,z)

zzn2 *x,*y,*z;
Module Description Parameters Return value
mrzzn2.c Multiplies two zzn2 variables. If x and y are the same variable, a faster squaring method is used. Three zzn2 variables x, y and z. On exit z=x.y None

Function:

void zzn2_negate(x,y)

zzn2 *x,*y;
Module Description Parameters Return value
mrzzn2.c Negate a zzn2. Two zzn2 variables x and y. On exit y=-x None

Function:

void zzn2_sadd(x,y,z)

zzn2 *x,*z;

big y;
Module Description Parameters Return value
mrzzn2.c Adds a big in n-residue format to a zzn2 . Two zzn2 variables x and z, and a big variable y. On exit z=x+y None

Function:

void zzn2_smul(x,y,z)

zzn2 *x,*z;

big y;
Module Description Parameters Return value
mrzzn2.c Multiplies a zzn2 variable by a big in n-residue. Two zzn2 variables x and z, and a big variable y. On exit z=x.y None

Function:

void zzn2_ssub(x,y,z)

zzn2 *x,*z;

big y;
Module Description Parameters Return value
mrzzn2.c Subtracts a big in n-residue format from a zzn2 . Two zzn2 variables x and z, and a big variable y. On exit z=x-y None

Function:

void zzn2_sub(x,y,z)

zzn2 *x,*y,*z;
Module Description Parameters Return value
mrzzn2.c Subtracts two zzn2 variables . Three zzn2 variables x, y and z. On exit z=x-y None

Function:

BOOL zzn2_timesi(x)

zzn2 *x;
Module Description Parameters Return value
mrzzn2.c In-place multiplication of a zzn2 by i, the imaginary square root of the quadratic non-residue. A single zzn2 variable x. If x=a+ib then on exit x=i2b+ia. None

Function:

void zzn2_iszero(x)

zzn2 *x;
Module Description Parameters Return value
mrzzn2.c Sets a zzn2 variable to zero A single zzn2 variable x. On exit x=0 None