苹果公司发布了新的开源 Swift 工具库,以便开发者使用 Swift 实现同态加密 (swift-homomorphic-encryption),此举标志着苹果在数据隐私保护方面迈出了重要一步。

开发文档:https://developer.apple.com/documentation/sms_and_call_reporting/getting_up-to-date_calling_and_blocking_information_for_your_app

下面是使用 Swift 实现同态加密的基本示例:

import HomomorphicEncryption// We start by choosing some encryption parameters for the Bfv<UInt64> scheme.// *These encryption parameters are insecure, suitable for testing only.*let encryptParams =    try EncryptionParameters<Bfv<UInt64>>(from: .insecure_n_8_logq_5x18_logt_5)// Perform pre-computation for HE computation with these parameters.let context = try Context(encryptionParameters: encryptParams)// We encode N values using coefficient encoding.let values: [UInt64] = [8, 5, 12, 12, 15, 0, 8, 5]let plaintext: Bfv<UInt64>.CoeffPlaintext = try context.encode(    values: values,    format: .coefficient)// We generate a secret key and use it to encrypt the plaintext.let secretKey = try context.generateSecretKey()let ciphertext = try plaintext.encrypt(using: secretKey)// Decrypting the plaintext yields the original values.let decrypted = try ciphertext.decrypt(using: secretKey)let decoded: [UInt64] = try decrypted.decode(format: .coefficient)precondition(decoded == values)

同态加密是一种前沿的加密算法,它允许对加密数据进行计算,而无需解密即可获取计算结果。这种“可算不可见”的特性,为数据的安全性和隐私性提供了更高级别的保护。

苹果为 Swift 发布同态加密工具库插图

苹果已经在最新操作系统 iOS 18 中部署了同态加密技术。一个典型应用实例是 Live Caller ID Lookup 功能,该功能利用同态加密技术,能够在不泄露用户电话号码的情况下,向服务器发送加密查询,并接收电话号码信息。

通过这种方式,服务器在处理请求期间永远不会解密原始数据,甚至无法访问解密密钥。这不仅为云服务的运行提供了新的机会,也极大地增强了用户数据的隐私和安全。

苹果发布的这款开源 Swift 工具库将同态加密技术开放给更广泛的开发者和研究者,鼓励行业内对这一技术进行更深入的探索和应用。这不仅有助于推动技术的发展,也为保护用户隐私提供了新的解决方案。

免责声明:本文系转载,版权归原作者所有;旨在传递信息,不代表一休教程网的观点和立场。