public McEliecePublicKey(int n, int t, GF2Matrix g) { this.n = n; this.t = t; this.g = new GF2Matrix(g); }
public McElieceCCA2PublicKey(int n, int t, GF2Matrix g, AlgorithmIdentifier digest) { this.n = n; this.t = t; this.g = new GF2Matrix(g.getEncoded()); this.digest = digest; }
/** * Copy constructor. * * @param a another {@link GF2Matrix} */ public GF2Matrix(GF2Matrix a) { numColumns = a.getNumColumns(); numRows = a.getNumRows(); length = a.length; matrix = new int[a.matrix.length][]; for (int i = 0; i < matrix.length; i++) { matrix[i] = IntUtils.clone(a.matrix[i]); } }
assignZeroMatrix(n, n); break; assignUnitMatrix(n); break; assignRandomLowerTriangularMatrix(n, sr); break; assignRandomUpperTriangularMatrix(n, sr); break; assignRandomRegularMatrix(n, sr); break;
GF2Matrix shortG = (GF2Matrix)shortH.computeTranspose(); GF2Matrix gPrime = shortG.extendLeftCompactForm(); int k = shortG.getNumRows(); .createRandomRegularMatrixAndItsInverse(k, random); GF2Matrix g = (GF2Matrix)matrixSandInverse[0].rightMultiply(gPrime); g = (GF2Matrix)g.rightMultiply(p2);
int n = h.getNumColumns(); GF2Matrix hp, sInv; GF2Matrix s = null; hp = (GF2Matrix)h.rightMultiply(p); sInv = hp.getLeftSubMatrix(); try s = (GF2Matrix)sInv.computeInverse(); GF2Matrix shp = (GF2Matrix)s.rightMultiply(hp); GF2Matrix m = shp.getRightSubMatrix();
public static void main( String[] args ) { System.out.println("ceil: [" + (15 >>> 5) + "]"); System.out.println("ceil: [" + (31 >>> 5) + "]"); System.out.println("ceil: [" + (32 >>> 5) + "]"); System.out.println("ceil: [" + (36 >>> 5) + "]"); System.out.println("ceil: [" + (63 >>> 5) + "]"); System.out.println("ceil: [" + (64 >>> 5) + "]"); System.out.println("ceil: [" + (66 >>> 5) + "]"); GF2Matrix m = new GF2Matrix(33, GF2Matrix.MATRIX_TYPE_RANDOM_REGULAR); System.out.println("Matrix: " + m.toString()); final int[][] a = m.getIntArray(); for(int i=0; i<m.getNumRows(); i++){ System.out.println("MatrixEnc["+i+"]: [" + Utils.toBinaryString(a[i])+ "]"); } System.out.println("MatrixEncLen: [" + m.getEncoded().length + "]"); System.out.println("MatrixEncHex: [" + IntUtils.toHexString(m.getRow(0)) + "]"); } }
/** * Create an nxn random regular matrix. * * @param n number of rows (and columns) * @param sr source of randomness */ private void assignRandomRegularMatrix(int n, SecureRandom sr) { numRows = n; numColumns = n; length = (n + 31) >>> 5; matrix = new int[numRows][length]; GF2Matrix lm = new GF2Matrix(n, Matrix.MATRIX_TYPE_RANDOM_LT, sr); GF2Matrix um = new GF2Matrix(n, Matrix.MATRIX_TYPE_RANDOM_UT, sr); GF2Matrix rm = (GF2Matrix)lm.rightMultiply(um); Permutation perm = new Permutation(n, sr); int[] p = perm.getVector(); for (int i = 0; i < n; i++) { System.arraycopy(rm.matrix[i], 0, matrix[p[i]], 0, length); } }
public McEliecePublicKey(ASN1ObjectIdentifier oid, int n, int t, GF2Matrix g) { this.oid = oid; this.n = n; this.t = t; this.matrixG = g.getEncoded(); }
GF2Matrix shortG = (GF2Matrix)shortH.computeTranspose(); int k = shortG.getNumRows();
/** * @return the dimension of the code */ public int getK() { return matrixG.getNumRows(); } }
/** * create the mxn zero matrix */ private GF2Matrix(int m, int n) { if ((n <= 0) || (m <= 0)) { throw new ArithmeticException("size of matrix is non-positive"); } assignZeroMatrix(m, n); }
GF2Matrix shortG = (GF2Matrix)shortH.computeTranspose(); GF2Matrix gPrime = shortG.extendLeftCompactForm(); int k = shortG.getNumRows(); .createRandomRegularMatrixAndItsInverse(k, random); GF2Matrix g = (GF2Matrix)matrixSandInverse[0].rightMultiply(gPrime); g = (GF2Matrix)g.rightMultiply(p2);
assignZeroMatrix(n, n); break; assignUnitMatrix(n); break; assignRandomLowerTriangularMatrix(n, sr); break; assignRandomUpperTriangularMatrix(n, sr); break; assignRandomRegularMatrix(n, sr); break;
int n = h.getNumColumns(); GF2Matrix hp, sInv; GF2Matrix s = null; hp = (GF2Matrix)h.rightMultiply(p); sInv = hp.getLeftSubMatrix(); try s = (GF2Matrix)sInv.computeInverse(); GF2Matrix shp = (GF2Matrix)s.rightMultiply(hp); GF2Matrix m = shp.getRightSubMatrix();
/** * Create an nxn random regular matrix. * * @param n number of rows (and columns) * @param sr source of randomness */ private void assignRandomRegularMatrix(int n, SecureRandom sr) { numRows = n; numColumns = n; length = (n + 31) >>> 5; matrix = new int[numRows][length]; GF2Matrix lm = new GF2Matrix(n, Matrix.MATRIX_TYPE_RANDOM_LT, sr); GF2Matrix um = new GF2Matrix(n, Matrix.MATRIX_TYPE_RANDOM_UT, sr); GF2Matrix rm = (GF2Matrix)lm.rightMultiply(um); Permutation perm = new Permutation(n, sr); int[] p = perm.getVector(); for (int i = 0; i < n; i++) { System.arraycopy(rm.matrix[i], 0, matrix[p[i]], 0, length); } }
public McElieceCCA2PublicKey(ASN1ObjectIdentifier oid, int n, int t, GF2Matrix g) { this.oid = oid; this.n = n; this.t = t; this.matrixG = g.getEncoded(); }
GF2Matrix shortG = (GF2Matrix)shortH.computeTranspose(); int k = shortG.getNumRows();