vc

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 10, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const VCContextV1 = "https://www.w3.org/2018/credentials/v1"

VCContextV1 is the context required for every credential and presentation

View Source
const VerifiableCredentialType = "VerifiableCredential"

VerifiableCredentialType is the default credential type required for every credential

View Source
const VerifiablePresentationType = "VerifiablePresentation"

VerifiablePresentationType is the default credential type required for every credential

Variables

This section is empty.

Functions

func VCContextV1URI

func VCContextV1URI() ssi.URI

VCContextV1URI returns 'https://www.w3.org/2018/credentials/v1' as URI

func VerifiableCredentialTypeV1URI

func VerifiableCredentialTypeV1URI() ssi.URI

VerifiableCredentialTypeV1URI returns VerifiableCredential as URI

func VerifiablePresentationTypeV1URI

func VerifiablePresentationTypeV1URI() ssi.URI

VerifiablePresentationTypeV1URI returns VerifiablePresentation as URI

Types

type CredentialStatus

type CredentialStatus struct {
	ID   url.URL `json:"id"`
	Type string  `json:"type"`
}

CredentialStatus defines the method on how to determine a credential is revoked.

type JSONWebSignature2020Proof

type JSONWebSignature2020Proof struct {
	Proof
	Jws string `json:"jws"`
}

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

type VerifiablePresentation

type VerifiablePresentation struct {
	// Context defines the json-ld context to dereference the URIs
	Context []ssi.URI `json:"@context"`
	// ID is an unique identifier for the presentation. It is optional
	ID *ssi.URI `json:"id,omitempty"`
	// Type holds multiple types for a presentation. A presentation must always have the 'VerifiablePresentation' type.
	Type []ssi.URI `json:"type"`
	// Holder refers to the party that generated the presentation. It is optional
	Holder *ssi.URI `json:"holder,omitempty"`
	// VerifiableCredential may hold credentials that are proven with this presentation.
	VerifiableCredential []VerifiableCredential `json:"verifiableCredential,omitempty"`
	// 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,omitempty"`
}

VerifiablePresentation represents a presentation as defined by the Verifiable Credentials Data Model 1.0 specification (https://www.w3.org/TR/vc-data-model/).

func (VerifiablePresentation) ContainsContext

func (vp VerifiablePresentation) ContainsContext(context ssi.URI) bool

ContainsContext returns true when a credential contains the requested context

func (VerifiablePresentation) IsType

func (vp VerifiablePresentation) IsType(vcType ssi.URI) bool

IsType returns true when a presentation contains the requested type

func (VerifiablePresentation) MarshalJSON

func (vp VerifiablePresentation) MarshalJSON() ([]byte, error)

func (VerifiablePresentation) Proofs

func (vp VerifiablePresentation) Proofs() ([]Proof, error)

Proofs returns the basic proofs for this presentation. For specific proof contents, UnmarshalProofValue must be used.

func (*VerifiablePresentation) UnmarshalJSON

func (vp *VerifiablePresentation) UnmarshalJSON(b []byte) error

func (VerifiablePresentation) UnmarshalProofValue

func (vp VerifiablePresentation) 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL