One Logo Pool Ball
CryptoKit · IOS API REFERENCE

P256.Signing.PrivateKey

struct · iOS 13.0+ · SDK 27.1

struct PrivateKey

A P-256 private key used to create cryptographic signatures.

Members (11)

get · iOS 13.0+

publicKey

TypeScript
get publicKey(): P256_Signing_PublicKey
Swift declaration
var publicKey: P256.Signing.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 · iOS 14.0+

init

TypeScript
static initDerRepresentation(derRepresentation: Array<number>): P256_Signing_PrivateKey
Swift declaration
init<Bytes>(derRepresentation: Bytes) throws where Bytes : RandomAccessCollection, Bytes.Element == UInt8

Creates a P-256 private key for signing from a Distinguished Encoding Rules (DER) encoded representation. - Parameters: - derRepresentation: A DER-encoded representation of the key.

init · iOS 14.0+

init

TypeScript
static initPemRepresentation(pemRepresentation: string): P256_Signing_PrivateKey
Swift declaration
init(pemRepresentation: String) throws

Creates a P-256 private key for signing 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.

get · iOS 13.0+

rawRepresentation

TypeScript
get rawRepresentation(): ArrayBuffer
Swift declaration
var rawRepresentation: Data { get }

A data representation of the private key.

init · iOS 13.0+

init

TypeScript
static initRawRepresentation(rawRepresentation: ArrayBuffer): P256_Signing_PrivateKey
Swift declaration
init<Bytes>(rawRepresentation: Bytes) throws where Bytes : ContiguousBytes

Creates a P-256 private key for signing from a collection of bytes. - Parameters: - rawRepresentation: A raw representation of the key as a collection of contiguous bytes.

get · iOS 13.0+

x963Representation

TypeScript
get x963Representation(): ArrayBuffer
Swift declaration
var x963Representation: Data { get }

An ANSI x9.63 representation of the private key.

init · iOS 13.0+

init

TypeScript
static initX963Representation(x963Representation: ArrayBuffer): P256_Signing_PrivateKey
Swift declaration
init<Bytes>(x963Representation: Bytes) throws where Bytes : ContiguousBytes

Creates a P-256 private key for signing from an ANSI x9.63 representation. - Parameters: - x963Representation: An ANSI x9.63 representation of the key.

init · iOS 13.0+

init

TypeScript
static initCompactRepresentable(compactRepresentable?: boolean): P256_Signing_PrivateKey
Swift declaration
init(compactRepresentable: Bool = true)

Creates a random P-256 private key for signing. 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.

method · iOS 13.0+

signature

TypeScript
signature(data: ArrayBuffer): P256_Signing_ECDSASignature
Swift declaration
func signature<D>(for data: D) throws -> P256.Signing.ECDSASignature where D : DataProtocol

Generates an Elliptic Curve Digital Signature Algorithm (ECDSA) signature of the data you provide over the P-256 elliptic curve, using SHA-256 as the hash function. - Parameters: - data: The data to sign. - Returns: The signature corresponding to the data. The signing algorithm employs randomization to generate a different signature on every call, even for the same data and key.

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

P256.Signing.PrivateKey.signature(for:)

This declaration needs Swift generic type arguments. (no canonical witness for D)

All CryptoKit types →