did

package
v0.1.3-0...-617a0de Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Context of the DID document
	Context = "https://w3id.org/did/v1"
)

Variables

View Source
var ErrKeyNotFound = errors.New("key not found")

ErrKeyNotFound is returned when key is not found

View Source
var ErrProofNotFound = errors.New("proof not found")

ErrProofNotFound is returned when proof is not found

Functions

func LookupRecipientKeys

func LookupRecipientKeys(didDoc *Doc, serviceType, keyType string) ([]string, bool)

LookupRecipientKeys gets the recipient keys from the did doc which match the given parameters.

Types

type Doc

type Doc struct {
	Context        []string
	ID             string
	PublicKey      []PublicKey
	Service        []Service
	Authentication []VerificationMethod
	Created        *time.Time
	Updated        *time.Time
	Proof          []Proof
}

Doc DID Document definition

func BuildDoc

func BuildDoc(opts ...DocOption) *Doc

BuildDoc creates the DID Doc from options.

func ParseDocument

func ParseDocument(data []byte) (*Doc, error)

ParseDocument creates an instance of DIDDocument by reading a JSON document from bytes

func (*Doc) JSONBytes

func (doc *Doc) JSONBytes() ([]byte, error)

JSONBytes converts document to json bytes

func (*Doc) VerifyProof

func (doc *Doc) VerifyProof(suite signatureSuite) error

VerifyProof verifies document proofs

type DocOption

type DocOption func(opts *Doc)

DocOption provides options to build DID Doc.

func WithAuthentication

func WithAuthentication(auth []VerificationMethod) DocOption

WithAuthentication DID doc Authentication.

func WithCreatedTime

func WithCreatedTime(t time.Time) DocOption

WithCreatedTime DID doc created time.

func WithPublicKey

func WithPublicKey(pubKey []PublicKey) DocOption

WithPublicKey DID doc PublicKey.

func WithService

func WithService(svc []Service) DocOption

WithService DID doc services.

func WithUpdatedTime

func WithUpdatedTime(t time.Time) DocOption

WithUpdatedTime DID doc updated time.

type Proof

type Proof struct {
	Type       string
	Created    *time.Time
	Creator    string
	ProofValue []byte
	Domain     string
	Nonce      []byte
}

Proof is cryptographic proof of the integrity of the DID Document

type PublicKey

type PublicKey struct {
	ID         string
	Type       string
	Controller string
	Value      []byte
}

PublicKey DID doc public key

func LookupPublicKey

func LookupPublicKey(id string, didDoc *Doc) (*PublicKey, bool)

LookupPublicKey returns the public key with the given id from the given DID Doc

type Service

type Service struct {
	ID              string
	Type            string
	Priority        uint
	RecipientKeys   []string
	RoutingKeys     []string
	ServiceEndpoint string
	Properties      map[string]interface{}
}

Service DID doc service

func LookupService

func LookupService(didDoc *Doc, serviceType string) (*Service, bool)

LookupService returns the service from the given DIDDoc matching the given service type.

type VerificationMethod

type VerificationMethod struct {
	PublicKey PublicKey
}

VerificationMethod authentication verification method

Jump to

Keyboard shortcuts

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