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, networkID uint32, chainID ids.ID)
- func TestSignerWrongChainID(t *testing.T, s Signer, _ *bls.SecretKey, _ uint32, _ ids.ID)
- func TestSignerWrongNetworkID(t *testing.T, s Signer, _ *bls.SecretKey, networkID uint32, ...)
- 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 AnycastID = ids.ID{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
}
AnycastID is a special DestinationChainID that is used to indicate that the message is intended to be able to be received by any chain.
var SignerTests = []func(t *testing.T, s Signer, sk *bls.SecretKey, networkID uint32, 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 ¶
func TestSignerVerifies(t *testing.T, s Signer, sk *bls.SecretKey, networkID uint32, chainID ids.ID)
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) NumSigners ¶ added in v1.9.10
func (s *BitSetSignature) NumSigners() (int, error)
func (*BitSetSignature) Verify ¶
func (s *BitSetSignature) Verify( ctx context.Context, msg *UnsignedMessage, networkID uint32, 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 Warp 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 { // NumSigners is the number of [bls.PublicKeys] that participated in the // [Signature]. This is exposed because users of these signatures typically // impose a verification fee that is a function of the number of // signers. NumSigners() (int, error) // 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, networkID uint32, 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 { NetworkID uint32 `serialize:"true"` SourceChainID ids.ID `serialize:"true"` Payload []byte `serialize:"true"` // contains filtered or unexported fields }
UnsignedMessage defines the standard format for an unsigned Warp message.
func NewUnsignedMessage ¶
func NewUnsignedMessage( networkID uint32, sourceChainID 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) ID ¶ added in v1.9.12
func (m *UnsignedMessage) ID() ids.ID
ID returns an identifier for 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].