Lux Docs
Warp

Warp API Reference

Core types, functions, and interfaces for Warp messaging

Core Types

UnsignedMessage

type UnsignedMessage struct {
    NetworkID     uint32
    SourceChainID ids.ID
    Payload       []byte
}
MethodReturnsDescription
Verify()errorValidates format and size
Bytes()[]byteSerialized representation
ID()ids.IDSHA-256 hash of the serialized message

Message

type Message struct {
    UnsignedMessage *UnsignedMessage
    Signature       Signature
}
MethodReturnsDescription
Verify()errorValidates message and signature are non-nil
Bytes()[]byteSerialized representation
ID()ids.IDHash of the unsigned message
Equal(other)boolDeep equality check

Constructors

func NewUnsignedMessage(networkID uint32, chainID ids.ID, payload []byte) (*UnsignedMessage, error)
func NewMessage(unsigned *UnsignedMessage, signature Signature) (*Message, error)
func ParseMessage(b []byte) (*Message, error)
func ParseUnsignedMessage(b []byte) (*UnsignedMessage, error)

Verification

func VerifyMessage(msg *Message, networkID uint32, state ValidatorState, quorumNum, quorumDen uint64) error
func VerifyWeight(signedWeight, totalWeight, quorumNum, quorumDen uint64) error

Interfaces

Signature

type Signature interface {
    Verify(unsignedBytes []byte, validators []Validator) error
    GetSignedWeight(validators []Validator) (uint64, error)
    Equal(other Signature) bool
    Bytes() []byte
}

ValidatorState

type ValidatorState interface {
    GetValidatorSet(ctx context.Context, height uint64, chainID ids.ID) ([]Validator, error)
    GetCurrentHeight(ctx context.Context) (uint64, error)
}

Validator

type Validator struct {
    PublicKey      *bls.PublicKey
    PublicKeyBytes []byte
    Weight         uint64
    NodeID         ids.NodeID
}

Constants

ConstantValueDescription
CodecVersion0Serialization codec version
MaxMessageSize256 KiBMaximum serialized message size

Errors

ErrorDescription
ErrInvalidSignatureSignature verification failed
ErrInvalidMessageMessage format is invalid
ErrUnknownValidatorValidator not in the expected set
ErrInsufficientWeightSigned weight below quorum

On this page