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