Skip to content

Swift end-to-end

This guide uses the Verity Swift SDK, which wraps the shared Verity dispatcher and the ProveKit backend for iOS.

Package.swift
dependencies: [
.package(url: "https://github.com/atheonxyz/verity", from: "0.3.2")
],
targets: [
.target(name: "MyApp", dependencies: [
.product(name: "Verity", package: "verity")
])
]

The from: "0.3.2" resolution uses the SDK’s published binary xcframework — no local build required.

import Verity
let verity = try Verity(backend: .provekit)
let prover = try verity.loadProver(from: "scheme.pkp")
let verifier = try verity.loadVerifier(from: "scheme.pkv")
let witness = Witness(values: ["age": "25", "threshold": "18"])
let proof = try prover.prove(witness: witness)
let valid = try verifier.verify(proof: proof)
precondition(valid, "proof did not verify")
prover.close()
verifier.close()

Use loadProver(data:) and loadVerifier(data:) when the app downloads or bundles artifacts as Data. Witness accepts a [String: String] of field-element strings, a TOML path, or a JSON string, whichever shape your inputs already have.

  • Call ProveKit’s memory configuration before constructing Verity when the app needs mobile RAM limits or file-backed memory.
  • prover.close() and verifier.close() release the underlying native handles. Always call them on cleanup paths (defer { … } or scope-bound wrappers); the wrapping Verity instance does not auto-release them.