---
title: WASharedSecret
framework: wifiaware
role: symbol
role_heading: Structure
path: wifiaware/washaredsecret
---

# WASharedSecret

A high-entropy shared secret unique to this network connection.

## Declaration

```swift
struct WASharedSecret
```

## Discussion

Discussion Use a WASharedSecret to pair and set up security for higher layer network protocols such as TLS, QUIC, or IPSec without requiring manual action or data entry by someone using these capabilities. The framework can use the shared secret to authenticate a password authenticated key agreement (PAKE) like SPAKE2, which it then uses to pair and derive long-term asymmetric keys for authentication and encryption of the upper-layer network protocol. Both sides of a connection derive the same shared secret value if the same connection and input parameters are used: Your app and a remote app can derive the same shared secret value by calling the deriveSharedSecret(for:method:context:) function on the same connection, with the same parameters. Devices and accessories can derive the same value as your app by using the derivation specified in the Wi-Fi Aware 5.0 standard, and providing the same parameters your app uses. The following example shows how to generate a shared secret: let secret = await connection.wifiAware?.deriveSharedSecret(for: .tlsPSK, method: .kdfHash256) important: If needed, get a new shared secret for each new network connection. Don’t save this value, send it to other devices, reuse it across connections, or use it as a long-term authentication or encryption key. Instead, use this to pair higher layer protocols, and derive unique longer term asymmetric keys for those protocols when pairing them.

## Topics

### Structures

- [WASharedSecret.Context](wifiaware/washaredsecret/context.md)
- [WASharedSecret.DerivationMethod](wifiaware/washaredsecret/derivationmethod.md)
- [WASharedSecret.ProtocolName](wifiaware/washaredsecret/protocolname.md)

### Instance Properties

- [data](wifiaware/washaredsecret/data.md)
- [derivation](wifiaware/washaredsecret/derivation.md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
