bls

package
v0.0.0-...-a38d99b Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const PublicKeyLen = blst.BLST_P1_COMPRESS_BYTES
View Source
const SecretKeyLen = blst.BLST_SCALAR_BYTES
View Source
const SignatureLen = blst.BLST_P2_COMPRESS_BYTES

Variables

View Source
var (
	ErrNoPublicKeys              = errors.New("no public keys")
	ErrFailedPublicKeyDecompress = errors.New("couldn't decompress public key")
)
View Source
var (
	ErrFailedSignatureDecompress = errors.New("couldn't decompress signature")
)

Functions

func PublicKeyToCompressedBytes

func PublicKeyToCompressedBytes(pk *PublicKey) []byte

PublicKeyToCompressedBytes returns the compressed big-endian format of the public key.

func PublicKeyToUncompressedBytes

func PublicKeyToUncompressedBytes(key *PublicKey) []byte

PublicKeyToUncompressedBytes returns the uncompressed big-endian format of the public key.

func SecretKeyToBytes

func SecretKeyToBytes(sk *SecretKey) []byte

SecretKeyToBytes returns the big-endian format of the secret key.

func SignatureToBytes

func SignatureToBytes(sig *Signature) []byte

SignatureToBytes returns the compressed big-endian format of the signature.

func Verify

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

Verify the [sig] of [msg] against the [pk]. The [sig] and [pk] may have been an aggregation of other signatures and keys. Invariant: [pk] and [sig] have both been validated.

func VerifyProofOfPossession

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

Verify the possession of the secret pre-image of [sk] by verifying a [sig] of [msg] against the [pk]. The [sig] and [pk] may have been an aggregation of other signatures and keys. Invariant: [pk] and [sig] have both been validated.

Types

type AggregatePublicKey

type AggregatePublicKey = blst.P1Aggregate

type AggregateSignature

type AggregateSignature = blst.P2Aggregate

type PublicKey

type PublicKey = blst.P1Affine

func AggregatePublicKeys

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

AggregatePublicKeys aggregates a non-zero number of public keys into a single aggregated public key. Invariant: all [pks] have been validated.

func PublicFromSecretKey

func PublicFromSecretKey(sk *SecretKey) *PublicKey

PublicFromSecretKey returns the public key that corresponds to this secret key.

func PublicKeyFromCompressedBytes

func PublicKeyFromCompressedBytes(pkBytes []byte) (*PublicKey, error)

PublicKeyFromCompressedBytes parses the compressed big-endian format of the public key into a public key.

func PublicKeyFromValidUncompressedBytes

func PublicKeyFromValidUncompressedBytes(pkBytes []byte) *PublicKey

PublicKeyFromValidUncompressedBytes parses the uncompressed big-endian format of the public key into a public key. It is assumed that the provided bytes are valid.

type SecretKey

type SecretKey = blst.SecretKey

func NewSecretKey

func NewSecretKey() (*SecretKey, error)

NewSecretKey generates a new secret key from the local source of cryptographically secure randomness.

func SecretKeyFromBytes

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

SecretKeyFromBytes parses the big-endian format of the secret key into a secret key.

type Signature

type Signature = blst.P2Affine

func AggregateSignatures

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

AggregateSignatures aggregates a non-zero number of signatures into a single aggregated signature. Invariant: all [sigs] have been validated.

func Sign

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

Sign [msg] to authorize this message from this [sk].

func SignProofOfPossession

func SignProofOfPossession(sk *SecretKey, msg []byte) *Signature

Sign [msg] to prove the ownership of this [sk].

func SignatureFromBytes

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

SignatureFromBytes parses the compressed big-endian format of the signature into a signature.

Jump to

Keyboard shortcuts

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