bls

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const PrivateKeySize = 32
View Source
const PublicKeySize = 96
View Source
const SignatureSize = 48

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

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

func KeyGen

func KeyGen(ikm, keyInfo []byte) (*PrivateKey, error)

KeyGen generates a private key deterministically from a secret octet string IKM and an optional octet string keyInfo. Based on https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-bls-signature-04#section-2.3

func PrivateKeyFromBytes

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

PrivateKeyFromBytes constructs a BLS private key from the raw bytes.

func PrivateKeyFromString

func PrivateKeyFromString(text string) (*PrivateKey, error)

PrivateKeyFromString decodes the input string and returns the PrivateKey if the string is a valid bech32m encoding of a BLS public key.

func (*PrivateKey) Bytes

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

Bytes return the raw bytes of the private key.

func (*PrivateKey) EqualsTo

func (prv *PrivateKey) EqualsTo(x crypto.PrivateKey) bool

func (*PrivateKey) PublicKey

func (prv *PrivateKey) PublicKey() crypto.PublicKey

func (*PrivateKey) PublicKeyNative added in v0.15.0

func (prv *PrivateKey) PublicKeyNative() *PublicKey

func (*PrivateKey) Sign

func (prv *PrivateKey) Sign(msg []byte) crypto.Signature

Sign calculates the signature from the private key and given message. It's defined in section 2.6 of the spec: CoreSign.

func (*PrivateKey) SignNative added in v0.15.0

func (prv *PrivateKey) SignNative(msg []byte) *Signature

func (*PrivateKey) String

func (prv *PrivateKey) String() string

String returns a human-readable string for the BLS private key.

type PublicKey

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

func PublicKeyAggregate added in v0.15.0

func PublicKeyAggregate(pubs ...*PublicKey) *PublicKey

func PublicKeyFromBytes

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

PublicKeyFromBytes constructs a BLS public key from the raw bytes.

func PublicKeyFromString

func PublicKeyFromString(text string) (*PublicKey, error)

PublicKeyFromString decodes the input string and returns the PublicKey if the string is a valid bech32m encoding of a BLS public key.

func (*PublicKey) AccountAddress added in v0.15.0

func (pub *PublicKey) AccountAddress() crypto.Address

AccountAddress returns the account address derived from the public key.

func (*PublicKey) Bytes

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

Bytes returns the raw byte representation of the public key.

func (*PublicKey) Decode

func (pub *PublicKey) Decode(r io.Reader) error

Decode reads the raw bytes of the public key from the provided reader and initializes the public key.

func (*PublicKey) Encode

func (pub *PublicKey) Encode(w io.Writer) error

Encode writes the raw bytes of the public key to the provided writer.

func (*PublicKey) EqualsTo

func (pub *PublicKey) EqualsTo(x crypto.PublicKey) bool

EqualsTo checks if the current public key is equal to another public key.

func (*PublicKey) MarshalCBOR

func (pub *PublicKey) MarshalCBOR() ([]byte, error)

MarshalCBOR encodes the public key into CBOR format.

func (*PublicKey) PointG2 added in v1.2.0

func (pub *PublicKey) PointG2() (*bls12381.G2Affine, error)

PointG2 returns the point on G2 for the public key.

func (*PublicKey) String

func (pub *PublicKey) String() string

String returns a human-readable string for the BLS public key.

func (*PublicKey) UnmarshalCBOR

func (pub *PublicKey) UnmarshalCBOR(bs []byte) error

UnmarshalCBOR decodes the public key from CBOR format.

func (*PublicKey) ValidatorAddress added in v0.15.0

func (pub *PublicKey) ValidatorAddress() crypto.Address

ValidatorAddress returns the validator address derived from the public key.

func (*PublicKey) Verify

func (pub *PublicKey) Verify(msg []byte, sig crypto.Signature) error

Verify checks that a signature is valid for the given message and public key. It's defined in section 2.6 of the spec: CoreVerify.

func (*PublicKey) VerifyAddress

func (pub *PublicKey) VerifyAddress(addr crypto.Address) error

VerifyAddress checks if the provided address matches the derived address from the public key.

type Signature

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

func SignatureAggregate added in v0.15.0

func SignatureAggregate(sigs ...*Signature) *Signature

func SignatureFromBytes

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

SignatureFromBytes constructs a BLS signature from the raw bytes.

func SignatureFromString

func SignatureFromString(text string) (*Signature, error)

SignatureFromString decodes the input string and returns the Signature if the string is a valid hexadecimal encoding of a BLS signature.

func (*Signature) Bytes

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

Bytes returns the raw byte representation of the signature.

func (*Signature) Decode

func (sig *Signature) Decode(r io.Reader) error

Decode reads the raw bytes of the signature from the provided reader and initializes the signature.

func (*Signature) Encode

func (sig *Signature) Encode(w io.Writer) error

Encode writes the raw bytes of the signature to the provided writer.

func (*Signature) EqualsTo

func (sig *Signature) EqualsTo(x crypto.Signature) bool

EqualsTo checks if the current signature is equal to another signature.

func (*Signature) MarshalCBOR

func (sig *Signature) MarshalCBOR() ([]byte, error)

MarshalCBOR encodes the signature into CBOR format.

func (*Signature) PointG1 added in v1.2.0

func (sig *Signature) PointG1() (*bls12381.G1Affine, error)

PointG1 returns the point on G1 for the signature.

func (*Signature) String

func (sig *Signature) String() string

String returns the hex-encoded string representation of the signature.

func (*Signature) UnmarshalCBOR

func (sig *Signature) UnmarshalCBOR(bs []byte) error

UnmarshalCBOR decodes the signature from CBOR format.

type ValidatorKey added in v0.15.0

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

ValidatorKey wraps a BLS private key, caching its public key and validator address.

func NewValidatorKey added in v0.15.0

func NewValidatorKey(prv *PrivateKey) *ValidatorKey

func (*ValidatorKey) Address added in v0.15.0

func (key *ValidatorKey) Address() crypto.Address

func (*ValidatorKey) PrivateKey added in v0.15.0

func (key *ValidatorKey) PrivateKey() *PrivateKey

func (*ValidatorKey) PublicKey added in v0.15.0

func (key *ValidatorKey) PublicKey() *PublicKey

func (*ValidatorKey) Sign added in v0.15.0

func (key *ValidatorKey) Sign(data []byte) *Signature

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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