types

package
v0.0.0-...-020e20f Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMerkleRootNotMatch indicates the merkle root not match error from verifier.
	ErrMerkleRootNotMatch = errors.New("merkle root not match")
	// ErrHashValueNotMatch indicates the hash value not match error from verifier.
	ErrHashValueNotMatch = errors.New("hash value not match")
	// ErrSignatureNotMatch indicates the signature not match error from verifier.
	ErrSignatureNotMatch = errors.New("signature not match")
)

Functions

This section is empty.

Types

type Block

type Block struct {
	SignedBlockHeader
	ReadQueries  []*types.Ack
	WriteQueries []*types.Ack
}

Block defines a block including a signed block header and its query list.

func (*Block) Sign

func (b *Block) Sign(signer *asymmetric.PrivateKey) (err error)

Sign signs the block.

func (*Block) Verify

func (b *Block) Verify() error

Verify verifies the block.

type BlockHeader

type BlockHeader struct {
	Version     int32
	Producer    proto.NodeID
	GenesisHash hash.Hash
	ParentHash  hash.Hash
	MerkleRoot  hash.Hash
	Timestamp   time.Time
}

BlockHeader defines a block header.

type DefaultHashSignVerifierImpl

type DefaultHashSignVerifierImpl struct {
	DataHash  hash.Hash
	Signee    *asymmetric.PublicKey
	Signature *asymmetric.Signature
}

DefaultHashSignVerifierImpl defines a default implementation of hashSignVerifier.

func (*DefaultHashSignVerifierImpl) Hash

Hash implements hashSignVerifier.Hash.

func (*DefaultHashSignVerifierImpl) Sign

func (i *DefaultHashSignVerifierImpl) Sign(
	obj marshalHasher, signer *asymmetric.PrivateKey) (err error,
)

Sign implements hashSignVerifier.Sign.

func (*DefaultHashSignVerifierImpl) Verify

func (i *DefaultHashSignVerifierImpl) Verify(obj marshalHasher) (err error)

Verify implements hashSignVerifier.Verify.

type SignedBlockHeader

type SignedBlockHeader struct {
	BlockHeader
	DefaultHashSignVerifierImpl
}

SignedBlockHeader defines a block along with its hasher, signer and verifier.

func (*SignedBlockHeader) Sign

func (h *SignedBlockHeader) Sign(signer *asymmetric.PrivateKey) error

Sign signs the block header.

func (*SignedBlockHeader) Verify

func (h *SignedBlockHeader) Verify() error

Verify verifies the block header.

Jump to

Keyboard shortcuts

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