bls

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: MIT Imports: 4 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateMasks

func AggregateMasks(a, b []byte) ([]byte, error)

AggregateMasks computes the bitwise OR of the two given participation masks.

func AggregateSig

func AggregateSig(sigs []*bls.Sign) *bls.Sign

AggregateSig aggregates all the BLS signature into a single multi-signature.

func BytesToBlsPublicKey

func BytesToBlsPublicKey(bytes []byte) (*bls.PublicKey, error)

BytesToBlsPublicKey converts bytes into bls.PublicKey pointer.

func RandPrivateKey

func RandPrivateKey() *bls.SecretKey

RandPrivateKey returns a random private key.

Types

type CompletePolicy

type CompletePolicy struct {
}

CompletePolicy is the default policy requiring that all participants have cosigned to make a collective signature valid.

func (CompletePolicy) Check

func (p CompletePolicy) Check(m *Mask) bool

Check verifies that all participants have contributed to a collective signature.

type Mask

type Mask struct {
	Bitmap []byte

	AggregatePublic *bls.PublicKey
	// contains filtered or unexported fields
}

Mask represents a cosigning participation bitmask.

func NewMask

func NewMask(publics []*bls.PublicKey, myKey *bls.PublicKey) (*Mask, error)

NewMask returns a new participation bitmask for cosigning where all cosigners are disabled by default. If a public key is given it verifies that it is present in the list of keys and sets the corresponding index in the bitmask to 1 (enabled).

func (*Mask) CountEnabled

func (m *Mask) CountEnabled() int

CountEnabled returns the number of enabled nodes in the CoSi participation Bitmap.

func (*Mask) CountTotal

func (m *Mask) CountTotal() int

CountTotal returns the total number of nodes this CoSi instance knows.

func (*Mask) GetPubKeyFromMask

func (m *Mask) GetPubKeyFromMask(flag bool) []*bls.PublicKey

GetPubKeyFromMask will return pubkeys which masked either zero or one depending on the flag it is used to show which signers are signed or not in the cosign message

func (*Mask) IndexEnabled

func (m *Mask) IndexEnabled(i int) (bool, error)

IndexEnabled checks whether the given index is enabled in the Bitmap or not.

func (*Mask) KeyEnabled

func (m *Mask) KeyEnabled(public *bls.PublicKey) (bool, error)

KeyEnabled checks whether the index, corresponding to the given key, is enabled in the Bitmap or not.

func (*Mask) Len

func (m *Mask) Len() int

Len returns the Bitmap length in bytes.

func (*Mask) Mask

func (m *Mask) Mask() []byte

Mask returns a copy of the participation bitmask.

func (*Mask) SetBit

func (m *Mask) SetBit(i int, enable bool) error

SetBit enables (enable: true) or disables (enable: false) the bit in the participation Bitmap of the given cosigner.

func (*Mask) SetKey

func (m *Mask) SetKey(public *bls.PublicKey, enable bool) error

SetKey set the bit in the Bitmap for the given cosigner

func (*Mask) SetMask

func (m *Mask) SetMask(mask []byte) error

SetMask sets the participation bitmask according to the given byte slice interpreted in little-endian order, i.e., bits 0-7 of byte 0 correspond to cosigners 0-7, bits 0-7 of byte 1 correspond to cosigners 8-15, etc.

type Policy

type Policy interface {
	Check(m *Mask) bool
}

Policy represents a fully customizable cosigning policy deciding what cosigner sets are and aren't sufficient for a collective signature to be considered acceptable to a verifier. The Check method may inspect the set of participants that cosigned by invoking cosi.Mask and/or cosi.MaskBit, and may use any other relevant contextual information (e.g., how security-critical the operation relying on the collective signature is) in determining whether the collective signature was produced by an acceptable set of cosigners.

type ThresholdPolicy

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

ThresholdPolicy allows to specify a simple t-of-n policy requring that at least the given threshold number of participants t have cosigned to make a collective signature valid.

func NewThresholdPolicy

func NewThresholdPolicy(thold int) *ThresholdPolicy

NewThresholdPolicy returns a new ThresholdPolicy with the given threshold.

func (ThresholdPolicy) Check

func (p ThresholdPolicy) Check(m *Mask) bool

Check verifies that at least a threshold number of participants have contributed to a collective signature.

Jump to

Keyboard shortcuts

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