Struct vade::Vade

source · []
pub struct Vade {
    pub plugins: Vec<Box<dyn VadePlugin>>,
}
Expand description

A Vade instance is your single point of contact for interacting with DIDs and VCs.

Fields

plugins: Vec<Box<dyn VadePlugin>>

registered plugins

Implementations

Creates new Vade instance, vectors are initialized as empty.

Creates a new DID. May also persist a DID document for it, depending on plugin implementation.

Arguments
  • did_method - did method to cater to, usually also used by plugins to decide if a plugins will process the request
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.did_create("did:example", "", "").await?;
    if !results.is_empty() {
        println!("created new did: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Fetch data about a DID. This usually returns a DID document.

Arguments
  • did - did to fetch data for
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.did_resolve("did:example:123").await?;
    if !results.is_empty() {
        println!("got did: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Updates data related to a DID. May also persist a DID document for it, depending on plugin implementation.

Arguments
  • did - DID to update data for
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.did_update("did:example", "", "").await?;
    if !results.is_empty() {
        println!("did successfully updated: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Processes a DIDComm message as received, this may prepare a matching response for it if the DIDComm message can be interpreted and answered by a plugin’s implementation.

This response may be sent, depending on the configuration and implementation of underlying plugins, but it is usually also returned as response to this request.

Arguments
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (usually a raw DIDComm message)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.didcomm_receive("", "").await?;
    if !results.is_empty() {
        println!("received DIDComm message: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Processes a DIDComm message and prepares it for sending.

It may be sent, depending on the configuration and implementation of underlying plugins.

Arguments
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (usually a raw DIDComm message)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.didcomm_send("", "").await?;
    if !results.is_empty() {
        println!("prepared DIDComm message: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Registers a new plugin. See VadePlugin for details about how they work.

Arguments
  • plugin - plugin to register
Example
use vade::Vade;
// use some_crate::ExamplePlugin;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    let mut example_plugin = ExamplePlugin::new();
    vade.register_plugin(Box::from(example_plugin));
    let results = vade.did_create("did:example", "", "").await?;
    if !results.is_empty() {
        println!("did successfully updated: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Runs a custom function, this allows to use Vades API for custom calls, that do not belong to Vades core functionality but may be required for a projects use cases.

Arguments
  • method - method to call a function for (e.g. “did:example”)
  • function - function to call (e.g. “test connection”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.run_custom_function("did:example", "test connection", "", "").await?;
    if !results.is_empty() {
        println!("connection status is: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Creates a new zero-knowledge proof credential definition. A credential definition holds cryptographic key material and is needed by an issuer to issue a credential, thus needs to be created before issuance. A credential definition is always bound to one credential schema.

Arguments
  • method - method to create a credential definition for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_create_credential_definition("did:example", "", "").await?;
    if !results.is_empty() {
        println!("created a credential definition: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Creates a new zero-knowledge proof credential offer. This message is the response to a credential proposal.

Arguments
  • method - method to create a credential offer for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_create_credential_offer("did:example", "", "").await?;
    if !results.is_empty() {
        println!("created a credential offer: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Creates a new zero-knowledge proof credential proposal. This message is the first in the credential issuance flow.

Arguments
  • method - method to create a credential proposal for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_create_credential_proposal("did:example", "", "").await?;
    if !results.is_empty() {
        println!("created a credential proposal: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Creates a new zero-knowledge proof credential schema. The schema specifies properties a credential includes, both optional and mandatory.

Arguments
  • method - method to create a credential schema for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_create_credential_schema("did:example", "", "").await?;
    if !results.is_empty() {
        println!("created a credential schema: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Creates a new revocation registry definition. The definition consists of a public and a private part. The public part holds the cryptographic material needed to create non-revocation proofs. The private part needs to reside with the registry owner and is used to revoke credentials.

Arguments
  • method - method to create a revocation registry definition for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_create_revocation_registry_definition("did:example", "", "").await?;
    if !results.is_empty() {
        println!("created a revocation registry definition: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Updates a revocation registry for a zero-knowledge proof. This step is necessary after revocation one or more credentials.

Arguments
  • method - method to update a revocation registry for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_update_revocation_registry("did:example", "", "").await?;
    if !results.is_empty() {
        println!("updated revocation registry: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Issues a new credential. This requires an issued schema, credential definition, an active revocation registry and a credential request message.

Arguments
  • method - method to issue a credential for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_issue_credential("did:example", "", "").await?;
    if !results.is_empty() {
        println!("issued credential: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Finishes a credential, e.g. by incorporating the prover’s master secret into the credential signature after issuance.

Arguments
  • method - method to update a finish credential for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_finish_credential("did:example", "", "").await?;
    if !results.is_empty() {
        println!("issued credential: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Presents a proof for a zero-knowledge proof credential. A proof presentation is the response to a proof request.

Arguments
  • method - method to presents a proof for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_present_proof("did:example", "", "").await?;
    if !results.is_empty() {
        println!("created a proof presentation: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Requests a credential. This message is the response to a credential offering.

Arguments
  • method - method to request a credential for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_request_credential("did:example", "", "").await?;
    if !results.is_empty() {
        println!("created credential request: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Requests a zero-knowledge proof for one or more credentials issued under one or more specific schemas.

Arguments
  • method - method to request a proof for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_request_proof("did:example", "", "").await?;
    if !results.is_empty() {
        println!("created proof request: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Revokes a credential. After revocation the published revocation registry needs to be updated with information returned by this function.

Arguments
  • method - method to revoke a credential for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_revoke_credential("did:example", "", "").await?;
    if !results.is_empty() {
        println!("revoked credential: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Verifies one or multiple proofs sent in a proof presentation.

Arguments
  • method - method to verify a proof for (e.g. “did:example”)
  • options - JSON string with additional information supporting the request (e.g. authentication data)
  • payload - JSON string with information for the request (e.g. actual data to write)
Example
use vade::Vade;
async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let mut vade = Vade::new();
    // // register example plugin e.g. with
    // vade.register_plugin(example_plugin);
    let results = vade.vc_zkp_verify_proof("did:example", "", "").await?;
    if !results.is_empty() {
        println!("verified proof: {}", results[0].as_ref().ok_or("result not found")?);
    }
    Ok(())
}

Trait Implementations

Default Vade instance

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.