Skip to content

WalletKit enables wallets to use World ID.

Notifications You must be signed in to change notification settings

worldcoin/walletkit

Repository files navigation

WalletKit enables mobile applications to use World ID.

Part of the World ID SDK.

WalletKit can be used as a Rust crate, or directly as a Swift or Android package. WalletKit includes foreign bindings for direct usage in Swift/Kotlin through UniFFI.

Installation

To use WalletKit in another Rust project:

cargo install --git https://github.com/worldcoin/walletkit
# // TODO: installation through crates.io is pending
# cargo install walletkit

To use WalletKit in an iOS app:

WalletKit is distributed through a separate repo specifically for Swift bindings. This repo contains all the binaries required and is a mirror of @worldcoin/walletkit.

  1. Navigate to File > Swift Packages > Add Package Dependency in Xcode.
  2. Enter the WalletKit repo URL (note this is not the same repo): https://github.com/worldcoin/walletkit-swift

To use WalletKit in an Android app:

WalletKit's bindings for Kotlin are distributed through GitHub packages.

  1. Update build.gradle (App Level)
dependencies {
    /// ...
    implementation "org.world:walletkit:VERSION-SNAPSHOT"
}

Replace VERSION with the desired WalletKit version.

  1. Sync Gradle.

Overview

WalletKit is broken down into separate crates, offering the following functionality.

  • walletkit-core - Enables basic usage of a World ID to generate ZKPs using different credentials.

World ID Secret

  • Each World ID requires a secret. The secret is used in ZKPs to prove ownership over a World ID.
  • Each host app is responsible for generating, storing and backing up a World ID secret.
  • A World ID secret is a 32-byte secret generated with a cryptographically secure random function.
  • The World ID secret must never be exposed to third-parties and must not leave the holder's device. //TODO: Additional guidelines for secret generation and storage.

Getting Started

WalletKit is generally centered around a World ID. The most basic usage requires initializing a World ID Identity.

A World ID can then be used to generate Zero-Knowledge Proofs.

A ZKP is analogous to presenting a credential.

use walletkit::{Context, CredentialType, Environment, Identity};
use std::sync::Arc;

async fn example() {
    let identity = Identity::new(b"not_a_real_secret", &Environment::Staging);
    let context = Context::new("app_ce4cb73cb75fc3b73b71ffb4de178410", Some("my_action".to_string()), None, Arc::new(CredentialType::Orb));
    let proof = identity.generate_proof(&context).await.unwrap();

    dbg!(proof.to_json()); // the JSON output can be passed to the Developer Portal or other places for verification
}