memory

package
v0.2300.8 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 7 Imported by: 7

Documentation

Overview

Package memory provides a memory backed Signer, primarily for use in testing.

Index

Constants

View Source
const (
	// SignerName is the name used to identify the memory backed signer.
	SignerName = "memory"

	// SeedSize is the size of an RFC 8032 seed in bytes.
	SeedSize = ed25519.SeedSize

	// StaticEntropySize is the size of the provided static entropy.
	StaticEntropySize = 32
)

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() signature.SignerFactory

NewFactory creates a new Factory.

func NewFromRuntime

func NewFromRuntime(rtPrivKey goEd25519.PrivateKey) signature.Signer

NewFromRuntime creates a new signer from a runtime private key.

func NewFromSeed added in v0.2102.0

func NewFromSeed(seed []byte) (signature.Signer, error)

NewFromSeed creates a new signer from a RFC 8032 seed.

func NewSigner

func NewSigner(entropy io.Reader) (signature.Signer, error)

NewSigner creates a new signer.

func NewTestSigner

func NewTestSigner(name string) signature.Signer

NewTestSigner generates a new signer deterministically from a test key name string, registers it as a test key, and returns the signer.

This routine will panic on failure.

Types

type Factory

type Factory struct{}

Factory is a memory backed SignerFactory.

func (*Factory) EnsureRole

func (fac *Factory) EnsureRole(signature.SignerRole) error

EnsureRole is a no-op for testing expedience.

func (*Factory) Generate

func (fac *Factory) Generate(role signature.SignerRole, rng io.Reader) (signature.Signer, error)

Generate will generate a new private key and return a Signer ready for use, using entropy from `rng`.

func (*Factory) Load

Load will return an error, as the factory does not support persistence.

type Signer

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

Signer is a memory backed Signer.

func (*Signer) ContextSign

func (s *Signer) ContextSign(context signature.Context, message []byte) ([]byte, error)

ContextSign generates a signature with the private key over the context and message.

func (*Signer) Prove added in v0.2200.0

func (s *Signer) Prove(alphaString []byte) ([]byte, error)

Prove generates a VRF proof with the private key over the alpha.

func (*Signer) Public

func (s *Signer) Public() signature.PublicKey

Public returns the PublicKey corresponding to the signer.

func (*Signer) Reset

func (s *Signer) Reset()

Reset tears down the Signer and obliterates any sensitive state if any.

func (*Signer) StaticEntropy added in v0.2200.0

func (s *Signer) StaticEntropy() ([]byte, error)

StaticEntropy returns PrivateKeySize bytes of cryptographic entropy that is independent from the Signer's private key. The value of this entropy is constant for the lifespan of the signer's underlying key pair.

func (*Signer) String

func (s *Signer) String() string

String returns anything but the actual private key backing the Signer.

func (*Signer) UnsafeBytes

func (s *Signer) UnsafeBytes() []byte

UnsafeBytes returns the byte representation of the private key. This MUST be removed for HSM support.

func (*Signer) UnsafeSetRole added in v0.2200.0

func (s *Signer) UnsafeSetRole(role signature.SignerRole)

UnsafeSetRole force-sets the role of the signer.

Jump to

Keyboard shortcuts

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