blssig

package module
v0.0.0-...-2477fe4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: MIT Imports: 5 Imported by: 0

README

BLS signature scheme library

Go Report PkgGoDev

BLS signature scheme library using kilic bls12-381 curve implementation

This library is only a wrapper around kilic/bls12-381 curve implementation to expose directly usable functions.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrorSecSize returned when the secret bytes doesn't match the length
	ErrorSecSize = errors.New("secret key should be 32 bytes")
	// ErrorSecUnmarshal returned when the secret key is not valid
	ErrorSecUnmarshal = errors.New("secret key bytes are not on curve")
	// ErrorPubSize returned when the public key bytes doesn't match the length
	ErrorPubSize = errors.New("public key should be 48 bytes")
	// ErrorPubKeyUnmarshal returned when the pubkey is not valid
	ErrorPubKeyUnmarshal = errors.New("could not unmarshal bytes into public key")
	// ErrorSigSize returned when the signature bytes doesn't match the length
	ErrorSigSize = errors.New("signature should be 96 bytes")
	// ErrorSigUnmarshal returned when the pubkey is not valid
	ErrorSigUnmarshal = errors.New("could not unmarshal bytes into signature")
)

Functions

func AggregateVerify

func AggregateVerify(s *Signature, pubKeys []*PublicKey, msgs [][32]byte) bool

AggregateVerify verifies each public key against its respective message.

func Engine

func Engine() *bls12381.Engine

func FastAggregateVerify

func FastAggregateVerify(s *Signature, pubKeys []*PublicKey, msg [32]byte) bool

FastAggregateVerify verifies all the provided public keys with their aggregated signature.

func Verify

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

Verify a bls signature given a public key, a message.

Types

type PublicKey

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

PublicKey used in the BLS signature scheme.

func PublicKeyFromBytes

func PublicKeyFromBytes(pubKey []byte) (*PublicKey, error)

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

func (*PublicKey) Aggregate

func (p *PublicKey) Aggregate(p2 *PublicKey) *PublicKey

Aggregate two public keys.

func (*PublicKey) Copy

func (p *PublicKey) Copy() *PublicKey

Copy the public key to a new pointer reference.

func (*PublicKey) Marshal

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

Marshal a public key into a LittleEndian byte slice.

type SecretKey

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

SecretKey used in the BLS signature scheme.

func RandKey

func RandKey() *SecretKey

RandKey creates a new private key using a random input.

func SecretKeyFromBytes

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

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

func (*SecretKey) Marshal

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

Marshal a secret key into a LittleEndian byte slice.

func (*SecretKey) PublicKey

func (s *SecretKey) PublicKey() *PublicKey

PublicKey obtains the public key corresponding to the BLS secret key.

func (*SecretKey) Sign

func (s *SecretKey) Sign(msg []byte) *Signature

Sign a message using a secret key - in a beacon/validator client.

In IETF draft BLS specification: Sign(SK, message) -> signature: a signing algorithm that generates

a deterministic signature given a secret key SK and a message.

In ETH2.0 specification: def Sign(SK: int, message: Bytes) -> BLSSignature

type Signature

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

Signature used in the BLS signature scheme.

func AggregateSignatures

func AggregateSignatures(sigs []*Signature) *Signature

AggregateSignatures converts a list of signatures into a single, aggregated sig.

func NewAggregateSignature

func NewAggregateSignature() *Signature

NewAggregateSignature creates a blank aggregate signature.

func SignatureFromBytes

func SignatureFromBytes(sig []byte) (*Signature, error)

SignatureFromBytes creates a BLS signature from a LittleEndian byte slice.

func (*Signature) Copy

func (s *Signature) Copy() *Signature

Copy returns a full deep copy of a signature.

func (*Signature) Marshal

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

Marshal a signature into a LittleEndian byte slice.

Jump to

Keyboard shortcuts

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