blst

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package blst implements a go-wrapper around a library implementing the BLS12-381 curve and signature scheme. This package exposes a public API for verifying and aggregating BLS signatures used by Ethereum.

This implementation uses the library written by Supranational, blst.

Index

Constants

View Source
const (
	SignatureLength = 96
	PubkeyLength    = 48 // PubkeyLength defines the byte length of a BLSSignature.
)

Variables

This section is empty.

Functions

func IsZero added in v0.1.1

func IsZero(sKey []byte) bool

IsZero checks if the secret key is a zero key.

func VerifySignature added in v0.1.1

func VerifySignature(sig []byte, msg [32]byte, pubKey PubKey) (bool, error)

VerifySignature verifies a single signature using public key and message.

Types

type PubKey

type PubKey interface {
	Marshal() []byte
	Copy() PubKey
	Equals(p2 PubKey) bool
}

func PublicKeyFromBytes added in v0.1.1

func PublicKeyFromBytes(pubKey []byte) (PubKey, error)

PublicKeyFromBytes creates a BLS public key from a BigEndian byte slice.

type PublicKey added in v0.1.1

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

PublicKey used in the BLS signature scheme.

func (*PublicKey) Copy added in v0.1.1

func (p *PublicKey) Copy() PubKey

Copy the public key to a new pointer reference.

func (*PublicKey) Equals added in v0.1.1

func (p *PublicKey) Equals(p2 PubKey) bool

Equals checks if the provided public key is equal to the current one.

func (*PublicKey) Marshal added in v0.1.1

func (p *PublicKey) Marshal() []byte

Marshal a public key into a LittleEndian byte slice.

type SecretKey

type SecretKey interface {
	PublicKey() PubKey
	Sign(msg []byte) SignatureI
	Marshal() []byte
}

SecretKey represents a BLS secret or private key.

func GenPrivKeyFromSeed added in v0.1.2

func GenPrivKeyFromSeed(seed [32]byte) (SecretKey, error)

GenPrivKeyFromSeed creates a new private key directly from the seed passed as parameter

func RandKey added in v0.1.1

func RandKey() (SecretKey, error)

RandKey creates a new private key using a random method provided as an io.Reader.

func SecretKeyFromBytes added in v0.1.1

func SecretKeyFromBytes(privKey []byte) (SecretKey, error)

SecretKeyFromBytes creates a BLS private key from a BigEndian byte slice.

type Signature added in v0.1.1

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

Signature used in the BLS signature scheme.

func (*Signature) Copy added in v0.1.1

func (s *Signature) Copy() SignatureI

Copy returns a full deep copy of a signature.

func (*Signature) Marshal added in v0.1.1

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

Marshal a signature into a LittleEndian byte slice.

func (*Signature) Verify added in v0.1.1

func (s *Signature) Verify(pubKey PubKey, msg []byte) bool

type SignatureI

type SignatureI interface {
	Verify(pubKey PubKey, msg []byte) bool
	Marshal() []byte
	Copy() SignatureI
}

SignatureI represents a BLS signature.

func SignatureFromBytes added in v0.1.1

func SignatureFromBytes(sig []byte) (SignatureI, error)

SignatureFromBytes creates a BLS signature from a LittleEndian byte slice.

func SignatureFromBytesNoValidation added in v0.1.1

func SignatureFromBytesNoValidation(sig []byte) (SignatureI, error)

SignatureFromBytesNoValidation creates a BLS signature from a LittleEndian byte slice. It does not validate that the signature is in the BLS group

Jump to

Keyboard shortcuts

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