bls12

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package bls12 implements the crypto primitives used by HotStuff using curve BLS12-381.

Index

Constants

View Source
const (
	// PrivateKeyFileType is the PEM type for a private key.
	PrivateKeyFileType = "BLS12-381 PRIVATE KEY"

	// PublicKeyFileType is the PEM type for a public key.
	PublicKeyFileType = "BLS12-381 PUBLIC KEY"
)

Variables

This section is empty.

Functions

func New

func New() consensus.CryptoImpl

New returns a new bls12-381 signer and verifier.

Types

type AggregateSignature

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

AggregateSignature is a bls12-381 aggregate signature. The participants map contains the IDs of the replicas who participated in the creation of the signature. This allows us to build an aggregated public key to verify the signature.

func RestoreAggregateSignature

func RestoreAggregateSignature(sig []byte, participants crypto.Bitfield) (s *AggregateSignature, err error)

RestoreAggregateSignature restores an existing aggregate signature. It should not be used to create new aggregate signatures. Use CreateThresholdSignature instead.

func (AggregateSignature) Bitfield

func (agg AggregateSignature) Bitfield() crypto.Bitfield

Bitfield returns the bitmask.

func (AggregateSignature) Participants

func (agg AggregateSignature) Participants() consensus.IDSet

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

func (*AggregateSignature) ToBytes

func (agg *AggregateSignature) ToBytes() []byte

ToBytes returns a byte representation of the aggregate signature.

type PrivateKey

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

PrivateKey is a bls12-381 private key.

func GeneratePrivateKey

func GeneratePrivateKey() (*PrivateKey, error)

GeneratePrivateKey generates a new private key.

func (*PrivateKey) FromBytes

func (priv *PrivateKey) FromBytes(b []byte)

FromBytes unmarshals the private key from a byte slice.

func (*PrivateKey) Public

func (priv *PrivateKey) Public() consensus.PublicKey

Public returns the public key associated with this private key.

func (PrivateKey) ToBytes

func (priv PrivateKey) ToBytes() []byte

ToBytes marshals the private key to a byte slice.

type PublicKey

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

PublicKey is a bls12-381 public key.

func (*PublicKey) FromBytes

func (pub *PublicKey) FromBytes(b []byte) (err error)

FromBytes unmarshals the public key from a byte slice.

func (PublicKey) ToBytes

func (pub PublicKey) ToBytes() []byte

ToBytes marshals the public key to a byte slice.

type Signature

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

Signature is a bls12-381 signature.

func (*Signature) FromBytes

func (s *Signature) FromBytes(b []byte) (err error)

FromBytes unmarshals a signature from a byte slice.

func (*Signature) Signer

func (s *Signature) Signer() hotstuff.ID

Signer returns the ID of the replica that generated the signature.

func (*Signature) ToBytes

func (s *Signature) ToBytes() []byte

ToBytes returns the object as bytes.

Jump to

Keyboard shortcuts

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