Documentation ¶
Overview ¶
Package credential aims to provide a set of tools to work with verifiable credentials. It includes necessary components to parse, verify, issue and sign credentials.
Although the components are designed to be used in a modular way, some provided types and intentionally specific to the Axone Ontology.
Index ¶
Constants ¶
const ( ProofPurposeAssertionMethod = "assertionMethod" ProofPurposeAuthentication = "authentication" )
const (
ClaimToService = "toService"
)
Variables ¶
var ErrKeyAlgorithm = fmt.Errorf("unsupported key algorithm")
var Secp256k1PubKeyFetcher = resolve
Functions ¶
func NewVCError ¶
func NewVCError(message MessageError, detail error) error
Types ¶
type AuthClaim ¶
AuthClaim carries the claims of a verifiable.Credential for authentication purpose.
func (*AuthClaim) From ¶
func (ac *AuthClaim) From(vc *verifiable.Credential) error
type AuthParser ¶
type AuthParser struct {
*DefaultParser
}
AuthParser is a verifiable.Credential parser expected to carry AuthClaim.
func NewAuthParser ¶
func NewAuthParser(documentLoader ld.DocumentLoader) *AuthParser
NewAuthParser creates a new AuthParser using the provided ld.DocumentLoader.
func (*AuthParser) ParseSigned ¶
func (ap *AuthParser) ParseSigned(raw []byte) (*AuthClaim, error)
type Claim ¶
type Claim interface { // From extracts the Claim from a [verifiable.Credential]. From(vc *verifiable.Credential) error }
Claim denotes a claim carried by a verifiable.Credential.
type DefaultParser ¶
type DefaultParser struct {
// contains filtered or unexported fields
}
DefaultParser is a simple verifiable.Credential parser.
func NewDefaultParser ¶
func NewDefaultParser(documentLoader ld.DocumentLoader) *DefaultParser
NewDefaultParser creates a new DefaultParser using the provided ld.DocumentLoader.
func (*DefaultParser) Parse ¶
func (cp *DefaultParser) Parse(raw []byte) (*verifiable.Credential, error)
Parse parses a verifiable.Credential from a raw byte slice.
It does not verify its proof, if you can to check the credential authenticity and integrity use ParseSigned instead.
func (*DefaultParser) ParseSigned ¶
func (cp *DefaultParser) ParseSigned(raw []byte) (*verifiable.Credential, error)
ParseSigned parse and verify the authenticity and integrity of a verifiable.Credential.
type Descriptor ¶
type Descriptor interface { IssuedAt() *time.Time Generate() (*bytes.Buffer, error) ProofPurpose() string }
Descriptor is an interface representing the description of a verifiable credential.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is a verifiable credential generator.
func New ¶
func New(descriptor Descriptor, opts ...Option) *Generator
New allows to Generate a verifiable credential with the given credential descriptor. Example:
vc, err := credential.New( template.NewGovernance("datasetID", "addr", template.WithID[*GovernanceDescriptor]("id")), WithParser(parser), WithSigner(signer) // Signature is optional and Generate a not signed VC if not provided. ).Generate()
func (*Generator) Generate ¶
func (generator *Generator) Generate() (*verifiable.Credential, error)
Generate generates and sign the verifiable.Credential.
type MessageError ¶
type MessageError string
const ( ErrExpired MessageError = "verifiable credential expired" ErrIssued MessageError = "verifiable credential issued in the future" ErrMissingProof MessageError = "missing verifiable credential proof" ErrInvalidProof MessageError = "invalid verifiable credential proof" ErrMalformedSubject MessageError = "malformed verifiable credential subject" ErrExpectSingleClaim MessageError = "expect a single verifiable credential claim" ErrExtractClaim MessageError = "failed to extract claim" ErrParse MessageError = "failed to parse verifiable credential" ErrMalformed MessageError = "malformed verifiable credential" ErrSign MessageError = "failed to sign verifiable credential" ErrNoParser MessageError = "no parser provided" ErrGenerate MessageError = "failed to Generate verifiable credential" )
const ErrAuthClaim MessageError = "invalid auth claim"
type Option ¶
type Option func(*Generator)
Option is a function that configures a Generator.
func WithParser ¶
func WithParser(parser *DefaultParser) Option
func WithSigner ¶
type Parser ¶
type Parser[T Claim] interface { // ParseSigned parse and verify the authenticity and integrity of a [verifiable.Credential] before returning its Claim. ParseSigned(raw []byte) (T, error) }
Parser is a verifiable.Credential parser for a certain type of Claim.
type VDRKeyResolverWithSecp256k1 ¶
type VDRKeyResolverWithSecp256k1 struct {
// contains filtered or unexported fields
}
VDRKeyResolverWithSecp256k1 is a VDR key resolver including a secp256k1 public key fetcher as is not available in the default VDRKeyResolver. It's a hack to include this algorithm in the resolver.
func NewVDRKeyResolverWithSecp256k1 ¶
func NewVDRKeyResolverWithSecp256k1(secp256k1PubKeyFetcher verifiable.PublicKeyFetcher) *VDRKeyResolverWithSecp256k1
func (*VDRKeyResolverWithSecp256k1) PublicKeyFetcher ¶
func (r *VDRKeyResolverWithSecp256k1) PublicKeyFetcher(issuerDID, keyID string) (*verifier.PublicKey, error)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package template provides some predefined descriptors used to issue verifiable credentials, they are compliant with the Axone Ontology.
|
Package template provides some predefined descriptors used to issue verifiable credentials, they are compliant with the Axone Ontology. |