Documentation
¶
Index ¶
- Constants
- Variables
- func AggregateSignatures(sigs []Signature) (cbls.Signature, error)
- func BuildPoPMessage(pk PublicKey, height uint32) []byte
- func Verify(pk PublicKey, msg []byte, sig Signature) (bool, error)
- func VerifyAggregate(pks []PublicKey, msg []byte, sig cbls.Signature) bool
- func VerifyPoP(pk PublicKey, height uint32, sig Signature) (bool, error)
- type KeyGenerationOption
- type PublicKey
- type SecretKey
- type Signature
Constants ¶
const ( SecretKeySize = 32 PublicKeySize = 48 SignatureSize = 96 )
const PoPMessageSize = PublicKeySize + 4
Variables ¶
var ( ErrNoSignatures = errors.New("no signatures") ErrDuplicateSignature = errors.New("duplicate signature") )
Functions ¶
func BuildPoPMessage ¶
BuildPoPMessage constructs the PoP message from the public key and height.
func VerifyAggregate ¶
VerifyAggregate verifies aggregated signature over the same message.
Types ¶
type KeyGenerationOption ¶
type KeyGenerationOption func(config *keyGenConfig) error
KeyGenerationOption is an option for BLS key generation.
func WithInfo ¶
func WithInfo(data []byte) KeyGenerationOption
WithInfo sets given info for BLS key generation.
func WithNoPreHash ¶
func WithNoPreHash() KeyGenerationOption
func WithRandomSalt ¶
func WithRandomSalt() KeyGenerationOption
WithRandomSalt generates random salt for BLS key generation.
func WithSalt ¶
func WithSalt(salt []byte) KeyGenerationOption
WithSalt sets given salt for BLS key generation.
type PublicKey ¶
type PublicKey [PublicKeySize]byte
PublicKey is 48-byte compressed BLS public key.
func NewPublicKeyFromBase58 ¶
NewPublicKeyFromBase58 creates PublicKey from base58-encoded string.
func NewPublicKeyFromBytes ¶
NewPublicKeyFromBytes creates PublicKey from byte slice.
func (PublicKey) MarshalJSON ¶
func (*PublicKey) UnmarshalJSON ¶
type SecretKey ¶
type SecretKey [SecretKeySize]byte
SecretKey is 32-byte BLS secret key.
func GenerateSecretKey ¶
func GenerateSecretKey(seed []byte, opts ...KeyGenerationOption) (SecretKey, error)
GenerateSecretKey generates BLS secret key from given seed and options. By default, zero salt and nil info are used. That leads to deterministic key generation. To use random salt, use WithRandomSalt() option. In this case, each call of GenerateSecretKey with the same seed will produce different secret keys. To use custom salt or info, use WithSalt() and WithInfo() options respectively.
func NewSecretKeyFromBase58 ¶
func NewSecretKeyFromBytes ¶
NewSecretKeyFromBytes creates BLS secret key from given slice of bytes.
type Signature ¶
type Signature [SignatureSize]byte
Signature is 96-byte compressed BLS signature.
func NewSignatureFromBase58 ¶
func NewSignatureFromBytes ¶
func ProvePoP ¶
ProvePoP creates a proof of possession (PoP) message from the given public key and height. Then the message is signed with a given secret key. The function returns the PoP message and its signature.
func Sign ¶
Sign calculates 96-byte compressed BLS signature over msg. Default separation tag "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_" is used.