# B.4 Basic Operations: Friend Functions

Team-Fly

## B.4 Basic Operations: Friend Functions

 ```const LINT operator + (const LINT& a, const LINT& b); ``` addition c = a + b; ```const LINT operator - (const LINT& a, const LINT& b); ``` subtraction c = a − b; ```const LINT operator * (const LINT& a, const LINT& b); ``` multiplication c = a * b; ```const LINT operator / (const LINT& a, const LINT& b); ``` division c = a / b; ```const LINT operator % (const LINT& a, const LINT& b); ``` remainder c = a % b; ```const LINT add (const LINT& a, const LINT& b); ``` addition c = add (a, b); ```const LINT sub (const LINT& a, const LINT& b); ``` subtraction c = sub (a, b); ```const LINT mul (const LINT& a, const LINT& b); ``` multiplication c = mul (a, b); ```const LINT sqr (const LINT& a); ``` squaring b = sqr (a); ```const LINT divr (const LINT& a, const LINT& b, LINT& r); ``` division with remainder quotient = div (dividend, divisor, remainder);

 Team-Fly
Team-Fly

## B.5 Modular Arithmetic: Member Functions

 ```const LINT& mod (const LINT& m); ``` remainder b = a.mod (m); ```const LINT& mod2 (const USHORT u); ``` remainder modulo power of two 2 u , b = a.mod (u); ```const int mequ (const LINT& b, const LINT& m) const; ``` comparison of a and b modulo m if (a.mequ (b, m)) ... ```const LINT& madd (const LINT& b, const LINT& m); ``` modular addition, c = a.madd (b, m); ```const LINT& msub (const LINT& b, const LINT& m); ``` modular subtraction, c = a.msub(b, m); ```const LINT& mmul (const LINT& b, const LINT& m); ``` modular multiplication, c = a.mmul (b, m); ```const LINT& msqr (const LINT& m); ``` modular squaring, c = a.msqr (m); ```const LINT& mexp (const LINT& e, const LINT& m); ``` modular exponentiation with Montgomery reduction for odd modulus m,c = a.mexp (e, m); ```const LINT& mexp (const USHORT u, const LINT& m); ``` modular exponentiation with USHORT exponent, Montgomery reduction for odd modulus m, c = a.mexp (u, m); ```const LINT& mexp5m (const LINT& e, const LINT& m); ``` modular exponentiation with Montgomery reduction for odd modulus m,c = a.mexp5m (e, m); ```const LINT& mexpkm (const LINT& e, const LINT& m); ``` modular exponentiation with Montgomery reduction for odd modulus m, c = a.mexpkm (e, m); ```const LINT& mexp2 (const USHORT u, const LINT& m); ``` modular exponentiation with power of two exponent 2 u , c = a.mexp2 (u, m);

 Team-Fly
Team-Fly

## B.6 Modular Arithmetic: Friend Functions

 ```const LINT mod (const LINT& a, const LINT& m); ``` remainder b = mod (a, m); ```const LINT mod2 (const LINT& a, const USHORT u); ``` remainder modulo power of two 2 u , b = mod (a, u); ```const int mequ (const LINT& a, const LINT& b, const LINT& m); ``` comparison of a and b modulo m if (mequ (a, b, m)) ... ```const LINT madd (const LINT& a, const LINT& b, const LINT& m); ``` modular addition, c = madd (a, b, m); ```const LINT msub (const LINT& a, const LINT& b, const LINT& m); ``` modular subtraction, c = msub(a, b, m); ```const LINT mmul (const LINT& a, const LINT& b, const LINT& m); ``` modular multiplication, c = mmul (a, b, m); ```const LINT msqr (const LINT& a, const LINT& m); ``` modular squaring, c = msqr (a, m); ```const LINT mexp (const LINT& a, const LINT& e, const LINT& m); ``` modular exponentiation with Montgomery reduction for odd modulus m, c = mexp (a, e, m); ```const LINT mexp (const USHORT u, const LINT& e, const LINT& m); ``` modular exponentiation with USHORT base, Montgomery reduction for odd modulus m, c = mexp (u, e, m); ```const LINT mexp (const LINT& a, const USHORT u, const LINT& m); ``` modular exponentiation with USHORT exponent, Montgomery reduction for odd modulus m, c = mexp (a, u, m); ```const LINT mexp5m (const LINT& a, const LINT& e, const LINT& m); ``` modular exponentiation with Montgomery reduction, only for odd modulus m, c = mexp5m (a, e, m); ```const LINT mexpkm (const LINT& a, const LINT& b, const LINT& m); ``` modular exponentiation with Montgomery reduction, only for odd modulus m, c = mexpkm (a, e, m); ```const LINT mexp2 (const LINT& a, const USHORT u, const LINT& m); ``` modular exponentiation with power of two exponent 2 u , c = mexp2 (a, u, m);

 Team-Fly