bls

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicKeySize = 128
)
View Source
const (
	SignatureSize = 64
)

Variables

View Source
var (
	ErrInvalidPublicKeySize = fmt.Errorf("public key must be %d bytes long", PublicKeySize)
)
View Source
var (
	ErrInvalidSignatureSize = fmt.Errorf("signature must be %d bytes long", SignatureSize)
)

Functions

This section is empty.

Types

type PrivateKey

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

PrivateKey holds private key for bls implementation

func CreateRandomBlsKeys

func CreateRandomBlsKeys(total int) ([]*PrivateKey, error)

CreateRandomBlsKeys creates an array of random private and their corresponding public keys

func GenerateBlsKey

func GenerateBlsKey() (*PrivateKey, error)

GenerateBlsKey creates a random private key (and its corresponding public key)

func NewZeroPrivateKey

func NewZeroPrivateKey() *PrivateKey

NewZeroPrivateKey is the constructor of an empty PrivateKey

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte) (*PrivateKey, error)

UnmarshalPrivateKey unmarshals the private key from the given byte slice. This function supports both raw big int string and hex-encoded big int string.

func (*PrivateKey) Marshal

func (p *PrivateKey) Marshal() ([]byte, error)

Marshal marshals private key hex (without 0x prefix) represented as a byte slice

func (*PrivateKey) PublicKey

func (p *PrivateKey) PublicKey() *PublicKey

PublicKey returns the public key from the PrivateKey

func (*PrivateKey) Sign

func (p *PrivateKey) Sign(message, domain []byte) (*Signature, error)

Sign generates a simple BLS signature of the given message

type PublicKey

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

PublicKey represents bls public key

func UnmarshalPublicKey

func UnmarshalPublicKey(data []byte) (*PublicKey, error)

UnmarshalPublicKey unmarshals bytes to public key

func UnmarshalPublicKeyFromBigInt

func UnmarshalPublicKeyFromBigInt(b [4]*big.Int) (*PublicKey, error)

UnmarshalPublicKeyFromBigInt unmarshals public key from 4 big ints Order of coordinates is [A.Y, A.X, B.Y, B.X]

func (*PublicKey) Marshal

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

Marshal marshal the key to bytes.

func (*PublicKey) MarshalText

func (p *PublicKey) MarshalText() ([]byte, error)

MarshalText implements the json.Marshaler interface.

func (*PublicKey) ToBigInt

func (p *PublicKey) ToBigInt() [4]*big.Int

ToBigInt converts public key to 4 big ints

func (*PublicKey) UnmarshalText

func (p *PublicKey) UnmarshalText(buf []byte) error

UnmarshalText implements encoding.TextMarshaler interface

type PublicKeys

type PublicKeys []*PublicKey

func (PublicKeys) Aggregate

func (pks PublicKeys) Aggregate() *PublicKey

Aggregate aggregates all public keys into one

type Signature

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

Signature represents bls signature which is point on the curve

func UnmarshalSignature

func UnmarshalSignature(raw []byte) (*Signature, error)

UnmarshalSignature reads the signature from the given byte array

func (*Signature) Marshal

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

Marshal the signature to bytes.

func (Signature) ToBigInt

func (s Signature) ToBigInt() ([2]*big.Int, error)

ToBigInt marshalls signature (which is point) to 2 big ints - one for each coordinate

func (*Signature) Verify

func (s *Signature) Verify(pub *PublicKey, message, domain []byte) bool

Verify checks the BLS signature of the message against the public key of its signer

func (*Signature) VerifyAggregated

func (s *Signature) VerifyAggregated(publicKeys []*PublicKey, msg, domain []byte) bool

VerifyAggregated checks the BLS signature of the message against the aggregated public keys of its signers

type Signatures

type Signatures []*Signature

Signatures is a slice of signatures

func (Signatures) Aggregate

func (sigs Signatures) Aggregate() *Signature

Aggregate aggregates all signatures into one

Jump to

Keyboard shortcuts

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