crypto

package
v0.0.0-...-7cc9995 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 9 Imported by: 0

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

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

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

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

func BitfieldFromBytes(b []byte) Bitfield

BitfieldFromBytes creates a bitfield from the given byte slice.

func (*Bitfield) Add

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

Add adds an ID to the set.

func (Bitfield) Bytes

func (bf Bitfield) Bytes() []byte

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

func (Bitfield) Contains

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

Contains returns true if the set contains the ID.

func (Bitfield) ForEach

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

ForEach calls f for each ID in the set.

func (Bitfield) Len

func (bf Bitfield) Len() int

Len returns the number of entries in the set.

func (Bitfield) RangeWhile

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

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

func (Bitfield) String

func (bf Bitfield) String() string

type Multi

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

Multi is a set of (partial) signatures.

func Restore

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

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

Add adds an ID to the set.

func (Multi[T]) Contains

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

Contains returns true if the set contains the ID.

func (Multi[T]) ForEach

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

ForEach calls f for each ID in the set.

func (Multi[T]) Len

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

Len returns the number of entries in the set.

func (Multi[T]) Participants

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

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

func (Multi[T]) RangeWhile

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

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

func (Multi[T]) String

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

func (Multi[T]) ToBytes

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

ToBytes returns the object as bytes.

type Signature

type Signature interface {
	Signer() consbench.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