Package org.bouncycastle.pqc.jcajce.provider.mceliece

## Class BCMcEliecePrivateKey

- java.lang.Object
- - org.bouncycastle.pqc.jcajce.provider.mceliece.BCMcEliecePrivateKey

- All Implemented Interfaces:
    `java.io.Serializable`, `java.security.Key`, `java.security.PrivateKey`, `javax.security.auth.Destroyable`, `CipherParameters`

      public class BCMcEliecePrivateKey
      extends java.lang.Object
      implements CipherParameters, java.security.PrivateKey

  This class implements a McEliece private key and is usually instantiated by the `McElieceKeyPairGenerator` or `McElieceKeyFactorySpi`.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `BCMcEliecePrivateKey​(McEliecePrivateKeyParameters params)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `equals​(java.lang.Object other)` | Compare this key with another object.
    `java.lang.String` | `getAlgorithm()` | Return the name of the algorithm.
    `byte[]` | `getEncoded()` | Return the key data to encode in the SubjectPublicKeyInfo structure.
    `GF2mField` | `getField()` |
    `java.lang.String` | `getFormat()` |
    `PolynomialGF2mSmallM` | `getGoppaPoly()` |
    `GF2Matrix` | `getH()` |
    `int` | `getK()` |
    `int` | `getN()` |
    `Permutation` | `getP1()` |
    `Permutation` | `getP2()` |
    `PolynomialGF2mSmallM[]` | `getQInv()` |
    `GF2Matrix` | `getSInv()` |
    `int` | `hashCode()` |

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface javax.security.auth.Destroyable

      `destroy, isDestroyed`

- - ### Constructor Detail

    - #### BCMcEliecePrivateKey

          public BCMcEliecePrivateKey​(McEliecePrivateKeyParameters params)

  - ### Method Detail

    - #### getAlgorithm

          public java.lang.String getAlgorithm()

      Return the name of the algorithm.
      Specified by:
        `getAlgorithm` in interface `java.security.Key`
      Returns:
        "McEliece"

    - #### getN

          public int getN()

      Returns:
        the length of the code

    - #### getK

          public int getK()

      Returns:
        the dimension of the code

    - #### getField

          public GF2mField getField()

      Returns:
        the finite field

    - #### getGoppaPoly

          public PolynomialGF2mSmallM getGoppaPoly()

      Returns:
        the irreducible Goppa polynomial

    - #### getSInv

          public GF2Matrix getSInv()

      Returns:
        the k x k random binary non-singular matrix S

    - #### getP1

          public Permutation getP1()

      Returns:
        the permutation used to generate the systematic check matrix

    - #### getP2

          public Permutation getP2()

      Returns:
        the permutation used to compute the public generator matrix

    - #### getH

          public GF2Matrix getH()

      Returns:
        the canonical check matrix

    - #### getQInv

          public PolynomialGF2mSmallM[] getQInv()

      Returns:
        the matrix for computing square roots in `(GF(2^m))^t`

    - #### equals

          public boolean equals​(java.lang.Object other)

      Compare this key with another object.
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `other` - the other object
      Returns:
        the result of the comparison

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`
      Returns:
        the hash code of this key

    - #### getEncoded

          public byte[] getEncoded()

      Return the key data to encode in the SubjectPublicKeyInfo structure.

      The ASN.1 definition of the key structure is

             McEliecePrivateKey ::= SEQUENCE {
               n          INTEGER                   -- length of the code
               k          INTEGER                   -- dimension of the code
               fieldPoly  OCTET STRING              -- field polynomial defining GF(2ˆm)
               getGoppaPoly()  OCTET STRING              -- irreducible Goppa polynomial
               sInv       OCTET STRING              -- matrix Sˆ-1
               p1         OCTET STRING              -- permutation P1
               p2         OCTET STRING              -- permutation P2
               h          OCTET STRING              -- canonical check matrix
               qInv       SEQUENCE OF OCTET STRING  -- matrix used to compute square roots
             }

      Specified by:
        `getEncoded` in interface `java.security.Key`
      Returns:
        the key data to encode in the SubjectPublicKeyInfo structure

    - #### getFormat

          public java.lang.String getFormat()

      Specified by:
        `getFormat` in interface `java.security.Key`