Documentation
¶
Index ¶
- Constants
- Variables
- func CachingJSONLDLoader() ld.DocumentLoader
- func LookupRecipientKeys(didDoc *Doc, serviceType, keyType string) ([]string, bool)
- type DID
- type Doc
- func (doc *Doc) JSONBytes() ([]byte, error)
- func (doc *Doc) MarshalJSON() ([]byte, error)
- func (doc *Doc) UnmarshalJSON(data []byte) error
- func (doc *Doc) VerificationMethods(customVerificationRelationships ...VerificationRelationship) map[VerificationRelationship][]Verification
- func (doc *Doc) VerifyProof(suites []verifier.SignatureSuite, jsonldOpts ...jsonld.ProcessorOpts) error
- type DocOption
- func WithAssertion(assertion []Verification) DocOption
- func WithAuthentication(auth []Verification) DocOption
- func WithCreatedTime(t time.Time) DocOption
- func WithService(svc []Service) DocOption
- func WithUpdatedTime(t time.Time) DocOption
- func WithVerificationMethod(pubKey []VerificationMethod) DocOption
- type Proof
- type Service
- type Verification
- type VerificationMethod
- type VerificationRelationship
Constants ¶
const (
// Context of the DID document.
Context = "https://w3id.org/did/v1"
)
Variables ¶
var ErrKeyNotFound = errors.New("key not found")
ErrKeyNotFound is returned when key is not found.
var ErrProofNotFound = errors.New("proof not found")
ErrProofNotFound is returned when proof is not found.
Functions ¶
func CachingJSONLDLoader ¶ added in v0.1.4
func CachingJSONLDLoader() ld.DocumentLoader
CachingJSONLDLoader creates JSON-LD CachingDocumentLoader with preloaded base JSON-LD DID and security contexts.
Types ¶
type DID ¶ added in v0.1.3
type DID struct {
Scheme string // Scheme is always "did"
Method string // Method is the specific DID methods
MethodSpecificID string // MethodSpecificID is the unique ID computed or assigned by the DID method
}
DID is parsed according to the generic syntax: https://w3c.github.io/did-core/#generic-did-syntax
func Parse ¶ added in v0.1.3
Parse parses the string according to the generic DID syntax. See https://w3c.github.io/did-core/#generic-did-syntax.
type Doc ¶
type Doc struct {
Context []string
ID string
VerificationMethod []VerificationMethod
Service []Service
Authentication []Verification
AssertionMethod []Verification
CapabilityDelegation []Verification
CapabilityInvocation []Verification
KeyAgreement []Verification
Created *time.Time
Updated *time.Time
Proof []Proof
// contains filtered or unexported fields
}
Doc DID Document definition.
func ParseDocument ¶
ParseDocument creates an instance of DIDDocument by reading a JSON document from bytes.
func (*Doc) MarshalJSON ¶ added in v0.1.5
MarshalJSON marshals the DID Document.
func (*Doc) UnmarshalJSON ¶ added in v0.1.5
UnmarshalJSON unmarshals a DID Document.
func (*Doc) VerificationMethods ¶ added in v0.1.3
func (doc *Doc) VerificationMethods(customVerificationRelationships ...VerificationRelationship) map[VerificationRelationship][]Verification
VerificationMethods returns verification methods of DID Doc of certain relationship. If customVerificationRelationships is empty, all verification methods are returned. Public keys which are not referred by any verification method are put into special VerificationRelationshipGeneral relationship category. nolint:gocyclo
func (*Doc) VerifyProof ¶
func (doc *Doc) VerifyProof(suites []verifier.SignatureSuite, jsonldOpts ...jsonld.ProcessorOpts) error
VerifyProof verifies document proofs.
type DocOption ¶
type DocOption func(opts *Doc)
DocOption provides options to build DID Doc.
func WithAssertion ¶ added in v0.1.5
func WithAssertion(assertion []Verification) DocOption
WithAssertion sets the verification methods for assertion: https://w3c.github.io/did-core/#assertionmethod.
func WithAuthentication ¶
func WithAuthentication(auth []Verification) DocOption
WithAuthentication sets the verification methods for authentication: https://w3c.github.io/did-core/#authentication.
func WithCreatedTime ¶
WithCreatedTime DID doc created time.
func WithUpdatedTime ¶
WithUpdatedTime DID doc updated time.
func WithVerificationMethod ¶ added in v0.1.5
func WithVerificationMethod(pubKey []VerificationMethod) DocOption
WithVerificationMethod DID doc VerificationMethod.
type Proof ¶
type Proof struct {
Type string
Created *time.Time
Creator string
ProofValue []byte
Domain string
Nonce []byte
ProofPurpose string
// contains filtered or unexported fields
}
Proof is cryptographic proof of the integrity of the DID Document.
type Service ¶
type Service struct {
ID string
Type string
Priority uint
RecipientKeys []string
RoutingKeys []string
ServiceEndpoint string
Properties map[string]interface{}
// contains filtered or unexported fields
}
Service DID doc service.
type Verification ¶ added in v0.1.5
type Verification struct {
VerificationMethod VerificationMethod
Relationship VerificationRelationship
Embedded bool
}
Verification authentication verification.
func NewEmbeddedVerification ¶ added in v0.1.5
func NewEmbeddedVerification(vm *VerificationMethod, r VerificationRelationship) *Verification
NewEmbeddedVerification creates a new verification method with embedded verification method.
func NewReferencedVerification ¶ added in v0.1.5
func NewReferencedVerification(vm *VerificationMethod, r VerificationRelationship) *Verification
NewReferencedVerification creates a new verification method with referenced verification method.
type VerificationMethod ¶
type VerificationMethod struct {
ID string
Type string
Controller string
Value []byte
// contains filtered or unexported fields
}
VerificationMethod DID doc verification method. The value of the verification method is defined either as raw public key bytes (Value field) or as JSON Web Key. In the first case the Type field can hold additional information to understand the nature of the raw public key.
func LookupPublicKey ¶ added in v0.1.1
func LookupPublicKey(id string, didDoc *Doc) (*VerificationMethod, bool)
LookupPublicKey returns the public key with the given id from the given DID Doc.
func NewVerificationMethodFromBytes ¶ added in v0.1.5
func NewVerificationMethodFromBytes(id, kType, controller string, value []byte) *VerificationMethod
NewVerificationMethodFromBytes creates a new VerificationMethod based on raw public key bytes.
func NewVerificationMethodFromJWK ¶ added in v0.1.5
func NewVerificationMethodFromJWK(id, kType, controller string, jwk *jose.JWK) (*VerificationMethod, error)
NewVerificationMethodFromJWK creates a new VerificationMethod based on JSON Web Key.
func (*VerificationMethod) JSONWebKey ¶ added in v0.1.5
func (pk *VerificationMethod) JSONWebKey() *jose.JWK
JSONWebKey returns JSON Web key if defined.
type VerificationRelationship ¶ added in v0.1.3
type VerificationRelationship int
VerificationRelationship defines a verification relationship between DID subject and a verification method.
const ( // VerificationRelationshipGeneral is a special case of verification relationship: when a verification method // defined in Verification is not used by any Verification. VerificationRelationshipGeneral VerificationRelationship = iota // Authentication defines verification relationship. Authentication // AssertionMethod defines verification relationship. AssertionMethod // CapabilityDelegation defines verification relationship. CapabilityDelegation // CapabilityInvocation defines verification relationship. CapabilityInvocation // KeyAgreement defines verification relationship. KeyAgreement )