ECSignature
public struct ECSignature
The signature produced by applying an Elliptic Curve Digital Signature Algorithm to some Plaintext data.
It consists of two binary unsigned integers, r
and s
.

The r value of the signature. The size of the signature data depends on the Secure Hash Algorithm used; it will be 32 bytes of data for SHA256, 48 bytes for SHA384, or 66 bytes for SHA512.
Declaration
Swift
public let r: Data

The s value of the signature. The size of the signature data depends on the Secure Hash Algorithm used; it will be 32 bytes of data for SHA256, 48 bytes for SHA384, or 66 bytes for SHA512.
Declaration
Swift
public let s: Data

The r and s values of the signature encoded into an ASN1 sequence.
Declaration
Swift
public let asn1: Data

Initialize an ECSignature by providing the r and s values.
These must be the same length and either 32, 48 or 66 bytes (Depending on the curve used).Throws
An ECError if the r or s values are not a valid length.Declaration
Swift
public init(r: Data, s: Data) throws
Parameters
r
The r value of the signature as raw data.
s
The s value of the signature as raw data.
Return Value
A new instance of
ECSignature
. 
Initialize an ECSignature by providing an ASN1 encoded sequence containing the r and s values.
Throws
An ECError if the ASN1 data can’t be decoded.Declaration
Swift
public init(asn1: Data) throws
Parameters
asn1
The r and s values of the signature encoded as an ASN1 sequence.
Return Value
A new instance of
ECSignature
.

Verify the signature for a given String using the provided public key. The Data is verified using ECDSA with either SHA256, SHA384 or SHA512, depending on the key’s curve.
Declaration
Swift
public func verify(plaintext: String, using ecPublicKey: ECPublicKey) > Bool
Parameters
plaintext
The String that was originally signed to produce the signature.
Return Value
true if the plaintext is valid for the provided signature. Otherwise it returns false.

Verify the signature for the given Data using the provided public key. The Data is verified using ECDSA with either SHA256, SHA384 or SHA512, depending on the key’s curve.
Declaration
Swift
public func verify(plaintext: Data, using ecPublicKey: ECPublicKey) > Bool
Parameters
plaintext
The Data that was originally signed to produce the signature.
Return Value
true if the plaintext is valid for the provided signature. Otherwise it returns false.