signing

package
v0.2.19-beta.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

View Source
const PrivateKeySize = ed25519.PrivateKeySize

PrivateKeySize size of the private key in bytes.

Variables

View Source
var DefaultVerifier = EDVerifier{}

DefaultVerifier used by ExtractPublicKey.

Functions

func ExtractPublicKey

func ExtractPublicKey(msg, sig []byte) (ed25519.PublicKey, error)

ExtractPublicKey using DefaultVerifier Extract method.

func Public added in v1.0.0

func Public(priv PrivateKey) ed25519.PublicKey

Public returns public key part from ed25519 private key.

func VRFVerify added in v0.1.34

func VRFVerify(pub, msg, sig []byte) bool

VRFVerify verifies a message and signature, given a public key.

Types

type EDVerifier

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

EDVerifier is a verifier for ED purposes.

func NewEDVerifier

func NewEDVerifier(opts ...VerifierOpt) EDVerifier

NewEDVerifier returns a new EDVerifier.

func (EDVerifier) Extract

func (e EDVerifier) Extract(msg, sig []byte) (*PublicKey, error)

Extract public key from signature.

type EdSigner

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

EdSigner represents an ED25519 signer.

func NewEdSigner

func NewEdSigner(opts ...SignerOpt) *EdSigner

NewEdSigner returns an auto-generated ed signer.

func NewEdSignerFromBuffer

func NewEdSignerFromBuffer(buff []byte, opts ...SignerOpt) (*EdSigner, error)

NewEdSignerFromBuffer builds a signer from a private key as byte buffer.

func NewEdSignerFromRand

func NewEdSignerFromRand(rand io.Reader) *EdSigner

NewEdSignerFromRand generate signer using predictable randomness source.

func (*EdSigner) LittleEndian

func (es *EdSigner) LittleEndian() bool

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

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) ToBuffer

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

ToBuffer returns the private key as a byte buffer.

func (*EdSigner) VRFSigner added in v1.0.0

func (es *EdSigner) VRFSigner() *VRFSigner

VRFSigner wraps same ed25519 key to provide ecvrf.

type PrivateKey added in v1.0.0

type PrivateKey = ed25519.PrivateKey

PrivateKey is an alias to spacemeshos/ed25519.PrivateKey.

type PublicKey

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

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 Signer

type Signer interface {
	Sign([]byte) []byte
	PublicKey() *PublicKey
	LittleEndian() bool
}

Signer is a common interface for signature generation.

type SignerOpt

type SignerOpt func(*EdSigner)

SignerOpt modifies EdSigner.

func WithSignerPrefix

func WithSignerPrefix(prefix []byte) SignerOpt

WithSignerPrefix sets used by EdSigner.

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) 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 struct{}

VRFVerifier is a verifier for VRF purposes.

func (VRFVerifier) Verify added in v1.0.0

func (VRFVerifier) Verify(pub *PublicKey, msg, sig []byte) bool

Verify that signature matches public key.

type Verifier

type Verifier interface {
	Verify(pub *PublicKey, msg, sig []byte) bool
}

Verifier is a common interface for signature verification.

type VerifierOpt

type VerifierOpt func(*EDVerifier)

VerifierOpt to modify verifier.

func WithVerifierPrefix added in v1.0.0

func WithVerifierPrefix(prefix []byte) VerifierOpt

WithVerifierPrefix ...

type VerifyExtractor

type VerifyExtractor interface {
	Extract(msg, sig []byte) (*PublicKey, error)
}

VerifyExtractor is a common interface for signature verification with support of public key extraction.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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