Warp
Warp API Reference
Core types, functions, and interfaces for Warp messaging
type UnsignedMessage struct {
NetworkID uint32
SourceChainID ids.ID
Payload []byte
}
| Method | Returns | Description |
|---|
Verify() | error | Validates format and size |
Bytes() | []byte | Serialized representation |
ID() | ids.ID | SHA-256 hash of the serialized message |
type Message struct {
UnsignedMessage *UnsignedMessage
Signature Signature
}
| Method | Returns | Description |
|---|
Verify() | error | Validates message and signature are non-nil |
Bytes() | []byte | Serialized representation |
ID() | ids.ID | Hash of the unsigned message |
Equal(other) | bool | Deep equality check |
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)
func VerifyMessage(msg *Message, networkID uint32, state ValidatorState, quorumNum, quorumDen uint64) error
func VerifyWeight(signedWeight, totalWeight, quorumNum, quorumDen uint64) error
type Signature interface {
Verify(unsignedBytes []byte, validators []Validator) error
GetSignedWeight(validators []Validator) (uint64, error)
Equal(other Signature) bool
Bytes() []byte
}
type ValidatorState interface {
GetValidatorSet(ctx context.Context, height uint64, chainID ids.ID) ([]Validator, error)
GetCurrentHeight(ctx context.Context) (uint64, error)
}
type Validator struct {
PublicKey *bls.PublicKey
PublicKeyBytes []byte
Weight uint64
NodeID ids.NodeID
}
| Constant | Value | Description |
|---|
CodecVersion | 0 | Serialization codec version |
MaxMessageSize | 256 KiB | Maximum serialized message size |
| Error | Description |
|---|
ErrInvalidSignature | Signature verification failed |
ErrInvalidMessage | Message format is invalid |
ErrUnknownValidator | Validator not in the expected set |
ErrInsufficientWeight | Signed weight below quorum |