identity

package
v1.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2023 License: Apache-2.0, BSD-2-Clause Imports: 14 Imported by: 35

Documentation

Overview

Package identity implements a node's identity, consisting out of id and public key. A LocalIdentity additionally contains the private key and enables signing messages.

Index

Constants

View Source
const IDLength = sha256.Size

IDLength defines the length of an ID.

Variables

This section is empty.

Functions

func RegisterIDAlias

func RegisterIDAlias(id ID, alias string)

RegisterIDAlias registers an alias that will modify the String() output of the ID to show a human readable string instead of the base58 encoded version of itself.

func UnregisterIDAliases

func UnregisterIDAliases()

UnregisterIDAliases removes all aliases registered through the RegisterIDAlias function.

Types

type ID

type ID [IDLength]byte

ID is a unique identifier for each peer.

func DecodeIDBase58

func DecodeIDBase58(s string) (ID, error)

DecodeIDBase58 decodes a base58 encoded ID.

func IDFromMarshalUtil

func IDFromMarshalUtil(marshalUtil *marshalutil.MarshalUtil) (id ID, err error)

IDFromMarshalUtil unmarshals an ID using a MarshalUtil (for easier unmarshaling).

func NewID

func NewID(key ed25519.PublicKey) ID

NewID computes the ID corresponding to the given public key.

func ParseID

func ParseID(s string) (ID, error)

ParseID parses a hex encoded ID.

func RandomIDInsecure

func RandomIDInsecure() (id ID, err error)

RandomIDInsecure creates a random id which can for example be used in unit tests. The result is not cryptographically secure.

func (ID) Bytes

func (id ID) Bytes() ([]byte, error)

Bytes returns the byte slice representation of the ID.

func (ID) EncodeBase58

func (id ID) EncodeBase58() string

EncodeBase58 returns a full version of the ID as a base58 encoded string.

func (*ID) FromBytes

func (id *ID) FromBytes(bytes []byte) (consumedBytes int, err error)

FromBytes decodes ID from bytes.

func (ID) String

func (id ID) String() string

String returns a shortened version of the ID as a base58 encoded string.

type Identity

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

LocalIdentity is a node's identity.

func GenerateIdentity

func GenerateIdentity() *Identity

func New

func New(publicKey ed25519.PublicKey) *Identity

New creates a new identity from the given PublicKey.

func Parse

func Parse(marshalUtil *marshalutil.MarshalUtil, optionalTargetObject ...*Identity) (result *Identity, err error)

func (Identity) ID

func (i Identity) ID() ID

func (Identity) PublicKey

func (i Identity) PublicKey() ed25519.PublicKey

type LocalIdentity

type LocalIdentity struct {
	*Identity
	// contains filtered or unexported fields
}

LocalIdentity is a local node's identity.

func GenerateLocalIdentity

func GenerateLocalIdentity() *LocalIdentity

func NewLocalIdentity

func NewLocalIdentity(publicKey ed25519.PublicKey, privateKey ed25519.PrivateKey) *LocalIdentity

NewLocalIdentity creates a new LocalIdentity.

func NewLocalIdentityWithIdentity

func NewLocalIdentityWithIdentity(identity *Identity, privateKey ed25519.PrivateKey) *LocalIdentity

NewLocalIdentityWithIdentity creates a new LocalIdentity with a given LocalIdentity.

func (LocalIdentity) Sign

func (l LocalIdentity) Sign(message []byte) ed25519.Signature

Sign signs the message with the local identity's private key and returns a signature.

Jump to

Keyboard shortcuts

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