SecretKey

public class SecretKey : KeyMaterial

A class for secret keys that can be used by the SecretBox.

  • The size of the secret key in bytes.

    Declaration

    Swift

    public static let SizeInBytes: UInt32
  • Generates a new secret key.

    Declaration

    Swift

    public init()
  • Creates a secret key from other key material.

    Precondition

    other.sizeInBytes = SizeInBytes

    Declaration

    Swift

    public override init(_ other: KeyMaterial)

    Parameters

    other

    The other key material.

  • Restores a secret key from a given byte array. The byte array is copied to a secure location and overwritten with zeroes to avoid the key being compromised in memory.

    Warning

    Do not initialize new keys with this function. If you need a new key, use init?() instead. This initializer is only to restore secret keys that were persisted.

    Declaration

    Swift

    public override init?(bytes: inout Bytes)

    Parameters

    bytes

    A secret key.