Documentation ¶
Index ¶
- Constants
- func VCContextV1URI() ssi.URI
- func VerifiableCredentialTypeV1URI() ssi.URI
- type CredentialStatus
- type JSONWebSignature2020Proof
- type Proof
- type VerifiableCredential
- func (vc VerifiableCredential) ContainsContext(context ssi.URI) bool
- func (vc VerifiableCredential) IsType(vcType ssi.URI) bool
- func (vc VerifiableCredential) MarshalJSON() ([]byte, error)
- func (vc VerifiableCredential) Proofs() ([]Proof, error)
- func (vc VerifiableCredential) UnmarshalCredentialSubject(target interface{}) error
- func (vc *VerifiableCredential) UnmarshalJSON(b []byte) error
- func (vc VerifiableCredential) UnmarshalProofValue(target interface{}) error
Constants ¶
const VCContextV1 = "https://www.w3.org/2018/credentials/v1"
DefaultContext is the context required for every credential
const VerifiableCredentialType = "VerifiableCredential"
VerifiableCredentialType is the default credential type required for every credential
Variables ¶
This section is empty.
Functions ¶
func VCContextV1URI ¶
VCContextV1URI returns 'https://www.w3.org/2018/credentials/v1' as URI
func VerifiableCredentialTypeV1URI ¶
VerifiableCredentialTypeV1URI returns VerifiableCredential as URI
Types ¶
type CredentialStatus ¶
CredentialStatus defines the method on how to determine a credential is revoked.
type JSONWebSignature2020Proof ¶
JSONWebSignature2020Proof is a VC proof with a signature according to JsonWebSignature2020
type Proof ¶
type Proof struct { // Type defines the specific proof type used. // For example, an Ed25519Signature2018 type indicates that the proof includes a digital signature produced by an ed25519 cryptographic key. Type ssi.ProofType `json:"type"` // ProofPurpose defines the intent for the proof, the reason why an entity created it. // Acts as a safeguard to prevent the proof from being misused for a purpose other than the one it was intended for. // For example, a proof can be used for purposes of authentication, for asserting control of a Verifiable Credential (assertionMethod), and several others. ProofPurpose string `json:"proofPurpose"` // VerificationMethod points to the ID that can be used to verify the proof, eg: a public key. VerificationMethod ssi.URI `json:"verificationMethod"` // Created notes when the proof was created using a iso8601 string Created time.Time `json:"created"` // Domain specifies the restricted domain of the proof Domain *string `json:"domain,omitempty"` }
Proof represents a credential/presentation proof as defined by the Linked Data Proofs 1.0 specification (https://w3c-ccg.github.io/ld-proofs/). The proof value must be implemented in a custom type since the specification doesn't define the json object for this. For example: a jws for detached JSON Web Signatures uses the 'jws' json field
type VerifiableCredential ¶
type VerifiableCredential struct { // Context defines the json-ld context to dereference the URIs Context []ssi.URI `json:"@context"` // ID is an unique identifier for the credential. It is optional ID *ssi.URI `json:"id,omitempty"` // Type holds multiplte types for a credential. A credential must always have the 'VerifiableCredential' type. Type []ssi.URI `json:"type"` // Issuer refers to the party that issued the credential Issuer ssi.URI `json:"issuer"` // IssuanceDate is a rfc3339 formatted datetime. IssuanceDate time.Time `json:"issuanceDate"` // ExpirationDate is a rfc3339 formatted datetime. It is optional ExpirationDate *time.Time `json:"expirationDate,omitempty"` // CredentialStatus holds information on how the credential can be revoked. It is optional CredentialStatus *CredentialStatus `json:"credentialStatus,omitempty"` // CredentialSubject holds the actual data for the credential. It must be extracted using the UnmarshalCredentialSubject method and a custom type. CredentialSubject []interface{} `json:"credentialSubject"` // Proof contains the cryptographic proof(s). It must be extracted using the Proofs method or UnmarshalProofValue method for non-generic proof fields. Proof []interface{} `json:"proof"` }
VerifiableCredential represents a credential as defined by the Verifiable Credentials Data Model 1.0 specification (https://www.w3.org/TR/vc-data-model/).
func (VerifiableCredential) ContainsContext ¶
func (vc VerifiableCredential) ContainsContext(context ssi.URI) bool
ContainsContext returns true when a credential contains the requested context
func (VerifiableCredential) IsType ¶
func (vc VerifiableCredential) IsType(vcType ssi.URI) bool
IsType returns true when a credential contains the requested type
func (VerifiableCredential) MarshalJSON ¶
func (vc VerifiableCredential) MarshalJSON() ([]byte, error)
func (VerifiableCredential) Proofs ¶
func (vc VerifiableCredential) Proofs() ([]Proof, error)
Proofs returns the basic proofs for this credential. For specific proof contents, UnmarshalProofValue must be used.
func (VerifiableCredential) UnmarshalCredentialSubject ¶
func (vc VerifiableCredential) UnmarshalCredentialSubject(target interface{}) error
UnmarshalCredentialSubject unmarshalls the credentialSubject to the given credentialSubject type. Always pass a slice as target.
func (*VerifiableCredential) UnmarshalJSON ¶
func (vc *VerifiableCredential) UnmarshalJSON(b []byte) error
func (VerifiableCredential) UnmarshalProofValue ¶
func (vc VerifiableCredential) UnmarshalProofValue(target interface{}) error
UnmarshalProofValue unmarshalls the proof to the given proof type. Always pass a slice as target since there could be multiple proofs. Each proof will result in a value, where null values may exist when the proof doesn't have the json member.