bls

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateAntiRogueCoefficients

func CalculateAntiRogueCoefficients(pubs []PublicKey) []big.Int

CalculateAntiRogueCoefficients returns an array of bigints used for subsequent key aggregations:

Ai = hash(Pi, {P1, P2, ...})

func Decrypt added in v0.1.2

func Decrypt(encrypted []byte, passphrase string) (decrypted []byte, err error)

func GenerateRandomKey

func GenerateRandomKey() (PrivateKey, PublicKey)

GenerateRandomKey creates a random private and its corresponding public keys

func MarshalBitmask added in v0.1.3

func MarshalBitmask(mask *big.Int) []byte

func UnmarshalBitmask added in v0.1.3

func UnmarshalBitmask(data []byte) *big.Int

func ZeroMultisigMask added in v0.1.3

func ZeroMultisigMask() *big.Int

ZeroMultisigMask returns zero bitmask

Types

type Multisig added in v0.1.3

type Multisig struct {
	PartSignature Signature // aggregated partial signature
	PartPublicKey PublicKey // aggregated partial public key
	PartMask      *big.Int  // bitmask of participants
}

Multisig is a BLS multisignature proof that anyone may provide to convince the verifier that the listed nodes has signed the message

func NewZeroMultisig added in v0.1.3

func NewZeroMultisig() Multisig

NewZeroMultisig returns zero multisignature

func (Multisig) Verify added in v0.1.3

func (multi Multisig) Verify(aggPublicKey PublicKey, message []byte) bool

Verify checks the BLS multisignature of the message against: * the aggregated public key of all its signers (whether signed or not), * the aggregated public key of participated signers (who really signed), * and the bitmask of signers

type PrivateKey

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

func ReadPrivateKey added in v0.1.3

func ReadPrivateKey(str string) (PrivateKey, error)

func UnmarshalPrivateKey

func UnmarshalPrivateKey(data []byte) (PrivateKey, error)

UnmarshalBlsPrivateKey reads the private key from the given byte array

func (*PrivateKey) Encrypt added in v0.1.2

func (blsKey *PrivateKey) Encrypt(passphrase string) (string, error)

Encrypt - encrypts a BLS PrivateKey with a given passphrase

func (PrivateKey) GenerateMembershipKeyPart

func (secretKey PrivateKey) GenerateMembershipKeyPart(index byte, aggPub PublicKey, anticoef big.Int) Signature

GenerateMembershipKeyPart generates the participant signature to be aggregated into membership key

func (PrivateKey) Marshal

func (secretKey PrivateKey) Marshal() []byte

func (PrivateKey) MarshalJSON

func (secretKey PrivateKey) MarshalJSON() ([]byte, error)

func (PrivateKey) Multisign

func (secretKey PrivateKey) Multisign(message []byte, aggPublicKey PublicKey, membershipKey Signature) Signature

Multisign generates BLS multi-signature of the given message, aggregated public key of all participants and the membership key of the signer

func (PrivateKey) Public added in v0.1.2

func (priv PrivateKey) Public() crypto.PublicKey

PublicKey calculates public key corresponding to the given private key

func (PrivateKey) PublicKey

func (priv PrivateKey) PublicKey() PublicKey

func (PrivateKey) Sign

func (secretKey PrivateKey) Sign(message []byte) Signature

Sign generates a simple BLS signature of the given message

func (*PrivateKey) UnmarshalJSON

func (secretKey *PrivateKey) UnmarshalJSON(data []byte) error

type PublicKey

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

func AggregatePublicKeys

func AggregatePublicKeys(pubs []PublicKey, anticoefs []big.Int) PublicKey

AggregatePublicKeys calculates P1*A1 + P2*A2 + ...

func ReadPublicKey added in v0.1.3

func ReadPublicKey(str string) (PublicKey, error)

func UnmarshalPublicKey

func UnmarshalPublicKey(raw []byte) (PublicKey, error)

func ZeroPublicKey

func ZeroPublicKey() PublicKey

ZeroPublicKey returns zero public key (point at infinity)

func (PublicKey) Aggregate

func (pub PublicKey) Aggregate(onemore PublicKey) PublicKey

Aggregate adds the given public keys

func (PublicKey) Marshal

func (pub PublicKey) Marshal() []byte

func (PublicKey) MarshalJSON

func (publicKey PublicKey) MarshalJSON() ([]byte, error)

func (*PublicKey) UnmarshalJSON

func (publicKey *PublicKey) UnmarshalJSON(data []byte) error

type Signature

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

func AggregateSignatures

func AggregateSignatures(sigs []Signature, anticoefs []big.Int) Signature

AggregateSignatures sums the given array of signatures

func HashToPointIndex

func HashToPointIndex(pub PublicKey, index byte) Signature

func ReadSignature added in v0.1.3

func ReadSignature(str string) (Signature, error)

func UnmarshalSignature

func UnmarshalSignature(raw []byte) (Signature, error)

func ZeroSignature

func ZeroSignature() Signature

ZeroSignature returns zero signature (point at infinity)

func (Signature) Aggregate

func (signature Signature) Aggregate(onemore Signature) Signature

Aggregate adds the given signatures

func (Signature) Marshal

func (signature Signature) Marshal() []byte

func (Signature) MarshalJSON

func (signature Signature) MarshalJSON() ([]byte, error)

func (*Signature) UnmarshalJSON

func (signature *Signature) UnmarshalJSON(data []byte) error

func (Signature) Verify

func (signature Signature) Verify(publicKey PublicKey, message []byte) bool

Verify checks the BLS signature of the message against the public key of its signer

func (Signature) VerifyMembershipKeyPart

func (signature Signature) VerifyMembershipKeyPart(aggPublicKey PublicKey, partPublicKey PublicKey, anticoef big.Int, index byte) bool

VerifyMembershipKeyPart verifies membership key part i ((a⋅pk)×H(P, i)) against aggregated public key (P) and public key of the party (pk×G)

Jump to

Keyboard shortcuts

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