Utility.Credential.V0.Credential
Templates
template Credential
A credential contract issued by an issuer to a holder for a specific purpose. It allows an issuer to attest a fact about a subject. The subject is typically the same as the holder of the credential. Credentials should be immutable, so that they can be fetched (i.e. verified) without contention. Credentials can be configured to be existential: by not providing an expiry date, they are valid as long as the contract exists on ledger.
Signatory: issuer, holder
Field
Type
Description
issuer
Issuer of the credential.
holder
Holder of the credential.
id
Identifier of the credential.
description
Description of the credential.
validFrom
Timestamp as of which the credential becomes valid. If not provided, the credential becomes valid as soon as it is created.
validUntil
Timestamp as of which the credential ceases to be valid. If not provided, the credential is valid indefinitely (or until it is revoked). Since credentials should be immutable, it is recommended to only provide this timestamp if it is guaranteed to stay constant. For example, paid credentials should typically have None here, because the initial validity period could either be extended (if the user tops up their balance) or shortened (if the USD vs CC rate changes).
claims
[Claim]
A list of claims, which are statements about a subject. The subject is typically the same as the holder of the credential.
observers
Observers of the credential.
Choice Archive
Controller: issuer, holder
Returns: ()
(no fields)
Choice Credential_Get
Fetch the credential.
Controller: actor
Returns: Credential_Get_Result
Field
Type
Description
actor
The actor party.
Choice Credential_Revoke
Revoke the credential.
Controller: actor
Returns: Credential_Revoke_Result
Field
Type
Description
actor
Revoker of the credential: This can either be the issuer or the holder.
Data Types
data Claim
A claim is a statement about a subject. Reference: https://www.w3.org/TR/vc-data-model-2.0/#claims (terminology therein used below) For example: "Pat is an alumni of XYZ University".
Result of
Credential_Get
.
Field
Type
Description
credential
The fetched credential.
data PartyCredentialRequirement
Defines a requirement for a credential held by a party. The party is expected to be the holder of the credential, as well as the subject of claims corresponding to the (property, value) pairs.
Functions
- validateFulfillsRequirement
: Time -> Party -> PartyCredentialRequirement -> Credential -> Validation Text Credential
Validates that a credential conforms to expected values.
- assertFulfillsAllRequirements
: (CanAssert m, HasTime m) => Party -> [PartyCredentialRequirement] -> [Credential] -> m ()
Assert that a party fulfills all credential requirements.
- validateCredentialHasIssuer
: Party -> Credential -> Validation Text Party
Validates that a credential has an expected issuer.
- validateCredentialHasHolder
: Party -> Credential -> Validation Text Party
Validates that a credential has an expected holder.
- validateCredentialHasId
: Optional Text -> Credential -> Validation Text Text
Validates that a credential has an expected id.
- validateCredentialIsValidFrom
: Time -> Credential -> Validation Text (Optional Time)
Validates that a credential has commenced.
- validateCredentialIsValidUntil
: Time -> Credential -> Validation Text (Optional Time)
Validates that a credential has not expired.
- validateCredentialHasClaims
: Party -> [(Text, Text)] -> Credential -> Validation Text [Claim]
Validates that a credential has required (property, value) pairs with the holder as the subject.