Skip to main content

DTGCommon

Struct DTGCommon 

Source
pub struct DTGCommon {
    pub context: Vec<String>,
    pub type_: Vec<String>,
    pub id: Option<String>,
    pub issuer: String,
    pub valid_from: DateTime<Utc>,
    pub valid_until: Option<DateTime<Utc>>,
    pub task_context: Option<String>,
    pub credential_subject: CredentialSubject,
    pub credential_status: Option<Value>,
    pub proof: Option<DataIntegrityProof>,
    pub extra: Map<String, Value>,
}
Expand description

All DTG Credentials follow a common structure.

Fields§

§context: Vec<String>§type_: Vec<String>

Credential type identifiers Must contain at least: DTGCredential VerifiableCredential

§id: Option<String>

OPTIONAL identifier for this specific credential, per the W3C VC Data Model.

When present it MUST be a single URL. A urn:uuid: URN is the usual choice for a credential with no dereferenceable home.

This is the handle a holder or verifier stores the credential under, so it is what makes re-delivery of the same credential idempotent and re-issuance of a different one recognisable as a renewal rather than a duplicate. A counterparty that keys credentials by id cannot accept one that has none — so issue with an id unless you know nobody on the other side needs it.

§Set it before signing

A Data Integrity proof covers the credential minus its proof, which includes this property. Set it while building — DTGCredential::with_id — never after DTGCredential::sign, which would leave a document whose proof no longer verifies.

§issuer: String

DID of the entity issuing this credential

§valid_from: DateTime<Utc>

ISO 8601 format of when this credentials become valid from

§valid_until: Option<DateTime<Utc>>

ISO 8601 format of when these credentials are valid to

§task_context: Option<String>

Identifier (threadId) of the trust task exchange in which this credential was issued.

REQUIRED for DTGCredentialType::Witness credentials, OPTIONAL for all other DTG credential types. A DTG credential without a taskContext MUST be interpretable standing alone, independent of any exchange.

NOTE: A verifier MUST NOT interpret a taskContext-bearing credential as proof that the associated trust task completed unless the matching trust task outcome evidence is also present and verified.

§credential_subject: CredentialSubject

The assertion between the entities involved

§credential_status: Option<Value>

A W3C VC status mechanism through which a verifier determines whether this credential has been revoked.

Held as an opaque Value: the mechanism is chosen by the governing VTC or VTN, and this library neither selects one nor resolves it. BitstringStatusListEntry is the common choice.

CONDITIONAL on a VDC — REQUIRED where the appointment outlives the freshness window the governing party defines for delegations, and permitted to be absent otherwise, with short validity and re-issuance preferred wherever the delegator is reachable. A status check is a live lookup that reveals the verification event to whoever hosts the status list.

§Modelled so that digests survive a round trip

Every VMC issued against a status list carries this, and before it was modelled a parse-then-re-serialise dropped it silently — producing a digest its issuer would not recognise. See DTGCommon::extra, which closes the same gap for members this library does not name at all.

§proof: Option<DataIntegrityProof>

Cryptographic proof of credential authenticity

§extra: Map<String, Value>

Top-level members this library does not model, preserved verbatim.

A DTG credential may legitimately carry properties beyond the ones named here — credentialSchema, termsOfUse, evidence, an extension a governing party defines. Without somewhere to keep them, a parse-then-re-serialise round trip drops them, and the digest computed over the result matches nothing the issuer signed.

Capturing them makes DTGCredential::digest_multibase agree with digest_multibase_json over the wire form for any credential whose extra members are top-level. It is not a complete answer — the credentialSubject types still reject members they do not model — so where you hold the bytes a counterparty sent, hashing those remains the safe habit.

Implementations§

Source§

impl DTGCommon

Source

pub fn signed(&self) -> bool

Has this credential been signed? Returns true if a proof exists NOTE: This does NOT validate the proof itself

Source

pub fn id(&self) -> Option<&str>

This credential’s own identifier, if it has one. See DTGCommon::id.

Source

pub fn issuer(&self) -> &str

Returns the issuer DID

Source

pub fn subject(&self) -> &str

Returns the subject DID

Source

pub fn authority(&self) -> Option<&AuthorityGrant>

The authority grant, when this credential is a VAC.

None for every other credential type — the accessor is deliberately fallible rather than panicking, so a caller handed a credential of unknown type can ask without first matching on type_.

Source

pub fn authority_mut(&mut self) -> Option<&mut AuthorityGrant>

Mutable access to the authority grant, when this credential is a VAC.

Present so that a caller can construct chains this library’s own DTGCredential::attenuate would refuse — which is exactly what a verifier must be tested against, since nothing stops another implementation emitting such JSON.

Source

pub fn delegation(&self) -> Option<&DelegationGrant>

The delegation object, when this credential is a VDC.

None for every other credential type, for the same reason DTGCommon::authority is fallible: a caller handed a credential of unknown type can ask without first matching on type_.

Source

pub fn delegation_mut(&mut self) -> Option<&mut DelegationGrant>

Mutable access to the delegation object, when this credential is a VDC.

Present for the same reason as DTGCommon::authority_mut: a verifier must be testable against chains this library’s own constructors would refuse to build, since nothing stops another implementation emitting such JSON.

Source

pub fn valid_from(&self) -> DateTime<Utc>

The credential is valid from this timestamp

Source

pub fn valid_until(&self) -> Option<DateTime<Utc>>

The credential is valid until this timestamp, if set

Source

pub fn task_context(&self) -> Option<&str>

The threadId of the trust task exchange this credential was issued in, if set

Trait Implementations§

Source§

impl Clone for DTGCommon

Source§

fn clone(&self) -> DTGCommon

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DTGCommon

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DTGCommon

Helps ensure default starting point is correct

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for DTGCommon

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for DTGCommon

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<DTGCommon> for DTGCredential

Post deserialize setup of a CredentialSubject and CredntialType

Source§

type Error = DTGCredentialError

The type returned in the event of a conversion error.
Source§

fn try_from(value: DTGCommon) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more