signing

package
v0.1.0-alpha4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package signing provides all functionality within arrebato regarding message signing. This includes both gRPC, raft and data store interactions.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoPublicKey is the error given when requesting a public key that does not exist.
	ErrNoPublicKey = errors.New("no public key")

	// ErrPublicKeyExists is the error given when performing an operation that would overwrite an existing
	// public key.
	ErrPublicKeyExists = errors.New("public key exists")
)

Functions

func NewKeyPair

func NewKeyPair() (public []byte, private []byte, err error)

NewKeyPair generates a new public/private key pair for message signing.

func SignProto

func SignProto(m proto.Message, privateKey []byte) ([]byte, error)

SignProto encodes the proto.Message and signs it using the private key, returning a signature. Ed25519 is used to sign messages.

func Verify

func Verify(signature []byte, publicKey []byte) bool

Verify a signature against the public key.

Types

type BoltStore

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

The BoltStore type is responsible for storing client public key data within a bolt database.

func NewBoltStore

func NewBoltStore(db *bbolt.DB) *BoltStore

NewBoltStore returns a new instance of the BoltStore type that stores signing key data within the provided bbolt.DB instance.

func (*BoltStore) Create

func (bs *BoltStore) Create(ctx context.Context, clientID string, publicKey []byte) error

Create a public key record for a client. Returns ErrPublicKeyExists if the client already has a public key.

func (*BoltStore) Get

func (bs *BoltStore) Get(ctx context.Context, clientID string) ([]byte, error)

Get a client's public key. Returns ErrNoPublic key if it does not exist.

func (*BoltStore) List

func (bs *BoltStore) List(ctx context.Context) ([]*signing.PublicKey, error)

List all public keys stored in state.

type Executor

type Executor interface {
	Execute(ctx context.Context, cmd command.Command) error
}

The Executor interface describes types that execute commands related to signing key data.

type GRPC

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

The GRPC type is a signingsvc.SigningServiceServer implementation that handles inbound gRPC requests to manage client signing keys.

func NewGRPC

func NewGRPC(executor Executor, publicKeys PublicKeyGetter) *GRPC

NewGRPC returns a new instance of the GRPC type that will handle inbound gRPC requests for signing key data. Commands will be executed via the Executor implementation and public keys will be queried via the PublicKeyGetter implementation.

func (*GRPC) CreateKeyPair

CreateKeyPair attmpts to create a new signing key pair for the client. It returns a codes.FailedPrecondition error code if this node is not the leader, or a codes.AlreadyExists error code if the client already has a key pair. The private key is not stored by the server and should be kept securely by the client.

func (*GRPC) GetPublicKey

GetPublicKey returns the public key for a client. It returns a codes.NotFound error code if there is no public key for a client.

func (*GRPC) ListPublicKeys

ListPublicKeys returns all public keys stored within the server.

func (*GRPC) Register

func (svr *GRPC) Register(registrar grpc.ServiceRegistrar, healthServer *health.Server)

Register the GRPC service onto the grpc.ServiceRegistrar.

type Handler

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

The Handler type is responsible for handling commands sent to the server regarding signing keys.

func NewHandler

func NewHandler(publicKeys PublicKeyCreator, logger hclog.Logger) *Handler

NewHandler returns a new instance of the Handler type that will store public key data via the PublicKeyCreator implementation.

func (*Handler) Create

func (h *Handler) Create(ctx context.Context, payload *signingcmd.CreatePublicKey) error

Create a new public key for the client.

type PublicKeyCreator

type PublicKeyCreator interface {
	// Create a public key for a client, should return ErrPublicKeyExists if the client already has a public
	// key.
	Create(ctx context.Context, clientID string, publicKey []byte) error
}

The PublicKeyCreator interface describes types that can create public key records for a client.

type PublicKeyGetter

type PublicKeyGetter interface {
	Get(ctx context.Context, clientID string) ([]byte, error)
	List(ctx context.Context) ([]*signing.PublicKey, error)
}

The PublicKeyGetter interface describes types that can obtain a public key for a client.

Jump to

Keyboard shortcuts

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