signing

package
v1.6.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ATX Domain = 0

	PROPOSAL = 1
	BALLOT   = 2
	HARE     = 3
	POET     = 4

	BEACON_FIRST_MSG    = 10
	BEACON_FOLLOWUP_MSG = 11
)
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 []byte, sig types.VrfSignature) bool

VRFVerify verifies that a signature matches public key and message.

Types

type Domain added in v1.0.0

type Domain byte

func (Domain) String added in v1.0.0

func (d Domain) String() string

String returns the string representation of a domain.

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) Matches added in v1.4.0

func (es *EdSigner) Matches(x any) bool

Matches implements the gomock.Matcher interface for testing.

func (*EdSigner) Name added in v1.4.0

func (es *EdSigner) Name() string

Name returns the name of the signer. This is the filename of the identity file.

func (*EdSigner) NodeID added in v1.0.0

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

NodeID returns the node ID of the signer.

func (*EdSigner) Prefix added in v1.0.0

func (es *EdSigner) Prefix() []byte

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(d Domain, m []byte) types.EdSignature

Sign signs the provided message.

func (*EdSigner) String added in v1.4.0

func (es *EdSigner) String() string

func (*EdSigner) VRFSigner added in v1.0.0

func (es *EdSigner) VRFSigner() *VRFSigner

VRFSigner wraps same ed25519 key to provide ecvrf.

type EdSignerOptionFunc added in v1.0.0

type EdSignerOptionFunc func(*edSignerOption) error

EdSignerOptionFunc modifies EdSigner.

func FromFile added in v1.4.0

func FromFile(path string) EdSignerOptionFunc

FromFile loads the private key from a file.

func ToFile added in v1.4.2

func ToFile(path string) EdSignerOptionFunc

ToFile writes the private key to a file after creation.

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 EdVerifier added in v1.0.0

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

EdVerifier extracts public keys from signatures.

func NewEdVerifier added in v1.0.0

func NewEdVerifier(opts ...VerifierOptionFunc) *EdVerifier

func (*EdVerifier) Verify added in v1.0.0

func (es *EdVerifier) Verify(d Domain, nodeID types.NodeID, m []byte, sig types.EdSignature) bool

Verify verifies that a signature matches public key and message.

type PrivateKey added in v1.0.0

type PrivateKey = ed25519.PrivateKey

PrivateKey is an alias to ed25519.PrivateKey.

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 if 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) 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) types.VrfSignature

Sign signs a message for VRF purposes.

type VRFVerifier added in v1.0.0

type VRFVerifier func(types.NodeID, []byte, types.VrfSignature) 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 []byte, sig types.VrfSignature) bool

Verify verifies that a signature matches public key and message.

type VerifierOptionFunc added in v1.0.0

type VerifierOptionFunc func(*edVerifierOption)

VerifierOptionFunc to modify verifier.

func WithVerifierPrefix added in v1.0.0

func WithVerifierPrefix(prefix []byte) VerifierOptionFunc

WithVerifierPrefix sets the prefix used by PubKeyVerifier. This usually is the Network ID.

Jump to

Keyboard shortcuts

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