// matrix used to compute square roots in (GF(2^m))^t
PolynomialGF2mSmallM[] sqRootMatrix = ring.getSquareRootMatrix();
// generate canonical check matrix
GF2Matrix h = GoppaCode.createCanonicalCheckMatrix(field, gp);
// compute short systematic form of check matrix
MaMaPe mmp = GoppaCode.computeSystematicForm(h, random);
GF2Matrix shortH = mmp.getSecondMatrix();
Permutation p1 = mmp.getPermutation();
// compute short systematic form of generator matrix
GF2Matrix shortG = (GF2Matrix)shortH.computeTranspose();
// extend to full systematic form
GF2Matrix gPrime = shortG.extendLeftCompactForm();
// obtain number of rows of G (= dimension of the code)
int k = shortG.getNumRows();
// generate random invertible (k x k)-matrix S and its inverse S^-1
GF2Matrix[] matrixSandInverse = GF2Matrix
.createRandomRegularMatrixAndItsInverse(k, random);
// generate random permutation P2
Permutation p2 = new Permutation(n, random);
// compute public matrix G=S*G'*P2
GF2Matrix g = (GF2Matrix)matrixSandInverse[0].rightMultiply(gPrime);
g = (GF2Matrix)g.rightMultiply(p2);
// generate keys
McEliecePublicKeyParameters pubKey = new McEliecePublicKeyParameters(OID, n, t, g, mcElieceParams.getParameters());
McEliecePrivateKeyParameters privKey = new McEliecePrivateKeyParameters(OID, n, k,