did

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDID       = errors.New("invalid DID")
	ErrInvalidKeyType   = errors.New("invalid key type")
	ErrInvalidSignature = errors.New("signature verification failed")
	ErrNoProvider       = errors.New("no provider")
	ErrNoAnchorMethod   = errors.New("no anchor method")
	ErrHardwareKey      = errors.New("hardware key")

	ErrTODO = errors.New("TODO")
)

Functions

func FormatKeyURI

func FormatKeyURI(pubk crypto.PubKey) string

func ParseKeyURI

func ParseKeyURI(uri string) (crypto.PubKey, error)

func PublicKeyFromDID

func PublicKeyFromDID(did DID) (crypto.PubKey, error)

Types

type Anchor

type Anchor interface {
	DID() DID
	Verify(data []byte, sig []byte) error
	PublicKey() crypto.PubKey
}

Anchor is a DID anchor that encapsulates a public key that can be used for verification of signatures.

func AnchorFromPublicKey

func AnchorFromPublicKey(pubk crypto.PubKey) (Anchor, error)

func GetAnchorForDID

func GetAnchorForDID(did DID) (Anchor, error)

func NewAnchor

func NewAnchor(did DID, pubk crypto.PubKey) Anchor

type BasicTrustContext

type BasicTrustContext struct {
	// contains filtered or unexported fields
}

func (*BasicTrustContext) AddAnchor

func (ctx *BasicTrustContext) AddAnchor(anchor Anchor)

func (*BasicTrustContext) AddProvider

func (ctx *BasicTrustContext) AddProvider(provider Provider)

func (*BasicTrustContext) Anchors

func (ctx *BasicTrustContext) Anchors() []DID

func (*BasicTrustContext) GetAnchor

func (ctx *BasicTrustContext) GetAnchor(did DID) (Anchor, error)

func (*BasicTrustContext) GetProvider

func (ctx *BasicTrustContext) GetProvider(did DID) (Provider, error)

func (*BasicTrustContext) Providers

func (ctx *BasicTrustContext) Providers() []DID

func (*BasicTrustContext) Start

func (ctx *BasicTrustContext) Start(gcInterval time.Duration)

func (*BasicTrustContext) Stop

func (ctx *BasicTrustContext) Stop()

type DID

type DID struct {
	URI string `json:"uri,omitempty"`
}

func FromID

func FromID(id crypto.ID) (DID, error)

func FromPublicKey

func FromPublicKey(pubk crypto.PubKey) DID

func FromString

func FromString(s string) (DID, error)

func (DID) Empty

func (did DID) Empty() bool

func (DID) Equal

func (did DID) Equal(other DID) bool

func (DID) Identifier

func (did DID) Identifier() string

func (DID) Method

func (did DID) Method() string

func (DID) String

func (did DID) String() string

type GetAnchorFunc

type GetAnchorFunc func(did DID) (Anchor, error)

type LedgerKeyOutput

type LedgerKeyOutput struct {
	Key     string `json:"key"`
	Address string `json:"address"`
}

type LedgerSignECDSAOutput

type LedgerSignECDSAOutput struct {
	V uint   `json:"v"`
	R string `json:"r"`
	S string `json:"s"`
}

type LedgerSignOutput

type LedgerSignOutput struct {
	ECDSA LedgerSignECDSAOutput `json:"ecdsa"`
}

type LedgerWalletProvider

type LedgerWalletProvider struct {
	// contains filtered or unexported fields
}

func (*LedgerWalletProvider) Anchor

func (p *LedgerWalletProvider) Anchor() Anchor

func (*LedgerWalletProvider) DID

func (p *LedgerWalletProvider) DID() DID

func (*LedgerWalletProvider) PrivateKey

func (p *LedgerWalletProvider) PrivateKey() (crypto.PrivKey, error)

func (*LedgerWalletProvider) Sign

func (p *LedgerWalletProvider) Sign(data []byte) ([]byte, error)

type PrivateKeyProvider

type PrivateKeyProvider struct {
	// contains filtered or unexported fields
}

func (*PrivateKeyProvider) Anchor

func (p *PrivateKeyProvider) Anchor() Anchor

func (*PrivateKeyProvider) DID

func (p *PrivateKeyProvider) DID() DID

func (*PrivateKeyProvider) PrivateKey

func (p *PrivateKeyProvider) PrivateKey() (crypto.PrivKey, error)

func (*PrivateKeyProvider) Sign

func (p *PrivateKeyProvider) Sign(data []byte) ([]byte, error)

type Provider

type Provider interface {
	DID() DID
	Sign(data []byte) ([]byte, error)
	Anchor() Anchor
	PrivateKey() (crypto.PrivKey, error)
}

Provider holds the private key material necessary to sign statements for a DID.

func NewLedgerWalletProvider

func NewLedgerWalletProvider(acct int) (Provider, error)

func NewProvider

func NewProvider(did DID, privk crypto.PrivKey) Provider

func ProviderFromPrivateKey

func ProviderFromPrivateKey(privk crypto.PrivKey) (Provider, error)

type PublicKeyAnchor

type PublicKeyAnchor struct {
	// contains filtered or unexported fields
}

func (*PublicKeyAnchor) DID

func (a *PublicKeyAnchor) DID() DID

func (*PublicKeyAnchor) PublicKey

func (a *PublicKeyAnchor) PublicKey() crypto.PubKey

func (*PublicKeyAnchor) Verify

func (a *PublicKeyAnchor) Verify(data []byte, sig []byte) error

type TrustContext

type TrustContext interface {
	Anchors() []DID
	Providers() []DID
	GetAnchor(did DID) (Anchor, error)
	GetProvider(did DID) (Provider, error)
	AddAnchor(anchor Anchor)
	AddProvider(provider Provider)

	Start(gcInterval time.Duration)
	Stop()
}

func NewTrustContext

func NewTrustContext() TrustContext

func NewTrustContextWithPrivateKey

func NewTrustContextWithPrivateKey(privk crypto.PrivKey) (TrustContext, error)

func NewTrustContextWithProvider

func NewTrustContextWithProvider(p Provider) TrustContext

Jump to

Keyboard shortcuts

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