INNER CODE UNIT · Swift
open
jedisct1/swift-sodium · Sources/Sodium/Box.swift:296
func open(authenticatedCipherText: Bytes, senderPublicKey: PublicKey, recipientSecretKey: SecretKey, nonce: Nonce, mac: MAC) -> Bytes? {
guard nonce.count == NonceBytes,
mac.count == MacBytes,
senderPublicKey.count == PublicKeyBytes,
recipientSecretKey.count == SecretKeyBytes
else { return nil }
var message = Bytes(count: authenticatedCipherText.count)
guard crypto_box_open_detached(
&message,
authenticatedCipherText,
mac,
UInt64(authenticatedCipherText.count),
nonce,
senderPublicKey,
recipientSecretKey
).exitCode == .SUCCESS else { return nil }