shbls

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomKeyPair

func RandomKeyPair(r io.Reader) (*SecretKey, *PublicKey, error)

RandomKeyPair generates a random BLS secret and corresponding public key.

func Verify

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

Verify checks that a signature over a certain message was created with the secret key corresponding to the given public key.

Types

type PublicKey

type PublicKey bn256.G1

func AggregatePublicKeys

func AggregatePublicKeys(publicKeys []*PublicKey) *PublicKey

AggregatePublicKeys aggregates a set of BLS public keys into one.

func SecretToPublicKey

func SecretToPublicKey(secretKey *SecretKey) *PublicKey

SecretToPublicKey returns the BLS public key corresponding to the given secret key.

func (*PublicKey) Equal

func (publicKey *PublicKey) Equal(otherPublicKey *PublicKey) bool

Equal checks if two public keys are equal to each other.

func (*PublicKey) Marshal

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

Marshal converts a BLS public key to bytes.

func (*PublicKey) Unmarshal

func (publicKey *PublicKey) Unmarshal(b []byte) error

Unmarshal sets the public key to the value stored in the given byte slice. The input byte slice must be 64 bytes and contain a valid key, otherwise an error is returned.

type SecretKey

type SecretKey big.Int

func (*SecretKey) Equal

func (secretKey *SecretKey) Equal(otherSecretKey *SecretKey) bool

Equal checks if two secret keys are equal to each other.

func (*SecretKey) Marshal

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

Marshal converts a BLS secret key to bytes. The result is a 32 byte slice. Make sure the input is a valid key, otherwise the method might panic or return something that when decoded would not match the original value.

func (*SecretKey) Unmarshal

func (secretKey *SecretKey) Unmarshal(b []byte) error

Unmarshal sets the secret key to the value stored in the given byte slice. The input byte slice must be 32 bytes and contain a valid key, otherwise an error is returned.

type Signature

type Signature bn256.G2

func AggregateSignatures

func AggregateSignatures(sigs []*Signature) *Signature

AggregateSignatures aggregates a set of BLS signatures into one.

func Sign

func Sign(msg []byte, secretKey *SecretKey) *Signature

Sign creates a signature over a message using a secret key.

func (*Signature) Equal

func (sig *Signature) Equal(otherSig *Signature) bool

Equal checks if two signatures are equal to each other.

func (*Signature) Marshal

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

Marshal converts a BLS signature to bytes.

func (*Signature) Unmarshal

func (sig *Signature) Unmarshal(b []byte) error

Unmarshal sets the signature to the value stored in the given byte slice. The input byte slice must be 128 bytes and contain a well formed signature, otherwise an error is returned.

Jump to

Keyboard shortcuts

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