verifiable

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: Apache-2.0 Imports: 12 Imported by: 115

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credential

type Credential struct {
	Context        []string
	CustomContext  []interface{}
	ID             string
	Types          []string
	Subject        Subject
	Issuer         Issuer
	Issued         *time.Time
	Expired        *time.Time
	Proof          *Proof
	Status         *TypedID
	Schemas        []TypedID
	Evidence       *Evidence
	TermsOfUse     []TypedID
	RefreshService *TypedID

	ExtraFields ExtraFields
}

Credential Verifiable Credential definition

func NewCredential

func NewCredential(vcData []byte, opts ...CredentialOpt) (*Credential, error)

NewCredential creates an instance of Verifiable Credential by reading a JSON document from bytes. It also applies miscellaneous options like custom decoders or settings of schema validation.

func (*Credential) JWTClaims

func (vc *Credential) JWTClaims(minimizeVC bool) (*JWTCredClaims, error)

JWTClaims converts Verifiable Credential into JWT Credential claims, which can be than serialized e.g. into JWS.

func (*Credential) MarshalJSON

func (vc *Credential) MarshalJSON() ([]byte, error)

MarshalJSON converts Verifiable Credential to JSON bytes

func (*Credential) SubjectID

func (vc *Credential) SubjectID() (string, error)

SubjectID gets ID of single subject if present or returns error if there are several subjects or one without ID defined

type CredentialDecoder

type CredentialDecoder func(dataJSON []byte, vc *Credential) error

CredentialDecoder makes a custom decoding of Verifiable Credential in JSON form to existent instance of Credential.

type CredentialOpt

type CredentialOpt func(opts *credentialOpts)

CredentialOpt is the Verifiable Credential decoding option

func WithDecoders

func WithDecoders(decoders []CredentialDecoder) CredentialOpt

WithDecoders option is for adding extra JSON decoders into Verifiable Credential data model.

func WithNoCustomSchemaCheck

func WithNoCustomSchemaCheck() CredentialOpt

WithNoCustomSchemaCheck option is for disabling of Credential Schemas download if defined in Verifiable Credential. Instead, the Verifiable Credential is checked against default Schema.

func WithPublicKeyFetcher

func WithPublicKeyFetcher(fetcher PublicKeyFetcher) CredentialOpt

WithPublicKeyFetcher set public key fetcher used when decoding from JWS.

func WithSchemaDownloadClient

func WithSchemaDownloadClient(client *http.Client) CredentialOpt

WithSchemaDownloadClient option is for definition of HTTP(s) client used during decoding of Verifiable Credential. If custom credentialSchema is defined in Verifiable Credential, the client downloads from the specified URL.

func WithTemplate

func WithTemplate(template CredentialTemplate) CredentialOpt

WithTemplate option is for setting a custom factory method to create new Credential instance.

type CredentialTemplate

type CredentialTemplate func() *Credential

CredentialTemplate defines a factory method to create new Credential template.

type Evidence

type Evidence interface{}

Evidence defines evidence of Verifiable Credential

type ExtraFields

type ExtraFields map[string]interface{}

ExtraFields is a map of extra fields of struct build when unmarshalling JSON which are not mapped to the struct fields.

type Issuer

type Issuer struct {
	ID   string
	Name string
}

Issuer of the Verifiable Credential

type JWSAlgorithm

type JWSAlgorithm int

JWSAlgorithm defines JWT signature algorithms of Verifiable Credential

const (
	// RS256 JWT Algorithm
	RS256 JWSAlgorithm = iota

	// EdDSA JWT Algorithm
	EdDSA
)

type JWTCredClaims

type JWTCredClaims struct {
	*jwt.Claims

	VC map[string]interface{} `json:"vc,omitempty"`
}

JWTCredClaims is JWT Claims extension by Verifiable Credential (with custom "vc" claim).

func (*JWTCredClaims) MarshalJWS

func (jcc *JWTCredClaims) MarshalJWS(signatureAlg JWSAlgorithm, privateKey interface{}, keyID string) (string, error)

MarshalJWS serializes JWT into signed form (JWS) todo refactor, do not pass privateKey (https://github.com/hyperledger/aries-framework-go/issues/339)

func (*JWTCredClaims) MarshalUnsecuredJWT

func (jcc *JWTCredClaims) MarshalUnsecuredJWT() (string, error)

MarshalUnsecuredJWT serialized JWT into unsecured JWT.

type JWTCredClaimsUnmarshaller

type JWTCredClaimsUnmarshaller func(vcJWTBytes []byte) (*JWTCredClaims, error)

JWTCredClaimsUnmarshaller unmarshals verifiable credential bytes into JWT claims with extra "vc" claim.

type JWTPresClaims

type JWTPresClaims struct {
	*jwt.Claims

	Presentation *rawPresentation `json:"vp,omitempty"`
}

JWTPresClaims is JWT Claims extension by Verifiable Presentation (with custom "vp" claim).

func (*JWTPresClaims) MarshalJWS

func (jpc *JWTPresClaims) MarshalJWS(signatureAlg JWSAlgorithm, privateKey interface{}, keyID string) (string, error)

MarshalJWS serializes JWT presentation claims into signed form (JWS) todo refactor, do not pass privateKey (https://github.com/hyperledger/aries-framework-go/issues/339)

func (*JWTPresClaims) MarshalUnsecuredJWT

func (jpc *JWTPresClaims) MarshalUnsecuredJWT() (string, error)

MarshalUnsecuredJWT serializes JWT presentation claims into unsecured JWT.

type JWTPresClaimsUnmarshaller

type JWTPresClaimsUnmarshaller func(vpJWTBytes []byte) (*JWTPresClaims, error)

JWTPresClaimsUnmarshaller parses JWT of certain type to JWT Claims containing "vp" (Presentation) claim.

type Presentation

type Presentation struct {
	Context        []interface{}
	ID             string
	Type           interface{}
	Credential     interface{}
	Holder         string
	Proof          Proof
	RefreshService *TypedID
}

Presentation Verifiable Presentation base data model definition

func NewPresentation

func NewPresentation(vpData []byte, opts ...PresentationOpt) (*Presentation, error)

NewPresentation creates an instance of Verifiable Presentation by reading a JSON document from bytes. It also applies miscellaneous options like custom decoders or settings of schema validation.

func (*Presentation) Credentials

func (vp *Presentation) Credentials() ([]PresentationCredential, error)

Credentials provides Verifiable Credentials enclosed into Presentation in raw byte array format.

func (*Presentation) JWTClaims

func (vp *Presentation) JWTClaims(audience []string, minimizeVP bool) *JWTPresClaims

JWTClaims converts Verifiable Presentation into JWT Presentation claims, which can be than serialized e.g. into JWS.

func (*Presentation) MarshalJSON

func (vp *Presentation) MarshalJSON() ([]byte, error)

MarshalJSON converts Verifiable Presentation to JSON bytes.

type PresentationCredential

type PresentationCredential []byte

PresentationCredential defines raw Verifiable Credential enclosed into Presentation.

type PresentationOpt

type PresentationOpt func(opts *presentationOpts)

PresentationOpt is the Verifiable Presentation decoding option

func WithPresPublicKeyFetcher

func WithPresPublicKeyFetcher(fetcher PublicKeyFetcher) PresentationOpt

WithPresPublicKeyFetcher indicates that Verifiable Presentation should be decoded from JWS using the public key fetcher.

func WithPresSkippedEmbeddedProofCheck

func WithPresSkippedEmbeddedProofCheck() PresentationOpt

WithPresSkippedEmbeddedProofCheck tells to skip a check of embedded proof presence.

type Proof

type Proof interface{}

Proof defines embedded proof of Verifiable Credential

type PublicKeyFetcher

type PublicKeyFetcher func(issuerID, keyID string) (interface{}, error)

PublicKeyFetcher fetches public key for JWT signing verification based on Issuer ID (possibly DID) and Key ID. If not defined, JWT encoding is not tested.

func SingleKey

func SingleKey(pubKey interface{}) PublicKeyFetcher

SingleKey defines the case when only one verification key is used and we don't need to pick the one.

type Subject

type Subject interface{}

Subject of the Verifiable Credential

type TypedID

type TypedID struct {
	ID   string `json:"id,omitempty"`
	Type string `json:"type,omitempty"`

	ExtraFields `json:"-"`
}

TypedID defines a flexible structure with id and name fields and arbitrary extra fields kept in ExtraFields.

func (*TypedID) MarshalJSON

func (tid *TypedID) MarshalJSON() ([]byte, error)

MarshalJSON defines custom marshalling of TypedID to JSON.

func (*TypedID) UnmarshalJSON

func (tid *TypedID) UnmarshalJSON(data []byte) error

UnmarshalJSON defines custom unmarshalling of TypedID from JSON.

Jump to

Keyboard shortcuts

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