Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 1.22 KB

README.md

File metadata and controls

38 lines (26 loc) · 1.22 KB

SwiftPaillier

An implementation of Paillier's homomorphic encryption in Swift. It's made for scientific purposes, so be careful when using this library.

Installation via SPM

Declare a dependency on this package inside your Package.swift:

.package(url: "https://github.com/code28/SwiftPaillier.git", from: "1.0.0"),
// ...
.target(..., dependencies: [..., "SwiftPaillier"]),

Usage

import BigInt
import SwiftPaillier

let crypto = Paillier()
let cleartext = BigUInt(123456)
let addend = BigUInt(44)

let encryption = crypto.encrypt(cleartext)
encryption.add(addend)
let ciphertext = encryption.ciphertext

let decryptedText = crypto.decrypt(ciphertext: ciphertext)
assert((cleartext + addend) == decryptedText)

License

This package is licensed under the MIT license. By default it uses GMP, which is licensed under GNU LGPLv3, and BigInt, which is MIT licensed.

Since GMP is dynamically linked, this conforms to the GNU LGPLv3, but pay attention to the conditions of the LGPLv3 when using this library.

(It is possible to use SwiftPaillier without GMP and only use BigInt, which is slower.)