bls

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 4 Imported by: 26

Documentation

Index

Constants

View Source
const (
	PublicKeyLength = bls12381.SizeOfG1AffineCompressed
	SecretKeyLength = fr.Bytes
	SignatureLength = bls12381.SizeOfG2AffineCompressed
)

Variables

View Source
var (
	ErrInvalidPubkeyLength    = errors.New("invalid public key length")
	ErrInvalidSecretKeyLength = errors.New("invalid secret key length")
	ErrInvalidSignatureLength = errors.New("invalid signature length")
	ErrSecretKeyIsZero        = errors.New("invalid secret key is zero")
)

Functions

func GenerateNewKeypair

func GenerateNewKeypair() (*SecretKey, *PublicKey, error)

func PublicKeyToBytes added in v1.3.0

func PublicKeyToBytes(pk *PublicKey) []byte

func SecretKeyToBytes added in v1.3.0

func SecretKeyToBytes(sk *SecretKey) []byte

func SignatureToBytes added in v1.3.0

func SignatureToBytes(sig *Signature) []byte

func VerifySignature

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

func VerifySignatureBytes

func VerifySignatureBytes(msg, sigBytes, pkBytes []byte) (bool, error)

Types

type PublicKey

type PublicKey = bls12381.G1Affine

func PublicKeyFromBytes

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

func PublicKeyFromSecretKey

func PublicKeyFromSecretKey(sk *SecretKey) (*PublicKey, error)

type SecretKey

type SecretKey = fr.Element

func GenerateRandomSecretKey

func GenerateRandomSecretKey() (*SecretKey, error)

func SecretKeyFromBytes

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

type Signature

type Signature = bls12381.G2Affine

func Sign

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

func SignatureFromBytes

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

Jump to

Keyboard shortcuts

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