Documentation
      ¶
    
    
  
    
  
    Index ¶
- Constants
 - Variables
 - func AggregatePublicKeys(vdrs []*validators.Warp) (*bls.PublicKey, error)
 - func FilterValidators(indices set.Bits, vdrs []*validators.Warp) ([]*validators.Warp, error)
 - func GetCanonicalValidatorSetFromChainID(ctx context.Context, pChainState validators.State, pChainHeight uint64, ...) (validators.WarpSet, error)
 - func GetCanonicalValidatorSetFromSubnetID(ctx context.Context, pChainState ValidatorState, pChainHeight uint64, ...) (validators.WarpSet, error)deprecated
 - func SumWeight(vdrs []*validators.Warp) (uint64, error)
 - func VerifyWeight(sigWeight uint64, totalWeight uint64, quorumNum uint64, quorumDen uint64) error
 - type BitSetSignature
 - type CanonicalValidatorSetdeprecated
 - type Message
 - type Signature
 - type Signer
 - type UnsignedMessage
 - type Validatordeprecated
 - type ValidatorState
 
Constants ¶
const CodecVersion = 0
    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 ( ErrWrongSourceChainID = errors.New("wrong SourceChainID") ErrWrongNetworkID = errors.New("wrong networkID") )
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 Codec codec.Manager
    var FlattenValidatorSet = validators.FlattenValidatorSet
    Deprecated: use validators.FlattenValidatorSet instead.
Functions ¶
func AggregatePublicKeys ¶
func AggregatePublicKeys(vdrs []*validators.Warp) (*bls.PublicKey, error)
AggregatePublicKeys returns the public key of the provided validators.
Invariant: All of the public keys in [vdrs] are valid.
func FilterValidators ¶
func FilterValidators( indices set.Bits, vdrs []*validators.Warp, ) ([]*validators.Warp, error)
FilterValidators returns the validators in [vdrs] whose bit is set to 1 in [indices].
Returns an error if [indices] references an unknown validator.
func GetCanonicalValidatorSetFromChainID ¶ added in v1.13.0
func GetCanonicalValidatorSetFromChainID(ctx context.Context, pChainState validators.State, pChainHeight uint64, sourceChainID ids.ID, ) (validators.WarpSet, error)
GetCanonicalValidatorSetFromChainID returns the canonical validator set given a validators.State, pChain height and a sourceChainID.
        
          
            func GetCanonicalValidatorSetFromSubnetID
            deprecated
            
          
  
    
      added in
      v1.13.0
    
  
      
      func GetCanonicalValidatorSetFromSubnetID( ctx context.Context, pChainState ValidatorState, pChainHeight uint64, subnetID ids.ID, ) (validators.WarpSet, error)
GetCanonicalValidatorSetFromSubnetID returns the CanonicalValidatorSet of [subnetID] at [pChainHeight]. The returned CanonicalValidatorSet includes the validator set in a canonical ordering and the total weight.
Deprecated: Use validators.State.GetWarpValidatorSet instead.
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) String ¶ added in v1.11.0
func (s *BitSetSignature) String() string
func (*BitSetSignature) Verify ¶
func (s *BitSetSignature) Verify( msg *UnsignedMessage, networkID uint32, validators validators.WarpSet, quorumNum uint64, quorumDen uint64, ) error
        
          
            type CanonicalValidatorSet
            deprecated
            
          
  
    
      added in
      v1.13.0
    
  
      
      type CanonicalValidatorSet = validators.WarpSet
Deprecated: use validators.WarpSet instead.
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 {
	fmt.Stringer
	// 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(
		msg *UnsignedMessage,
		networkID uint32,
		validators validators.WarpSet,
		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().
func (*UnsignedMessage) String ¶ added in v1.11.0
func (m *UnsignedMessage) String() string
        
          
            type Validator
            deprecated
            
          
  
    
  
      
      type Validator = validators.Warp
Deprecated: use validators.Warp instead.
type ValidatorState ¶ added in v1.10.9
type ValidatorState interface {
	GetValidatorSet(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*validators.GetValidatorOutput, error)
}
    ValidatorState defines the functions that must be implemented to get the canonical validator set for warp message validation.