java.lang.Object
org.bouncycastle.pqc.legacy.math.linearalgebra.Permutation

public class Permutation extends Object
This class implements permutations of the set {0,1,...,n-1} for some given n > 0, i.e., ordered sequences containing each number m (0 <= m < n) once and only once.
  • Constructor Details

    • Permutation

      public Permutation(int n)
      Create the identity permutation of the given size.
      Parameters:
      n - the size of the permutation
    • Permutation

      public Permutation(int[] perm)
      Create a permutation using the given permutation vector.
      Parameters:
      perm - the permutation vector
    • Permutation

      public Permutation(byte[] enc)
      Create a permutation from an encoded permutation.
      Parameters:
      enc - the encoded permutation
    • Permutation

      public Permutation(int n, SecureRandom sr)
      Create a random permutation of the given size.
      Parameters:
      n - the size of the permutation
      sr - the source of randomness
  • Method Details

    • getEncoded

      public byte[] getEncoded()
      Encode this permutation as byte array.
      Returns:
      the encoded permutation
    • getVector

      public int[] getVector()
      Returns:
      the permutation vector (perm(0),perm(1),...,perm(n-1))
    • computeInverse

      public Permutation computeInverse()
      Compute the inverse permutation P-1.
      Returns:
      this-1
    • rightMultiply

      public Permutation rightMultiply(Permutation p)
      Compute the product of this permutation and another permutation.
      Parameters:
      p - the other permutation
      Returns:
      this * p
    • equals

      public boolean equals(Object other)
      checks if given object is equal to this permutation.

      The method returns false whenever the given object is not permutation.

      Overrides:
      equals in class Object
      Parameters:
      other - - permutation
      Returns:
      true or false
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      a human readable form of the permutation
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of this permutation