Saltar al contenido principal
Versión: V4

Mobile SDKs

Community Packages

These mobile SDKs are maintained by zkmopro, a community project focused on bringing ZK proofs to mobile devices. While not part of the core Semaphore repository, they provide native mobile implementations of the Semaphore protocol.

Overview

The mobile SDKs enable native ZK proof generation on iOS, Android, React Native, and Flutter platforms, delivering significantly faster results than WASM-based alternatives.

All SDKs follow the same core workflow:

  1. Create an identity
  2. Create a group with members
  3. Generate a proof of group membership
  4. Verify the proof

Installation

Swift Package

For detailed setup and API reference, see the GitHub repository.

Xcode (Swift Package Manager)

  1. In Xcode, go to File > Add Package Dependencies
  2. Enter the repository URL: https://github.com/zkmopro/SemaphoreSwift

Package.swift

dependencies: [
.package(url: "https://github.com/zkmopro/SemaphoreSwift", from: "0.1.0")
]

CocoaPods

pod 'Semaphore', :git => 'https://github.com/zkmopro/SemaphoreSwift'

Create an Identity

A Semaphore identity is required to join groups and generate proofs. See the identities guide for more details on the concept.

import Semaphore

// Create a random identity
let identity = Identity()

// Or create a deterministic identity from a private key
let identity = Identity(privateKey: privateKey)

// Access the commitment (public identifier)
let commitment = identity.commitment()

Create a Group

A Semaphore group is a Merkle tree containing identity commitments. See the groups guide for more details.

import Semaphore

// Create a group with the identity's element
let group = Group(members: [identity.toElement()])

// Or create a group with multiple members
let group = Group(members: [identity1.toElement(), identity2.toElement()])

Generate a Proof

Generate a ZK proof that demonstrates group membership without revealing your identity. See the proofs guide for more details on scopes and messages.

import Semaphore

let proof = try generateSemaphoreProof(
identity: identity,
group: group,
message: "Hello World",
scope: "app-scope",
merkleTreeDepth: 16
)
tip

The merkleTreeDepth parameter determines the maximum group size (2^depth members). A depth of 16 supports up to 65,536 members. Match this value with your on-chain group configuration.

Verify a Proof

Verify that a proof is valid. This can be done locally on the device or on a server.

import Semaphore

let isValid = try verifySemaphoreProof(proof: proof)
información

For on-chain verification, you can send the proof to your backend and use the Semaphore smart contract's validateProof function. See the proofs guide for details.

Performance

By proving natively, the mobile SDKs deliver significantly faster proof generation performance than WASM-based alternatives.

The benchmarks below were measured using the Semaphore-32 circuit with rapidsnark, which supports groups with up to 2^32 members. For detailed performance comparisons across different devices, proving systems, and circuits, see the performance section of zkmopro docs.

PlatformDeviceProof Generation Time
iOSiPhone 16 Pro (2024)~143 ms
AndroidSamsung S23 Ultra (2023)~166 ms

Resources