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

Party

Issuer of the credential.

holder

Party

Holder of the credential.

id

Text

Identifier of the credential.

description

Text

Description of the credential.

validFrom

Optional Time

Timestamp as of which the credential becomes valid. If not provided, the credential becomes valid as soon as it is created.

validUntil

Optional Time

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

Parties

Observers of the credential.

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".

Claim

Field

Type

Description

subject

Text

A subject is a thing about which claims can be made ("Pat" in the example above).

property

Text

Property of the claim ("alumniOf" in the example above).

value

Text

Value of the claim property ("XYZ University" in the example above).

data Credential_Get_Result

Result of Credential_Get.

Credential_Get_Result

Field

Type

Description

credential

Credential

The fetched credential.

data Credential_Revoke_Result

Result of Credential_Revoke.

Credential_Revoke_Result

(no fields)

type Parties

= Set Party

Type synonym for a set of parties.

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.

PartyCredentialRequirement

Field

Type

Description

issuer

Party

Required issuer of the credential.

requiredClaims

[(Text, Text)]

Required (property, value) pairs that the holder has to have claims for as a subject.

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.