identity

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0, BSD-2-Clause Imports: 10 Imported by: 0

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

This section is empty.

Types

type ID

type ID [IDLength]byte

ID is a unique identifier for each peer.

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 RandomID

func RandomID() (id ID, err error)

RandomID creates a random id which can for example be used in unit tests.

func (ID) Bytes

func (id ID) Bytes() []byte

Bytes returns the byte slice representation of the ID

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