crypto

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2025 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package crypto provides implementations of the Crypto interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCombineMultiple is used when Combine is called with less than two signatures.
	ErrCombineMultiple = errors.New("must have at least two signatures")

	// ErrCombineOverlap is used when Combine is called with signatures that have overlapping participation.
	ErrCombineOverlap = errors.New("overlapping signatures")
)

Functions

func New added in v0.3.0

func New(impl modules.CryptoBase) modules.Crypto

New returns a new implementation of the Crypto interface. It will use the given CryptoBase to create and verify signatures.

func NewCache added in v0.3.0

func NewCache(impl modules.CryptoBase, capacity int) modules.Crypto

NewCache returns a new Crypto instance that caches the results of the operations of the given CryptoBase. implementation.

Types

type Bitfield added in v0.3.0

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

Bitfield is an IDSet implemented by a bitfield. To check if an ID 'i' is present in the set, we simply check if the bit at i-1 is set (because IDs start at 1). This scales poorly if IDs are not sequential.

func BitfieldFromBytes added in v0.5.0

func BitfieldFromBytes(b []byte) Bitfield

BitfieldFromBytes creates a bitfield from the given byte slice.

func (*Bitfield) Add added in v0.3.0

func (bf *Bitfield) Add(id hotstuff.ID)

Add adds an ID to the set.

func (Bitfield) Bytes added in v0.5.0

func (bf Bitfield) Bytes() []byte

Bytes returns the raw byte slice containing the data of this bitfield.

func (Bitfield) Contains added in v0.3.0

func (bf Bitfield) Contains(id hotstuff.ID) bool

Contains returns true if the set contains the ID.

func (Bitfield) ForEach added in v0.3.0

func (bf Bitfield) ForEach(f func(hotstuff.ID))

ForEach calls f for each ID in the set.

func (Bitfield) Len added in v0.5.0

func (bf Bitfield) Len() int

Len returns the number of entries in the set.

func (Bitfield) RangeWhile added in v0.5.0

func (bf Bitfield) RangeWhile(f func(hotstuff.ID) bool)

RangeWhile calls f for each ID in the set until f returns false.

func (Bitfield) String added in v0.5.0

func (bf Bitfield) String() string

type Multi added in v0.5.0

type Multi[T Signature] map[hotstuff.ID]T

Multi is a set of (partial) signatures.

func Restore added in v0.5.0

func Restore[T Signature](signatures []T) Multi[T]

Restore should only be used to restore an existing threshold signature from a set of signatures.

func (Multi[T]) Add added in v0.5.0

func (sig Multi[T]) Add(_ hotstuff.ID)

Add adds an ID to the set.

func (Multi[T]) Contains added in v0.5.0

func (sig Multi[T]) Contains(id hotstuff.ID) bool

Contains returns true if the set contains the ID.

func (Multi[T]) ForEach added in v0.5.0

func (sig Multi[T]) ForEach(f func(hotstuff.ID))

ForEach calls f for each ID in the set.

func (Multi[T]) Len added in v0.5.0

func (sig Multi[T]) Len() int

Len returns the number of entries in the set.

func (Multi[T]) Participants added in v0.5.0

func (sig Multi[T]) Participants() hotstuff.IDSet

Participants returns the IDs of replicas who participated in the threshold signature.

func (Multi[T]) RangeWhile added in v0.5.0

func (sig Multi[T]) RangeWhile(f func(hotstuff.ID) bool)

RangeWhile calls f for each ID in the set until f returns false.

func (Multi[T]) String added in v0.5.0

func (sig Multi[T]) String() string

func (Multi[T]) ToBytes added in v0.5.0

func (sig Multi[T]) ToBytes() []byte

ToBytes returns the object as bytes.

type Signature added in v0.5.0

type Signature interface {
	Signer() hotstuff.ID
	ToBytes() []byte
}

Signature is the individual component in MultiSignature

Directories

Path Synopsis
Package bls12 implements the crypto primitives used by HotStuff using curve BLS12-381.
Package bls12 implements the crypto primitives used by HotStuff using curve BLS12-381.
Package ecdsa implements the spec-k256 curve signature.
Package ecdsa implements the spec-k256 curve signature.
Package eddsa implements the ed25519 curve signature.
Package eddsa implements the ed25519 curve signature.
Package keygen provides helper methods for generating, serializing, and deserializing public keys, private keys and certificates.
Package keygen provides helper methods for generating, serializing, and deserializing public keys, private keys and certificates.

Jump to

Keyboard shortcuts

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