Skip to main content

Crate walletkit_core

Crate walletkit_core 

Source
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
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 CoreCredential to enable FFI interoperability.
FieldElement
A wrapper around FieldElement to enable FFI interoperability.
OwnershipProof
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.