Cryptography Reference
In-Depth Information
Many of the methods of ModMatrix throw a MatricesNonConformableException; this
means the matrices were simply of the wrong dimensions to do the operation.
public class MatricesNonConformableException extends Exception {
public MatricesNonConformableException() {super();}
public MatricesNonConformableException(String s) {super(s);}
}
The following test applet, called TestModMatrixCalculatorApplet, just verifies that the
arithmetic methods as we have defined them actually work. It is a calculator for modular
matrices. The applet and its source code can be found on the topic's website. A screen shot
is shown in Figure 6.1.
The ModSquareMatrix inherits all methods from the ModMatrix class, and supplies other
methods to do Gaussian elimination modulo n . It also uses these same methods to produce
an inverse modulo n . Of course, if the Gaussian elimination fails an exception will be thrown;
namely, either a SingularMatrixException or an ArithmeticException. The gaussianSolve()
method I have written here only works when the modulus is prime; you will be asked in the
exercises to modify the method so that it works with a composite modulus.
public class SingularMatrixException extends Exception {
public SingularMatrixException() {super();}
public SingularMatrixException(String s) {super(s);}
}
The ModSquareMatrix class definition follows:
import java.math.BigInteger;
import java.security.*;
import java.util.*;
//ModSquareMatrix objects inherit all methods from ModMatrix
public class ModSquareMatrix extends ModMatrix {
//Creates a square matrix with random entries
//Or, it creates a matrix with all zeros
FIGURE 6.1
Search WWH ::




Custom Search