walletkit_core/
lib.rs

1//! `walletkit-core` contains the basic primitives for using a World ID.
2//! It enables basic usage of a World ID to generate ZKPs using different credentials.
3//!
4//! # Examples
5//! ```rust
6//! use walletkit_core::{proof::ProofContext, CredentialType, Environment, world_id::WorldId};
7//! async fn example() {
8//!     let world_id = WorldId::new(b"not_a_real_secret", &Environment::Staging);
9//!     let context = ProofContext::new("app_ce4cb73cb75fc3b73b71ffb4de178410", Some("my_action".to_string()), None, CredentialType::Orb);
10//!     let proof = world_id.generate_proof(&context).await.unwrap();
11//!     println!("{}", proof.to_json().unwrap()); // the JSON output can be passed to the Developer Portal, World ID contracts, etc. for verification
12//! }
13//! ```
14#![deny(
15    clippy::all,
16    clippy::pedantic,
17    clippy::nursery,
18    missing_docs,
19    dead_code
20)]
21
22use strum::EnumString;
23
24/// Represents the environment in which a World ID is being presented and used.
25///
26/// Each environment uses different sources of truth for the World ID credentials.
27///
28/// More information on testing for the World ID Protocol can be found in: `https://docs.world.org/world-id/quick-start/testing`
29#[derive(Debug, Clone, PartialEq, Eq, EnumString)]
30#[cfg_attr(feature = "ffi", derive(uniffi::Enum))]
31#[strum(serialize_all = "lowercase")]
32pub enum Environment {
33    /// For testing purposes ONLY.
34    Staging,
35    /// Live production environment. World ID Tree: `id.worldcoin.eth`
36    Production,
37}
38
39mod credential_type;
40pub use credential_type::CredentialType;
41
42/// Contains error outputs from `WalletKit`
43pub mod error;
44
45/// Contains all components to interact and use a World ID
46pub mod world_id;
47
48/// This module handles World ID proof generation
49pub mod proof;
50
51/// This module exposes helper functions to interact with common apps & contracts related to the World ID Protocol.
52#[cfg(feature = "common-apps")]
53pub mod common_apps;
54
55mod u256;
56pub use u256::U256Wrapper;
57
58////////////////////////////////////////////////////////////////////////////////
59// Private modules
60////////////////////////////////////////////////////////////////////////////////
61
62mod merkle_tree;
63mod request;
64
65#[cfg(feature = "ffi")]
66uniffi::setup_scaffolding!("walletkit_core");