-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from alan-turing-institute/59-vp-api
Verifiable presentation API for ION attestor #59
- Loading branch information
Showing
13 changed files
with
532 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
pub mod api; | ||
use crate::api::{TrustchainDIDAPI, TrustchainVCAPI}; | ||
use crate::api::{TrustchainDIDAPI, TrustchainVCAPI, TrustchainVPAPI}; | ||
|
||
/// A type for implementing CLI traits on. | ||
pub struct TrustchainAPI; | ||
|
||
impl TrustchainDIDAPI for TrustchainAPI {} | ||
impl TrustchainVCAPI for TrustchainAPI {} | ||
impl TrustchainVPAPI for TrustchainAPI {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//! DID issuer API. | ||
use crate::key_manager::KeyManagerError; | ||
use crate::subject::Subject; | ||
use async_trait::async_trait; | ||
use ssi::did_resolve::DIDResolver; | ||
use ssi::vc::{LinkedDataProofOptions, Presentation}; | ||
use thiserror::Error; | ||
|
||
/// An error relating to a Trustchain holder. | ||
#[derive(Error, Debug)] | ||
pub enum HolderError { | ||
/// Wrapped error for SSI error. | ||
#[error("A wrapped variant for an SSI error: {0}")] | ||
SSI(ssi::error::Error), | ||
/// Wrapped error for key manager error. | ||
#[error("A wrapped variant for a key manager error: {0}")] | ||
KeyManager(KeyManagerError), | ||
/// Holder field mismatched with attestor DID. | ||
#[error("Holder field mismatched with attestor DID.")] | ||
MismatchedHolder, | ||
} | ||
|
||
impl From<ssi::error::Error> for HolderError { | ||
fn from(err: ssi::error::Error) -> Self { | ||
HolderError::SSI(err) | ||
} | ||
} | ||
|
||
impl From<KeyManagerError> for HolderError { | ||
fn from(err: KeyManagerError) -> Self { | ||
HolderError::KeyManager(err) | ||
} | ||
} | ||
|
||
/// A holder signs a presentation to generate a verifiable presentation. | ||
#[async_trait] | ||
pub trait Holder: Subject { | ||
/// Attests to a given presentation of one or many credentials returning the presentation with a | ||
/// proof. The `@context` of the presentation has linked-data fields strictly checked as part of | ||
/// proof generation. | ||
async fn sign_presentation<T: DIDResolver>( | ||
&self, | ||
presentation: &Presentation, | ||
linked_data_proof_options: Option<LinkedDataProofOptions>, | ||
key_id: Option<&str>, | ||
resolver: &T, | ||
) -> Result<Presentation, HolderError>; | ||
} |
Oops, something went wrong.