Sunteți pe pagina 1din 41

NUMBER CRYPTOGRAPHY SYSTEM

An Industry Oriented Mini Project report submitted to

Jawaharlal Nehru Technological University, Anantapur

In Partial fulfilment of the Requirements for the Award of the degree of

BACHELOR OF TECHNOLOGY

IN

INFORMATION TECHNOLOGY

Submitted by

A. Madhu Sudhan Reddy (06121A1241)


K. Revathi (06121A1270)
N. Navya (06121A1250)
P. Nagarjuna (06121A1245)

Under the esteemed guidance of

Ms. K. Jyothsna Devi,

Assistant Professor,

Department of Information Technology

SREE VIDYANIKETHAN ENGINEERING COLLEGE

(AFFILIATED TO JNTU, ANANTAPUR)


Sree Sainath Nagar, A.Rangampet-517102
Tirupati, Chittoor Dist, A.P.
DEPARTMENT OF INFORMATION TECHNOLOGY

SREE VIDYANIKETHAN ENGINEERING COLLEGE


(AFFILIATED TO JNTU, ANANTAPUR)
Sree Sainath Nagar, A.Rangampet-517102
Tirupati, Chittoor Dist, A.P.

Certificate
This is to certify that the project work entitled

NUMBER CRYPTOGRAPHY SYSTEM


Is the bona fide work done by

A. Madhu Sudhan Reddy (06121A1241)


K. Revathi (06121A1270)
N. Navya (06121A1250)
P. Nagarjuna (06121A1245)

In the department of Information Technology,


Sree Vidyanikethan Engineering College, Tirupati and is submitted to
Jawaharlal Nehru Technological University, Anantapur partial fulfillment of the
requirement of the award of B.Tech Degree in Information Technology during
academic year 2006-2010. This work is done under my guidance.

Project Guide: Head of Department:

Ms.K.Jyothsna Devi, Dr V.V.Rama Prasad Ph.D


Assistant Professor, Professor and Vice Principal,
Dept. of IT Dept. of IT

ii
Sree Vidyanikethan Engg. College Sree Vidyanikethan Engg. College

ABSTRACT

Security in a network can come from in many different ways. Some


organisations need better protection of their data, and need more sophisticated means,
like the ability to encrypt messages, so that only the receiver will be able to read them.
Every organization and individual possesses certain vital information. The organization
would be compromised if such data fell into the wrong hands Encryption renders our
data, even if accessed by an unauthorized person. By adopting the simplest prevention
techniques, complete data privacy can be achieved.

There are many kinds of security methods like DES algorithm, RSA algorithm
etc, but the most recent and efficient algorithm being the NTRU public key algorithm.
The earlier algorithms are less efficient in time. The NTRU public key provides the
more time efficient key creation with message. Integrity (i.e. use independent keys for
every transaction).

In this project, NTRU is implemented through three stages Key generation,


encryption, and decryption. NTRU's polynomial multiplication takes more time, so
there is a necessity of reducing time taken to multiply the operands of the NTRU.To
reduces the time we have used the Montgomery Multiplication algorithm.

iii
ACKNOWLEDGEMENT
Before getting into the thickness of the things, we would like to thank the
personalities who were part of my project in numerous ways, those who gave me
outstanding support from birth of this project.

First and foremost, we express our sincere gratitude to our beloved Chairman,
PADMASRI Dr. M. MOHAN BABU for constant encouragement and support.

We are extremely thankful to express our special officer Prof. T. GOPAL RAO
who took keen interest and encouraged us in every effort throughout this course.

We owe our gratitude to our college Director Dr. V. SREENIVASULU for


permitting us to use the facilities available to accomplish the project successfully.

We owe our gratitude to our Principal Dr. P. C. KRISHNAMACHARI for


permitting us to use the facilities available to accomplish the project successfully.

We are highly indebted to the Dr. V. V. RAMA PRASAD, Head of the


Department for having been a constant source of support and encouragement for the
completion of the project.

We are thankful with profound respect and sincere thanks to esteem guide
Ms.K. JYOTHSNA DEVI, Assistant Professor for her invaluable support and offering
us complete cooperation.

We are very much grateful to all the faculty members of the IT department for their
value based imparting of theory and practical subjects, which we have put to use in our

iv
project work. We also thank the members of the non-teaching staff for their cooperation
and timely help

CONTENTS
CHAPTER NAME PAGE NO

ABSTRACT i
ACKNOWLEDGEMENT ii

1 INTRODUCTION 1

2 SYSTEM DESIGN 5
2.1. Design using UML diagrams 5

3 SYSTEM IMPLEMENTATION 13
3.1. Requirements 13
3.1.1. Hardware Requirements 13
3.1.2. Software Requirements 13
3.2. Project Implementation Details 14
3.2.1. Algorithm Analysis 14
3.2.1.1. Modular Arithmetic 14
3.2.1.2. Truncated Polynomial Rings 15
3.2.1.3. Inverse in Truncated Polynomials 15
3.2.1.4. Inverse of Polynomial modulo m 16
3.2.1.5. Extended Euclidean Algorithm 18
3.2.1.6. Montgomery for NTRU 19
3.2.2. Modular Description 20
3.2.2.1. NTRU PKCS Parameters 20
3.2.2.2. Key Generation 19
3.2.2.3. Encryption 22
3.2.2.4. Decryption 23
3.2.2.5. The Principle 24

4 TESTING 26

5 RESULTS 29

6 CONCLUSTIONS 33

v
7 REFERENCES 34
LIST OF TABLES

TABLE NO NAME
PAGE NO

2.1 Description for the use case Generate polynomial 7

2.2 Description for the use case Generate public private keys 7

2.3 Description for the use case Receive public private keys 8

2.4 Description for the use case Select a public key 8

2.5 Description for the use case Input data 8

2.6 Description for the use case Encrypt the data 8

2.7 Description for the use case Receive data 8

2.8 Description for the use case Decrypt the data 8

2.9 Description for the class Sender 9

2.10 Description for the class Receiver 10

2.11 Description for the class Encryption 10

2.12 Description for the class Decryption 10

2.13 Description for the class key Generation 10

2.14 Description for the class Monto 11

2.15 Description for the class Inverse 11

4.1 Test Inputs 28

vi
LIST OF FIGURES

FIGURE NO NAME PAGE NO

2.1 Use case Diagram for NCS 7

2.2 Class diagram for NTRU pkcs 9

2.3 Sequence diagram for client server 12

vii
1. INTRODUCTION
1.1 CRYPTOGRAPHY:
Cryptography is an algorithmic process of converting a plain text
message to a cipher text message based on an algorithm that both the sender
and receiver know, so that the cipher text message can be returned to
its original, plain text form. In its cipher form, a message cannot be
read by anyone other than the intended receiver. The act of converting a
plain text message to its cipher text is called enciphering. Reversing that
act is deciphering. Enciphering and deciphering are most commonly
referred to as encryption and decryption, respectively. Cryptography
concerns itself with four objectives:

1) Confidentiality (the information cannot be understood by anyone for


whom it was unintended)

2) Integrity (the information cannot be altered in storage or transit


between sender and intended receiver without the alteration being detected)

3) Non-repudiation (the creator/sender of the information cannot deny at


a later stage his or her intentions in the creation or transmission of the
information)

4) Authentication (the sender and receiver can confirm each other’s identity
and the origin/destination of the information)

Procedures and protocols that meet some or all of the above


criteria are known as crypto systems. There are a number of algorithms
for performing encryption and decryption, but comparatively few such
algorithms have stood the test of time. The most successful algorithms
use a key. A key is simply a parameter to the algorithm that allows the
encryption and decryption process to occur. There are many
modern key-based cryptographic techniques. These are divided into two
classes: symmetric and asymmetric (also called public/private) key
cryptography.

1
In symmetric Key cryptography, the same key is used for both
encryption and decryption. In asymmetric key cryptography, one key
is used for encryption and another, mathematically related key, is used for
decryption.

Cryptographic algorithms are of two types:


1.1.1 Secret key or Symmetric key algorithms
1.1.2 Public key cryptographic algorithms

1.1.1 SYMMETRIC KEY CRYPTOGRAPHY:

Symmetric-key systems are simpler and faster, but their main drawback is
that the two parties must somehow exchange the key in a secure way. Public
key encryption avoids this problem because the public key can be distributed
in a non-secure way, and the private key is never transmitted. Symmetric-key
cryptography is sometimes called secret-Key cryptography.
The most popular symmetric-key system is the Data Encryption
Standard (DES).

1.1.2 PUBLIC KEY CRYPTOGRAPHY:

The study and application of asymmetric encryption systems Classical


symmetric cryptographic algorithms provide a secure communication
channel to each pair of users. In order to establish such a channel, the
symmetric key algorithms employ a classical encryption scheme in which
both the algorithm depends on the same secret key k. This key is used for
both encryption and decryption. After establishing a secure communication
channel, the secrecy of a message can be guaranteed. Symmetric
cryptography also includes methods to detect modification s of messages
and methods to verify the origin of a message. Thus, confidentiality and
integrity can be accomplished using secret key techniques.

2
In secret key algorithms we have
D (k, E (k, m)) = m for each plain text m.
There are many algorithms in this process .The famous ones among them are
DES, IDEA etc.
An encryption system in which the sender and receiver of a message
share a single, common key that is used to encrypt and decrypt the
message. Contrast this with public-key cryptology, which utilizes two keys
a public key to encrypt messages and a private key to decrypt them. Which
use one key for encryption and another for decryption? A corresponding
pair of such keys constitutes a key pair. Also called asymmetric
cryptography.It is a coding system in which encryption and decryption
are done with public and private keys, allowing users who don’t know
each other to send secure or verifiable messages. Suppose Fred wants to
send a message. He would encrypt it with his private key, which no one
else knows; then, the recipient would decrypt it using Fred’s publicly
available key, thus verifying that themessage came from Fred. Alternately,
suppose Fred wants to receive an encrypted message. The sender would
encrypt the message with Fred’s public key, and only Fred would be
able to decrypt it, using his private key. This method, also known as dual-
key cryptography contrasts with the older secret-key or symmetric
cryptography, in which the sender and recipient must agree on and use
the same private key for encryption and decryption. Type of cryptography in
which the encryption process is publicly available and unprotected, but in
which a part of the decryption key is protected so that only a party with
knowledge of both parts of the decryption process can decrypt the cipher
text. In public key cryptography, keys are created in matched pairs.
Encrypt with one half of a pair and only the matching other half can
decrypt it. This contrasts with symmetric or secret key cryptography in
which a single key known to both parties is used for both encryption
and decryption.

3
One half of each pair, called the public key, is made public. The
other half, called the private key, is kept secret. Messages can then be sent
by anyone who knows the public key to the holder of the private key.
Encrypt with the public key and you know only someone with the matching
private key can decrypt. Public key techniques can be used to
create digital signatures and to deal with key management issues,
perhaps the hardest part of effective deployment of symmetric ciphers. The
resulting hybrid cryptosystems use public key methods to manage keys
for symmetric ciphers. Many organizations are currently creating PKCs,
public key infrastructures to make these benefits widely available.

Example:
A widely used public/private key algorithm is RSA, named after the
initials of its inventors, Ronald L. Rivest, Adi Shamir, and Leonard
M.Adleman .RSA depends on the difficulty of factoring the product
of two very large prime numbers . Although used for encrypting whole
messages, RSA is much less efficient than symmetric key algorithms
such as DES. ElGamal is another public/private key algorithm. It uses a
different arithmetic algorithm than RSA, called the discrete logarithm
problem. The most recently evolved public key cryptography is the NTRU
pkcs.

The NTRUEncrypt cryptosystem is much faster than exponentiation


systems such as RSA, El Gamal, and ECC. One reason is that the basic
operations used by NTRUEncrypt involve manipulation of small
numbers, generally numbers less than 255. Exponentiation systems, on
the other hand, require numbers with hundreds of digits.

A careful mathematical analysis shows that for keys consisting of


around N bits, the RSA, El Gamal, and ECC systems require on the
order of N3 operations to encrypt or decrypt a message, while
NTRUEncrypt requires only on the order of N2 operations to encrypt or
decrypt a message.

4
2. SYSTEM DESIGN

2.1 Design using UML


The unification of object-oriented modeling became possible as
experience allowed evaluation of the various concepts proposed by existing
methods.

Based on the fact that differences between the various methods


were becoming smaller, and that the method wars did not move object-
oriented technology forward any longer, Jim Rambaugh, Grady Booch and
Jacbson adopted following goals:

• To represent complete systems (instead of only the software portion)


using object oriented concepts.

• To establish an explicit coupling between concepts and executable


code.
•To take into account the scaling factors that are inherent to complex and
critical systems.
•To create a modeling language usable by both humans and machines.

The Unified Modeling Language (UML) is a standard language for


specifying, visualizing, constructing and documenting the software system
and its components. It is a graphical language, which provides a vocabulary
and set of semantics and rules. The UML focuses on the conceptual and
physical representation of the system. It captures the decisions and
understanding about systems that must be constructed. It is used to analyze,
design, configure, maintain and control information about systems. It also
captures the static structure and dynamic behavior of a system.

5
UML contains a variety of diagram types, including:

• Class diagrams, which describe classes and their relationships.


• Interaction diagrams, of which there are two types: sequence diagrams
and collaboration diagrams. These show the behavior of systems in terms of
how objects interact with each other.

• Component and deployment diagrams, which show how the various


components of systems are arranged logically and physically.

In addition to these, UML has the following additional features

• It has a detailed semantics, describing the meaning of various


notations.
• It has extension mechanisms, which allow software designers to
represent concepts that are not part of the core of UML.
• It has an associated textual language called Object Constraint
Language (OCL) that allows you to state various facts about the elements of
the diagram.

6
UML Diagrams

Fig 2.1.1 Use case diagram for NCS

Table 2.1: Description for the Use case Generate polynomial


Actors Administrator
Description This use case generates polynomials required for
public private key generation.

Table 2.2: Description for the Use case Generate public private key pairs
Actors Administrator
Description This use case generates public private key pairs based

7
on the polynomials.

Table 2.3: Description for the Use case Receive public private keys
Actors Administrator, Sender, Receiver
Description This usecase performs distribution of public private
keys to sender and receiver.

Table 2.4: Description for the Use case selects a public key
Actors Sender
Description This use case selects the public key of receiver for
encryption.

Table 2.5: Description for the Use case input data


Actors Sender
Description This use case gets the input data from sender.

Table 2.6: Description for the Use case encrypt data


Actors Sender
Description This use case describes how encryption of data is
performed at sender.

Table 2.7: Description for the Use case receive data


Actors Receiver
Description This use case performs reception of data at receiver.

Table 2.8: Description for the Use case decrypts data


Actors Receiver
Description This use case describes how the decryption of data is
performed at receiver.

8
Fig 2.1.2 Class Diagram for NTRU pkcs

Table 2.9: Description of class Sender


Class: Sender

Description: Sends the message.


Operation1: Sendmessage()
Description: The sender sends message by this operation.

Table 2.10: Description of class Receiver

9
Class: Receiver

Description: Receives the message.


Operation1: receivemessage()
Description: The receiver gets message by this operation.

Table 2.11: Description of class Encryption


Class: Encryption

Description: Encrypts the message.


Attribute1: Publickey
Description: It is used to encrypt the message.
Attribute2 : Privatekey
Description: It is used to encrypt the message.
Operation1: encryptmessage()
Description: The encrypter class encrypts the message by this operation.

Table 2.12: Description of class Decryption


Class: Decryption

Description: Decrypts the message.


Attribute1: Privatekey
Description: It is used to decrypt the message.
Attribute2: Public key
Description: It is used to decrypt the message.
Operation1: decryptmessage()
Description: The decrypter class decrypts the message by this operation.

Table 2.13: Description of class Key Generator


Class: Key Generator

Description: Generates public and private keys.


Attribute1: Polynomialf
Description: It is used for key generation.
Attribute2: Polynomialg
Description: It is used for key generation.
Attribute3: Polynomialh
Description: It is used for encrypting messages.
Operation1: Generate()
Description: This operation generates public and private keys.

10
Table 2.14: Description of class Monto
Class: Monto

Description: Multiplies the polynomials.


Attribute1: Polynomialf
Description: It is a part of public and private keys.
Attribute2: Polynomialg
Description: It is a part of public key.
Operation1: multiply()
Description: Multiplies polynomialf, polynomialg using montgomery.

Table 2.15: Description of class Inverse


Class: Inverse

Description: Find inverse of the polynomial.


Attribute1: Polynomialf
Description: It is the polynomial to be inversed.
Attribute2: Polynomial
Description: It is part of public key.
Operation1: inverse()
Description: Calculates inverse for polynomial.

11
Fig 2.1.3 Sequence Diagram for client server

Interactions in the Sequence Diagram are:

1. Generate keys
2. Receive public, private keys
3. Receive public private keys
4. Provide data for encryption
5. Generate cipher text
6. Gets the encrypted data
7. Transmit cipher text
8. Provides cipher text
9. Generate plain text
10. Display plain text

12
3. SYSTEM IMPLEMENTATION

3.1. Requirements

The project is security-based application. When we talk about


hardware and software, we have to mention requirements of both the
hardware and software.

3.1.1 Hardware Requirements

• 40 GB HDD.
• 512 MB RAM.
• Pentium IV processor

3.1.2 Software Requirements

• JDK 1.4 Enterprise Edition (J2EE).

• Operating System (Windows).

13
3.2 Project Implementation Details
3.2.1 Algorithm Analysis

3.2.1.1 Modular Arithmetic


Modular arithmetic is simple division with
remainder, where you keep the remainder and throw everything else away.
For example, the expression 147 (modulo 17) Means to divide 147 by 17
and keep the remainder.Now 147 divided by 17 gives a quotient of 8and
a remainder of 11 (since 147=8*17+11).
So 147 (modulo 17) are equal to 11.
This is written as an equality (called a congruence) 147=11(modulo 17)

In general the expression a (modulo m) means to divide a by m and


keep the remainder. Similarly, a congruence a=b (modulo m) simply means
that a and b leave the same remainder when they are divided by m. This is
the same as saying that the difference a-b is a multiple of m. the integer m
is called the modulus of the congruence. Numbers and congruence’s
with the same modulus may be added, subtracted, and multiplied just
as is done with ordinary equations. For example
(8 modulo 23)+ (6 modulo 23) =14 modulo 23 and
(8 modulo 23)*(6 modulo 23) =48 modulo 23=2 modulo 23.
If a and m have no common factors, Then it is also possible to find an
inverse for a (modulo m), That is, to find an integer b so that
A * b=1(modulo m)
For example, the inverse of 10 (modulo 23) is 7,
since7*10=70=1(modulo 23).

14
3.2.1.2 Truncated polynomial Ring
The principal objects used by the NTRU Encrypt PKCS are
polynomials of degree N-1 having integer coefficients
a=a[0] + a[1]x + a[2]x^2 + - - - - - - + a[N-2]x^(N-2) + a[N-1]x^(N-1).
The coefficients a [0], a [1] - -- - - a [N-1] are integers. Some of the
coefficients are allowed to be 0.
The set of all such polynomials is denoted by R. The polynomials in R
are added together in the usual way by simply adding their coefficients.
a + b = ( a[0] + b[0] ) + ( a[1]+ b[1] )x + -- - + ( a[N-1] + b[N-1] )x^(N-1)
They are also multiplied in almost the usual manner, with one change.
After doing the multiplication, the power of x^n should be replaced by 1,
the power x^ (n+1) should be replaced by x, the power x^ (n+2)
should be replaced by x^2, and so on.

3.2.1.3 Inverse in Truncated Ring

The inverse modulo q of a polynomial a is a polynomial A with


the property that
A *A=1(modulo q)
Not every polynomial has an inverse modulo q, But it is easy to determine
if a has an inverse, and to compute the inverse if it exists.
Example:
Take N=7, q=11, a=3+2x^2-3x^4+x^6.The inverse of a modulo 11 is
A=2+4x+2x^2+4x^3-4x^4+2x^5-2x^6 since
(3+2x-3x^4+x^6)*(-2+4x+2x^2+4x^3-4x^4+2x^5-2x^6) =-10+22x+22x^3-
22x^6 =1(modulo 11).

15
3.2.1.4 Inverse of Polynomial modulo M:
The inverse of f modulo p, f modulo q is determined using the
inverse algorithm of Silverman.

Input: polynomial f, a(x), p (a prime)


Output: inverse of f modulo m (inverse should lie in the truncated ring)

Step 1: Initialization k:=0,b(x)=1,c(x)=0,f(x)=a(x),g(x)=x^n -1.


Step 2: loop
Step 3: do while f0=0
Step 4: f(x) = f(x)/x
Step 5: c(x) =c(x)*x
Step6: k =k+1
Step7: if deg (f) =0 then
Step8: b(x) =f0^-1*b(x) (mod p);
Step9: return x^n-k b(x) (mod x^n-1)
Step10: if deg (f) <deg (g) then
Step11: exchange f &g and b & c
Step12: u=f0*g0^-1(mod p)
Step13: f(x) =f(x)-u*g(x) (mod p);
Step14: b(x) =b(x)-u*c(x) (mod p);
Step15: go to loop

16
Working:
The input to the algorithm is the polynomial (a(x)) to which we are
finding the inverse and the value p. The output is inverse of a(x) which is
stored in polynomial (b(x)).First the variables and arrays are initialized i.e.
the coefficients of the polynomial are stored in the single dimensional array.
Loop until the degree of the polynomial (f) is zero. Next in do-while loop the
polynomial (f) is equated to the quotient polynomial which is obtained by
dividing f(x)/x. In order to perform this operation we left shift the
polynomial f(x) by once. In the step c(x) is shifted right once to obtain the
equivalent of(c(x)*x). Here k is incremented by one as long as f [0] is zero.
In the next step if the degree of the polynomial f is zero, then the inverse is
returned. Here the polynomial b is equated to the product of f0^-1 and b(x),
and the result is reduced modulo p. After calculating b(x) we return the
inverse by left rotating b(x) by k times or right rotating b(x) by N-k times. If
the degree of the Polynomial f is not zero then we checked the next
condition i.e. step 11.If the condition is true then f and g, b and c are
swapped. At step 13 the value of u is calculated by multiplying f0 with
inverse of g0.After calculating u we find F(x) and g(x) as stated in step 14,
15.This process is repeated until theinverse is found. The creation of NTRU
key pair often requires finding the inverse of polynomial f(x) modulo not
only a prime but also a prime power in particular a power of 2.However once
the inverse is determined modulo a prime p, a method based on Newton
iteration allows one to rapidly compute the inverse modulo powers p^ r.

17
3.2.1.5 The Extended Euclidean Algorithm
We will number the steps of the Euclidean algorithm starting with step 0.
The quotient obtained at step i will be denoted by q i. As we carry out each
step of the Euclidean algorithm, we will also calculate an auxiliary
number, pi.
For the first two steps, the value of this number is given:
p0 = 0 and p 1 = 1.
For the remainder of the steps, we recursively calculate
Pi = p i-2 - p i-1 qi-2 (mod n).
Continue this calculation for one step beyond the last step of the
Euclidean algorithm. The algorithm starts by "dividing" n by x. If the last
non-zero Remainder occurs at step k, and then if this remainder is 1, x has
an inverse and it is pk+2. (If the remainder is not 1, then x does not have an
inverse.) Here is an Example: Find the inverse of 15 mod 26.

Step 0: 26 = 1(15) + 11 p0 = 0
Step 1: 15 = 1(11) + 4 p1 = 1
Step 2: 11 = 2(4) + 3 p2 = 0 - 1(1) mod 26 = 25
Step 3: 4 = 1(3) + 1 p3 = 1 - 25(1) mod 26 = -24 mod 26 = 2
Step 4: 3 = 3(1) + 0 p4 = 25 - 2(2) mod 26 = 21
p5 = 2 - 21(1) mod 26 = -19 mod 26 = 7

Notice that 15(7) = 105 = 1 + 4(26)1 (mod 26).

18
3.2.1.6 Word Level Montgomery for NTRU

Step1: for j=0 to N-1


Step2: CS= (a [0]*b[j] +c [0])
Step3: U=S*m [0] ` mod 2^w
Step4: CS=CS + (m [0].U)
Step5: CS>>w
Step6: for I=1 to N
Step7: CS=CS + (a [I]*b[j]) + (m [I]*U) +c [I]
Step8: c [i-1] =S
Step9: CS>>w
Step10: end for
Step11: c [N] =S
Step12: end for

Here the operands of NTRU are in the form of polynomials. One


coefficient of operand is multiplied with the other Operand and the result is
stored in a Boolean array (CS). The Lower word is extracted (w=32 bits)
using the bitwise AND Operation to the result and (2^31-1).the lower word
is stored In a variable S and it is multiplied with the negative of inverse To
m [0], the obtained result is stored in a variable U .The Result of
multiplication of U and m [0] is stored in a temporary Variable .Now
temporary variable is added to CS. Right shift the value in Boolean array for
w (32) times. This process is repeated for 2nd, 3rd etc. coefficients of the
first operand with The other operand of NTRU .finally the result is right
shifted for W (32) times.

19
3.2.2 Module Description
3.2.2.1 NTRU PKCS Parameters
The basic collection of objects used by the NTRU Public Key Cryptosystem
is the ring R that consists of all truncated Polynomials of degree N-1
having integer coefficients.
a=a[0]+a[1]x+a[2]x^2+a[3]x^3+- - - - - - - - +a[N-2]x^(N-2)+a[N-1]x^(N-1)

Polynomials are added in the usual way. They also multiplied more-or-less
as usual, except that x^n is replaced by 1, x^ (n+1) is replaced by x, x^
(n+2) is replaced by x^2, and so on.
A full implementation of the NTRU Public Key Cryptosystem is specified
by a number of parameters. However, for the purpose of this overview
we will concentrate on the three most important:

N the polynomials in the truncated polynomial ring have degree N-1


Q Large modulus, usually, the coefficients of the truncated
polynomialswill be reduced mod q.
P small modulus. As the final step in decryption, the coefficients of the
message are reduced mod p.

In order to ensure security, it is essential that p and q have no


common factors.

3.2.2.2 Key Generation:


Bob wants to create a public/private key pair for the NTRU Public Key
Cryptosystem. He first randomly chooses two small polynomials f and g in
the ring of truncated polynomials R.A small polynomial is small
relative to a random polynomial mod q. In a random polynomial, the
coefficients will in general be randomly distributed mod q. In a small
polynomial, the coefficients are much smaller than q.

20
Bob must keep the values of the polynomials f and g private, since
anyone who knows the value of either one of them will be able to decrypt
messages sent to Bob. Bob's next step is to compute the inverse of f
modulo q and the inverse of f modulo p. Thus he computes polynomials
fp and fq with the property that
F*fq=1(modulo q) and
F*fp=1 (modulo p)
(If by some chance these inverses do not exist, Bob will need to go back
and choose another f.)
Now Bob computes the product
h=p * fq * g (modulo q).

Bob's private key is the pair of polynomials f and fp.


Bob's public key is the polynomial h.
Example
Let us consider the parameters
N=11 q=32 p=3
We also need to define a small polynomial more precisely. For the purposes
of this example, we do this using the quantities DF and dg.
1. The polynomial f has DF coefficients equal to +1, (df-1) coefficients
equal to -1, and the rest equal 0.
2. The polynomial g has dg coefficients equal to +1, dg coefficients equal
to -1, and the rest equal to 0.
(The reason for the slight difference in form between f and g is that f has to
be invertible, while g doesn't).for the purpose of this section, we take
DF=4 dg=3
So Bob needs to choose a polynomial f of degree 10 with four 1's and three
-1's, and he needs to choose a polynomial g of degree 10 with three 1's
and three -1's .suppose he chooses

f = -1+x+x^2-x^4+x^6+x^9-x^10

21
g = -1+x^2+x^3+x^5-x^8-x^10

Next Bob computes the inverse fp of f and the inverse fq of f modulo q.


he finds that
Fp = 1+2x+2x^3+2x^4+x^5+2x^7+x^8+2x^9

Fq=5+9x+6x^2+16x^3+4x^4+15x^5+16x^6+22x^7+20x^8+18x^9+30x^10

The final step in key creation is to compute the product


h= p*fq*g

=8+25x+22x^2+20x^3+12x^4+24x^5+15x^6+19x^7+12x^8+19x^9+16x^10
(mo dulo 32)

Bob's private key is the pair of polynomials f and fp, and his public key is
the polynomial h.

3.2.2.3 Encryption
Alice wants to send a message to Bob using Bob's public key h. she first
puts her message in the form of a polynomial m whose coefficients are
chosen modulo p, say between -p/2 and p/2(in other words , m is a small
polynomial mod q). Next she randomly chooses another small polynomial, r.
this is the "Blinding value”, which is used to obscure the message.
Alice uses the message m, her randomly chosen polynomial r, and
Bob's public key h to compute the polynomial
e=r*h+m (modulo q).
The polynomial e is the encrypted message which Alice sends to Bob.
Example
As before, we need to specify what we mean by saying that r is a small
polynomial. we do this using the quantity dr. r has dr of its coefficients equal
to 1,it has dr of its coefficients equal to 1,it has dr of its coefficients equal to

22
-1, and it has all of the rest of its coefficients equal to 0.
For the purpose of this section, we take dr=3.
Now, suppose Alice wants to send the message
m=-1+x^3-x^4-x^8+x^9+x^10
Using the Bob's public key
h=8+25x+22x^2+20x^3+12x^4+24x^5+15x^6+19x^7+12x^8+19x^9+16x^10.

She first chooses a random polynomial r of degree 10 with three 1's and
Three -1's.say she chooses
r=1+x^2+x^3+x^4-x^5-x^7
Then her encrypted message e is e=r*h+m
=14+11x+26x^2+24x^3+14x^4+16x^5+30x^6+7x^7+25x^8+6x^9
+19x^10(modulo 32).

Alice sends the encrypted message e to Bob.

3.2.2.4 Decryption
Now Bob has received Alice's encrypted message e and he wants to decrypt
it. He begins by using his private polynomial f to compute the polynomial.

a=f*e (modulo q).


Since Bob is computing a modulo q, he can choose the coefficients of a to
lie between -q/2 and +q/2(In general, Bob will choose the coefficients of a to
lie in an interval of length q. the specific interval depends on the form of the
small Polynomials).it is very important that Bob does this before performing
the next step. Bob next computes the polynomial
b=a (modulo p).
That is, he reduces each of the coefficients of a modulo p. Finally Bob
uses his other private polynomial fp to compute
c= fp*b (modulo p).

The polynomial c will be Alice's original message m.

23
Example
Bob has received the encrypted message
e=14+11x+26x^2+24x^3+14x^4+16x^5+30x^6+7x^7+25x^8+6x^9+19x^10

From Alice. He uses his private key f to compute

a=f*e=3-7x-10x^2-11x^3+10x^4+7x^5+6x^6+7x^7+5x^8-3x^9-
7x^10(modulo 32).

Note that when Bob reduces the coefficients of f*e modulo 32, he
chooses values lying between -15 and 16, not between 0 and 31.It is very
important that he choose the coefficients in this way. Next Bob reduces the
coefficients of a modulo 3 to get

b= a=-x-x^2+x^3+x^4+x^5+x^7-x^8-x^10(modulo 3).

Finally Bob uses fp, the other part of his private key, to compute

c= fp*b=-1+x^3-x^4-x^8+x^9+x^10(modulo 3).

The polynomial c is Alice's message m, so Bob has successfully Decrypted


Alice's message.

3.2.2.5 The Principle

Alice's encrypted message e looks like e= r*h + m (modulo q), but of


course Bob doesn't initially know the values of r and m Bob's first step is
to compute f*e and reduce the coefficients modulo q. Remember that
Bob's public key h was actually formed by multiplying p* fq * g and
reducing its coefficients modulo q.

24
So although Bob doesn't know r and m, when he computes
a=f*e (modulo q), he is actually performing the following computation

a=f*e (modulo q)
=f*(r*h+m) (modulo q) [since e=r*h+m (modulo q)]
=f*(r*p*fq*g+m) (modulo q) [since h=p*fq*g (modulo q)]
=p*r*g + f*m (modulo p) [since f* fq =1(modulo q)]

Now look back at the sizes of the various parameters. The polynomials r,
g, f and m all have coefficients that are quite small. This means that
the coefficients of the products r*g and f*m are also quite small, at
least in comparison to q. since the prime p is also small compared to q,
this means (assuming that the parameters have been properly
chosen)that the coefficients of the polynomial p*r*g + f*m already lie
between -q/2 and q/2,so reducing the coefficients modulo q has no effect at
all!.

In other words when Bob computes a by first multiplying f*e and then
reducing the coefficients modulo q, the polynomial a that he ends up
with is exactly equal to the polynomial p*r*g + f*m. when Bob next
reduces the coefficients of a modulo p to form the polynomial b, he is
really reducing the coefficients of p*r*g + f*m modulo p, so the b that he
ends up with is equal to

b= f*m (modulo p)
Keep in mind that Bob still doesn't know the value of m, but he now knows
the value of b. so his final step is to multiply b by fp and use the
fact that fp*f=1(modulo p) to compute

c= fp*b=fp*f*m=m (modulo p)
Which allows him to recover Alice’s message m?

25
4. TESTING
4.1 Software Testing Techniques:
Software testing is a critical element of software quality assurance and
represents the ultimate review of specification, designing and coding.
4.1.1 Testing Objectives:
1. Testing is process of executing a program with the intent of finding an error.
2. A good test case design is one that has a probability of finding an as yet
undiscovered error.
3. A successful test is one that uncovers an as yet undiscovered error.
Testing cannot show the absence of defects, it can only show that software errors are
present.

4.1.2 Unit Testing:

In this testing each and every unit implemented in the project is tested individually.

For Key Generation when the participiants are registered the private and public
keys are generated automatically. Private keys, public keys generated are stored in a file in
the windows file system. These private and public keys are generated in matched pairs.
The sender receives the public keys of the receiver from the file and then stores the public
keys. The receiver has matched private keys.

In NTRUpkcs, the number of participants in the group is dynamic. And one of


them is the group controller different from the group members. The group controller
generates the private keys and public keys and sends to the group members. The private
keys are sent only to the owners and are kept private where as public keys are public and
known to all. The members keep their private keys sent by the controller privately. Using
the public keys the data in a file is encrypted and sent. At the receiving side the matched
private key for public key is used for decrypting the data in the file.

26
Each and every operation mentioned above is tested separately for accurate results
and are obtained. Each and every component in all the frames is tested and accurate results
are obtained.

4.1.3 Module Testing:

As mentioned earlier our project consists of three modules. They are Key
Generation, Encryption and Decryption. Each and every module is tested.

For Key Generation Module the input is given and tested whether the public key
and private keys are generated at the sender and receiver side and are same or not. The
private and public key pairs are generated and are found to be same. The module testing
for this module yielded accurate results.

For Encryption Module data is fed at the server and the file is encrypted. The
encrypted file is then send to the receiver and the encryption is performed based on the
public key of the receiver.And also it is tested whether the encryption is performed for the
valid key or not and is found that the encryption operation is performed for valid key input
only. The module testing for this module yeilded accurate results.

For Decryption Module data is received at the receiver and the file is decrypted.
The encrypted file is decrypted at the receiver based on the private key of the receiver.And
also it is tested whether the decryption is performed for the valid key or not and is found
that the decryption operation is performed for valid key input only. The module testing for
this module yeilded accurate results.

4.1.4 Integration Testing:

In this testing all the three modules are combined and are tested, in the below table
we have given the inputs to the modules with description, data type and sample values.

27
Table 4.1: Test Inputs
Name Description Type Sample Values
Generation In order to generate small int 3
random numbers. 4
4
Private In order to generate public Polynomial -1,1,1,0,-1,0,1,0,0,1,-1
keys keys. These are kept secret. 1,2,0,2,2,1,0,2,1,1,0
Public These keys are generated by Polynomial 2,18,0,8,20,8,22,26,6,24
keys the participants. In order to
communicate.
Encryption In order to encrypt the data. String Svec
Public key is used.
Decryption In order to decrypt the data. byte 1,21,16,12,13,27,19,2,8,12,2
Private key is used. 0,21,17,12,13,27,19,2,8,12,12
1,20,17,12,12,27,19,2,8,12,12
0,21,17,13,12,27,19,2,8,12,2

5. RESULTS

28
1. This screen shot shows the keys generated for the server.

Fig 5.1 shows the keys generated for server

2. This screen shot shows the keys generated for the client.

29
Fig 5.2 shot shows the keys generated for the client.

3. This screen shot shows encryption of data.

30
Fig 5.3. Shows encryption of data

4. This screen shot shows decryption of data.

31
Fig 5.4. Shows decryption of data.
6. CONCLUSTION

32
6.1. Conclustion

The project titled “Number Cryptography System” is aimed to meet


the following objectives. We are generating public and private keys to
encrypt and decrypt the messages, which require a specific integer modulo.

The time taken for polynomial multiplications which is involved in


NTRU cryptosystems is decreased using Montgomery Multiplication
algorithm. As Montgomery Multiplication uses the simple and cost
effective shift operations instead of costly division operations we achieved
high performance and less execution time for polynomial multiplication.

Since, the private key is prerequisite and kept secret, the message
can’t be decrypted easily. The reason is that the keys are generated
randomly .So the probability to decrypt the message is highly negligible.

REFERENCES

33
1. Optimizations for NTRU, J. Hoffstein, J. Silverman, Public-Key-
Cryptography and Computational Number Theory, Berlin-New York.

2. Analyzing and Comparing Montgomery Multiplication Algorithms, C.k.Koc,


T.Acar and B.kaliski, IEEE Micro, pp 26-33, June 1996.

3. Modular Multiplication without Trial Division, P.L.Montgomery,


Mathematics of Computation, vol. 44, No.170.

4. www.ntru.com.
www.tiac.net/users/ntru

5. Software Engineering, Roger.S.Pressman, a Practitioner’s Approach, Fifth


Edition, McGraw Hill International Edition, Computer Science Series.

6. Programming With Java, a Primer, 2nd Edition, E.Balaguruswamy, and


TMH.

7. The Complete Reference, Java2, Fifth Edition, Herbert Schildt, TMH.

34

S-ar putea să vă placă și