Added in [API level 37](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder#inhmethods)

# Recipient.Builder

*** ** * ** ***


`
public
static


class
Recipient.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.crypto.hpke.Recipient.Builder |

<br />

*** ** * ** ***

A builder for HPKE Recipient objects.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder#Builder(android.crypto.hpke.Hpke,%20byte[],%20java.security.PrivateKey)(https://developer.android.com/reference/android/crypto/hpke/Hpke hpke, byte[] encapsulated, https://developer.android.com/reference/java/security/PrivateKey recipientKey) ` Creates the builder. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/crypto/hpke/Recipient` | ` https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder#build()() ` Builds the `https://developer.android.com/reference/android/crypto/hpke/Recipient`. |
| ` https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder` | ` https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder#setApplicationInfo(byte[])(byte[] applicationInfo) ` Adds optional application-related data which will be used during the key generation process. |
| ` https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder` | ` https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder#setPsk(byte[],%20byte[])(byte[] psk, byte[] pskId) ` Sets pre-shared key information to be used for message authentication. |
| ` https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder` | ` https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder#setSenderKey(java.security.PublicKey)(https://developer.android.com/reference/java/security/PublicKey senderKey) ` Sets the sender key to be used by the recipient for message authentication. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### Builder

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

```
public Builder (Hpke hpke, 
                byte[] encapsulated, 
                PrivateKey recipientKey)
```

Creates the builder.

<br />

| Parameters ||
|---|---|
| `hpke` | `Hpke`: This value cannot be `null`. <br /> |
| `encapsulated` | `byte`: encapsulated ephemeral key from an `https://developer.android.com/reference/android/crypto/hpke/Sender` This value cannot be `null`. <br /> |
| `recipientKey` | `PrivateKey`: private key of the recipient. This value cannot be `null`. <br /> |

## Public methods

### build

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

```
public Recipient build ()
```

Builds the `https://developer.android.com/reference/android/crypto/hpke/Recipient`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/crypto/hpke/Recipient` | the Recipient. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/UnsupportedOperationException` | if this Provider does not support the expected mode |
| `https://developer.android.com/reference/java/security/InvalidKeyException` | if the sender or recipient key are unsupported |

### setApplicationInfo

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

```
public Recipient.Builder setApplicationInfo (byte[] applicationInfo)
```

Adds optional application-related data which will be used during the key generation
process.

<br />

| Parameters ||
|---|---|
| `applicationInfo` | `byte`: application-specific information. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder` | the Builder. This value cannot be `null`. <br /> |

### setPsk

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

```
public Recipient.Builder setPsk (byte[] psk, 
                byte[] pskId)
```

Sets pre-shared key information to be used for message authentication.

<br />

| Parameters ||
|---|---|
| `psk` | `byte`: the pre-shared secret key. This value cannot be `null`. <br /> |
| `pskId` | `byte`: the id of the pre-shared key. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder` | the Builder. This value cannot be `null`. <br /> |

### setSenderKey

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

```
public Recipient.Builder setSenderKey (PublicKey senderKey)
```

Sets the sender key to be used by the recipient for message authentication.

<br />

| Parameters ||
|---|---|
| `senderKey` | `PublicKey`: the sender's public key. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/crypto/hpke/Recipient.Builder` | the Builder. This value cannot be `null`. <br /> |