Documentation ¶
Index ¶
- Constants
- type PrivateKey
- func (prv *PrivateKey) Bytes() []byte
- func (prv *PrivateKey) EqualsTo(x crypto.PrivateKey) bool
- func (prv *PrivateKey) PublicKey() crypto.PublicKey
- func (prv *PrivateKey) PublicKeyNative() *PublicKey
- func (prv *PrivateKey) Sign(msg []byte) crypto.Signature
- func (prv *PrivateKey) SignNative(msg []byte) *Signature
- func (prv *PrivateKey) String() string
- type PublicKey
- func (pub *PublicKey) AccountAddress() crypto.Address
- func (pub *PublicKey) Bytes() []byte
- func (pub *PublicKey) Decode(r io.Reader) error
- func (pub *PublicKey) Encode(w io.Writer) error
- func (pub *PublicKey) EqualsTo(x crypto.PublicKey) bool
- func (pub *PublicKey) MarshalCBOR() ([]byte, error)
- func (pub *PublicKey) PointG2() (*bls12381.G2Affine, error)
- func (*PublicKey) SerializeSize() int
- func (pub *PublicKey) String() string
- func (pub *PublicKey) UnmarshalCBOR(bs []byte) error
- func (pub *PublicKey) ValidatorAddress() crypto.Address
- func (pub *PublicKey) Verify(msg []byte, sig crypto.Signature) error
- func (pub *PublicKey) VerifyAddress(addr crypto.Address) error
- type Signature
- func (sig *Signature) Bytes() []byte
- func (sig *Signature) Decode(r io.Reader) error
- func (sig *Signature) Encode(w io.Writer) error
- func (sig *Signature) EqualsTo(x crypto.Signature) bool
- func (sig *Signature) MarshalCBOR() ([]byte, error)
- func (sig *Signature) PointG1() (*bls12381.G1Affine, error)
- func (*Signature) SerializeSize() int
- func (sig *Signature) String() string
- func (sig *Signature) UnmarshalCBOR(bs []byte) error
- type ValidatorKey
Constants ¶
const PrivateKeySize = 32
const PublicKeySize = 96
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 PublicKeyFromBytes ¶
PublicKeyFromBytes constructs a BLS public key from the raw bytes.
func PublicKeyFromString ¶
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
AccountAddress returns the account address derived from the public key.
func (*PublicKey) Decode ¶
Decode reads the raw bytes of the public key from the provided reader and initializes the public key.
func (*PublicKey) EqualsTo ¶
EqualsTo checks if the current public key is equal to another public key.
func (*PublicKey) MarshalCBOR ¶
MarshalCBOR encodes the public key into CBOR format.
func (*PublicKey) SerializeSize ¶ added in v1.6.0
func (*PublicKey) UnmarshalCBOR ¶
UnmarshalCBOR decodes the public key from CBOR format.
func (*PublicKey) ValidatorAddress ¶ added in v0.15.0
ValidatorAddress returns the validator address derived from the public key.
type Signature ¶
type Signature struct {
// contains filtered or unexported fields
}
func SignatureAggregate ¶ added in v0.15.0
func SignatureFromBytes ¶
SignatureFromBytes constructs a BLS signature from the raw bytes.
func SignatureFromString ¶
SignatureFromString decodes the input string and returns the Signature if the string is a valid hexadecimal encoding of a BLS signature.
func (*Signature) Decode ¶
Decode reads the raw bytes of the signature from the provided reader and initializes the signature.
func (*Signature) EqualsTo ¶
EqualsTo checks if the current signature is equal to another signature.
func (*Signature) MarshalCBOR ¶
MarshalCBOR encodes the signature into CBOR format.
func (*Signature) SerializeSize ¶ added in v1.6.0
func (*Signature) UnmarshalCBOR ¶
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