Cryptography Reference
In-Depth Information
and the corresponding shift vector
B
is
5
2
It is now a simple matter for her to compute
, an inverse of
modulo 26.
A
A
17
5
18
23
In these examples we have chosen the block size to be artificially small to simplify the
computations. In reality larger block sizes would be used; the computations involved are the
same, there are only more of them.
Java Algorithm. You will be asked in the exercises to develop some classes to perform
encryption and decryption with matrices, but before you do that, we review a couple of con-
structors, one from ModMatrix, and the other from ModSquareMatrix. I refer to the con-
structors which produce a ModMatrix or a ModSquareMatrix with random entries; here is
the code for review:
//Creates a matrix with random entries having r rows, c columns,
//Or, it creates a matrix of all zeros
//Matrices start indexing at 1,1. Zeroth column and row are not used.
public ModMatrix(int r,int c,BigInteger m,boolean makeZero) {
SecureRandom sr=new SecureRandom();
modulus=m;
array=new BigInteger[r+1][c+1];
numRows=r;
numCols=c;
for (int i=0;i<r;i++) {
for (int j=0;j<c;j++) {
//If makeZero set to true, make the zero matrix
if (makeZero) array[i+1][j+1]=new BigInteger(“0”);
//otherwise, make matrix with random entries
else array[i+1][j+1]=new
BigInteger(modulus.bitLength(),sr).mod(modulus);
}
}
}
//Creates a square matrix with random entries
//Or, it creates a matrix with all zeros
//Another parameter specifies whether or not you wish the random
//matrix to be invertible; if NOT, matrix may still be invertible by accident
Search WWH ::




Custom Search