blocksigner

package
v0.0.0-...-024a0a0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2017 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package blocksigner implements remote block signing.

Index

Constants

This section is empty.

Variables

View Source
var ErrConsensusChange = errors.New("consensus program has changed")

ErrConsensusChange is returned from ValidateAndSignBlock when a new consensus program is detected.

View Source
var ErrInvalidKey = errors.New("misconfigured signer public key")

ErrInvalidKey is returned from SignBlock when the key specified on the Signer is invalid. It may be not found by the mock HSM or not paired to a valid private key.

Functions

This section is empty.

Types

type BlockSigner

type BlockSigner struct {
	Pub ed25519.PublicKey
	// contains filtered or unexported fields
}

BlockSigner validates and signs blocks.

func New

func New(pub ed25519.PublicKey, hsm Signer, db pg.DB, c *protocol.Chain) *BlockSigner

New returns a new Signer that validates blocks with c and signs them with k.

func (*BlockSigner) SignBlock

func (s *BlockSigner) SignBlock(ctx context.Context, marshalledBlock []byte) ([]byte, error)

SignBlock computes the signature for the block using the private key in s. It does not validate the block.

This function fails if this node has ever signed a different block at the same height as b.

func (*BlockSigner) String

func (s *BlockSigner) String() string

func (*BlockSigner) ValidateAndSignBlock

func (s *BlockSigner) ValidateAndSignBlock(ctx context.Context, b *legacy.Block) ([]byte, error)

ValidateAndSignBlock validates the given block against the current blockchain and, if valid, computes and returns a signature for the block. It is used as the httpjson handler for /rpc/signer/sign-block.

type EnclaveClient

type EnclaveClient struct {
	// URLs is called on every Sign call to retrieve the URLs
	// and access tokens for Chain Enclave.
	URLs       func() [][]string
	BaseClient rpc.Client
}

EnclaveClient implements the Signer interface by calling Chain Enclave to sign blocks.

func (EnclaveClient) Sign

type Signer

type Signer interface {
	Sign(context.Context, ed25519.PublicKey, *legacy.BlockHeader) ([]byte, error)
}

Signer provides the interface for computing the block signature. It's implemented by the MockHSM and EnclaveClient.

Jump to

Keyboard shortcuts

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