signing

package
v0.2.22-beta.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const PrivateKeySize = ed25519.PrivateKeySize

PrivateKeySize size of the private key in bytes.

Variables

This section is empty.

Functions

func Public added in v1.0.0

func Public(priv PrivateKey) ed25519.PublicKey

func VRFVerify added in v0.1.34

func VRFVerify(nodeID types.NodeID, msg, sig []byte) bool

VRFVerify verifies that a signature matches public key and message.

Types

type EdSigner

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

EdSigner represents an ED25519 signer.

func NewEdSigner

func NewEdSigner(opts ...EdSignerOptionFunc) (*EdSigner, error)

NewEdSigner returns an auto-generated ed signer.

func (*EdSigner) NodeID added in v1.0.0

func (es *EdSigner) NodeID() types.NodeID

NodeID returns the node ID of the signer.

func (*EdSigner) PrivateKey added in v1.0.0

func (es *EdSigner) PrivateKey() PrivateKey

PrivateKey returns private key.

func (*EdSigner) PublicKey

func (es *EdSigner) PublicKey() *PublicKey

PublicKey returns the public key of the signer.

func (*EdSigner) Sign

func (es *EdSigner) Sign(m []byte) []byte

Sign signs the provided message.

func (*EdSigner) VRFSigner added in v1.0.0

func (es *EdSigner) VRFSigner() (*VRFSigner, error)

VRFSigner wraps same ed25519 key to provide ecvrf.

type EdSignerOptionFunc added in v1.0.0

type EdSignerOptionFunc func(*edSignerOption) error

EdSignerOptionFunc modifies EdSigner.

func WithKeyFromRand added in v1.0.0

func WithKeyFromRand(rand io.Reader) EdSignerOptionFunc

WithKeyFromRand sets the private key used by EdSigner using predictable randomness source.

func WithPrefix added in v1.0.0

func WithPrefix(prefix []byte) EdSignerOptionFunc

WithPrefix sets the prefix used by EdSigner. This usually is the Network ID.

func WithPrivateKey added in v1.0.0

func WithPrivateKey(priv PrivateKey) EdSignerOptionFunc

WithPrivateKey sets the private key used by EdSigner.

type ExtractorOptionFunc

type ExtractorOptionFunc func(*edExtractorOption) error

ExtractorOptionFunc to modify verifier.

func WithExtractorPrefix

func WithExtractorPrefix(prefix []byte) ExtractorOptionFunc

WithExtractorPrefix sets the prefix used by PubKeyExtractor. This usually is the Network ID.

type PrivateKey added in v1.0.0

type PrivateKey = ed25519.PrivateKey

PrivateKey is an alias to spacemeshos/ed25519.PrivateKey.

type PubKeyExtractor

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

PubKeyExtractor extracts public keys from signatures.

func NewPubKeyExtractor

func NewPubKeyExtractor(opts ...ExtractorOptionFunc) (*PubKeyExtractor, error)

NewPubKeyExtractor returns a new PubKeyExtractor.

func (PubKeyExtractor) Extract

func (e PubKeyExtractor) Extract(m, sig []byte) (*PublicKey, error)

Extract public key from a signature.

func (PubKeyExtractor) ExtractNodeID

func (e PubKeyExtractor) ExtractNodeID(m, sig []byte) (types.NodeID, error)

ExtractNodeID from a signature.

type PublicKey

type PublicKey struct {
	ed25519.PublicKey
}

PublicKey is the type describing a public key.

func NewPublicKey

func NewPublicKey(pub []byte) *PublicKey

NewPublicKey constructs a new public key instance from a byte array.

func (*PublicKey) Bytes

func (p *PublicKey) Bytes() []byte

Bytes returns the public key as byte array.

func (*PublicKey) Equals

func (p *PublicKey) Equals(o *PublicKey) bool

Equals returns true iff the public keys are equal.

func (*PublicKey) Field added in v0.1.15

func (p *PublicKey) Field() log.Field

Field returns a log field. Implements the LoggableField interface.

func (*PublicKey) ShortString

func (p *PublicKey) ShortString() string

ShortString returns a representative sub string.

func (*PublicKey) String

func (p *PublicKey) String() string

String returns the public key as a hex representation string.

type VRFSigner added in v0.1.34

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

VRFSigner is a signer for VRF purposes.

func (VRFSigner) LittleEndian added in v1.0.0

func (s VRFSigner) LittleEndian() bool

LittleEndian indicates whether byte order in a signature is little-endian.

func (VRFSigner) NodeID added in v1.0.0

func (s VRFSigner) NodeID() types.NodeID

NodeID of the signer.

func (VRFSigner) PublicKey added in v1.0.0

func (s VRFSigner) PublicKey() *PublicKey

PublicKey of the signer.

func (VRFSigner) Sign added in v0.1.34

func (s VRFSigner) Sign(msg []byte) []byte

Sign signs a message for VRF purposes.

type VRFVerifier added in v1.0.0

type VRFVerifier func(types.NodeID, []byte, []byte) bool

func NewVRFVerifier added in v1.0.0

func NewVRFVerifier() VRFVerifier

func (VRFVerifier) Verify added in v1.0.0

func (v VRFVerifier) Verify(nodeID types.NodeID, msg, sig []byte) bool

Verify verifies that a signature matches public key and message.

Jump to

Keyboard shortcuts

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