Implementation of Finite Field Arithmetic Operations for Large Prime and Binary Fields using java BigInteger C lass

—Many cryptographic protocols are based on the difficulty of factoring large composite integers or a related problem. Therefore, we implement the finite field arithmetic operations for large prime and binary fields by using java BigInteger class to study our research under large integers for public key cryptosystems and elliptic curve.


INTRODUCTION
The origins and history of finite fields can be traced back to the 17 th and 18 th centuries, but there, these fields played only a minor role in the mathematics of the day. In more recent times, however, finite fields have assumed a much more fundamental role and in fact are of rapidly increasing importance because of practical applications in a wide variety of areas such as coding theory, cryptography, algebraic geometry and number theory.
Nowadays, a finite field is very important structure in cryptography. Many cryptographic applications use finite field arithmetic. Public key systems based on various discrete logarithm problems are frequently implemented over finite fields to provide structure and efficient arithmetic.
The finite field arithmetic operations need to be implemented for the development and research of stream ciphers, block ciphers, public key cryptosystems and cryptographic schemes over elliptic curves. Many cryptographic protocols are based on the difficulty of factoring large composite integers or a related problem. Therefore, we implement the finite field arithmetic operations for large prime and binary fields by using java BigInteger class to study our research under large integers.
The organization of this paper is as follows: section 2 is devoted to finite fields and their properties. In section 3, how to implement finite field arithmetic operations under prime field and binary field are described. Some algorithms applied in the implementation are listed in section 4. The results of implementation for finite field arithmetic operations under prime field and binary field are shown in section 5. Finally, we conclude our discussion in section 6.

II. INTRODUCTION TO FINITE FIELDS
A finite field is a field containing a finite number of elements. Fields are abstractions of familiar number systems (such as the rational numbers Q, the real numbers R, and the complex numbers C) and their essential properties. They consist of a set F together with two operations, addition (denoted by +) and multiplication (denoted by ·), that satisfy the usual arithmetic properties:  (F,+) is an abelian group with (additive) identity denoted by 0.  (F\{0}, ·) is an abelian group with (multiplicative) identity denoted by 1.  The distributive law holds: (a+b) · c = (a · c) + (b · c) for all a, b, c ∈ F.
If the set F is finite, then the field is said to be finite. Galois showed that for a field to be finite, the number of elements should be p m , where p is a prime number called the characteristic of F and m is a positive integer. The finite fields are usually called Galois fields and also denoted as GF(p m ). If m = 1, then GF is called a prime field. If m ≥ 2, then F is called an extension field. The order of a finite field is the number of elements in the field. Any two fields are said to be isomorphic if their orders are the same [4].

A. Field Operations
A field F is equipped with two operations, addition and multiplication. Subtraction of field elements is defined in terms of addition:

B. Prime Field
Let p be a prime number. The integers modulo p, consisting of the integers {0,1,2, . . ., p −1} with addition and multiplication performed modulo p, is a finite field of order p. We shall denote this field by GF(p) and call p the modulus of GF(p). For any integer a, a mod p shall denote the unique integer remainder r, 0 ≤r ≤ p−1, obtained upon dividing a by p; this operation is called reduction modulo p.

C. Binary Field
Finite fields of order 2 m are called binary fields or characteristic-two finite fields. One way to construct GF(2 m ) is to use a polynomial basis representation. Here, the elements of GF(2 m ) are the binary polynomials (polynomials whose coefficients are in the field GF(2) = {0,1}) of degree at most m −1: An irreducible binary polynomial f (x) of degree m is chosen. Irreducibility of f(x) means that f(x) cannot be factored as a product of binary polynomials each of degree less than m. Addition of field elements is the usual addition of polynomials, with coefficient arithmetic performed modulo 2. Multiplication of field elements is performed modulo the reduction polynomial f(x). For any binary polynomial a(x), a(x) mod f(x) shall denote the unique remainder polynomial r(x) of degree less than m obtained upon long division of a(x) by f(x); this operation is called reduction modulo f(x). (2 4 )) The elements of GF (2 4 ) are the 16 binary polynomials of degree at most 3: 0 2 3 3 + 2 1 2 + 1 3 + 1 3 + 2 + 1 2 + 3 + 3 + 2 + + 1 2 + + 1 3 + + 1 3 + 2 + + 1

III. IMPLEMENTATION OF FIELD OPERATIONS
The finite field arithmetic operations: addition, subtraction, division, multiplication and multiplicative inverse, need to be implemented for the development and research of stream ciphers, public key cryptosystems and cryptographic schemes over elliptic curves. We implement the finite field arithmetic operations by using java BigInteger class to study our research under large numbers.

A. Arithmetic Operations of Prime Field
The arithmetic operations of prime field need to be implemented to study our research under prime fields. Therefore, we implement a PrimeField class with methods of arithmetic operations for addition, subtraction, multiplication and division of elements (a, b) in the prime field GF(p). The methods of PrimeField class are implemented as follows. . In this case, b -1 is a multiplicative inverse of prime number p.
(v). The multiplicative inverse method is adopted from the modInverse method.

B. Arithmetic Operations of Binary Field
The arithmetic operations of binary field need to be implemented to study our research under prime fields. Therefore, we implement a BinaryField class with methods of arithmetic operations for addition, subtraction, multiplication and division of elements (a, b) in the binary field GF(2 m ) with reduction polynomial p. The methods of BinaryField class are implemented as follows. . In this case, b -1 is a multiplicative inverse of prime polynomial p. The multiplicative inverse is adopted from the multiplicativeInverse method.

RESULTS OF IMPLEMENTATION
We measure the performance of finite field arithmetic operations: addition, subtraction, division, multiplication and multiplicative inverse, under prime field and binary field for comparison of execution time on the processor Intel Core i5@1.60GHz, 2.30GHz. The finite field arithmetic operations use the large integers of the prime field and the binary field defined by NIST recommended elliptic curve for federal government [6]. The results are listed in Table ( CONCLUSION This is the first step to study our research under large integers for public key cryptosystems and elliptic curve. The performance of addition and subtraction operations of binary field are more efficient than prime field. The performance of division, multiplication and multiplicative inverse operations of prime field are more efficient than binary field. Therefore, a java BigInteger class is more efficient for the software implementation of finite field arithmetic operations in prime field.