Expand description
walletkit-core contains the basic primitives for using a World ID.
It enables basic usage of a World ID to generate ZKPs using different credentials.
§Example
ⓘ
// Note: `EmbeddedZkArtifacts` requires the `embed-zkeys` Cargo feature.
// On native targets, use `CachingZkArtifacts` to cache embedded material on disk.
use std::sync::Arc;
use walletkit_core::authenticator::artifacts::embedded::EmbeddedZkArtifacts;
use walletkit_core::requests::ProofRequest;
use walletkit_core::storage::CredentialStore;
use walletkit_core::{Authenticator, Environment};
async fn generate_world_id_proof(
store: Arc<CredentialStore>,
) -> Result<(), Box<dyn std::error::Error>> {
let artifacts = Arc::new(EmbeddedZkArtifacts::new());
// Initialize an authenticator for an already-registered World ID.
let seed = b"my_secret_seed_at_length_32_bytes!";
let authenticator = Authenticator::init_with_defaults(
seed.to_vec(),
None, // uses default RPC URL
&Environment::Staging,
None, // uses default region
artifacts,
store,
)
.await?;
// Parse an incoming proof request from a relying party.
let json = r#"{ "id": "req_01", "version": 1, "credentials": [] }"#;
let request = ProofRequest::from_json(json)?;
// Generate a zero-knowledge proof and serialise the response.
let response = authenticator.generate_proof(&request, None).await?;
println!("{}", response.to_json()?);
Ok(())
}Re-exports§
pub use authenticator::Authenticator;pub use authenticator::GatewayRequestStatus;pub use authenticator::InitializingAuthenticator;pub use authenticator::RecoveryData;pub use authenticator::RecoveryUpdateSignature;pub use authenticator::RegistrationStatus;pub use user_agent::UserAgent;pub use user_agent::UserAgentBuilder;
Modules§
- authenticator
- The Authenticator is the main component with which users interact with the World ID Protocol.
- defaults
- Default configuration values for each
Environment. - error
- Contains error outputs from
WalletKit - flamingo
- Attested Flamingo matching in preparation for zero-knowledge proof generation.
Attested
Flamingomatching in preparation for zero-knowledge proof generation. - issuers
- Credential issuers for World ID (NFC, etc.) Logic for different specific issuers of Credentials in World ID.
- logger
- Contains logging functionality that can be integrated with foreign language bindings.
- proof_
request_ credential_ constraints_ check - Pre-flight check of whether stored credentials can satisfy a
requests::ProofRequest. Pre-flight check of whether the credential store can satisfy a proof request. - requests
- Proof requests and responses in World ID v4.
- storage
- Credential storage primitives for World ID v4.
- user_
agent - User agent for HTTP requests. User agent for HTTP requests.
Structs§
- Credential
- A wrapper around
CoreCredentialto enable FFI interoperability. - Field
Element - A wrapper around
FieldElementto enable FFI interoperability. - Ownership
Proof - A WIP-103 Ownership Proof available to foreign bindings
Enums§
- Environment
- Represents the environment in which a World ID is being presented and used.
- Region
- Region for node selection.