java.lang.Object
org.bouncycastle.pqc.legacy.math.linearalgebra.Matrix
org.bouncycastle.pqc.legacy.math.linearalgebra.GF2mMatrix

public class GF2mMatrix extends Matrix
This class describes some operations with matrices over finite field GF(2m) with small m (1< m <32).
See Also:
  • Field Details

    • field

      protected GF2mField field
      finite field GF(2^m)
    • matrix

      protected int[][] matrix
      For the matrix representation the array of type int[][] is used, thus every element of the array keeps one element of the matrix (element from finite field GF(2^m))
  • Constructor Details

    • GF2mMatrix

      public GF2mMatrix(GF2mField field, byte[] enc)
      Constructor.
      Parameters:
      field - a finite field GF(2^m)
      enc - byte[] matrix in byte array form
    • GF2mMatrix

      public GF2mMatrix(GF2mMatrix other)
      Copy constructor.
      Parameters:
      other - another GF2mMatrix
    • GF2mMatrix

      protected GF2mMatrix(GF2mField field, int[][] matrix)
      Constructor.
      Parameters:
      field - a finite field GF(2^m)
      matrix - the matrix as int array. Only the reference is copied.
  • Method Details

    • getEncoded

      public byte[] getEncoded()
      Specified by:
      getEncoded in class Matrix
      Returns:
      a byte array encoding of this matrix
    • isZero

      public boolean isZero()
      Check if this is the zero matrix (i.e., all entries are zero).
      Specified by:
      isZero in class Matrix
      Returns:
      true if this is the zero matrix
    • computeInverse

      public Matrix computeInverse()
      Compute the inverse of this matrix.
      Specified by:
      computeInverse in class Matrix
      Returns:
      the inverse of this matrix (newly created).
    • rightMultiply

      public Matrix rightMultiply(Matrix a)
      Description copied from class: Matrix
      Compute the product of this matrix and another matrix.
      Specified by:
      rightMultiply in class Matrix
      Parameters:
      a - the other matrix
      Returns:
      this * a (newly created)
    • rightMultiply

      public Matrix rightMultiply(Permutation perm)
      Description copied from class: Matrix
      Compute the product of this matrix and a permutation.
      Specified by:
      rightMultiply in class Matrix
      Parameters:
      perm - the permutation
      Returns:
      this * p (newly created)
    • leftMultiply

      public Vector leftMultiply(Vector vector)
      Description copied from class: Matrix
      Compute the product of a vector and this matrix. If the length of the vector is greater than the number of rows of this matrix, the matrix is multiplied by each m-bit part of the vector.
      Specified by:
      leftMultiply in class Matrix
      Parameters:
      vector - a vector
      Returns:
      vector * this (newly created)
    • rightMultiply

      public Vector rightMultiply(Vector vector)
      Description copied from class: Matrix
      Compute the product of this matrix and a vector.
      Specified by:
      rightMultiply in class Matrix
      Parameters:
      vector - a vector
      Returns:
      this * vector (newly created)
    • equals

      public boolean equals(Object other)
      Checks if given object is equal to this matrix. The method returns false whenever the given object is not a matrix over GF(2^m).
      Overrides:
      equals in class Object
      Parameters:
      other - object
      Returns:
      true or false
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Specified by:
      toString in class Matrix
      Returns:
      a human readable form of the matrix.