pub struct DTGCredential { /* private fields */ }Expand description
Defined DTG Credentials
Implementations§
Source§impl DTGCredential
impl DTGCredential
Sourcepub fn new_vmc(
issuer: String,
subject: String,
valid_from: DateTime<Utc>,
valid_until: Option<DateTime<Utc>>,
personhood: bool,
) -> Self
pub fn new_vmc( issuer: String, subject: String, valid_from: DateTime<Utc>, valid_until: Option<DateTime<Utc>>, personhood: bool, ) -> Self
Creates a new Verified Memebrship Credential (VMC) issuer: The issuer DID of the credential subject: The DID of the subject of this credential valid_from: The datetime from which this credential is valid valid_until: Optional: The datetime this credential is valid until personhood: Whether this VMC can be used as a form of Personhood Credential - Adds PersonhoodCredential to the type array if true
Sourcepub fn new_vrc(
issuer: String,
subject: String,
valid_from: DateTime<Utc>,
valid_until: Option<DateTime<Utc>>,
) -> Self
pub fn new_vrc( issuer: String, subject: String, valid_from: DateTime<Utc>, valid_until: Option<DateTime<Utc>>, ) -> Self
Creates a new Verified Relationship Credential (VRC) issuer: The issuer DID of the credential subject: The DID of the subject of this credential valid_from: The datetime from which this credential is valid valid_until: Optional: The datetime this credential is valid until
Sourcepub fn new_vic(
issuer: String,
subject: String,
valid_from: DateTime<Utc>,
valid_until: Option<DateTime<Utc>>,
) -> Self
pub fn new_vic( issuer: String, subject: String, valid_from: DateTime<Utc>, valid_until: Option<DateTime<Utc>>, ) -> Self
Creates a new Verified Invitation Credential (VIC) issuer: The issuer DID of the credential subject: The DID of the subject of this credential valid_from: The datetime from which this credential is valid valid_until: Optional: The datetime this credential is valid until
Sourcepub fn new_vpc(
issuer: String,
subject: String,
valid_from: DateTime<Utc>,
valid_until: Option<DateTime<Utc>>,
) -> Self
pub fn new_vpc( issuer: String, subject: String, valid_from: DateTime<Utc>, valid_until: Option<DateTime<Utc>>, ) -> Self
Creates a new Verified Persona Credential (VPC) issuer: The issuer DID of the credential subject: The DID of the subject of this credential valid_from: The datetime from which this credential is valid valid_until: Optional: The datetime this credential is valid until
Sourcepub fn new_vec(
issuer: String,
subject: String,
valid_from: DateTime<Utc>,
valid_until: Option<DateTime<Utc>>,
endorsement: Value,
) -> Self
pub fn new_vec( issuer: String, subject: String, valid_from: DateTime<Utc>, valid_until: Option<DateTime<Utc>>, endorsement: Value, ) -> Self
Creates a new Verified Endorsement Credential (VEC) issuer: The issuer DID of the credential subject: The DID of the subject of this credential valid_from: The datetime from which this credential is valid valid_until: Optional: The datetime this credential is valid until endorsement: The endorsement details for this credential
Sourcepub fn new_vwc(
issuer: String,
subject: String,
valid_from: DateTime<Utc>,
valid_until: Option<DateTime<Utc>>,
task_context: String,
digest: Option<String>,
witness_context: Option<WitnessContext>,
) -> Self
pub fn new_vwc( issuer: String, subject: String, valid_from: DateTime<Utc>, valid_until: Option<DateTime<Utc>>, task_context: String, digest: Option<String>, witness_context: Option<WitnessContext>, ) -> Self
Creates a new Verified Witness Credential (VWC)
issuer: The issuer DID of the credential - an M-DID, or the DID of a VTA acting
according to VTC policy
subject: The DID of the observed party. For a witnessed bi-directional exchange this
MUST be the issuer of the VRC that this VWC attests (the VRC referenced by
digest), so that the two VWCs of an exchange are unambiguously bound to
their respective directions. The witness should issue one VWC per direction.
valid_from: The datetime from which this credential is valid
valid_until: Optional: The datetime this credential is valid until
task_context: Required threadId of the trust task exchange the witnessing occurred in
digest: Optional Witness cryptographic hash of the witnessed VRC (prevents misuse).
Produce this with DTGCredential::digest_multibase on the witnessed VRC.
witness_context: Optional Semantic context for the witness
Sourcepub fn new_rcard(
issuer: String,
subject: String,
valid_from: DateTime<Utc>,
valid_until: Option<DateTime<Utc>>,
card: Value,
) -> Self
👎Deprecated since 0.2.0: The r-card is a verifiable data structure (VDS), not a DTGCredential subtype. It was removed from the DTG Core Credentials specification in Working Draft 01 and will be defined by the planned DTG Verifiable Data Structures specification. This constructor will be removed in a future release.
pub fn new_rcard( issuer: String, subject: String, valid_from: DateTime<Utc>, valid_until: Option<DateTime<Utc>>, card: Value, ) -> Self
The r-card is a verifiable data structure (VDS), not a DTGCredential subtype. It was removed from the DTG Core Credentials specification in Working Draft 01 and will be defined by the planned DTG Verifiable Data Structures specification. This constructor will be removed in a future release.
Creates a new Verified RCard Credential (VWC) issuer: The issuer DID of the credential subject: The DID of the subject of this credential valid_from: The datetime from which this credential is valid valid_until: Optional: The datetime this credential is valid until card: JSON Value representing a Jcard (RFC 7095) format
Source§impl DTGCredential
impl DTGCredential
Sourcepub fn credential(&self) -> &DTGCommon
pub fn credential(&self) -> &DTGCommon
get the raw credential
Sourcepub fn credential_mut(&mut self) -> &mut DTGCommon
pub fn credential_mut(&mut self) -> &mut DTGCommon
Get the raw credential as mutable
Sourcepub fn type_(&self) -> DTGCredentialType
pub fn type_(&self) -> DTGCredentialType
get the credential type
Sourcepub fn valid_from(&self) -> DateTime<Utc>
pub fn valid_from(&self) -> DateTime<Utc>
Returns the valid_from timestamp
Sourcepub fn valid_until(&self) -> Option<DateTime<Utc>>
pub fn valid_until(&self) -> Option<DateTime<Utc>>
Returns the valid until timestamp
Sourcepub fn task_context(&self) -> Option<&str>
pub fn task_context(&self) -> Option<&str>
The threadId of the trust task exchange this credential was issued in, if set
This is always Some for DTGCredentialType::Witness credentials, where the spec
makes taskContext REQUIRED.
Sourcepub fn digest_multibase(&self) -> Result<String, DTGCredentialError>
pub fn digest_multibase(&self) -> Result<String, DTGCredentialError>
Computes the digest of this credential, for use as the digest property of a
Witness Credential (VWC) attesting it.
The digest is the SHA-256 hash of this credential canonicalized with the JSON
Canonicalization Scheme (JCS, RFC 8785),
wrapped as a multihash and encoded as a base58btc multibase string (z...), matching
the W3C digestMultibase convention.
NOTE: This intentionally differs from the DTG Core Credentials Working Draft 01, which
specifies a sha256:<lowercase-hex> encoding. The underlying hash is the same; only the
encoding differs. See CHANGELOG.md.
The digest covers the credential exactly as it stands, including its proof if it has
been signed. A witness should therefore digest the VRC in the form it was witnessed in.
Sourcepub fn verify_digest(
&self,
witnessed: &DTGCredential,
) -> Result<bool, DTGCredentialError>
pub fn verify_digest( &self, witnessed: &DTGCredential, ) -> Result<bool, DTGCredentialError>
Checks that this credential’s digest matches the credential it claims to witness.
Returns Ok(false) if the digests do not match, or if this credential carries no
digest (it is OPTIONAL), in which case there is nothing to rely on.
Sourcepub fn proof_value(&self) -> Option<&str>
pub fn proof_value(&self) -> Option<&str>
Returns the proof value if signed else None
Sourcepub async fn sign(
&mut self,
signing_secret: &Secret,
create_time: Option<DateTime<Utc>>,
) -> Result<DataIntegrityProof, DTGCredentialError>
pub async fn sign( &mut self, signing_secret: &Secret, create_time: Option<DateTime<Utc>>, ) -> Result<DataIntegrityProof, DTGCredentialError>
Sign the credential using W3C Data Integrity Proof with JCS EdDSA 2022 signing_secret: The secret key to use to sign the credential create_time: Optional creation time for the proof, defaults to now if None
Sourcepub fn verify_proof_with_public_key(
&self,
public_key_bytes: &[u8],
) -> Result<(), DTGCredentialError>
pub fn verify_proof_with_public_key( &self, public_key_bytes: &[u8], ) -> Result<(), DTGCredentialError>
Verify the credential if you already know the public key bytes otherwise use the affinidi_tdk:verify_data() method public_key_bytes: The public key bytes to use to verify the credential
Sourcepub fn get_w3c_vc_version(&self) -> W3CVCVersion
pub fn get_w3c_vc_version(&self) -> W3CVCVersion
Is this credential a W3C VC Version 1.1 or 2.0 credential?
Sourcepub fn is_personhood_credential(&self) -> bool
pub fn is_personhood_credential(&self) -> bool
returns true if this credential a personhood credential (PHC)
Trait Implementations§
Source§impl Clone for DTGCredential
impl Clone for DTGCredential
Source§fn clone(&self) -> DTGCredential
fn clone(&self) -> DTGCredential
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more