12.3 Big Integers and Cryptography

   

 
Java Number Cruncher: The Java Programmer's Guide to Numerical Computing
By Ronald  Mak

Table of Contents
Chapter  12.   Big Numbers

12.3 Big Integers and Cryptography

The BigInteger class also contains methods that are useful for cryptography. Although this topic is beyond the scope of this book, it's worth a quick look.

A public key encryption system requires two keys. All message senders know the public key, which they use to encrypt their messages. Only the recipient of the messages knows the private key, which he or she uses to decrypt the messages.

The trick is to be able to give out the public key to multiple senders of secret messages, without making it easy to then figure out the corresponding private key that decrypts the messages. One scheme for generating keys relies on the fact that it is extremely difficult to factor a very large number (50 digits or more) that is the product of two primes. [2]

[2] The Fundamental Theorem of Arithmetic states that any integer greater than 2 either is prime or can be factored into a product of primes in a unique way.

Class BigInteger has a constructor that generates a large, random integer value with a certain level of certainty that it is prime. Arguments to this constructor include the desired bit length of the number and the certainty level. The higher the certainty level, the longer it takes this constructor to create a BigInteger object. Method isProbablePrime() tests a given BigInteger value to determine, to a given level of certainty, whether or not the value is prime. Like the constructor, the higher the level of certainty, the longer it takes this method to execute. (We'll examine primality testing in Chapter 15.)

Encrypting and decrypting messages involves modulo arithmetic [3] with large integer values, and BigInteger includes the methods modInverse() and modPow() .

[3] This is also called modular arithmetic. Chapter 15 will explore modulo arithmetic.


   
Top
 


Java Number Cruncher. The Java Programmer's Guide to Numerical Computing
Java Number Cruncher: The Java Programmers Guide to Numerical Computing
ISBN: 0130460419
EAN: 2147483647
Year: 2001
Pages: 141
Authors: Ronald Mak

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net