This package is used to generate a Swift SDK that wraps zkEmail bindings for use in iOS applications.
-
Open your project in Xcode.
-
Go to File > Add package dependencies.
-
In Search or Enter Package URL, enter the URL:
https://github.com/zkmopro/zkemail-swift-package
-
Choose the version and add the package to your project.
Add the following to your Package.swift
dependencies:
let package = Package(
name: "YourSwiftProject",
// ...
dependencies: [
.package(url: "https://github.com/zkmopro/zkemail-swift-package") // Or change to your own URL
],
// ...
targets: [
.target(name: "YourSwiftProject", dependencies: ["ZKEmailSwift"])
]
)
Add the following to your Podfile
:
platform :ios, '15.0'
use_frameworks!
target 'YourAppTarget' do
pod 'ZKEmailSwift', :git => 'https://github.com/zkmopro/zkemail-swift-package.git', :tag => 'v0.1.0'
end
Then run:
pod install
Alternatively, if the pod is published to CocoaPods trunk, you can simply add:
pod 'ZKEmailSwift', '~> 0.1.0'
and run pod install
.
import ZKEmailSwift
// Parse your .eml files as inputs
let inputs: [String: [String]] = [
"header_storage": [...], // Array of header storage bytes as strings
"header_len": ["123"], // Header length
"pubkey_modulus": [...], // Modulus components
"pubkey_redc": [...], // REDC components
"signature": [...], // Signature components
"date_index": ["42"],
"subject_index": ["100"],
"subject_length": ["20"],
"from_header_index": ["150"],
"from_header_length": ["30"],
"from_address_index": ["200"],
"from_address_length": ["40"]
]
// Generate the proof
let proofData = try! proveZkemail(srsPath: "/path/to/srs", inputs: inputs)
// Verify the proof
let isValid = try! verifyZkemail(srsPath: "/path/to/srs", proof: proofData)
Warning
The package supports multiple circuit types including zkEmail's Noir circuits. If you'd like to update the circuits or switch to a different proving scheme, please refer to the How to Build the Package section.
Circuit source code: https://github.com/zkmopro/circuit-registry
Example assets can be found in the test-e2e app or the circuit registry.
This package relies on bindings generated by the Mopro CLI. To learn how to build Mopro bindings, refer to the Getting Started section. If you'd like to generate custom bindings for your own circuits or proving schemes, check out the guide on how to use the Mopro CLI: Rust Setup for Android/iOS Bindings.
Then, replace the entire bindings directory with your generated files in the following location: Sources/MoproiOSBindings
Alternatively, you can run the following commands to copy your generated bindings into the correct location:
cp -r ../path/to/your/bindings/MoproiOSBindings ./Sources
This work was initially sponsored by a joint grant from PSE and 0xPARC. It is currently incubated by PSE.
This project is heavily inspired by ezkl-swift-package and follows a similar approach for integrating native cryptographic libraries into Swift via a Swift Package.