# PrivateKey

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Constants](https://developer.android.com/reference/java/security/PrivateKey#constants)\|[Inherited Constants](https://developer.android.com/reference/java/security/PrivateKey#inhconstants)\|[Inherited Methods](https://developer.android.com/reference/java/security/PrivateKey#inhmethods)  

# PrivateKey

`
public


interface
PrivateKey
`  
`


implements

`[Destroyable](https://developer.android.com/reference/javax/security/auth/Destroyable)`,

`[Key](https://developer.android.com/reference/java/security/Key)`


`

|--------------------------|
| java.security.PrivateKey |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Known indirect subclasses [DHPrivateKey](https://developer.android.com/reference/javax/crypto/interfaces/DHPrivateKey),[DSAPrivateKey](https://developer.android.com/reference/java/security/interfaces/DSAPrivateKey),[ECPrivateKey](https://developer.android.com/reference/java/security/interfaces/ECPrivateKey),[EdECPrivateKey](https://developer.android.com/reference/java/security/interfaces/EdECPrivateKey),[RSAMultiPrimePrivateCrtKey](https://developer.android.com/reference/java/security/interfaces/RSAMultiPrimePrivateCrtKey),[RSAPrivateCrtKey](https://developer.android.com/reference/java/security/interfaces/RSAPrivateCrtKey),[RSAPrivateKey](https://developer.android.com/reference/java/security/interfaces/RSAPrivateKey),[XECPrivateKey](https://developer.android.com/reference/java/security/interfaces/XECPrivateKey) |---------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [DHPrivateKey](https://developer.android.com/reference/javax/crypto/interfaces/DHPrivateKey)                              | The interface to a Diffie-Hellman private key.                                                                                                                                                 | | [DSAPrivateKey](https://developer.android.com/reference/java/security/interfaces/DSAPrivateKey)                           | The standard interface to a DSA private key.                                                                                                                                                   | | [ECPrivateKey](https://developer.android.com/reference/java/security/interfaces/ECPrivateKey)                             | The interface to an elliptic curve (EC) private key.                                                                                                                                           | | [EdECPrivateKey](https://developer.android.com/reference/java/security/interfaces/EdECPrivateKey)                         | An interface for an elliptic curve private key as defined by[RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA)](https://tools.ietf.org/html/rfc8032).                                | | [RSAMultiPrimePrivateCrtKey](https://developer.android.com/reference/java/security/interfaces/RSAMultiPrimePrivateCrtKey) | The interface to an RSA multi-prime private key, as defined in the[PKCS#1 v2.2](https://tools.ietf.org/rfc/rfc8017.txt)standard, using the*Chinese Remainder Theorem*(CRT) information values. | | [RSAPrivateCrtKey](https://developer.android.com/reference/java/security/interfaces/RSAPrivateCrtKey)                     | The interface to an RSA private key, as defined in the[PKCS#1 v2.2](https://tools.ietf.org/rfc/rfc8017.txt)standard, using the*Chinese Remainder Theorem*(CRT) information values.             | | [RSAPrivateKey](https://developer.android.com/reference/java/security/interfaces/RSAPrivateKey)                           | The interface to an RSA private key.                                                                                                                                                           | | [XECPrivateKey](https://developer.android.com/reference/java/security/interfaces/XECPrivateKey)                           | An interface for an elliptic curve private key as defined by RFC 7748.                                                                                                                         | |

<br />

*** ** * ** ***

A private key. The purpose of this interface is to group (and provide type safety for) all private key interfaces.

Note: The specialized private key interfaces extend this interface. See, for example, the`DSAPrivateKey`interface in[java.security.interfaces](https://developer.android.com/reference/java/security/interfaces/package-summary).

Implementations should override the default`destroy`and`isDestroyed`methods from the[Destroyable](https://developer.android.com/reference/javax/security/auth/Destroyable)interface to enable sensitive key information to be destroyed, cleared, or in the case where such information is immutable, unreferenced. Finally, since`PrivateKey`is`Serializable`, implementations should also override[ObjectOutputStream.writeObject(java.lang.Object)](https://developer.android.com/reference/java/io/ObjectOutputStream#writeObject(java.lang.Object))to prevent keys that have been destroyed from being serialized.  
**See also:**

- [Key](https://developer.android.com/reference/java/security/Key)
- [PublicKey](https://developer.android.com/reference/java/security/PublicKey)
- [Certificate](https://developer.android.com/reference/java/security/Certificate)
- [Signature.initVerify(PublicKey)](https://developer.android.com/reference/java/security/Signature#initVerify(java.security.PublicKey))
- [DSAPrivateKey](https://developer.android.com/reference/java/security/interfaces/DSAPrivateKey)
- [RSAPrivateKey](https://developer.android.com/reference/java/security/interfaces/RSAPrivateKey)
- [RSAPrivateCrtKey](https://developer.android.com/reference/java/security/interfaces/RSAPrivateCrtKey)

## Summary

|                                                                                                                   ### Constants                                                                                                                    ||
|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | [serialVersionUID](https://developer.android.com/reference/java/security/PrivateKey#serialVersionUID) *This constant was deprecated in API level 34. A`serialVersionUID`field in an interface is ineffectual. Do not use; no replacement.* |

|                                                                                                                                                                                                                                                                                    ### Inherited constants                                                                                                                                                                                                                                                                                     |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From interface[java.security.Key](https://developer.android.com/reference/java/security/Key) |--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `long` | [serialVersionUID](https://developer.android.com/reference/java/security/Key#serialVersionUID) *This constant was deprecated in API level 34. A`serialVersionUID`field in an interface is ineffectual. Do not use; no replacement.* | |

| ### Inherited methods |
|-----------------------|---|
| From interface` `[javax.security.auth.Destroyable](https://developer.android.com/reference/javax/security/auth/Destroyable)` ` |--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| | ` default void`    | ` `[destroy](https://developer.android.com/reference/javax/security/auth/Destroyable#destroy())`() ` Destroy this`Object`.                                | | ` default boolean` | ` `[isDestroyed](https://developer.android.com/reference/javax/security/auth/Destroyable#isDestroyed())`() ` Determine if this`Object`has been destroyed. | ||
| From interface` `[java.security.Key](https://developer.android.com/reference/java/security/Key)` ` |--------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[String](https://developer.android.com/reference/java/lang/String) | ` `[getAlgorithm](https://developer.android.com/reference/java/security/Key#getAlgorithm())`() ` Returns the standard algorithm name for this key.                                                     | | ` abstract byte[]`                                                             | ` `[getEncoded](https://developer.android.com/reference/java/security/Key#getEncoded())`() ` Returns the key in its primary encoding format, or null if this key does not support encoding.            | | ` abstract `[String](https://developer.android.com/reference/java/lang/String) | ` `[getFormat](https://developer.android.com/reference/java/security/Key#getFormat())`() ` Returns the name of the primary encoding format of this key, or null if this key does not support encoding. | ||

## Constants

### serialVersionUID

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final long serialVersionUID
```

<br />

**This constant was deprecated in API level 34.**   
A`serialVersionUID`field in an interface is ineffectual. Do not use; no replacement.

The class fingerprint that is set to indicate serialization compatibility with a previous version of the class.

<br />

Constant Value: 6034044314589513430 (0x53bd3b559a12c6d6)