Skip to content

zkmopro/mopro-swift-package

Repository files navigation

Mopro Swift Package

This package is used to generate a Swift SDK that wraps Mopro bindings for use in iOS applications.

How to Import the Package

Option 1: Using Xcode

  1. Open your project in Xcode.

  2. Go to File > Add package dependencies.

  3. In Search or Enter Package URL, enter the URL: https://github.com/zkmopro/mopro-swift-package

  4. Choose the version and add the package to your project.

Option 2: Using Package.swift

Add the following to your Package.swift dependencies:

let package = Package(
    name: "YourSwiftProject",
    // ...
    dependencies: [
        .package(url: "https://github.com/zkmopro/mopro-swift-package") // Or change to your own URL
    ],
    // ...
    targets: [
        .target(name: "YourSwiftProject", dependencies: ["MoproFFI"])
    ]
)

Option 3: Using CocoaPods

  1. Add the following to your Podfile:
pod 'MoproFFI', :git => 'https://github.com/zkmopro/mopro-swift-package'
  1. Run the installation command:
pod install
  1. Import the package in your Swift code:
import MoproFFI

How to Use the Package

Here is an example of how to integrate and use this package

import MoproFFI

// ...
let generateProofResult = try generateCircomProof(zkeyPath: zkeyPath, circuitInputs: input_str, proofLib: ProofLib.arkworks)

Or checkout the test-e2e app.

Warning

The default bindings are built specifically for the multiplier2 circom circuit. If you'd like to update the circuit 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/tree/main/multiplier2
Example .zkey file for the circuit: http://ci-keys.zkmopro.org/multiplier2_final.zkey

How to Build the Package

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

Community

  • X account:
  • Telegram group:

Acknowledgements

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •