Documentation
¶
Index ¶
- Variables
- func AggregatePublicKeys(vdrs []*Validator) (*bls.PublicKey, error)
- func SumWeight(vdrs []*Validator) (uint64, error)
- func TestSignerVerifies(t *testing.T, s Signer, sk *bls.SecretKey, chainID ids.ID)
- func TestSignerWrongChainID(t *testing.T, s Signer, _ *bls.SecretKey, _ ids.ID)
- func VerifyWeight(sigWeight uint64, totalWeight uint64, quorumNum uint64, quorumDen uint64) error
- type BitSetSignature
- type Message
- type Signature
- type Signer
- type UnsignedMessage
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidBitSet = errors.New("bitset is invalid") ErrInsufficientWeight = errors.New("signature weight is insufficient") ErrInvalidSignature = errors.New("signature is invalid") ErrParseSignature = errors.New("failed to parse signature") )
var ( ErrUnknownValidator = errors.New("unknown validator") ErrWeightOverflow = errors.New("weight overflowed") )
var SignerTests = []func(t *testing.T, s Signer, sk *bls.SecretKey, chainID ids.ID){ TestSignerWrongChainID, TestSignerVerifies, }
SignerTests is a list of all signer tests
Functions ¶
func AggregatePublicKeys ¶
AggregatePublicKeys returns the public key of the provided validators.
Invariant: All of the public keys in [vdrs] are valid.
func TestSignerVerifies ¶
Test that a signature generated with the signer verifies correctly
func TestSignerWrongChainID ¶
Test that using a random SourceChainID results in an error
Types ¶
type BitSetSignature ¶
type BitSetSignature struct { // Signers is a big-endian byte slice encoding which validators signed this // message. Signers []byte `serialize:"true"` Signature [bls.SignatureLen]byte `serialize:"true"` }
func (*BitSetSignature) Verify ¶
func (s *BitSetSignature) Verify( ctx context.Context, msg *UnsignedMessage, pChainState validators.State, pChainHeight uint64, quorumNum uint64, quorumDen uint64, ) error
type Message ¶
type Message struct { UnsignedMessage `serialize:"true"` Signature Signature `serialize:"true"` // contains filtered or unexported fields }
Message defines the standard format for a Teleporter cross-subnet message.
func NewMessage ¶
func NewMessage( unsignedMsg *UnsignedMessage, signature Signature, ) (*Message, error)
NewMessage creates a new *Message and initializes it.
func ParseMessage ¶
ParseMessage converts a slice of bytes into an initialized *Message.
func (*Message) Bytes ¶
Bytes returns the binary representation of this message. It assumes that the message is initialized from either New, Parse, or an explicit call to Initialize.
func (*Message) Initialize ¶
Initialize recalculates the result of Bytes(). It does not call Initialize() on the UnsignedMessage.
type Signature ¶
type Signature interface { // Verify that this signature was signed by at least [quorumNum]/[quorumDen] // of the validators of [msg.SourceChainID] at [pChainHeight]. // // Invariant: [msg] is correctly initialized. Verify( ctx context.Context, msg *UnsignedMessage, pChainState validators.State, pChainHeight uint64, quorumNum uint64, quorumDen uint64, ) error }
type Signer ¶
type Signer interface { // Returns this node's BLS signature over an unsigned message. If the caller // does not have the authority to sign the message, an error will be // returned. // // Assumes the unsigned message is correctly initialized. Sign(msg *UnsignedMessage) ([]byte, error) }
type UnsignedMessage ¶
type UnsignedMessage struct { SourceChainID ids.ID `serialize:"true"` DestinationChainID ids.ID `serialize:"true"` Payload []byte `serialize:"true"` // contains filtered or unexported fields }
UnsignedMessage defines the standard format for an unsigned Teleporter cross-subnet message.
func NewUnsignedMessage ¶
func NewUnsignedMessage( sourceChainID ids.ID, destinationChainID ids.ID, payload []byte, ) (*UnsignedMessage, error)
NewUnsignedMessage creates a new *UnsignedMessage and initializes it.
func ParseUnsignedMessage ¶
func ParseUnsignedMessage(b []byte) (*UnsignedMessage, error)
ParseUnsignedMessage converts a slice of bytes into an initialized *UnsignedMessage.
func (*UnsignedMessage) Bytes ¶
func (m *UnsignedMessage) Bytes() []byte
Bytes returns the binary representation of this message. It assumes that the message is initialized from either New, Parse, or an explicit call to Initialize.
func (*UnsignedMessage) Initialize ¶
func (m *UnsignedMessage) Initialize() error
Initialize recalculates the result of Bytes().
type Validator ¶
type Validator struct { PublicKey *bls.PublicKey PublicKeyBytes []byte Weight uint64 NodeIDs []ids.NodeID }
func FilterValidators ¶
FilterValidators returns the validators in [vdrs] whose bit is set to 1 in [indices].
Returns an error if [indices] references an unknown validator.
func GetCanonicalValidatorSet ¶
func GetCanonicalValidatorSet( ctx context.Context, pChainState validators.State, pChainHeight uint64, subnetID ids.ID, ) ([]*Validator, uint64, error)
GetCanonicalValidatorSet returns the validator set of [subnetID] at [pChcainHeight] in a canonical ordering. Also returns the total weight on [subnetID].