Computes a shared secret with the provided public key from another party.
- Parameters:
- publicKeyShare: The public key from another party to be combined with the private
key from this user to create the shared secret.
- Returns: The computed shared secret.
get · iOS 13.0+
publicKey
TypeScript
get publicKey(): P256_KeyAgreement_PublicKey
Swift declaration
var publicKey: P256.KeyAgreement.PublicKey { get }
The corresponding public key.
get · iOS 14.0+
derRepresentation
TypeScript
get derRepresentation(): ArrayBuffer
Swift declaration
var derRepresentation: Data { get }
A Distinguished Encoding Rules (DER) encoded representation of the private key.
init<Bytes>(derRepresentation: Bytes) throws where Bytes : RandomAccessCollection, Bytes.Element == UInt8
Creates a P-256 private key for key agreement from a Distinguished Encoding
Rules (DER) encoded representation.
- Parameters:
- derRepresentation: A DER-encoded representation of the key.
Creates a P-256 private key for key agreement from a Privacy-Enhanced Mail
PEM) representation.
- Parameters:
- pemRepresentation: A PEM representation of the key.
get · iOS 14.0+
pemRepresentation
TypeScript
get pemRepresentation(): string
Swift declaration
var pemRepresentation: String { get }
A Privacy-Enhanced Mail (PEM) representation of the private key.
init<Bytes>(rawRepresentation: Bytes) throws where Bytes : ContiguousBytes
Creates a P-256 private key for key agreement from a collection of bytes.
- Parameters:
- rawRepresentation: A raw representation of the key as a collection of
contiguous bytes.
init<Bytes>(x963Representation: Bytes) throws where Bytes : ContiguousBytes
Creates a P-256 private key for key agreement from an ANSI x9.63
representation.
- Parameters:
- x963Representation: An ANSI x9.63 representation of the key.
Creates a random P-256 private key for key agreement.
Keys that use a compact point encoding enable shorter public keys, but aren’t
compliant with FIPS certification. If your app requires FIPS certification,
create a key with ``init(rawRepresentation:)``.
- Parameters:
- compactRepresentable: A Boolean value that indicates whether CryptoKit
creates the key with the structure to enable compact point encoding.
init · iOS 17.0+
init
TypeScript
static init(): P256_KeyAgreement_PrivateKey
Swift declaration
init()
Creates a NIST P-256 elliptic curve private key for use with Diffie-Hellman key exchange.