Module certificate_client

Module certificate_client 

Source
Expand description

A client which retrieves and validates certificates from an aggregator.

In order to do so it defines a CertificateClient exposes the following features:

  • get: get a certificate data from its hash
  • list: get the list of available certificates
  • verify_chain: verify a certificate chain

§Get a certificate

To get a certificate using the ClientBuilder.

use mithril_client::ClientBuilder;

let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let certificate = client.certificate().get("CERTIFICATE_HASH").await?.unwrap();

println!("Certificate hash={}, signed_message={}", certificate.hash, certificate.signed_message);

§List available certificates

To list available certificates using the ClientBuilder.

use mithril_client::ClientBuilder;

let client = mithril_client::ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let certificates = client.certificate().list().await?;

for certificate in certificates {
    println!("Certificate hash={}, signed_message={}", certificate.hash, certificate.signed_message);
}

§Validate a certificate chain

To validate a certificate using the ClientBuilder.

use mithril_client::ClientBuilder;

let client = ClientBuilder::aggregator("YOUR_AGGREGATOR_ENDPOINT", "YOUR_GENESIS_VERIFICATION_KEY").build()?;
let certificate = client.certificate().verify_chain("CERTIFICATE_HASH").await?;

println!("Chain of Certificate (hash: {}) is valid", certificate.hash);

Structs§

CertificateClient
Aggregator client for the Certificate
MemoryCertificateVerifierCache
A in-memory cache for the certificate verifier.
MithrilCertificateVerifier
Implementation of a CertificateVerifier that can send feedbacks using the feedback mechanism.

Traits§

CertificateAggregatorRequest
Define the requests against an aggregator related to Mithril certificate.
CertificateVerifier
API that defines how to validate certificates.
CertificateVerifierCache
API that defines how to cache certificates validation results.