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§
source§impl Vade
impl Vade
sourcepub async fn did_create(
&mut self,
did_method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn did_create( &mut self, did_method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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 requestoptions
- 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(())
}
sourcepub async fn did_resolve(
&mut self,
did: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn did_resolve( &mut self, did: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn did_update(
&mut self,
did: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn did_update( &mut self, did: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
Updates data related to a DID. May also persist a DID document for it, depending on plugin implementation.
Arguments
did
- DID to update data foroptions
- 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(())
}
sourcepub async fn didcomm_receive(
&mut self,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn didcomm_receive( &mut self, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn didcomm_send(
&mut self,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn didcomm_send( &mut self, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub fn register_plugin(&mut self, plugin: Box<dyn VadePlugin>)
pub fn register_plugin(&mut self, plugin: Box<dyn VadePlugin>)
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(())
}
sourcepub async fn run_custom_function(
&mut self,
method: &str,
function: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn run_custom_function( &mut self, method: &str, function: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
Runs a custom function, this allows to use Vade
s API for custom calls, that do not belong
to Vade
s 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(())
}
sourcepub async fn vc_zkp_create_credential_definition(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_create_credential_definition( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_create_credential_offer(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_create_credential_offer( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_create_credential_proposal(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_create_credential_proposal( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_create_credential_schema(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_create_credential_schema( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_create_revocation_registry_definition(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_create_revocation_registry_definition( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_update_revocation_registry(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_update_revocation_registry( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_issue_credential(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_issue_credential( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_finish_credential(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_finish_credential( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_present_proof(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_present_proof( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_propose_proof(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_propose_proof( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
Proposes a zero-knowledge proof for one or more credentials issued under one or more specific schemas.
Arguments
method
- method to propose a proof for (e.g. “did:example”)options
- JSON string with additional information supporting the proposal (e.g. authentication data)payload
- JSON string with information for the proposal (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_propose_proof("did:example", "", "").await?;
if !results.is_empty() {
println!("created proof proposal: {}", results[0].as_ref().ok_or("result not found")?);
}
Ok(())
}
sourcepub async fn vc_zkp_request_credential(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_request_credential( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_request_proof(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_request_proof( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_revoke_credential(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_revoke_credential( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}
sourcepub async fn vc_zkp_verify_proof(
&mut self,
method: &str,
options: &str,
payload: &str
) -> Result<Vec<Option<String>>, Box<dyn Error>>
pub async fn vc_zkp_verify_proof( &mut self, method: &str, options: &str, payload: &str ) -> Result<Vec<Option<String>>, Box<dyn Error>>
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(())
}