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: `Groth16Materials::from_embedded` requires the `embed-zkeys` Cargo feature.
// On native targets you can alternatively use `Groth16Materials::from_cache` after
// calling `storage::cache_embedded_groth16_material` to populate the on-disk cache.
use std::sync::Arc;
use walletkit_core::requests::ProofRequest;
use walletkit_core::storage::CredentialStore;
use walletkit_core::{Authenticator, Environment, Groth16Materials};

async fn generate_world_id_proof(
    store: Arc<CredentialStore>,
) -> Result<(), Box<dyn std::error::Error>> {
    let materials = Arc::new(Groth16Materials::from_embedded()?);

    // 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,
        None, // uses default RPC URL
        &Environment::Staging,
        None, // uses default region
        materials,
        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 user_agent::UserAgent;
pub use user_agent::UserAgentBuilder;

Modules§

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§

Authenticator
The Authenticator is the main component with which users interact with the World ID Protocol.
Credential
A wrapper around CoreCredential to enable FFI interoperability.
FieldElement
A wrapper around FieldElement to enable FFI interoperability.
Groth16Materials
ZK Proof material for both Groth16 proofs (query & nullifier proofs)
InitializingAuthenticator
Represents an Authenticator in the process of being initialized.
OwnershipProof
A WIP-103 Ownership Proof available to foreign bindings
RecoveryData
Identity material derived from a seed for use during account recovery.
RecoveryUpdateSignature
The signature and signing nonce returned by Authenticator::danger_sign_initiate_recovery_agent_update.

Enums§

Environment
Represents the environment in which a World ID is being presented and used.
Region
Region for node selection.
RegistrationStatus
Registration status for a World ID being created through the gateway.