Structureswift-crypto 3.8.0Crypto
SharedSecret
A key agreement result from which you can derive a symmetric cryptographic key.
DH.swift:50struct SharedSecret
Generate a shared secret by calling your private key’s sharedSecretFromKeyAgreement(publicKeyShare:)
method with the public key from another party. The other party computes the same secret by passing your public key to the equivalent method on their own private key.
The shared secret isn’t suitable as a symmetric cryptographic key (SymmetricKey
) by itself. However, you use it to generate a key by calling either the hkdfDerivedSymmetricKey(using:salt:sharedInfo:outputByteCount:)
or x963DerivedSymmetricKey(using:sharedInfo:outputByteCount:)
method of the shared secret. After the other party does the same, then you both share a symmetric key suitable for creating a message authentication code like HMAC
, or for opening and closing a sealed box with a cipher like ChaChaPoly
or AES
.
Citizens in Crypto
Conformances
protocol ContiguousBytes
Indicates that the conforming type is a contiguous collection of raw bytes whose underlying storage is directly accessible by withUnsafeBytes.
protocol Copyable
A type whose values can be implicitly or explicitly copied.
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Escapable
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.
Type members
Instance members
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.