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, uniffi::Enum)]
30#[strum(serialize_all = "lowercase")]
31pub enum Environment {
32 /// For testing purposes ONLY.
33 Staging,
34 /// Live production environment. World ID Tree: `id.worldcoin.eth`
35 Production,
36}
37
38pub(crate) mod primitives;
39
40mod credential_type;
41pub use credential_type::CredentialType;
42
43/// Contains error outputs from `WalletKit`
44pub mod error;
45
46/// Contains logging functionality that can be integrated with foreign language bindings.
47pub mod logger;
48
49mod u256;
50pub use u256::U256Wrapper;
51
52#[cfg(feature = "v4")]
53mod authenticator;
54#[cfg(feature = "v4")]
55pub use authenticator::{Authenticator, InitializingAuthenticator, RegistrationStatus};
56
57#[cfg(feature = "v4")]
58pub(crate) mod defaults;
59
60////////////////////////////////////////////////////////////////////////////////
61// Legacy modules
62////////////////////////////////////////////////////////////////////////////////
63
64/// Contains all components to interact and use a World ID
65pub mod world_id;
66
67/// This module handles World ID proof generation
68pub mod proof;
69
70/// This module exposes helper functions to interact with common apps & contracts related to the World ID Protocol.
71#[cfg(feature = "common-apps")]
72pub mod common_apps;
73
74////////////////////////////////////////////////////////////////////////////////
75// Private modules
76////////////////////////////////////////////////////////////////////////////////
77
78mod merkle_tree;
79mod request;
80
81uniffi::setup_scaffolding!("walletkit_core");