bls

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PublicKeyLen is the length of a serialized public key
	PublicKeyLen = 48

	// PrivateKeyLen is the length of a serialized private key
	PrivateKeyLen = 32

	// SignatureLen is the length of a serialized signature
	SignatureLen = 96
)

Variables

View Source
var (
	// ErrInvalidPublicKey is returned when a public key is invalid
	ErrInvalidPublicKey = errors.New("invalid public key")

	// ErrInvalidPrivateKey is returned when a private key is invalid
	ErrInvalidPrivateKey = errors.New("invalid private key")

	// ErrInvalidSignature is returned when a signature is invalid
	ErrInvalidSignature = errors.New("invalid signature")
)

Functions

func PublicKeyToBytes

func PublicKeyToBytes(pk *PublicKey) []byte

PublicKeyToBytes serializes a public key to bytes

func SignatureToBytes

func SignatureToBytes(sig *Signature) []byte

SignatureToBytes serializes a signature to bytes

func Verify

func Verify(pk *PublicKey, sig *Signature, msg []byte) bool

Verify verifies a signature against a public key and message This is a simplified implementation - in production use proper BLS12-381

Types

type PrivateKey

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

PrivateKey represents a BLS private key

func GeneratePrivateKey

func GeneratePrivateKey() (*PrivateKey, error)

GeneratePrivateKey generates a new random private key

func PrivateKeyFromBytes

func PrivateKeyFromBytes(b []byte) (*PrivateKey, error)

PrivateKeyFromBytes deserializes a private key from bytes

func (*PrivateKey) Bytes

func (sk *PrivateKey) Bytes() []byte

Bytes returns the byte representation of the private key

func (*PrivateKey) PublicKey

func (sk *PrivateKey) PublicKey() *PublicKey

PublicKey returns the public key corresponding to the private key

type PublicKey

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

PublicKey represents a BLS public key

func AggregatePublicKeys

func AggregatePublicKeys(pks []*PublicKey) (*PublicKey, error)

AggregatePublicKeys aggregates multiple public keys This is a simplified implementation - in production use proper BLS12-381

func PublicFromPrivateKey

func PublicFromPrivateKey(sk *PrivateKey) *PublicKey

PublicFromPrivateKey derives the public key from a private key This is a simplified implementation - in production use proper BLS12-381

func PublicKeyFromBytes

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

PublicKeyFromBytes deserializes a public key from bytes

func (*PublicKey) Bytes

func (pk *PublicKey) Bytes() []byte

Bytes returns the compressed byte representation of the public key

func (*PublicKey) Equal

func (pk *PublicKey) Equal(other *PublicKey) bool

Equal returns true if two public keys are equal

type Signature

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

Signature represents a BLS signature

func AggregateSignatures

func AggregateSignatures(sigs []*Signature) (*Signature, error)

AggregateSignatures aggregates multiple signatures This is a simplified implementation - in production use proper BLS12-381

func Sign

func Sign(sk *PrivateKey, msg []byte) (*Signature, error)

Sign creates a signature for a message This is a simplified implementation - in production use proper BLS12-381

func SignatureFromBytes

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

SignatureFromBytes deserializes a signature from bytes

func (*Signature) Bytes

func (sig *Signature) Bytes() []byte

Bytes returns the compressed byte representation of the signature

Jump to

Keyboard shortcuts

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