identityprovider

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: Apache-2.0, MIT Imports: 8 Imported by: 23

Documentation

Overview

Package identityprovider defines a default identity provider for IPFS Log and OrbitDB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddIdentityProvider

func AddIdentityProvider(identityProvider func(*CreateIdentityOptions) Interface) error

AddIdentityProvider registers an new identity provider.

func IsSupported

func IsSupported(typeName string) bool

IsSupported checks if an identity type is supported.

func RemoveIdentityProvider

func RemoveIdentityProvider(name string)

RemoveIdentityProvider unregisters an identity provider.

Types

type CborIdentity

type CborIdentity struct {
	ID         string
	PublicKey  string
	Signatures *CborIdentitySignature
	Type       string
}

func (*CborIdentity) ToIdentity

func (c *CborIdentity) ToIdentity(provider Interface) (*Identity, error)

ToIdentity converts a CBOR serializable to a plain Identity object.

type CborIdentitySignature

type CborIdentitySignature struct {
	ID        string
	PublicKey string
}

func (*CborIdentitySignature) ToIdentitySignature

func (c *CborIdentitySignature) ToIdentitySignature() (*IdentitySignature, error)

ToIdentitySignature converts a CBOR serializable identity signature to a plain IdentitySignature.

type CreateIdentityOptions

type CreateIdentityOptions struct {
	IdentityKeysPath string
	Type             string
	Keystore         keystore.Interface
	//Migrate          func(*MigrateOptions) error
	ID string
}

type Identities

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

func (*Identities) CreateIdentity

func (i *Identities) CreateIdentity(options *CreateIdentityOptions) (*Identity, error)

CreateIdentity creates a new Identity.

func (*Identities) Sign

func (i *Identities) Sign(identity *Identity, data []byte) ([]byte, error)

func (*Identities) Verify

func (i *Identities) Verify(signature []byte, publicKey crypto.PubKey, data []byte) (bool, error)

Verify checks a signature.

func (*Identities) VerifyIdentity

func (i *Identities) VerifyIdentity(identity *Identity) error

VerifyIdentity checks an identity.

type Identity

type Identity struct {
	ID         string             `json:"id,omitempty"`
	PublicKey  []byte             `json:"publicKey,omitempty"`
	Signatures *IdentitySignature `json:"signatures,omitempty"`
	Type       string             `json:"type,omitempty"`
	Provider   Interface
}

func CreateIdentity

func CreateIdentity(options *CreateIdentityOptions) (*Identity, error)

CreateIdentity creates a new identity.

func (*Identity) Filtered

func (i *Identity) Filtered() *Identity

Filtered gets fields that should be present in the CBOR representation of identity.

func (*Identity) GetPublicKey

func (i *Identity) GetPublicKey() (ic.PubKey, error)

GetPublicKey returns the public key of an identity.

func (*Identity) ToCborIdentity

func (i *Identity) ToCborIdentity() *CborIdentity

ToCborIdentity converts an identity to a CBOR serializable identity.

type IdentitySignature

type IdentitySignature struct {
	ID        []byte `json:"id,omitempty"`
	PublicKey []byte `json:"publicKey,omitempty"`
}

func (*IdentitySignature) ToCborIdentitySignature

func (i *IdentitySignature) ToCborIdentitySignature() *CborIdentitySignature

ToCborIdentitySignature converts to a CBOR serialized identity signature a plain IdentitySignature.

type Interface

type Interface interface {
	// GetID returns id of identity (to be signed by orbit-db public key).
	GetID(*CreateIdentityOptions) (string, error)

	// SignIdentity returns signature of OrbitDB public key signature.
	SignIdentity(data []byte, id string) ([]byte, error)

	// GetType returns the type for this identity provider.
	GetType() string

	// VerifyIdentity checks an identity.
	VerifyIdentity(identity *Identity) error

	// Sign will sign a value.
	Sign(identity *Identity, bytes []byte) ([]byte, error)

	// UnmarshalPublicKey will provide a crypto.PubKey from a key bytes.
	UnmarshalPublicKey(data []byte) (crypto.PubKey, error)
}

func NewOrbitDBIdentityProvider

func NewOrbitDBIdentityProvider(options *CreateIdentityOptions) Interface

NewOrbitDBIdentityProvider creates a new identity for use with OrbitDB.

type OrbitDBIdentityProvider

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

func (*OrbitDBIdentityProvider) GetID

GetID returns the identity's ID.

func (*OrbitDBIdentityProvider) GetType

func (*OrbitDBIdentityProvider) GetType() string

GetType returns the current identity type.

func (*OrbitDBIdentityProvider) Sign

func (p *OrbitDBIdentityProvider) Sign(identity *Identity, data []byte) ([]byte, error)

Sign signs a value using the current.

func (*OrbitDBIdentityProvider) SignIdentity

func (p *OrbitDBIdentityProvider) SignIdentity(data []byte, id string) ([]byte, error)

SignIdentity signs an OrbitDB identity.

func (*OrbitDBIdentityProvider) UnmarshalPublicKey

func (p *OrbitDBIdentityProvider) UnmarshalPublicKey(data []byte) (crypto.PubKey, error)

func (*OrbitDBIdentityProvider) VerifyIdentity

func (p *OrbitDBIdentityProvider) VerifyIdentity(identity *Identity) error

VerifyIdentity checks an OrbitDB identity.

Jump to

Keyboard shortcuts

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