INNER CODE UNIT · Swift

open

jedisct1/swift-sodium · Sources/Sodium/Box.swift:371

    func open(anonymousCipherText: Bytes, recipientPublicKey: PublicKey, recipientSecretKey: SecretKey) -> Bytes? {
        guard recipientPublicKey.count == PublicKeyBytes,
              recipientSecretKey.count == SecretKeyBytes,
              anonymousCipherText.count >= SealBytes
        else { return nil }

        var message = Bytes(count: anonymousCipherText.count - SealBytes)

        guard crypto_box_seal_open(
            &message,
            anonymousCipherText, UInt64(anonymousCipherText.count),
            recipientPublicKey,
            recipientSecretKey
        ).exitCode == .SUCCESS else { return nil }

        return message
    }
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…